Beispiel #1
0
 /**
  * Checks if location is anywhere in the island space (island distance)
  *
  * @param target
  * @return true if in the area
  */
 public boolean inIslandSpace(Location target) {
   if (target.getWorld().equals(ASkyBlock.getIslandWorld())
       || target.getWorld().equals(ASkyBlock.getNetherWorld())) {
     if (target.getX() >= center.getBlockX() - islandDistance / 2
         && target.getX() < center.getBlockX() + islandDistance / 2
         && target.getZ() >= center.getBlockZ() - islandDistance / 2
         && target.getZ() < center.getBlockZ() + islandDistance / 2) {
       return true;
     }
   }
   return false;
 }
Beispiel #2
0
 /**
  * Checks if a location is within this island's protected area
  *
  * @param loc
  * @return
  */
 public boolean onIsland(Location target) {
   if (world != null) {
     // If the new nether is being used, islands exist in the nether too
     if (target.getWorld().equals(world)
         || (Settings.createNether
             && Settings.newNether
             && target.getWorld().equals(ASkyBlock.getNetherWorld()))) {
       if (target.getX() >= center.getBlockX() - protectionRange / 2
           && target.getX() < center.getBlockX() + protectionRange / 2
           && target.getZ() >= center.getBlockZ() - protectionRange / 2
           && target.getZ() < center.getBlockZ() + protectionRange / 2) {
         return true;
       }
     }
   }
   return false;
 }
Beispiel #3
0
 /**
  * Checks to see if a sign has been broken
  *
  * @param e
  */
 @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
 public void onSignBreak(BlockBreakEvent e) {
   Block b = e.getBlock();
   Player player = e.getPlayer();
   if (b.getWorld().equals(ASkyBlock.getIslandWorld())
       || b.getWorld().equals(ASkyBlock.getNetherWorld())) {
     if (b.getType().equals(Material.SIGN_POST) || b.getType().equals(Material.WALL_SIGN)) {
       Sign s = (Sign) b.getState();
       if (s != null) {
         // plugin.getLogger().info("DEBUG: sign found at location " + s.toString());
         if (s.getLine(0).equalsIgnoreCase(ChatColor.GREEN + plugin.myLocale().warpswelcomeLine)) {
           // Do a quick check to see if this sign location is in
           // plugin.getLogger().info("DEBUG: welcome sign");
           // the list of warp signs
           if (warpList.containsValue(s.getLocation())) {
             // plugin.getLogger().info("DEBUG: warp sign is in list");
             // Welcome sign detected - check to see if it is
             // this player's sign
             if ((warpList.containsKey(player.getUniqueId())
                 && warpList.get(player.getUniqueId()).equals(s.getLocation()))) {
               // Player removed sign
               removeWarp(s.getLocation());
             } else if (player.isOp()
                 || player.hasPermission(Settings.PERMPREFIX + "mod.removesign")) {
               // Op or mod removed sign
               player.sendMessage(
                   ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).warpsremoved);
               removeWarp(s.getLocation());
             } else {
               // Someone else's sign - not allowed
               player.sendMessage(
                   ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNoRemove);
               e.setCancelled(true);
             }
           }
         }
       }
     }
   }
 }
Beispiel #4
0
  /**
   * Event handler for Sign Changes
   *
   * @param e
   */
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
  public void onSignWarpCreate(SignChangeEvent e) {
    // plugin.getLogger().info("DEBUG: SignChangeEvent called");
    String title = e.getLine(0);
    Player player = e.getPlayer();
    if (player.getWorld().equals(ASkyBlock.getIslandWorld())
        || player.getWorld().equals(ASkyBlock.getNetherWorld())) {
      // plugin.getLogger().info("DEBUG: Correct world");
      if (e.getBlock().getType().equals(Material.SIGN_POST)
          || e.getBlock().getType().equals(Material.WALL_SIGN)) {

        // plugin.getLogger().info("DEBUG: The first line of the sign says " + title);
        // Check if someone is changing their own sign
        // This should never happen !!
        if (title.equalsIgnoreCase(plugin.myLocale().warpswelcomeLine)) {
          // plugin.getLogger().info("DEBUG: Welcome sign detected");
          // Welcome sign detected - check permissions
          if (!(VaultHelper.checkPerm(player, Settings.PERMPREFIX + "island.addwarp"))) {
            player.sendMessage(
                ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNoPerm);
            return;
          }
          // Check that the player is on their island
          if (!(plugin.getGrid().playerIsOnIsland(player))) {
            player.sendMessage(
                ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorNoPlace);
            e.setLine(0, ChatColor.RED + plugin.myLocale().warpswelcomeLine);
            return;
          }
          // Check if the player already has a sign
          final Location oldSignLoc = getWarp(player.getUniqueId());
          if (oldSignLoc == null) {
            // plugin.getLogger().info("DEBUG: Player does not have a sign already");
            // First time the sign has been placed or this is a new
            // sign
            if (addWarp(player.getUniqueId(), e.getBlock().getLocation())) {
              player.sendMessage(
                  ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).warpssuccess);
              e.setLine(0, ChatColor.GREEN + plugin.myLocale().warpswelcomeLine);
              for (int i = 1; i < 4; i++) {
                e.setLine(i, ChatColor.translateAlternateColorCodes('&', e.getLine(i)));
              }
            } else {
              player.sendMessage(
                  ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDuplicate);
              e.setLine(0, ChatColor.RED + plugin.myLocale().warpswelcomeLine);
              for (int i = 1; i < 4; i++) {
                e.setLine(i, ChatColor.translateAlternateColorCodes('&', e.getLine(i)));
              }
            }
          } else {
            // plugin.getLogger().info("DEBUG: Player already has a Sign");
            // A sign already exists. Check if it still there and if
            // so,
            // deactivate it
            Block oldSignBlock = oldSignLoc.getBlock();
            if (oldSignBlock.getType().equals(Material.SIGN_POST)
                || oldSignBlock.getType().equals(Material.WALL_SIGN)) {
              // The block is still a sign
              // plugin.getLogger().info("DEBUG: The block is still a sign");
              Sign oldSign = (Sign) oldSignBlock.getState();
              if (oldSign != null) {
                // plugin.getLogger().info("DEBUG: Sign block is a sign");
                if (oldSign
                    .getLine(0)
                    .equalsIgnoreCase(ChatColor.GREEN + plugin.myLocale().warpswelcomeLine)) {
                  // plugin.getLogger().info("DEBUG: Old sign had a green welcome");
                  oldSign.setLine(0, ChatColor.RED + plugin.myLocale().warpswelcomeLine);
                  oldSign.update();
                  player.sendMessage(
                      ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpsdeactivate);
                  removeWarp(player.getUniqueId());
                }
              }
            }
            // Set up the warp
            if (addWarp(player.getUniqueId(), e.getBlock().getLocation())) {
              player.sendMessage(
                  ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).warpssuccess);
              e.setLine(0, ChatColor.GREEN + plugin.myLocale().warpswelcomeLine);
            } else {
              player.sendMessage(
                  ChatColor.RED + plugin.myLocale(player.getUniqueId()).warpserrorDuplicate);
              e.setLine(0, ChatColor.RED + plugin.myLocale().warpswelcomeLine);
            }
          }
        }
      }
    }
  }