Package org.bukkit.block

Examples of org.bukkit.block.Sign


    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onSignChange(SignChangeEvent e){
        Player player = e.getPlayer();

        Sign sign = (Sign) e.getBlock().getState();
        String[] lines = e.getLines();
        String function = lines[0].toLowerCase();

        if (function.equals("[balance]")){
            if (Permissions.checkPerms(player, "cex.sign.create.balance")){
                if (!lines[1].equals("") || !lines[2].equals("") || !lines[3].equals("")){
                    LogHelper.showWarning("commandSignInvalid", player);
                    sign.getBlock().breakNaturally();
                } else {
                    LogHelper.showInfo("commandSignBalance", player, ChatColor.GREEN);
                }
            } else {
                sign.getBlock().breakNaturally();
            }
        } else if (function.equals("[pay]")){
            if (Permissions.checkPerms(player, "cex.sign.create.pay")){
                if (lines[1].equals("")){
                    LogHelper.showWarning("commandSignInvalid", player);
                    sign.getBlock().breakNaturally();
                } else {
                    if (lines[2].equals("")){
                        e.setLine(2, player.getName());
                    }

                    try {
                        double amount = Double.parseDouble(lines[1]);
                        e.setLine(1, Economy.fixDecimals(amount));
                        LogHelper.showInfo("commandSignPay", player, ChatColor.GREEN);
                    } catch (NumberFormatException ex){
                        LogHelper.showWarning("commandSignInvalid", player);
                        sign.getBlock().breakNaturally();
                    }
                }
            }
        } else if (function.equals("[item]")){
            if (Permissions.checkPerms(player, "cex.sign.create.item")){
                if (lines[1].equals("")){
                    LogHelper.showWarning("commandSignInvalid", player);
                    sign.getBlock().breakNaturally();
                } else {
                    String[] data = lines[1].split(":");
                    List<Material> matches = ClosestMatches.material(data[0]);
                    Material material = (matches.size() > 0 ? matches.get(0) : null);
                    if (material == null){
                        LogHelper.showWarning("itemNotFound", player);
                        sign.getBlock().breakNaturally();
                    } else {
                        if (data.length > 0){
                            if (data.length != 2){
                                LogHelper.showWarning("commandSignInvalid", player);
                                sign.getBlock().breakNaturally();
                            } else {
                                if (material == Material.WOOL || material == Material.INK_SACK){
                                    List<DyeColor> dyeMatches = ClosestMatches.dyeColor(data[1]);
                                    DyeColor dye = (dyeMatches.size() > 0 ? dyeMatches.get(0) : null);
                                    if (dye == null){
                                        LogHelper.showWarning("commandSignInvalid", player);
                                        sign.getBlock().breakNaturally();
                                        return;
                                    } else {
                                        e.setLine(1, WordUtils.capitalize(material.name().toLowerCase().replaceAll("_", ""))  + ":" + WordUtils.capitalize(dye.toString().toLowerCase().replaceAll("_", "")));
                                    }
                                } else {
                                    if (!data[1].matches(CommandsEX.intRegex)){
                                        LogHelper.showWarning("commandSignInvalid", player);
                                        sign.getBlock().breakNaturally();
                                        return;
                                    } else {
                                        e.setLine(1, WordUtils.capitalize(material.name().toLowerCase().replaceAll("_", "")));
                                    }
                                }
                            }
                        }
                       
                        if (lines[2].equals("")){
                            e.setLine(2, String.valueOf(1));
                        } else {
                            try {
                                Integer.parseInt(lines[2]);

                                if (!lines[3].equals("")){
                                    try {
                                        double amount = Double.parseDouble(lines[3]);

                                        e.setLine(3, Economy.fixDecimals(amount));
                                    } catch (NumberFormatException ex1){
                                        LogHelper.showWarning("commandSignInvalid", player);
                                        sign.getBlock().breakNaturally();
                                        return;
                                    }
                                }
                            } catch (NumberFormatException ex){
                                LogHelper.showWarning("commandSignInvalid", player);
                                sign.getBlock().breakNaturally();
                                return;
                            }
                        }

                        LogHelper.showInfo("commandSignItem", player, ChatColor.GREEN);
View Full Code Here


    public void onPlayerInteract(PlayerInteractEvent e){
        BlockState bs = e.getClickedBlock().getState();
        Player player = e.getPlayer();

        if (bs instanceof Sign){
            Sign sign = (Sign) bs;
            String[] lines = sign.getLines();
            String function = lines[0].toLowerCase();

            if (function.equals("[balance]")){
                if (Permissions.checkPerms(player, "cex.sign.use.balance")){
                    if (Vault.ecoEnabled()){
View Full Code Here

                      } else {
                        worldBlock.setType(Material.getMaterial(diskBlockType));
                        BlockState state = worldBlock.getState();
                        state.setData(new org.bukkit.material.Sign(diskBlockType, diskBlockData));
                        if (state instanceof Sign) {
                          Sign sign = (Sign) state;
                          if (lines != null && sign.getLines() != null) {
                            if (lines.length > 0) {
                              sign.setLine(0, lines[0]);
                            }
                            if (lines.length > 1) {
                              sign.setLine(1, lines[1]);
                            }
                            if (lines.length > 2) {
                              sign.setLine(2, lines[2]);
                            }
                            if (lines.length > 3) {
                              sign.setLine(3, lines[3]);
                            }
                            sign.update(true);
                          }
                        }
                      }
                    } else if (diskBlockType == Material.CHEST.getId()) {
                      // Chests read
View Full Code Here

                blocksOutput.write(data);

                if (state instanceof Sign) {
                  // Signs
                  String extra = "";
                  Sign sign = (Sign) state;
                  if (sign.getLines() != null) {
                    for (String line : sign.getLines()) {
                      extra += line + ";;";
                    }
                    signsWriter.write(extra);
                    signsWriter.newLine();
                  }
View Full Code Here

                            } else {
                              worldBlock.setType(Material.getMaterial(diskBlockType));
                              BlockState state = worldBlock.getState();
                              state.setData(new org.bukkit.material.Sign(diskBlockType, diskBlockData));
                              if (state instanceof Sign) {
                                Sign sign = (Sign) state;
                                if (lines != null && sign.getLines() != null) {
                                  if (lines.length > 0) {
                                    sign.setLine(0, lines[0]);
                                  }
                                  if (lines.length > 1) {
                                    sign.setLine(1, lines[1]);
                                  }
                                  if (lines.length > 2) {
                                    sign.setLine(2, lines[2]);
                                  }
                                  if (lines.length > 3) {
                                    sign.setLine(3, lines[3]);
                                  }
                                  sign.update(true);
                                }
                              }
                            }
                          }
                        } else if (diskBlockType == Material.CHEST.getId()) {
View Full Code Here

        if (event.getClickedBlock().getTypeId() == 42) {
            handleReadyBlock(p);
        }
        // Sign
        else if (event.getClickedBlock().getState() instanceof Sign) {
            Sign sign = (Sign) event.getClickedBlock().getState();
            handleSign(sign, p);
        }
    }
View Full Code Here

            return false;
        }
       
        // Grab the top left sign and set up a copy for parsing.
        this.topLeftSign = (Sign) state;
        Sign current = this.topLeftSign;
       
        // Calculate matrix dimensions.
        this.direction = getRightDirection(current);
        this.rows = getSignCount(current, BlockFace.DOWN);
        this.cols = getSignCount(current, direction);
       
        // Require at least 2x2 to be valid
        if (rows <= 1 || cols <= 1) {
            return false;
        }
       
        // Get the left-most sign in the current row.
        Sign first = getAdjacentSign(current, BlockFace.DOWN);
       
        for (int i = 1; i < rows; i++)
        {
            // Back to the first sign of the row.
            current = first;
View Full Code Here

     * Requires: The grid MUST be valid!
     */
    private void initializeBoards()
    {
        boards.clear();
        Sign header = this.topLeftSign;
        Sign current;
       
        do
        {
            // Strip the sign of any colors.
            String name = ChatColor.stripColor(header.getLine(2));
View Full Code Here

        // Make sure the stats will fit on the signs.
        int range = Math.min(stats.size(), signs.size()*4);
       
        for (int i = 0; i < range; i++) {
            // Grab the right sign.
            Sign s = signs.get(i/4);
           
            // Call the template method.
            String value = getLine(stats.get(i));
           
            // And set the line
            s.setLine(i % 4, value);
            s.update();
        }
    }
View Full Code Here

        //Iterator<String> iterator = am.getClasses().iterator();
        Iterator<String> iterator = am.getClasses().keySet().iterator();
        for (int i = lx1+2; i <= lx2-2; i++) // Signs
        {
            world.getBlockAt(i,ly1+1,lz2-1).setTypeIdAndData(63, (byte)0x8, false);
            Sign sign = (Sign) world.getBlockAt(i,ly1+1,lz2-1).getState();
            sign.setLine(0, TextUtils.camelCase((String)iterator.next()));
            sign.update();
        }
        world.getBlockAt(lx2-2,ly1+1,lz1+2).setType(Material.IRON_BLOCK);
       
        // Set up the monster points.
        ArenaRegion region = arena.getRegion();
View Full Code Here

TOP

Related Classes of org.bukkit.block.Sign

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.