Package com.sk89q.craftbook

Examples of com.sk89q.craftbook.ChangedSign


        if (Power.OFF == isActive(event.getBlocks())) return;

        // go
        if (event.getMinecart().getPassenger() instanceof Player) {
            Player p = (Player) event.getMinecart().getPassenger();
            ChangedSign s = event.getBlocks().getSign();
            if (!s.getLine(0).equalsIgnoreCase("[print]") && !s.getLine(1).equalsIgnoreCase("[print]")) return;

            ArrayList<String> messages = new ArrayList<String>();

            boolean stack = false;

            if (s.getLine(1) != null && !s.getLine(1).isEmpty() && !s.getLine(1).equalsIgnoreCase("[print]")) {
                messages.add(s.getLine(1));
                stack = s.getLine(1).endsWith("+") || s.getLine(1).endsWith(" ");
            }
            if (s.getLine(2) != null && !s.getLine(2).isEmpty()) {
                if (stack) {
                    messages.set(messages.size() - 1, messages.get(messages.size() - 1) + s.getLine(2));
                    stack = s.getLine(2).endsWith("+") || s.getLine(2).endsWith(" ");
                } else {
                    messages.add(s.getLine(2));
                    stack = s.getLine(2).endsWith("+") || s.getLine(2).endsWith(" ");
                }
            }
            if (s.getLine(3) != null && !s.getLine(3).isEmpty()) {
                if (stack) {
                    messages.set(messages.size() - 1, messages.get(messages.size() - 1) + s.getLine(3));
                } else {
                    messages.add(s.getLine(3));
                }
            }

            for (String mes : messages) {
                if (stack) mes = StringUtils.replace(mes, "+", "");
View Full Code Here


                player.printError("area.use-permissions");
            return;
        }

        try {
            ChangedSign sign = event.getSign();

            if (CraftBookPlugin.inst().getConfiguration().safeDestruction && sign != null && !sign.getLine(0).equalsIgnoreCase("infinite"))
                if (event.getPlayer().getItemInHand() != null)
                    if (getBlockBase(event.getClickedBlock()).getType() == event.getPlayer().getItemInHand().getType() && getBlockBase(event.getClickedBlock()).getData() == event.getPlayer().getItemInHand().getData().getData()) {

                        if (!player.hasPermission("craftbook.mech.bridge.restock")) {
                            if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
View Full Code Here

    @Override
    public CuboidRegion getCuboidArea(Block trigger, Block proximalBaseCenter, Block distalBaseCenter) throws InvalidMechanismException {

        CuboidRegion toggle = new CuboidRegion(BukkitUtil.toVector(proximalBaseCenter), BukkitUtil.toVector(distalBaseCenter));
        ChangedSign sign = BukkitUtil.toChangedSign(trigger);
        int left, right;
        try {
            left = Math.max(0, Math.min(maxWidth, Integer.parseInt(sign.getLine(2))));
        } catch (Exception e) {
            left = 1;
        }
        try {
            right = Math.max(0, Math.min(maxWidth, Integer.parseInt(sign.getLine(3))));
        } catch (Exception e) {
            right = 1;
        }

        // Expand Left
View Full Code Here

                player.printError("area.use-permissions");
            return;
        }

        try {
            ChangedSign sign = event.getSign();

            if (CraftBookPlugin.inst().getConfiguration().safeDestruction && sign != null && !sign.getLine(0).equalsIgnoreCase("infinite"))
                if (event.getPlayer().getItemInHand() != null)
                    if (getBlockBase(event.getClickedBlock()).getType() == event.getPlayer().getItemInHand().getType() && getBlockBase(event.getClickedBlock()).getData() == event.getPlayer().getItemInHand().getData().getData()) {

                        if (!player.hasPermission("craftbook.mech.door.restock")) {
                            if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
View Full Code Here

    public boolean flipState(Block trigger, LocalPlayer player) throws InvalidMechanismException {

        if (!SignUtil.isCardinal(trigger)) throw new InvalidMechanismException();

        ChangedSign sign = BukkitUtil.toChangedSign(trigger);

        // Attempt to detect whether the bridge is above or below the sign,
        // first assuming that the bridge is above
        Block proximalBaseCenter = getBlockBase(trigger);

        // Find the other side
        Block farSide = getFarSign(trigger);

        if (farSide.getType() != trigger.getType()) throw new InvalidMechanismException("mech.door.other-sign");

        // Check the other side's base blocks for matching type
        Block distalBaseCenter = null;
        if (sign.getLine(1).equalsIgnoreCase("[Door Up]")) {
            distalBaseCenter = farSide.getRelative(BlockFace.DOWN);
        } else if (sign.getLine(1).equalsIgnoreCase("[Door Down]")) {
            distalBaseCenter = farSide.getRelative(BlockFace.UP);
        }
        if (!BlockUtil.areBlocksIdentical(distalBaseCenter, proximalBaseCenter))
            throw new InvalidMechanismException("mech.door.material");
View Full Code Here

    @Override
    public Block getFarSign(Block trigger) {
        // Find the other side
        Block otherSide = null;

        ChangedSign sign = BukkitUtil.toChangedSign(trigger);

        if (sign.getLine(1).equals("[Door Up]")) {
            otherSide = trigger.getRelative(BlockFace.UP);
        } else if (sign.getLine(1).equals("[Door Down]")) {
            otherSide = trigger.getRelative(BlockFace.DOWN);
        }
        for (int i = 0; i <= maxLength; i++) {
            // about the loop index:
            // i = 0 is the first block after the proximal base
            // since we're allowed to have settings.maxLength toggle blocks,
            // i = settings.maxLength is actually the farthest place we're
            // allowed to find the distal signpost

            if (otherSide.getType() == Material.SIGN_POST) {
                String otherSignText = BukkitUtil.toChangedSign(otherSide).getLine(1);
                if (isApplicableSign(otherSignText))
                    break;
                if ("[Door]".equals(otherSignText))
                    break;
            }

            if (sign.getLine(1).equals("[Door Up]")) {
                otherSide = otherSide.getRelative(BlockFace.UP);
            } else if (sign.getLine(1).equals("[Door Down]")) {
                otherSide = otherSide.getRelative(BlockFace.DOWN);
            }
        }

        return otherSide;
View Full Code Here

        return otherSide;
    }

    @Override
    public Block getBlockBase(Block trigger) throws InvalidMechanismException {
        ChangedSign s = BukkitUtil.toChangedSign(trigger);

        Block proximalBaseCenter = null;

        if (s.getLine(1).equalsIgnoreCase("[Door Up]")) {
            proximalBaseCenter = trigger.getRelative(BlockFace.UP);
        } else if (s.getLine(1).equalsIgnoreCase("[Door Down]")) {
            proximalBaseCenter = trigger.getRelative(BlockFace.DOWN);
        } else throw new InvalidMechanismException("Sign is incorrectly made.");

        if (blocks.contains(new ItemInfo(proximalBaseCenter)))
            return proximalBaseCenter;
View Full Code Here

    @Override
    public CuboidRegion getCuboidArea(Block trigger, Block proximalBaseCenter, Block distalBaseCenter) throws InvalidMechanismException {
        // Select the togglable region
        CuboidRegion toggle = new CuboidRegion(BukkitUtil.toVector(proximalBaseCenter), BukkitUtil.toVector(distalBaseCenter));
        ChangedSign sign = BukkitUtil.toChangedSign(trigger);
        int left, right;
        try {
            left = Math.max(0, Math.min(maxWidth, Integer.parseInt(sign.getLine(2))));
        } catch (Exception e) {
            left = 1;
        }
        try {
            right = Math.max(0, Math.min(maxWidth, Integer.parseInt(sign.getLine(3))));
        } catch (Exception e) {
            right = 1;
        }

        // Expand Left
View Full Code Here

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

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

        ChangedSign sign = event.getSign();
        if(!sign.getLine(1).equals("[Marquee]")) return;
        LocalPlayer lplayer = CraftBookPlugin.inst().wrapPlayer(event.getPlayer());
        if(!lplayer.hasPermission("craftbook.mech.marquee.use")) {
            if(CraftBookPlugin.inst().getConfiguration().showPermissionMessages)
                lplayer.printError("mech.use-permission");
            return;
        }

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

        String var = VariableManager.instance.getVariable(sign.getLine(2), sign.getLine(3).isEmpty() ? "global" : sign.getLine(3));
        if(var == null || var.isEmpty()) var = "variable.missing";
        lplayer.print(var);

        event.setCancelled(true);
    }
View Full Code Here

    private static boolean isValidWallSign(Block b) {

        // Must be Wall Sign
        if (b == null || b.getType() != Material.WALL_SIGN) return false;
        ChangedSign s = BukkitUtil.toChangedSign(b);

        return s.getLine(1).equalsIgnoreCase("[X]");
    }
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.