From ee9cee6ec81faa0ffca3e05a2de193be537707d7 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Tue, 21 Oct 2014 19:01:34 +0200 Subject: [PATCH] * Added Fly Flag * Moved stuff away from the actual listener class * Ability to delete plot on player ban --- .idea/workspace.xml | 381 +++++++++++------- .../plot/listeners/PlayerEvents.java | 41 +- .../plot/listeners/PlotListener.java | 47 +-- 3 files changed, 257 insertions(+), 212 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 0760df20d..2770c8f28 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -10,9 +10,8 @@ - - - + + @@ -39,7 +38,7 @@ - + @@ -49,51 +48,105 @@ - - + + - + - - - + + + + + + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -172,31 +225,11 @@ - - - - - - - - - - - - - - - - - - - - - - + + @@ -225,8 +258,6 @@ @@ -418,7 +451,7 @@ - @@ -1023,11 +1065,12 @@ - + + @@ -1037,6 +1080,7 @@ + @@ -1047,8 +1091,6 @@ - - @@ -1097,10 +1139,6 @@ - - - - @@ -1122,7 +1160,11 @@ - @@ -1134,20 +1176,6 @@ - - - - - - - - - - - - - - @@ -1162,13 +1190,6 @@ - - - - - - - @@ -1204,13 +1225,6 @@ - - - - - - - @@ -1365,14 +1379,6 @@ - - - - - - - - @@ -1401,13 +1407,6 @@ - - - - - - - @@ -1424,14 +1423,6 @@ - - - - - - - - @@ -1440,6 +1431,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1448,33 +1470,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + @@ -1555,6 +1562,14 @@ + + + + + + + + @@ -1563,18 +1578,76 @@ + + + + + + + + - - + + - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java index d2a7c59b5..11c24660b 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -61,7 +61,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi @EventHandler public void onChangeWorld(PlayerChangedWorldEvent event) { - if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) { + /*if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) { event.getPlayer().setResourcePack(""); } else { @@ -88,46 +88,17 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } plotEntry(player, plot); - } - else - if (leftPlot(event.getFrom(), event.getTo())) { + } else if (leftPlot(event.getFrom(), event.getTo())) { Plot plot = getCurrentPlot(event.getFrom()); plotExit(player, plot); } } - } - catch (Exception e) { + } catch (Exception e) { // Gotta catch 'em all. } - public static void PlayerMove(PlayerMoveEvent event) { - try { - Player player = event.getPlayer(); - Location from = event.getFrom(); - Location to = event.getTo(); - if ((from.getBlockX() != to.getBlockX()) || (from.getBlockZ() != to.getBlockZ())) { - if (!isPlotWorld(player.getWorld())) { - return; - } - if (enteredPlot(from, to)) { - Plot plot = getCurrentPlot(event.getTo()); - boolean admin = player.hasPermission("plots.admin"); - if (plot.deny_entry(player) && !admin) { - event.setCancelled(true); - return; - } - plotEntry(player, plot); - } - else - if (leftPlot(event.getFrom(), event.getTo())) { - Plot plot = getCurrentPlot(event.getFrom()); - plotExit(player, plot); - } - } - } - catch (Exception e) { - // Gotta catch 'em all. - } - } + } + + @EventHandler( priority = EventPriority.HIGHEST) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java index 8faaeaddd..82a42c2b9 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -16,37 +16,37 @@ import java.util.UUID; */ public class PlotListener { - public void textures(Player p) { + public static void textures(Player p) { if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld())) { p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK); } } - public boolean isInPlot(Player player) { + public static boolean isInPlot(Player player) { return PlayerFunctions.isInPlot(player); } - public Plot getPlot(Player player) { + public static Plot getPlot(Player player) { return PlayerFunctions.getCurrentPlot(player); } - public boolean isPlotWorld(World world) { + public static boolean isPlotWorld(World world) { return PlotMain.isPlotWorld(world); } - public PlotWorld getPlotWorld(World world) { + public static PlotWorld getPlotWorld(World world) { return PlotMain.getWorldSettings(world); } - public String getName(UUID uuid) { + public static String getName(UUID uuid) { return UUIDHandler.getName(uuid); } - public UUID getUUID(String name) { + public static UUID getUUID(String name) { return UUIDHandler.getUUID(name); } - public boolean enteredPlot(Location l1, Location l2) { + public static boolean enteredPlot(Location l1, Location l2) { PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ())); PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ())); if (p2 == null) { @@ -61,7 +61,7 @@ public class PlotListener { return true; } - public boolean leftPlot(Location l1, Location l2) { + public static boolean leftPlot(Location l1, Location l2) { PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ())); PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ())); if (p1 == null) { @@ -76,7 +76,7 @@ public class PlotListener { return true; } - public boolean isPlotWorld(Location l) { + public static boolean isPlotWorld(Location l) { return PlotMain.isPlotWorld(l.getWorld()); } @@ -96,7 +96,7 @@ public class PlotListener { return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), loc.getWorld().getName()); } - private WeatherType getWeatherType(String str) { + private static WeatherType getWeatherType(String str) { str = str.toLowerCase(); if(str.equals("rain")) { return WeatherType.DOWNFALL; @@ -105,19 +105,20 @@ public class PlotListener { } } - private GameMode getGameMode(String str) { - if (str.equals("creative")) { - return GameMode.CREATIVE; - } else if (str.equals("survival")) { - return GameMode.SURVIVAL; - } else if (str.equals("adventure")) { - return GameMode.ADVENTURE; - } else { - return Bukkit.getDefaultGameMode(); + private static GameMode getGameMode(String str) { + switch (str) { + case "creative": + return GameMode.CREATIVE; + case "survival": + return GameMode.SURVIVAL; + case "adventure": + return GameMode.ADVENTURE; + default: + return Bukkit.getDefaultGameMode(); } } - public void plotEntry(Player player, Plot plot) { + public static void plotEntry(Player player, Plot plot) { if (plot.hasOwner()) { if(plot.settings.getFlag("gamemode") != null) { player.setGameMode(getGameMode(plot.settings.getFlag("gamemode").getValue())); @@ -155,7 +156,7 @@ public class PlotListener { } } - public void plotExit(Player player, Plot plot) { + public static void plotExit(Player player, Plot plot) { { PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); Bukkit.getPluginManager().callEvent(callEvent); @@ -166,7 +167,7 @@ public class PlotListener { PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage()); } - public boolean getFlagValue(String value) { + public static boolean getFlagValue(String value) { return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase()); } }