Package com.sk89q.craftbook.util

Examples of com.sk89q.craftbook.util.SignText


        this.language = language;
    }

    public void think(ChipState chip) {

        SignText t = chip.getText();

        String code;
        try {
            code = getCode(chip.getWorld(), chip.getPosition());
        } catch (PlcException e) {
            t.setLine2("§c" + t.getLine2());
            t.setLine3("!ERROR!");
            t.setLine4("code not found");
            return;
        }

        if (!t.getLine3().equals("HASH:" + Integer.toHexString(code.hashCode()))) {
            t.setLine2("§c" + t.getLine2());
            t.setLine3("!ERROR!");
            t.setLine4("code modified");
            return;
        }

        boolean[] output;
        try {
            output = language.tick(chip, code);
        } catch (PlcException e) {
            t.setLine2("§c" + t.getLine2());
            t.setLine3("!ERROR!");
            t.setLine4(e.getMessage());
            return;
        } catch (Throwable r) {
            t.setLine2("§c" + t.getLine2());
            t.setLine3("!ERROR!");
            t.setLine4(r.getClass().getSimpleName());
            return;
        }

        try {
            for (int i = 0; i < output.length; i++) {
                Signal out = chip.getOut(i + 1);
                if (out == null) break;
                out.set(output[i]);
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            t.setLine2("§c" + t.getLine2());
            t.setLine3("!ERROR!");
            t.setLine4("too many outputs");
            return;
        }

        t.supressUpdate();
    }
View Full Code Here


     */
    public static boolean validateEnvironment(ServerInterface server, WorldInterface world,
                                              PlayerInterface player, Vector pt) {

        ToggleArea area = new ToggleArea(server, world, pt, null);
        SignText signText = area.signText;

        String activeID = area.getSignActiveStateID();
        String inactiveID = area.getSignInactiveStateID();
        String signNS = area.getSignNamespace();
        String playerNS = CraftBookUtil.trimLength(player.getName(), 15);

        boolean noInactiveCopy = inactiveID.equals("-");

        if (!CopyManager.isValidName(activeID)) {
            player.printError("An invalid area name was indicated.");
            return false;
        }

        if (inactiveID.length() > 0 && !noInactiveCopy
                && !CopyManager.isValidName(inactiveID)) {
            player.printError("An invalid off state area name was indicated.");
            return false;
        }

        // Coerce the namespace to the player's name
        if (signNS.equals("") || signNS.equalsIgnoreCase(playerNS)) {
            signText.setLine3(playerNS);
        } else if (signNS.equals("@")) {
            if (!player.canCreateObject("savensarea")) {
                player.printError("You are unable to make toggles for global areas.");
                return false;
            }
        } else {
            if (!player.canCreateObject("savensarea")) {
                player.printError("You are unable to make toggles for global areas.");
                return false;
            }
        }

        if (area.isNewArea) {
            signText.setLine2("[Area]");
        } else {
            signText.setLine2("[Toggle]");
        }

        player.print("Area toggle created!");

        return true;
View Full Code Here

TOP

Related Classes of com.sk89q.craftbook.util.SignText

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.