Package com.sk89q.craftbook

Examples of com.sk89q.craftbook.ChangedSign


    }

    public boolean testBlock(Block switchBlock, BlockFace eventFace, Player player) {

        LocalPlayer lplayer = CraftBookPlugin.inst().wrapPlayer(player);
        ChangedSign s = null;
        Block testBlock = null;
        if(anyside) {

            for(BlockFace face : LocationUtil.getDirectFaces()) {
                testBlock = switchBlock.getRelative(face);
                if(testBlock.getType() == Material.WALL_SIGN) {
                    s = BukkitUtil.toChangedSign(testBlock);
                    break;
                }
            }
        } else {
            BlockFace face = eventFace.getOppositeFace();
            testBlock = switchBlock.getRelative(face);
            if(testBlock.getType() == Material.WALL_SIGN)
                s = BukkitUtil.toChangedSign(testBlock);
        }

        if(s == null)
            return false;

        if (s.getLine(1).equalsIgnoreCase("[X]")) {

            ItemStack itemID = null;

            if (!s.getLine(0).trim().isEmpty()) {
                itemID = ItemSyntax.getItem(s.getLine(0).trim());
            }

            if (!s.getLine(2).trim().isEmpty())
                if (!CraftBookPlugin.inst().inGroup(player, s.getLine(2).trim())) {
                    lplayer.printError("mech.group");
                    return true;
                }

            boolean success = false;
View Full Code Here


    public void onSelfTriggerPing(SelfTriggerPingEvent event) {

        if(!CraftBookPlugin.inst().getConfiguration().convertNamesToCBID) return;
        if(SignUtil.isSign(event.getBlock())) {

            ChangedSign sign = BukkitUtil.toChangedSign(event.getBlock());

            int i = 0;

            for(String line : sign.getLines()) {
                for(String var : ParsingUtil.getPossibleVariables(line)) {
                    String namespace = getNamespace(var);
                    if(namespace == null || namespace.isEmpty() || namespace.equals("global")) continue;
                    if(CraftBookPlugin.inst().getUUIDMappings().getUUID(namespace) != null) continue;
                    OfflinePlayer player = Bukkit.getOfflinePlayer(namespace);
                    if(player.hasPlayedBefore()) {
                        try {
                            ProfileService resolver = HttpRepositoryService.forMinecraft();
                            Profile profile = resolver.findByName(player.getName()); // May be null

                            UUID uuid = profile.getUniqueId();
                            line = StringUtils.replace(line, var, var.replace(namespace, CraftBookPlugin.inst().getUUIDMappings().getCBID(uuid)));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                sign.setLine(i++, line);
            }

            sign.update(false);
        }
    }
View Full Code Here

    public void onRightClick(SignClickEvent event) {

        if(!EventUtil.passesFilter(event)) return;

        if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
        ChangedSign s = event.getSign();

        if(!s.getLine(1).equals("[Command]")) return;

        if(s.getLine(0).equals("EXPANSION")) return;

        LocalPlayer localPlayer = CraftBookPlugin.inst().wrapPlayer(event.getPlayer());

        if (!localPlayer.hasPermission("craftbook.mech.command.use")) {
            if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
View Full Code Here

        if (!event.isOn() || event.isMinor() || !allowRedstone || !SignUtil.isSign(event.getBlock()))
            return;

        if(!EventUtil.passesFilter(event)) return;

        ChangedSign s = BukkitUtil.toChangedSign(event.getBlock());

        if(!s.getLine(1).equals("[Command]")) return;

        if(s.getLine(0).equals("EXPANSION")) return;

        runCommandSign(s, null);
    }
View Full Code Here

    public void onSignClick(SignClickEvent event) {

        if(!EventUtil.passesFilter(event)) return;

        if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
        ChangedSign sign = event.getSign();
        if(!sign.getLine(1).equalsIgnoreCase("[map]")) return;

        LocalPlayer player = CraftBookPlugin.inst().wrapPlayer(event.getPlayer());
        if (!player.hasPermission("craftbook.mech.map.use")) {
            if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
                player.printError("mech.use-permission");
            return;
        }

        if(!ProtectionUtil.canUse(event.getPlayer(), event.getClickedBlock().getLocation(), event.getBlockFace(), event.getAction())) {
            if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
                player.printError("area.use-permissions");
            return;
        }
        if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getType() == Material.MAP) {
            byte id;
            try {
                id = Byte.parseByte(sign.getLine(2));
            } catch (Exception e) {
                id = -1;
            }
            if (id <= -1) {
                player.printError("mech.map.invalid");
View Full Code Here

    @EventHandler(priority = EventPriority.HIGH)
    public void onRightClick(SignClickEvent event) {

        if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;

        ChangedSign sign = event.getSign();
        if(!sign.getLine(1).equalsIgnoreCase("[I]") && !sign.getLine(1).equalsIgnoreCase("[|]")) return;

        if (!EventUtil.passesFilter(event))
            return;

        LocalPlayer player = event.getWrappedPlayer();
View Full Code Here

        // check if this looks at all like something we're interested in first
        if (!SignUtil.isSign(block)) return false;
        int radius = Math.min(10, maxRange);
        int maximum = Math.min(maxLights, 20);
        ChangedSign sign = BukkitUtil.toChangedSign(block);
        try {
            radius = Math.min(Integer.parseInt(sign.getLine(2)), maxRange);
        } catch (Exception ignored) {
        }
        try {
            maximum = Math.min(Integer.parseInt(sign.getLine(3)), maxLights);
        } catch (Exception ignored) {
        }

        int wx = block.getX();
        int wy = block.getY();
View Full Code Here

                BlockFace[] faces = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
                boolean found = false;
                for(BlockFace face : faces) {
                    Block sign = block.getRelative(face);
                    if(sign.getType() == Material.WALL_SIGN) {
                        ChangedSign s = BukkitUtil.toChangedSign(sign);
                        if(s.getLine(1).equals("[Cauldron]")) {
                            found = true;
                            break;
                        }
                    }
                }
View Full Code Here

        if (!event.getBlocks().matches(getMaterial())) return;
        if (event.isMinor()) return;

        // validate
        if (!event.getBlocks().matches("sort")) return;
        ChangedSign sign = event.getBlocks().getSign();

        // pi(sign)hich sort conditions apply
        // (left dominates if both apply)
        Hand dir = Hand.STRAIGHT;
        if (isSortApplicable(sign.getLine(2), event.getMinecart())) {
            dir = Hand.LEFT;
        } else if (isSortApplicable(sign.getLine(3), event.getMinecart())) {
            dir = Hand.RIGHT;
        }

        // pick the track block to modify and the curve to give it.
        // perhaps oddly, it's the sign facing that determines the concepts of left and right, and not the track.
View Full Code Here

        if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
        LocalPlayer player = CraftBookPlugin.inst().wrapPlayer(event.getPlayer());
        boolean save = false;

        ChangedSign sign = event.getSign();

        if (!sign.getLine(1).equals("[Area]") && !sign.getLine(1).equals("[SaveArea]")) return;

        if (!player.hasPermission("craftbook.mech.area.use")) {
            if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
                player.print("mech.use-permission");
            return;
        }

        if(!ProtectionUtil.canUse(event.getPlayer(), event.getClickedBlock().getLocation(), event.getBlockFace(), event.getAction())) {
            if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
                player.printError("area.use-permissions");
            return;
        }

        // check if the namespace and area exists
        if(!isValidArea(sign)) {
            player.printError("mech.area.missing");
            return;
        }
        save = sign.getLine(1).equals("[SaveArea]");

        // toggle the area on or off
        toggle(event.getClickedBlock(), sign, save);

        event.setCancelled(true);
View Full Code Here

TOP

Related Classes of com.sk89q.craftbook.ChangedSign

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.