Package org.bukkit.block

Examples of org.bukkit.block.Sign


  @EventHandler
  public void HeavyClassBuy(PlayerInteractEvent event){
   
    if(event.getClickedBlock().getState() instanceof Sign){
     
      Sign sign = (Sign) event.getClickedBlock().getState();
     
      if(sign.getLine(0).equalsIgnoreCase("[PrideShop]")){
       
        if(sign.getLine(1).equalsIgnoreCase("Class")){
         
          if(sign.getLine(2).equalsIgnoreCase("Heavy")){
           
            if(sign.getLine(3).equalsIgnoreCase("5")){
             
             
            }
          }
        }
View Full Code Here


 
  public final void setWallSign(int x, int y, int z, Direction.General direction, String[] text) {
    Block block = getActualBlock(x, y, z);
    if (BlackMagic.setBlockType(block, Material.WALL_SIGN, direction.getData())) {
      if (block.getType() == Material.WALL_SIGN) {
        Sign sign = (Sign) block.getState();
        for (int i = 0; i < text.length && i < 4; i++)
          sign.setLine(i, text[i]);
        sign.update(true);
      }
    }
  }
View Full Code Here

  public final void setSignPost(int x, int y, int z, BlockFace direction, String[] text) {
    Block block = getActualBlock(x, y, z);
    block.setType(Material.SIGN_POST);
    if (block.getType() == Material.SIGN_POST) {
      Sign signState = (Sign) block.getState();
     
      org.bukkit.material.Sign signDirection = new org.bukkit.material.Sign();
      signDirection.setFacingDirection(direction);
      signState.setData(signDirection);
     
      for (int i = 0; i < text.length && i < 4; i++)
        signState.setLine(i, text[i]);

      signState.update(true);
    }
  }
View Full Code Here

   * Extracts the sign data from a block
   * @param block
   */
  private void interpretSignBlock(Block block) {
    if (!(block.getState() instanceof Sign)) return;
    Sign sign = (Sign) block.getState();
    org.bukkit.material.Sign signData = (org.bukkit.material.Sign) sign.getData();
    if (signData.isWallSign()) this.facing = signData.getAttachedFace();
    else this.facing = signData.getFacing();
    this.wallSign = signData.isWallSign();
    this.lines = sign.getLines();
  }
View Full Code Here

    //if it is a sign break
    else {
      if (wallSign) block.setType(Material.WALL_SIGN);
      else block.setType(Material.SIGN_POST);
      Sign sign = (Sign)(block.getState());
      for (int i = 0; i < lines.length; i++) if (lines[i] != null) sign.setLine(i, lines[i]);
      if (wallSign) ((org.bukkit.material.Sign)sign.getData()).setFacingDirection(facing.getOppositeFace());
      else ((org.bukkit.material.Sign)sign.getData()).setFacingDirection(facing);
      sign.update();
    }

    return true;

  }
View Full Code Here

    if (type == DataType.SIGN_BREAK) block.setTypeId(0);
    else {
      if (wallSign) block.setType(Material.WALL_SIGN);
      else block.setType(Material.SIGN_POST);
      Sign sign = (Sign)(block.getState());
      for (int i = 0; i < lines.length; i++) if (lines[i] != null) sign.setLine(i, lines[i]);
      if (wallSign) ((org.bukkit.material.Sign)sign.getData()).setFacingDirection(facing.getOppositeFace());
      else ((org.bukkit.material.Sign)sign.getData()).setFacingDirection(facing);
      sign.update();
    }
    return true;

  }
View Full Code Here

      if(signBlock == null) return;
     

      // Check main three users.

      Sign    sign = (Sign) signBlock.getState();
      String    line;
      int      y;
     
      for(y = 1; y <= 3; ++y) if(!sign.getLine(y).isEmpty()){
        line = sign.getLine(y).replaceAll("(?i)\u00A7[0-F]", "");
       
        if(line.equalsIgnoreCase("[Everyone]") || line.equalsIgnoreCase(Lockette.altEveryone)) return;
      }
     
     
      // Check for more users.
     
      List<Block>  list = Lockette.findBlockUsers(block, signBlock);
      int      x, count = list.size();
     
      for(x = 0; x < count; ++x){
        sign = (Sign) list.get(x).getState();
       
        for(y = 1; y <= 3; ++y) if(!sign.getLine(y).isEmpty()){
          line = sign.getLine(y).replaceAll("(?i)\u00A7[0-F]", "");
         
          if(line.equalsIgnoreCase("[Everyone]") || line.equalsIgnoreCase(Lockette.altEveryone)) return;
        }
      }
     
View Full Code Here

    */
   
    // But also need this along with stuff in PrefixListener
   
    if(typeWallSign){
      Sign    sign = (Sign) block.getState();
      String    text = sign.getLine(0).replaceAll("(?i)\u00A7[0-F]", "");
     
      if(text.equalsIgnoreCase("[Private]") || text.equalsIgnoreCase(Lockette.altPrivate) ||
          text.equalsIgnoreCase("[More Users]") || text.equalsIgnoreCase(Lockette.altMoreUsers)){
        if(event.isCancelled()) return;
        //event.setCancelled(true);
        //return;
      }
    }
    else if(typeSignPost){
     
    }
    else{
      // Not a sign, wtf!
      event.setCancelled(true);
      return;
    }
   
    /*
    // Alternative: Enforce a blank sign, as bukkit catches spoofed packets now.
    // No longer needed, as the findOwner now has an ignore block.
   
    if(typeWallSign || (block.getTypeId() == Material.SIGN_POST.getId())){
      Sign    sign = (Sign) block.getState();
      String    text = sign.getLine(0).replaceAll("(?i)\u00A7[0-F]", "").toLowerCase();
     
      if(text.equals("[private]") || text.equals(Lockette.altPrivate) || text.equals("[more users]") || text.equals(Lockette.altMoreUsers)){
        sign.setLine(0, "");
        sign.setLine(1, "");
        sign.setLine(2, "");
        sign.setLine(3, "");
        sign.update(true);
      }
    }
    */
    /*
    // Colorizer code.
    // Moved to PrefixListener
   
    if(Lockette.colorTags){
      event.setLine(0, event.getLine(0).replaceAll("&([0-9A-Fa-f])", "\u00A7$1"));
      event.setLine(1, event.getLine(1).replaceAll("&([0-9A-Fa-f])", "\u00A7$1"));
      event.setLine(2, event.getLine(2).replaceAll("&([0-9A-Fa-f])", "\u00A7$1"));
      event.setLine(3, event.getLine(3).replaceAll("&([0-9A-Fa-f])", "\u00A7$1"));
    }
    */
   
    // Check for a new [Private] or [More Users] sign.
   
    String    text = event.getLine(0).replaceAll("(?i)\u00A7[0-F]", "");
   
   
   
    if(text.equalsIgnoreCase("[Private]") || text.equalsIgnoreCase(Lockette.altPrivate)){
      //Player    player = event.getPlayer();
      //Block    block = event.getBlock();
      //boolean    typeWallSign = (block.getTypeId() == Material.WALL_SIGN.getId());
      boolean    doChests = true, doFurnaces = true, doDispensers = true;
      boolean    doBrewingStands = true, doCustoms = true;
      boolean    doTrapDoors = true, doDoors = true;
     
     
      // Check for permission first.
     
      if(plugin.usingExternalZones()){
        if(!plugin.canBuild(player, block)){
          event.setLine(0, "[?]");
         
          plugin.localizedMessage(player, null, "msg-error-zone", PluginCore.lastZoneDeny());
          return;
        }
      }
     
      if(plugin.usingExternalPermissions()){
        boolean    create = false;
       
        doChests = false;
        doFurnaces = false;
        doDispensers = false;
        doBrewingStands = false;
        doCustoms = false;
        doTrapDoors = false;
        doDoors = false;
       
        if(plugin.hasPermission(block.getWorld(), player, "lockette.create.all")){
          create = true;
          doChests = true;
          doFurnaces = true;
          doDispensers = true;
          doBrewingStands = true;
          doCustoms = true;
          doTrapDoors = true;
          doDoors = true;
        }
        else{
          if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.chest")){
            create = true;
            doChests = true;
          }
          if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.furnace")){
            create = true;
            doFurnaces = true;
          }
          if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.dispenser")){
            create = true;
            doDispensers = true;
          }
          if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.brewingstand")){
            create = true;
            doBrewingStands = true;
          }
          if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.custom")){
            create = true;
            doCustoms = true;
          }
          if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.trapdoor")){
            create = true;
            doTrapDoors = true;
          }
          if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.door")){
            create = true;
            doDoors = true;
          }
        }
       
        if(!create){
          event.setLine(0, "[?]");
         
          plugin.localizedMessage(player, null, "msg-error-permission");
          return;
        }
      }
     
     
     
      int      x;
      Block    checkBlock[] = new Block[4];
      byte    face = 0;
      int      type = 0;
      boolean    conflict = false;
      boolean    deny = false;
      boolean    zonedeny = false;
     
     
      // Check wall sign attached block for trap doors.
     
      if(Lockette.protectTrapDoors) if(typeWallSign){
        checkBlock[3] = Lockette.getSignAttachedBlock(block);
       
        if(checkBlock[3] != null) if(!isInList(checkBlock[3].getTypeId(), materialListBad)){
          checkBlock[0] = checkBlock[3].getRelative(BlockFace.NORTH);
          checkBlock[1] = checkBlock[3].getRelative(BlockFace.EAST);
          checkBlock[2] = checkBlock[3].getRelative(BlockFace.SOUTH);
          checkBlock[3] = checkBlock[3].getRelative(BlockFace.WEST);

          for(x = 0; x < 4; ++x){
            if(checkBlock[x].getTypeId() == Material.TRAP_DOOR.getId()){
              if(Lockette.findBlockOwner(checkBlock[x], block, true) == null){
                if(!doTrapDoors) deny = true;
                else{
                  face = block.getData();
                  type = 4;
                  break;
                }
              }
            }
          }
          /*
          if(Lockette.findBlockOwner(checkBlock[3], block, true) == null){
            if(!doTrapDoors) deny = true;
            else{
              face = block.getData();
              type = 4;
            }
          }*/
        }
      }
     
     
      // Check wall sign attached block for doors, above and below.
     
      if(Lockette.protectDoors) if(typeWallSign){
        checkBlock[0] = Lockette.getSignAttachedBlock(block);
       
        if(checkBlock[0] != null) if(!isInList(checkBlock[0].getTypeId(), materialListBad)){
          checkBlock[1] = checkBlock[0].getRelative(BlockFace.UP);
          checkBlock[2] = checkBlock[0].getRelative(BlockFace.DOWN);
         
          if(isInList(checkBlock[1].getTypeId(), materialListDoors)){
            if(Lockette.findBlockOwner(checkBlock[1], block, true) == null){
              if(isInList(checkBlock[2].getTypeId(), materialListDoors)){
                if(Lockette.findBlockOwner(checkBlock[2], block, true) == null){
                  // unclaimed (unowned above, unowned below)
                  if(!doDoors) deny = true;
                  else{
                    face = block.getData();
                    type = 5;
                  }
                }
                // else conflict (unowned above, but already owned below)
                else conflict = true;
              }
              else{
                // unclaimed (unowned above, empty below)
                if(!doDoors) deny = true;
                else{
                  face = block.getData();
                  type = 5;
                }
              }
            }
            // else unknown (already owned above, unknown below)
            //else if(isInList(checkBlock[2].getTypeId(), materialListDoors)){
              //if(Lockette.findBlockOwner(checkBlock[2]) == null){
                // conflict (already owned above, but unowned below)
                //conflict = true;
              //}
              //else claimed (+ conflict) (already owned above, already owned below)
              //else
              //conflict = true;
            //}
            // else claimed (+ conflict obscure) (already owned above, empty below)
            else conflict = true;
          }
          else if(isInList(checkBlock[2].getTypeId(), materialListDoors)){
            if(Lockette.findBlockOwner(checkBlock[2], block, true) == null){
              // unclaimed (empty above, unowned below)
              if(!doDoors) deny = true;
              else{
                face = block.getData();
                type = 5;
              }
            }
            // else claimed (+ conflict) (empty above, already owned below)
            else conflict = true;
          }
          // else none (empty above, empty below)
        }
      }
     
      // Reset trapdoor face if there is a conflict with a door.
      if(conflict == true){
        face = 0;
        type = 0;
      }
     
     
      if(face == 0){
        int      lastType;
       
        // Check for chests first, dispensers second, furnaces third.
       
        checkBlock[0] = block.getRelative(BlockFace.NORTH);
        checkBlock[1] = block.getRelative(BlockFace.EAST);
        checkBlock[2] = block.getRelative(BlockFace.SOUTH);
        checkBlock[3] = block.getRelative(BlockFace.WEST);
       
        for(x = 0; x < 4; ++x){
          if(plugin.usingExternalZones()){
            if(!plugin.canBuild(player, checkBlock[x])){
              zonedeny = true;
              continue;
            }
          }
         
         
          // Check if allowed by type.
          if(checkBlock[x].getTypeId() == Material.CHEST.getId()){
            if(!doChests){
              deny = true;
              continue;
            }
            lastType = 1;
          }
          else if(isInList(checkBlock[x].getTypeId(), materialListFurnaces)){
            if(!doFurnaces){
              deny = true;
              continue;
            }
            lastType = 2;
          }
          else if(checkBlock[x].getTypeId() == Material.DISPENSER.getId()){
            if(!doDispensers){
              deny = true;
              continue;
            }
            lastType = 3;
          }
          else if(checkBlock[x].getTypeId() == Material.BREWING_STAND.getId()){
            if(!doBrewingStands){
              deny = true;
              continue;
            }
            lastType = 6;
          }
          else if(Lockette.isInList(checkBlock[x].getTypeId(), Lockette.customBlockList)){
            if(!doCustoms){
              deny = true;
              continue;
            }
            lastType = 7;
          }
          else if(checkBlock[x].getTypeId() == Material.TRAP_DOOR.getId()){
            if(!Lockette.protectTrapDoors) continue;
            if(!doTrapDoors){
              deny = true;
              continue;
            }
            lastType = 4;
          }
          else if(isInList(checkBlock[x].getTypeId(), materialListDoors)){
            if(!Lockette.protectDoors) continue;
            if(!doDoors){
              deny = true;
              continue;
            }
            lastType = 5;
          }
          else continue;
         
          // Allowed, lets see if it is claimed.
          if(Lockette.findBlockOwner(checkBlock[x], block, true) == null){
            face = faceList[x];
            type = lastType;
            break;
          }
          // For when the last type is a door, and it is conflicting.
          else{
            if(Lockette.protectTrapDoors) if(doTrapDoors){
              if(checkBlock[x].getTypeId() == Material.TRAP_DOOR.getId()){
                conflict = true;
              }
            }
            if(Lockette.protectDoors) if(doDoors){
              if(isInList(checkBlock[x].getTypeId(), materialListDoors)){
                conflict = true;
              }
            }
          }
        }
      }
     
     
      // None found, send a message.
     
      if(face == 0){
        event.setLine(0, "[?]");
       
        if(conflict) plugin.localizedMessage(player, null, "msg-error-claim-conflict");
        else if(zonedeny) plugin.localizedMessage(player, null, "msg-error-zone", PluginCore.lastZoneDeny());
        else if(deny) plugin.localizedMessage(player, null, "msg-error-permission");
        else plugin.localizedMessage(player, null, "msg-error-claim");
        return;
      }
     
     
      // Claim it...

      boolean    anyone = true;
      int      length = player.getName().length();
     
      if(event.getLine(1).isEmpty()) anyone = false;
      if(length > 15) length = 15;
     
      // In case some other plugin messed with the cancel state.
      event.setCancelled(false);
     
      if(anyone){
        // Check if allowed by type.
        if(type == 1){  // Chest
          if(!plugin.hasPermission(block.getWorld(), player, "lockette.admin.create.chest")) anyone = false;
        }
        else if(type == 2){  // Furnace
          if(!plugin.hasPermission(block.getWorld(), player, "lockette.admin.create.furnace")) anyone = false;
        }
        else if(type == 3){  // Dispenser
          if(!plugin.hasPermission(block.getWorld(), player, "lockette.admin.create.dispenser")) anyone = false;
        }
        else if(type == 6){  // Brewing Stand
          if(!plugin.hasPermission(block.getWorld(), player, "lockette.admin.create.brewingstand")) anyone = false;
        }
        else if(type == 7){  // Custom
          if(!plugin.hasPermission(block.getWorld(), player, "lockette.admin.create.custom")) anyone = false;
        }
        else if(type == 4){  // Trap Door
          if(!plugin.hasPermission(block.getWorld(), player, "lockette.admin.create.trapdoor")) anyone = false;
        }
        else if(type == 5){  // Door
          if(!plugin.hasPermission(block.getWorld(), player, "lockette.admin.create.door")) anyone = false;
        }
        else anyone = false;
      }
     
      if(!anyone) event.setLine(1, player.getName().substring(0, length));
     
     
      if(!typeWallSign){
        // Set to wall type.
        block.setType(Material.WALL_SIGN);
        block.setData(face);
       
        // Re-set the text.
        Sign    sign = (Sign) block.getState();
       
        sign.setLine(0, event.getLine(0));
        sign.setLine(1, event.getLine(1));
        sign.setLine(2, event.getLine(2));
        sign.setLine(3, event.getLine(3));
        sign.update(true);
      }
      else block.setData(face);
     
     
      // All done!
     
      if(anyone){
        Lockette.log.info("[" + plugin.getDescription().getName() + "] (Admin) " + player.getName() + " has claimed a container for " + event.getLine(1) + ".");
       
        if(!plugin.playerOnline(event.getLine(1))) plugin.localizedMessage(player, null, "msg-admin-claim-error", event.getLine(1));
        else plugin.localizedMessage(player, null, "msg-admin-claim", event.getLine(1));
      }
      else{
        Lockette.log.info("[" + plugin.getDescription().getName() + "] " + player.getName() + " has claimed a container.");
       
        plugin.localizedMessage(player, null, "msg-owner-claim");
      }
    }
    else if(text.equalsIgnoreCase("[More Users]") || text.equalsIgnoreCase(Lockette.altMoreUsers)){
      //Player    player = event.getPlayer();
      //Block    block = event.getBlock();
      //boolean    typeWallSign = (block.getTypeId() == Material.WALL_SIGN.getId());
     
      int      x;
      Block    checkBlock[]  = new Block[4];
      Block    signBlock = null;
      Sign    sign = null;
      byte    face = 0;
      //int      type = 0;

      int      length = player.getName().length();
     
      if(length > 15) length = 15;
     
     
      // Check wall sign attached block for owner.
     
      if(Lockette.protectDoors || Lockette.protectTrapDoors) if(typeWallSign){
        checkBlock[0] = Lockette.getSignAttachedBlock(block);
       
        if(checkBlock[0] != null) if(!isInList(checkBlock[0].getTypeId(), materialListBad)){
          signBlock = Lockette.findBlockOwner(checkBlock[0]);
         
          if(signBlock != null){
            sign = (Sign) signBlock.getState();
           
            // Check owner.
            if(sign.getLine(1).replaceAll("(?i)\u00A7[0-F]", "").equals(player.getName().substring(0, length))){
              face = block.getData();
            }
          }
        }
      }
     
     
      if(face == 0){
        // Check for chests first, dispensers second, furnaces third.
       
        checkBlock[0] = block.getRelative(BlockFace.NORTH);
        checkBlock[1] = block.getRelative(BlockFace.EAST);
        checkBlock[2] = block.getRelative(BlockFace.SOUTH);
        checkBlock[3] = block.getRelative(BlockFace.WEST);
       
        for(x = 0; x < 4; ++x){
          if(!isInList(checkBlock[x].getTypeId(), materialList)) continue;
         
          if(!Lockette.protectTrapDoors){
            if(checkBlock[x].getTypeId() == Material.TRAP_DOOR.getId()) continue;
          }
         
          if(!Lockette.protectDoors){
            if(isInList(checkBlock[x].getTypeId(), materialListDoors)) continue;
          }
         
         
          signBlock = Lockette.findBlockOwner(checkBlock[x]);
         
          if(signBlock != null){
            sign = (Sign) signBlock.getState();
           
            // Check owner.
            if(sign.getLine(1).replaceAll("(?i)\u00A7[0-F]", "").equals(player.getName().substring(0, length))){
              face = faceList[x];
              //type = y;
              break;
            }
          }
        }
      }
     
     
      // None found, send a message.
     
      if(face == 0){
        event.setLine(0, "[?]");
        if(sign != null){
          plugin.localizedMessage(player, null, "msg-error-adduser-owned", sign.getLine(1));
        }
        else{
          plugin.localizedMessage(player, null, "msg-error-adduser");
        }
        return;
      }
     
     
      // Add the users sign.

      // In case some other plugin messed with the cancel state.
      event.setCancelled(false);
      if(!typeWallSign){
        // Set to wall type.
        block.setType(Material.WALL_SIGN);
        block.setData(face);
       
        // Re-set the text.
        //Sign   
        sign = (Sign) block.getState();
       
        sign.setLine(0, event.getLine(0));
        sign.setLine(1, event.getLine(1));
        sign.setLine(2, event.getLine(2));
        sign.setLine(3, event.getLine(3));
        sign.update(true);
       
      }
      else block.setData(face);
     
     
View Full Code Here

        // Fix for mcMMO error.
        block.setData((byte) 5);
      }
     
     
      Sign    sign = (Sign) block.getState();
      String    text = sign.getLine(0).replaceAll("(?i)\u00A7[0-F]", "").toLowerCase();
     
      if(text.equals("[private]") || text.equalsIgnoreCase(Lockette.altPrivate)){
        int      length = player.getName().length();
       
        if(length > 15) length = 15;
       
        // Check owner.
        if(sign.getLine(1).replaceAll("(?i)\u00A7[0-F]", "").equals(player.getName().substring(0, length))){
          //Block    checkBlock = Lockette.getSignAttachedBlock(block);
          //if(checkBlock == null) checkBlock = block;
         
          //if((checkBlock.getTypeId() != Material.WOODEN_DOOR.getId()) && (checkBlock.getTypeId() != Material.IRON_DOOR_BLOCK.getId())){
          Lockette.log.info("[" + plugin.getDescription().getName() + "] " + player.getName() + " has released a container.");
          //}
          //else Lockette.log.info("[" + plugin.getDescription().getName() + "] " + player.getName() + " has released a door.");
         
          plugin.localizedMessage(player, null, "msg-owner-release");
          return;
        }
       
        // At this point, check admin.

        if(Lockette.adminBreak){
          boolean    snoop = false;
         
          if(plugin.hasPermission(block.getWorld(), player, "lockette.admin.break")) snoop = true;
         
          if(snoop){
            Lockette.log.info("[" + plugin.getDescription().getName() + "] (Admin) " + player.getName() + " has broken open a container owned by " + sign.getLine(1) + "!");
           
            plugin.localizedMessage(player, Lockette.broadcastBreakTarget, "msg-admin-release", sign.getLine(1));
            return;
          }
        }
       
       
        event.setCancelled(true);
        sign.update();
       
        plugin.localizedMessage(player, null, "msg-user-release-owned", sign.getLine(1));
      }
      else if(text.equals("[more users]") || text.equalsIgnoreCase(Lockette.altMoreUsers)){
        Block    checkBlock = Lockette.getSignAttachedBlock(block);
        if(checkBlock == null) return;
       
        Block    signBlock = Lockette.findBlockOwner(checkBlock);
        if(signBlock == null) return;
       
        Sign    sign2 = (Sign) signBlock.getState();
        int      length = player.getName().length();
       
        if(length > 15) length = 15;
       
        if(sign2.getLine(1).replaceAll("(?i)\u00A7[0-F]", "").equals(player.getName().substring(0, length))){
          plugin.localizedMessage(player, null, "msg-owner-remove");
          return;
        }
       
        event.setCancelled(true);
        sign.update();
       
        plugin.localizedMessage(player, null, "msg-user-remove-owned", sign2.getLine(1));
      }
    }
    else{
      Block    signBlock = Lockette.findBlockOwner(block);

      if(signBlock == null) return;
     
      Sign    sign = (Sign) signBlock.getState();
      int      length = player.getName().length();

      if(length > 15) length = 15;
     
      // Check owner.
      if(sign.getLine(1).replaceAll("(?i)\u00A7[0-F]", "").equals(player.getName().substring(0, length))){
        if(Lockette.findBlockOwnerBreak(block) != null){
          // This block has the sign attached.  (Or the the door above the block.)
         
          Lockette.log.info("[" + plugin.getDescription().getName() + "] " + player.getName() + " has released a container.");
        }
        else{
          // Partial release for chest/doors, the sign may now be invalid for doors, but is always valid for chests.
         
          if((type == Material.WOODEN_DOOR.getId()) || (type == Material.IRON_DOOR_BLOCK.getId())){
            // Check for invalid signs somehow?
            // But valid signs can be collided anyways... so probably doesn't matter.  (Unless this is prevented too.)
          }
        }
        return;
      }
     
      event.setCancelled(true);
      //if(!Lockette.enhancedEvents){
      //  // Fix for broken doors in build xxx-560.
      //  if(type == Material.WOODEN_DOOR.getId()) Lockette.toggleSingleDoor(block);
      //}
     
      plugin.localizedMessage(player, null, "msg-user-break-owned", sign.getLine(1));
    }
  }
View Full Code Here

   
    // Check if someone accidentally put any block on an owned sign.
   
    if(against.getTypeId() == Material.WALL_SIGN.getId()){
      // Only cancel it for our signs.
      Sign    sign = (Sign) against.getState();
      String    text = sign.getLine(0).replaceAll("(?i)\u00A7[0-F]", "").toLowerCase();
     
      if(text.equals("[private]") || text.equalsIgnoreCase(Lockette.altPrivate) || text.equals("[more users]") || text.equalsIgnoreCase(Lockette.altMoreUsers)){
        event.setCancelled(true);
        return;
      }
    }
   
   
    // Check the placing of a door by a door here.
    // Though it is usually an item, not a block?  Is this still needed?
   
    if((type == Material.WOODEN_DOOR.getId()) || (type == Material.IRON_DOOR_BLOCK.getId()) || (type == Material.TRAP_DOOR.getId()) || (type == Material.FENCE_GATE.getId())){
      //player.sendMessage(ChatColor.DARK_PURPLE + "Lockette: Door block block has been placed");
     
      if(canBuildDoor(block, against, player)) return;
     
     
      event.setCancelled(true);
     
     
      plugin.localizedMessage(player, null, "msg-user-conflict-door");
      return;
    }
   
   
    if(Lockette.directPlacement) if(type == Material.WALL_SIGN.getId()){
      Block    checkBlock = Lockette.getSignAttachedBlock(block);
     
      if(checkBlock == null) return;
     
      type = checkBlock.getTypeId();
     
      if((type == Material.CHEST.getId()) || (type == Material.DISPENSER.getId()) ||
          (type == Material.FURNACE.getId()) || (type == Material.BURNING_FURNACE.getId()) ||
          (type == Material.BREWING_STAND.getId()) || Lockette.isInList(type, Lockette.customBlockList)){
       
        Sign    sign = (Sign) block.getState();
        int      length = player.getName().length();
       
        if(length > 15) length = 15;
       
        if(Lockette.isProtected(checkBlock)){
          // Add a users sign only if owner.
          if(Lockette.isOwner(checkBlock, player.getName())){
            sign.setLine(0, Lockette.altMoreUsers);
            sign.setLine(1, Lockette.altEveryone);
            sign.setLine(2, "");
            sign.setLine(3, "");
            sign.update(true);
           
            plugin.localizedMessage(player, null, "msg-owner-adduser");
          }
          else event.setCancelled(true);
        }
        else{
          // Check for permission first.
         
          if(plugin.usingExternalZones()){
            if(!plugin.canBuild(player, block)){
              event.setCancelled(true);
             
              plugin.localizedMessage(player, null, "msg-error-zone", PluginCore.lastZoneDeny());
              return;
            }
           
            if(!plugin.canBuild(player, checkBlock)){
              event.setCancelled(true);
             
              plugin.localizedMessage(player, null, "msg-error-zone", PluginCore.lastZoneDeny());
              return;
            }
          }
         
          if(plugin.usingExternalPermissions()){
            boolean    create = false;
           
            if(plugin.hasPermission(block.getWorld(), player, "lockette.create.all")) create = true;
            else if(type == Material.CHEST.getId()){
              if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.chest")) create = true;
            }
            else if((type == Material.FURNACE.getId()) || (type == Material.BURNING_FURNACE.getId())){
              if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.furnace")) create = true;
            }
            else if(type == Material.DISPENSER.getId()){
              if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.dispenser")) create = true;
            }
            else if(type == Material.BREWING_STAND.getId()){
              if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.brewingstand")) create = true;
            }
            else if(Lockette.isInList(type, Lockette.customBlockList)){
              if(plugin.hasPermission(block.getWorld(), player, "lockette.user.create.custom")) create = true;
            }
           
           
            if(!create){
              event.setCancelled(true);
             
              plugin.localizedMessage(player, null, "msg-error-permission");
              return;
            }
          }
         
         
          sign.setLine(0, Lockette.altPrivate);
          sign.setLine(1, player.getName().substring(0, length));
          sign.setLine(2, "");
          sign.setLine(3, "");
          sign.update(true);
         
          Lockette.log.info("[" + plugin.getDescription().getName() + "] " + player.getName() + " has claimed a container.");
         
          plugin.localizedMessage(player, null, "msg-owner-claim");
        }
      }
     
      return;
    }
   
   
    // The rest is for chests only.
   
    if(type != Material.CHEST.getId()) return;
   
   
    // Count nearby chests to find illegal sized chests.
   
    int      chests = Lockette.findChestCountNear(block);
   
    if(chests > 1){
      event.setCancelled(true);
     
      plugin.localizedMessage(player, null, "msg-user-illegal");
      return;
    }
   
   
    Block    signBlock = Lockette.findBlockOwner(block);
   
    if(signBlock != null){
      // Expanding a private chest, see if its allowed.
     
      Sign    sign = (Sign) signBlock.getState();
      int      length = player.getName().length();
     
      if(length > 15) length = 15;
     
      // Check owner.
      if(sign.getLine(1).replaceAll("(?i)\u00A7[0-F]", "").equals(player.getName().substring(0, length))) return;
     
     
      // If we got here, then not allowed.
     
      event.setCancelled(true);
     
      plugin.localizedMessage(player, null, "msg-user-resize-owned", sign.getLine(1));
    }
    else{
      // Only send one helpful message per user per session.
     
      if(plugin.playerList.get(player.getName()) == null){
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.