From 3035bd46d2486ddce655773f13a6092ac61102d6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 29 Dec 2014 01:33:40 +1100 Subject: [PATCH] Removing entity listener (Can't figure out how to finish it) --- .../com/intellectualcrafters/plot/PlotMain.java | 14 +++++++------- .../plot/commands/Helpers.java | 13 ------------- .../intellectualcrafters/plot/config/Settings.java | 4 ++-- .../plot/listeners/EntityListener.java | 13 +++++++++++-- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index d3d79f250..85acc1222 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -871,8 +871,8 @@ import java.util.concurrent.TimeUnit; options.put("UUID.read-from-disk", Settings.UUID_FROM_DISK); options.put("titles", Settings.TITLES); options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN); - options.put("perm-based-mob-cap.enabled", Settings.MOB_CAP_ENABLED); - options.put("perm-based-mob-cap.max", Settings.MOB_CAP); +// options.put("perm-based-mob-cap.enabled", Settings.MOB_CAP_ENABLED); +// options.put("perm-based-mob-cap.max", Settings.MOB_CAP); options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION); for (final Entry node : options.entrySet()) { @@ -893,8 +893,8 @@ import java.util.concurrent.TimeUnit; Settings.MAX_AUTO_SIZE = config.getInt("claim.max-auto-area"); Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); Settings.TITLES = config.getBoolean("titles"); - Settings.MOB_CAP_ENABLED = config.getBoolean("perm-based-mob-cap.enabled"); - Settings.MOB_CAP = config.getInt("perm-based-mob-cap.max"); +// Settings.MOB_CAP_ENABLED = config.getBoolean("perm-based-mob-cap.enabled"); +// Settings.MOB_CAP = config.getInt("perm-based-mob-cap.max"); Settings.MAX_PLOTS = config.getInt("max_plots"); Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); @@ -1460,9 +1460,9 @@ import java.util.concurrent.TimeUnit; plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot")); plotCommand.setTabCompleter(command); } - if (Settings.MOB_CAP_ENABLED) { - getServer().getPluginManager().registerEvents(new EntityListener(), this); - } +// if (Settings.MOB_CAP_ENABLED) { +// getServer().getPluginManager().registerEvents(new EntityListener(), this); +// } // Main event handler getServer().getPluginManager().registerEvents(new PlayerEvents(), this); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 32503280c..8a5cbc9f1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -106,19 +106,6 @@ import java.util.UUID; PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); return true; } - /* - * if (!hasBeenOnServer(args[1])) { - * PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON); - * return true; } UUID uuid = null; if - * (Bukkit.getPlayer(args[1]) != null) { uuid = - * Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = - * Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid == - * null) { PlayerFunctions.sendMessage(plr, - * C.PLAYER_HAS_NOT_BEEN_ON); return true; } if - * (!plot.helpers.contains(uuid)) { - * PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); return - * true; } - */ final UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeHelper(uuid); DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index b7416c480..32f2bd35c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -56,11 +56,11 @@ public class Settings { /** * Mob Cap Enabled */ - public static boolean MOB_CAP_ENABLED = false; +// public static boolean MOB_CAP_ENABLED = false; /** * The Mob Cap */ - public static int MOB_CAP = 20; +// public static int MOB_CAP = 20; /** * Display titles */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java index 72dbfbec7..46be099f9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java @@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlotHelper; + import org.bukkit.*; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -110,7 +111,8 @@ import java.util.Set; mobs = 0; } if (!(PlotMain.hasPermissionRange(p, "plots.mobcap", Settings.MOB_CAP) > mobs)) { - PlayerFunctions.sendMessage(p, C.NO_PLOTS, "plots.mobcap." + (mobs + 1)); + PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.mobcap." + (mobs + 1)); + e.setCancelled(true); } } } @@ -149,11 +151,14 @@ import java.util.Set; } public static void addEntity(final Entity entity, final Plot plot) { + if (!entityMap.containsKey(plot.world)) { + entityMap.put(plot.world, new HashMap>()); + } if (!entityMap.containsKey(plot.world)) { entityMap.put(plot.world, new HashMap>()); } final HashMap> section = entityMap.get(plot.world); - if (section.containsKey(plot)) { + if (!section.containsKey(plot)) { section.put(plot, new HashSet()); } section.get(plot).add(entity.getEntityId()); @@ -164,6 +169,10 @@ import java.util.Set; final Entity entity = e.getEntity(); final Location l = entity.getLocation(); final String w = l.getWorld().getName(); + remove(w, entity); + } + + public static void remove(String w, Entity entity) { if (entityMap.containsKey(w)) { final int id = entity.getEntityId(); final Plot plot = PlotHelper.getCurrentPlot(entity.getLocation());