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 02687bd0e..8abe9c35a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/EntityListener.java @@ -27,9 +27,13 @@ import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; +/** + * @author Empire92 + */ +@SuppressWarnings({"unused", "deprecation"}) public class EntityListener implements Listener { - public static HashMap>> entityMap = new HashMap>>(); + public static HashMap>> entityMap = new HashMap<>(); public EntityListener() { BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); @@ -169,9 +173,7 @@ public class EntityListener implements Listener { entityMap.get(w).get(plot).remove(id); } } else { - Iterator>> it = entityMap.get(w).entrySet().iterator(); - while (it.hasNext()) { - Entry> n = it.next(); + for (Entry> n : entityMap.get(w).entrySet()) { n.getValue().remove(id); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index 44e4ec46f..6760ee76e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -36,7 +36,7 @@ import java.util.HashSet; import java.util.Set; /** - * Created by Citymonstret on 2014-10-24. + * @author Citymonstret */ public class ForceFieldListener implements Listener { @@ -46,7 +46,7 @@ public class ForceFieldListener implements Listener { private Set getNearbyPlayers(final Player player, final Plot plot) { final Set players = new HashSet<>(); - Player oPlayer = null; + Player oPlayer; for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !PlayerFunctions.isInPlot(oPlayer) || !PlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; @@ -59,7 +59,7 @@ public class ForceFieldListener implements Listener { } private Player hasNearbyPermitted(final Player player, final Plot plot) { - Player oPlayer = null; + Player oPlayer; for (final Entity entity : player.getNearbyEntities(5d, 5d, 5d)) { if (!(entity instanceof Player) || ((oPlayer = (Player) entity) == null) || !PlayerFunctions.isInPlot(oPlayer) || !PlayerFunctions.getCurrentPlot(oPlayer).equals(plot)) { continue; @@ -95,6 +95,7 @@ public class ForceFieldListener implements Listener { } @EventHandler + @SuppressWarnings("unused") public void onPlotEntry(final PlayerMoveEvent event) { final Player player = event.getPlayer(); if (!PlayerFunctions.isInPlot(player)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index 7349ffef5..5eff5912d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -1,6 +1,7 @@ package com.intellectualcrafters.plot.listeners; import com.intellectualcrafters.plot.object.InfoInventory; +import com.intellectualcrafters.plot.util.PlayerFunctions; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.EventHandler; @@ -29,6 +30,16 @@ public class InventoryListener implements Listener { final Player player = (Player) event.getWhoClicked(); if (inventory.getHolder() instanceof InfoInventory) { // TODO: Do stuff + switch (event.getSlot()) { + case 3: + case 4: + case 5: + case 6: + PlayerFunctions.sendMessage(player, "This is not implemented yet"); + break; + default: + break; + } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 4c0443042..d761b2861 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -56,6 +56,7 @@ import java.util.Set; * Player Events involving plots * * @author Citymonstret + * @author Empire92 */ @SuppressWarnings("unused") public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index fc1dccec7..2553e3740 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -41,8 +41,10 @@ import java.util.Arrays; import java.util.UUID; /** - * Created by Citymonstret on 2014-10-21. + * @author Citymonstret + * @author Empire92 */ +@SuppressWarnings({"unused", "deprecation"}) public class PlotListener { public static void textures(final Player p) { @@ -87,37 +89,19 @@ public class PlotListener { event.setCancelled(true); } } - return; } public static boolean enteredPlot(final Location l1, final Location l2) { final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ())); final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ())); - if (p2 == null) { - return false; - } - if (p1 == null) { - return true; - } - if (p1.equals(p2)) { - return false; - } - return true; + return p2 != null && (p1 == null || !p1.equals(p2)); + } public static boolean leftPlot(final Location l1, final Location l2) { final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ())); final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ())); - if (p1 == null) { - return false; - } - if (p2 == null) { - return true; - } - if (p1.equals(p2)) { - return false; - } - return true; + return p1 != null && (p2 == null || !p1.equals(p2)); } public static boolean isPlotWorld(final Location l) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index aee3b0b71..fba3c0185 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -43,8 +43,11 @@ import org.bukkit.plugin.java.JavaPlugin; import java.util.*; /** - * Created by Citymonstret on 2014-10-30. + * Created 2014-10-30 for PlotSquared + * + * @author Citymonstret */ +@SuppressWarnings({"deprecation", "unused"}) public class PlotPlusListener extends PlotListener implements Listener { private static HashMap feedRunnable = new HashMap<>(); @@ -239,7 +242,9 @@ public class PlotPlusListener extends PlotListener implements Listener { } /** - * Created by Citymonstret on 2014-10-22. + * Record Meta Class + * + * @author Citymonstret */ public static class RecordMeta { public static List metaList = new ArrayList<>(); @@ -263,6 +268,11 @@ public class PlotPlusListener extends PlotListener implements Listener { return this.name; } + @Override + public int hashCode() { + return this.name.hashCode(); + } + public Material getMaterial() { return this.material; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java index df6d20135..d1fe13e9c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -45,11 +45,13 @@ import java.util.Set; /** * @author Citymonstret + * @author Empire92 */ +@SuppressWarnings("unused") public class WorldEditListener implements Listener { - public final Set blockedcmds = new HashSet(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask")); - public final Set restrictedcmds = new HashSet(Arrays.asList("/up", "//up", "/worldedit:up")); + public final Set blockedcmds = new HashSet<>(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask")); + public final Set restrictedcmds = new HashSet<>(Arrays.asList("/up", "//up", "/worldedit:up")); private boolean isPlotWorld(final Location l) { return (PlotMain.isPlotWorld(l.getWorld())); @@ -93,7 +95,7 @@ public class WorldEditListener implements Listener { } final Plot plot = PlotHelper.getCurrentPlot(b.getLocation()); if (plot != null) { - if ((plot != null) && plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) { + if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) { PWE.setMask(p, l); } } @@ -173,7 +175,6 @@ public class WorldEditListener implements Listener { } if ((f != null) && isPlotWorld(f)) { PWE.removeMask(p); - return; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java index abbcbf36a..96eb01200 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldGuardListener.java @@ -52,14 +52,19 @@ import java.util.Map; import java.util.UUID; /** - * Created by Citymonstret on 2014-09-24. + * Created 2014-09-24 for PlotSquared + * + * @author Citymonstret + * @author Empire92 */ public class WorldGuardListener implements Listener { - public ArrayList str_flags = new ArrayList(); - public ArrayList> flags = new ArrayList>(); + public final ArrayList str_flags; + public final ArrayList> flags; public WorldGuardListener(final PlotMain plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); + str_flags = new ArrayList<>(); + flags = new ArrayList<>(); for (final Flag flag : DefaultFlag.getFlags()) { this.str_flags.add(flag.getName()); this.flags.add(flag); @@ -127,6 +132,7 @@ public class WorldGuardListener implements Listener { } } + @SuppressWarnings("unused") @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onMerge(final PlotMergeEvent event) { final Plot main = event.getPlot(); @@ -134,7 +140,7 @@ public class WorldGuardListener implements Listener { final World world = event.getWorld(); final RegionManager manager = PlotMain.worldGuard.getRegionManager(world); for (final PlotId plot : plots) { - if (!plot.equals(main)) { + if (!plot.equals(main.getId())) { manager.removeRegion(plot.x + "-" + plot.y); } } @@ -160,6 +166,7 @@ public class WorldGuardListener implements Listener { manager.addRegion(rg); } + @SuppressWarnings("unused") @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onUnlink(final PlotUnlinkEvent event) { try { @@ -193,10 +200,11 @@ public class WorldGuardListener implements Listener { manager.addRegion(rg); } } catch (final Exception e) { - + // } } + @SuppressWarnings("unused") @EventHandler public void onPlotClaim(final PlayerClaimPlotEvent event) { try { @@ -219,10 +227,11 @@ public class WorldGuardListener implements Listener { manager.addRegion(region); } catch (final Exception e) { - + // } } + @SuppressWarnings("unused") @EventHandler public void onPlotDelete(final PlotDeleteEvent event) { try { @@ -232,7 +241,7 @@ public class WorldGuardListener implements Listener { final RegionManager manager = PlotMain.worldGuard.getRegionManager(world); manager.removeRegion(plot.x + "-" + plot.y); } catch (final Exception e) { - + // } } }