diff --git a/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java b/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java index 2b2d543ad..684488cdc 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java @@ -9,6 +9,11 @@ public class AbstractFlag { private final String key; + /** + * AbstractFlag is a parameter used in creating a new Flag + * @param key + * The key must be alphabetical characters and <= 16 characters in length + */ public AbstractFlag(String key) { if (!StringUtils.isAlpha(key)) { throw new IllegalArgumentException("Flag must be alphabetic characters"); @@ -18,9 +23,17 @@ public class AbstractFlag { } this.key = key.toLowerCase(); } - + /** + * AbstractFlag key + * @return String + */ public String getKey() { return this.key; } + + @Override + public String toString() { + return this.key; + } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Flag.java b/PlotSquared/src/com/intellectualcrafters/plot/Flag.java index 7d332f1f5..19e98b3dd 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Flag.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Flag.java @@ -7,6 +7,17 @@ public class Flag { private AbstractFlag key; private String value; + /** + * Flag object used to store basic information for a Plot. + * Flags are a key/value pair. + * For a flag to be usable by a player, you need to register it with PlotSquared. + * + * @param key + * AbstractFlag + * @param value + * Value must be alphanumerical (can have spaces) and be <= 48 characters + * @throws IllegalArgumentException if you provide inadequate inputs + */ public Flag(AbstractFlag key, String value) { if (!StringUtils.isAlphanumericSpace(ChatColor.stripColor(value))) { throw new IllegalArgumentException("Flag must be alphanumerical"); @@ -18,14 +29,26 @@ public class Flag { this.value = value; } + /** + * Get the AbstractFlag used in creating the flag + * @return AbstractFlag + */ public AbstractFlag getAbstractFlag() { return this.key; } + /** + * Get the key for the AbstractFlag + * @return String + */ public String getKey() { return this.key.getKey(); } + /** + * Get the value + * @return String + */ public String getValue() { return this.value; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java b/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java index a632552fa..fca7a122f 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java @@ -8,6 +8,11 @@ public class FlagManager { private static ArrayList flags; + /** + * Register an AbstractFlag with PlotSquared + * @param flag + * @return + */ public static boolean addFlag(AbstractFlag flag) { if (getFlag(flag.getKey()) != null) { return false; @@ -15,10 +20,20 @@ public class FlagManager { return flags.add(flag); } + /** + * Get a list of registered AbstractFlag objects + * @return List (AbstractFlag) + */ public static List getFlags() { return flags; } + /** + * Get an AbstractFlag by a string + * Returns null if flag does not exist + * @param string + * @return AbstractFkag + */ public static AbstractFlag getFlag(String string) { for (AbstractFlag flag : flags) { if (flag.getKey().equalsIgnoreCase(string)) { @@ -28,6 +43,14 @@ public class FlagManager { return null; } + /** + * Get an AbstractFlag by a string + * + * @param string + * @param create + * If to create the flag if it does not exist + * @return AbstractFlag + */ public static AbstractFlag getFlag(String string, boolean create) { if ((getFlag(string) == null) && create) { AbstractFlag flag = new AbstractFlag(string); @@ -35,7 +58,22 @@ public class FlagManager { } return getFlag(string); } + + /** + * Remove a registered AbstractFlag + * @param flag + * @return boolean + * Result of operation + */ + public static boolean removeFlag(AbstractFlag flag) { + return flags.remove(flag); + } + /** + * Get the flags for a plot + * @param plot + * @return List (AbstractFlag) + */ public static List getPlotFlags(Plot plot) { Set plotFlags = plot.settings.getFlags(); List flags = new ArrayList<>(); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java b/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java index 39383282a..72beeb95f 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java @@ -136,7 +136,6 @@ public class PlayerFunctions { return null; } HashMap plots = PlotMain.getPlots(world); - if (plots != null) { if (plots.containsKey(id)) { return plots.get(id); @@ -196,15 +195,12 @@ public class PlayerFunctions { if (p.hasPermission("plots.admin")) { return Integer.MAX_VALUE; } - int y = 0; - for (int x = 1; x <= 100; x++) { - if (p.hasPermission("plots.plot." + x)) { - y = x; - } else { - break; + for (int x = 0; x <= 100; x++) { + if (p.hasPermission("plots.plot." + (100-x))) { + return 100-x; } } - return y; + return 0; } /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java index 253fa679c..6fde608f2 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java @@ -456,10 +456,15 @@ public class PlotHelper { } return new Short[] { Short.parseShort(block), 0 }; } - + + /** + * Clear a plot + * @param requester + * @param plot + */ public static void clear(final Player requester, final Plot plot) { - final PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world)); final long start = System.nanoTime(); + final PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world)); PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST); PlotHelper.removeSign(requester, plot); PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotId.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotId.java index ed632844e..312324fd4 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotId.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotId.java @@ -1,9 +1,22 @@ package com.intellectualcrafters.plot; public class PlotId { + /** + * x value + */ public int x; + /** + * y value + */ public int y; + /** + * PlotId class (PlotId x,y values do not correspond to Block locations) + * @param x + * The plot x coordinate + * @param y + * The plot y coordinate + */ public PlotId(int x, int y) { this.x = x; this.y = y; @@ -23,6 +36,11 @@ public class PlotId { PlotId other = (PlotId) obj; return ((this.x == other.x) && (this.y == other.y)); } + + @Override + public String toString() { + return this.x+";"+this.y; + } @Override public int hashCode() { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index cfb9013d9..8f52ac7f4 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -10,6 +10,7 @@ package com.intellectualcrafters.plot; import ca.mera.CameraAPI; + import com.intellectualcrafters.plot.Logger.LogLevel; import com.intellectualcrafters.plot.Settings.Web; import com.intellectualcrafters.plot.commands.Camera; @@ -25,7 +26,9 @@ import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.listeners.WorldGuardListener; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; + import me.confuser.barapi.BarAPI; + import org.bukkit.*; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.*; @@ -67,10 +70,6 @@ public class PlotMain extends JavaPlugin { public static File translationsFile; public static YamlConfiguration translations; public static int translations_ver = 1; - /** - * list of usable flags - */ - public static Set registeredFlags = new HashSet(); /** * MySQL Object */ @@ -126,28 +125,6 @@ public class PlotMain extends JavaPlugin { * All loaded plot worlds */ private static HashMap worlds = new HashMap(); - - public static Set getFlags() { - return registeredFlags; - } - - public static boolean isRegisteredFlag(String arg) { - for (Flag flag : registeredFlags) { - if (flag.getKey().equalsIgnoreCase(arg)) { - return true; - } - } - return false; - } - - public static boolean registerFlag(Flag flag) { - return registeredFlags.add(flag); - } - - public static boolean unRegisterFlag(Flag flag) { - return registeredFlags.remove(flag); - } - /** * Get all plots * @@ -269,12 +246,14 @@ public class PlotMain extends JavaPlugin { return (plots.get(world.getName()).values().toArray(new Plot[0])); } - public static boolean removePlot(String world, PlotId id) { - PlotDeleteEvent event = new PlotDeleteEvent(world, id); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - event.setCancelled(true); - return false; + public static boolean removePlot(String world, PlotId id, boolean callEvent) { + if (callEvent) { + PlotDeleteEvent event = new PlotDeleteEvent(world, id); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + event.setCancelled(true); + return false; + } } plots.get(world).remove(id); return true; @@ -493,6 +472,7 @@ public class PlotMain extends JavaPlugin { worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); getServer().getPluginManager().registerEvents(new WorldEditListener(), this); } + if (Settings.WORLDGUARD) if (getServer().getPluginManager().getPlugin("WorldGuard") != null) { worldGuard = (WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard"); getServer().getPluginManager().registerEvents(new WorldGuardListener(this), this); @@ -823,7 +803,8 @@ public class PlotMain extends JavaPlugin { private static void setupConfig() { config.set("version", config_ver); Map options = new HashMap(); - // options.put("auto_update", false); + options.put("auto_update", false); + options.put("worldguard.enabled", Settings.WORLDGUARD); options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT); options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT); options.put("web.enabled", Web.ENABLED); @@ -845,6 +826,7 @@ public class PlotMain extends JavaPlugin { Web.ENABLED = config.getBoolean("web.enabled"); Web.PORT = config.getInt("web.port"); Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs"); + Settings.WORLDGUARD = config.getBoolean("worldguard.enabled"); Settings.MOB_PATHFINDING = config.getBoolean("mob_pathfinding"); Settings.METRICS = config.getBoolean("metrics"); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java index 43ba18be5..86aec60cb 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java @@ -4,26 +4,27 @@ import java.util.ArrayList; import org.bukkit.Material; +/** + * This is the PlotWorld class (obviously) + *
- All existing PlotWorld instances should be kept in PlotMain (worlds variable) + *
- The accessors and mutators are: + *
PlotMain.isPlotWorld(world) + *
PlotMain.getPlotWorlds() or PlotMain.getPlotWorldsString() <- use this if you don't need to get world objects + *
PlotMain.getWorldSettings(World) - get the PlotWorld class for a world + *
+ *
Also added is getWorldPlots(World) as the plots are now sorted per world + *
+ *
To get the world of a plot, you can use plot.world - (string) or plot.getWorld() (world object) + *
+ *
All PlotWorld settings are per world in the settings.yml (these settings are automatically added when a world is loaded, either at startup or if a new world is created): + *
- You can find this in the WorldGenerator class (yeah, it's possibly not the best place, but it makes sure worlds are added to the settings.yml) + *
+ *
All new DEFAULT CONSTANTS should be static and be given a value + *
All new variables should not be static and should not be given any values here, but rather in the WorldGenerator class + * + **/ public class PlotWorld { - /* - * This is the PlotWorld class (obviously) - All existing PlotWorld - * instances should be kept in PlotMain (worlds variable) - The accessors - * and mutators are: PlotMain.isPlotWorld(world) PlotMain.getPlotWorlds() or - * PlotMain.getPlotWorldsString() <- use this if you don't need to get world - * objects PlotMain.getWorldSettings(World) - get the PlotWorld class for a - * world Also added is getWorldPlots(World) as the plots are now sorted per - * world To get the world of a plot, you can use plot.world - (string) or - * plot.getWorld() (world object) All PlotWorld settings are per world in - * the settings.yml (these settings are automatically added when a world is - * loaded, either at startup or if a new world is created): - You can find - * this in the WorldGenerator class (yeah, it's possibly not the best place, - * but it makes sure worlds are added to the settings.yml) All new DEFAULT - * CONSTANTS should be static and be given a value All new variables should - * not be static and should not be given any values here, but rather in the - * WorldGenerator class - */ - /** * Road Height */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/SetBlockFast.java b/PlotSquared/src/com/intellectualcrafters/plot/SetBlockFast.java index 810dd7130..f9279dae4 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/SetBlockFast.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/SetBlockFast.java @@ -5,6 +5,12 @@ import static com.intellectualcrafters.plot.ReflectionUtils.getRefClass; import com.intellectualcrafters.plot.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.ReflectionUtils.RefMethod; +/** + * + * SetBlockFast class
+ * Used to do fast world editing + * + */ public class SetBlockFast { private static final RefClass classBlock = getRefClass("{nms}.Block"); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java index e5901f3a8..a52c57df9 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java @@ -17,6 +17,13 @@ package com.intellectualcrafters.plot; * @author Empire92 */ public class Settings { + /** + * WorldGuard region on claimed plots + */ + public static boolean WORLDGUARD = false; + /** + * metrics + */ public static boolean METRICS = true; /** * plot specific resource pack diff --git a/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java index c7c656706..2baab1784 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java @@ -18,8 +18,10 @@ import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import com.intellectualcrafters.plot.AbstractFlag; import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.Flag; +import com.intellectualcrafters.plot.FlagManager; import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.PlotHelper; @@ -96,8 +98,8 @@ public class PlotAPI { * * @param flag */ - public void registerFlag(Flag flag) { - PlotMain.registerFlag(flag); + public void addFlag(AbstractFlag flag) { + FlagManager.addFlag(flag); } /** @@ -105,8 +107,8 @@ public class PlotAPI { * * @return array of Flag[] */ - public Flag[] getRegisteredFlags() { - return PlotMain.getFlags().toArray(new Flag[0]); + public AbstractFlag[] getFlags() { + return FlagManager.getFlags().toArray(new AbstractFlag[0]); } /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Clear.java index 4c8fe32a4..5c9b232d0 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Clear.java @@ -32,10 +32,10 @@ public class Clear extends SubCommand { return true; } Plot plot = PlayerFunctions.getCurrentPlot(plr); - boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id); + boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true); if (result) { - DBFunc.delete(plr.getWorld().getName(), plot); plot.clear(plr); + DBFunc.delete(plr.getWorld().getName(), plot); } else { PlayerFunctions.sendMessage(plr, "Plot clearing has been denied."); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java index da069739d..f36db9f28 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java @@ -24,6 +24,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.AbstractFlag; import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.Flag; +import com.intellectualcrafters.plot.FlagManager; import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.PlotHelper; @@ -87,10 +88,10 @@ public class Set extends SubCommand { if (args[0].equalsIgnoreCase("flag")) { if (args.length < 2) { - PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", StringUtils.join(PlotMain.getFlags(), "&c, &6"))); + PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", StringUtils.join(FlagManager.getFlags(), "&c, &6"))); return false; } - if (!PlotMain.isRegisteredFlag(args[1])) { + if (FlagManager.getFlag(args[1])==null) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); return false; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/SubCommand.java index 81c6db7d4..14b32532a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/SubCommand.java @@ -105,6 +105,12 @@ public abstract class SubCommand { this.execute(null, args); } + /** + * Send a message + * @param plr + * @param c + * @param args + */ public void sendMessage(Player plr, C c, String... args) { PlayerFunctions.sendMessage(plr, c, args); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java index 5a4d50198..9216983cb 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java @@ -149,33 +149,31 @@ public class DBFunc { * @param plot */ public static void delete(final String world, final Plot plot) { - boolean result = PlotMain.removePlot(world, plot.id); - if (result) { - runTask(new Runnable() { - @Override - public void run() { - PreparedStatement stmt = null; - int id = getId(world, plot.id); - try { - stmt = connection.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?"); - stmt.setInt(1, id); - stmt.executeUpdate(); - stmt.close(); - stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?"); - stmt.setInt(1, id); - stmt.executeUpdate(); - stmt.close(); - stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `id` = ?"); - stmt.setInt(1, id); - stmt.executeUpdate(); - stmt.close(); - } catch (SQLException e) { - e.printStackTrace(); - Logger.add(LogLevel.DANGER, "Failed to delete plot " + plot.id); - } + boolean result = PlotMain.removePlot(world, plot.id, false); + runTask(new Runnable() { + @Override + public void run() { + PreparedStatement stmt = null; + int id = getId(world, plot.id); + try { + stmt = connection.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?"); + stmt.setInt(1, id); + stmt.executeUpdate(); + stmt.close(); + stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?"); + stmt.setInt(1, id); + stmt.executeUpdate(); + stmt.close(); + stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `id` = ?"); + stmt.setInt(1, id); + stmt.executeUpdate(); + stmt.close(); + } catch (SQLException e) { + e.printStackTrace(); + Logger.add(LogLevel.DANGER, "Failed to delete plot " + plot.id); } - }); - } + } + }); } /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java index 2a3a043d6..2a38037b3 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java @@ -25,11 +25,20 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { private Plot plot; + /** + * PlayerClaimPlotEvent: Called when a plot is claimed + * @param player + * @param plot + */ public PlayerClaimPlotEvent(Player player, Plot plot) { super(player); this.plot = plot; } - + + /** + * Get the plot involved + * @return Plot + */ public Plot getPlot() { return this.plot; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java index fb35d54ab..78bb31cd8 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java @@ -15,11 +15,20 @@ public class PlayerEnterPlotEvent extends PlayerEvent { private Plot plot; + /** + * PlayerEnterPlotEvent: Called when a player leaves a plot + * @param player + * @param plot + */ public PlayerEnterPlotEvent(Player player, Plot plot) { super(player); this.plot = plot; } + /** + * Get the plot involved + * @return Plot + */ public Plot getPlot() { return this.plot; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java index 39637926c..1f1a197f0 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java @@ -13,16 +13,23 @@ public class PlayerLeavePlotEvent extends PlayerEvent { private static HandlerList handlers = new HandlerList(); private Plot plot; - + /** + * PlayerLeavePlotEvent: Called when a player leaves a plot + * @param player + * @param plot + */ public PlayerLeavePlotEvent(Player player, Plot plot) { super(player); this.plot = plot; } - + /** + * Get the plot involved + * @return Plot + */ public Plot getPlot() { return this.plot; } - + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java index bad02b66d..04ce2eb56 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java @@ -18,7 +18,13 @@ public class PlayerPlotDeniedEvent extends Event { private Player initiator; private boolean added; private UUID player; - + /** + * PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a plot + * @param initiator + * @param plot + * @param player + * @param added + */ public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player, boolean added) { this.initiator = initiator; this.plot = plot; @@ -26,18 +32,31 @@ public class PlayerPlotDeniedEvent extends Event { this.player = player; } + /** + * If a user was added + * @return boolean + */ public boolean wasAdded() { return this.added; } - + /** + * The player added/removed + * @return UUID + */ public UUID getPlayer() { return this.player; } - + /** + * The plot involved + * @return Plot + */ public Plot getPlot() { return this.plot; } - + /** + * The player initiating the action + * @return Player + */ public Player getInitiator() { return this.initiator; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java index 71030b89e..e5ba69ed1 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java @@ -18,26 +18,45 @@ public class PlayerPlotHelperEvent extends Event { private Player initiator; private boolean added; private UUID player; - + /** + * PlayerPlotHelperEvent: Called when a plot helper is added/removed + * @param initiator + * @param plot + * @param player + * @param added + */ public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player, boolean added) { this.initiator = initiator; this.plot = plot; this.added = added; this.player = player; } - + + /** + * If a player was added + * @return boolean + */ public boolean wasAdded() { return this.added; } - + /** + * The UUID added/removed + * @return UUID + */ public UUID getPlayer() { return this.player; } - + /** + * The plot involved + * @return Plot + */ public Plot getPlot() { return this.plot; } - + /** + * The player initiating the action + * @return Player + */ public Player getInitiator() { return this.initiator; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java index bdaf36a4d..c00d09e99 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java @@ -16,7 +16,9 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; import com.intellectualcrafters.plot.Plot; - +/** + * Called when a player teleports to a plot + */ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); @@ -24,7 +26,12 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl private Plot plot; private boolean cancelled; - + /** + * PlayerTeleportToPlotEvent: Called when a player teleports to a plot + * @param player + * @param from + * @param plot + */ public PlayerTeleportToPlotEvent(Player player, Location from, Plot plot) { super(player); this.from = from; @@ -36,10 +43,18 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl return handlers; } + /** + * Get the from location + * @return Location + */ public Location getFrom() { return this.from; } + /** + * Get the plot involved + * @return Plot + */ public Plot getPlot() { return this.plot; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotDeleteEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotDeleteEvent.java index 111c5809f..ab1e021e4 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotDeleteEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotDeleteEvent.java @@ -16,7 +16,7 @@ import org.bukkit.event.HandlerList; import com.intellectualcrafters.plot.PlotId; /** - * Created by Citymonstret on 2014-08-09. + * Called when a plot is deleted */ public class PlotDeleteEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); @@ -24,16 +24,28 @@ public class PlotDeleteEvent extends Event implements Cancellable { private PlotId id; private String world; - + /** + * PlotDeleteEvent: Called when a plot is deleted + * @param world + * @param id + */ public PlotDeleteEvent(String world, PlotId id) { this.id = id; this.world = world; } + /** + * Get the PlotId + * @return PlotId + */ public PlotId getPlotId() { return this.id; } + /** + * Get the world name + * @return String + */ public String getWorld() { return this.world; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java index 7f7797092..601b30bd0 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java @@ -17,7 +17,7 @@ import com.intellectualcrafters.plot.Flag; import com.intellectualcrafters.plot.Plot; /** - * Created by Citymonstret on 2014-08-09. + * Called when a Flag is added to a plot */ public class PlotFlagAddEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); @@ -26,15 +26,28 @@ public class PlotFlagAddEvent extends Event implements Cancellable { private Plot plot; private Flag flag; + /** + * PlotFlagAddEvent: Called when a Flag is added to a plot + * @param flag + * @param plot + */ public PlotFlagAddEvent(Flag flag, Plot plot) { this.plot = plot; this.flag = flag; } + /** + * Get the plot involved + * @return Plot + */ public Plot getPlot() { return this.plot; } + /** + * Get the flag involved + * @return Flag + */ public Flag getFlag() { return this.flag; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java index 574106220..7c2cd9350 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java @@ -17,7 +17,7 @@ import com.intellectualcrafters.plot.Flag; import com.intellectualcrafters.plot.Plot; /** - * Created by Citymonstret on 2014-08-09. + * Called when a flag is removed from a plot */ public class PlotFlagRemoveEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); @@ -26,19 +26,30 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { private Plot plot; private Flag flag; + /** + * PlotFlagRemoveEvent: Called when a flag is removed from a plot + * @param flag + * @param plot + */ public PlotFlagRemoveEvent(Flag flag, Plot plot) { this.plot = plot; this.flag = flag; } - + /** + * Get the plot involved + * @return Plot + */ public Plot getPlot() { return this.plot; } - + /** + * Get the flag involved + * @return Flag + */ public Flag getFlag() { return this.flag; } - + public static HandlerList getHandlerList() { return handlers; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java index 13cb45f61..3327680b6 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java @@ -41,7 +41,7 @@ public class WorldGuardListener implements Listener { BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); BlockVector vector2 = new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ()); - ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + ";" + plot.getId().y, vector1, vector2); + ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2); DefaultDomain owner = new DefaultDomain(); owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player)); @@ -57,6 +57,6 @@ public class WorldGuardListener implements Listener { World world = Bukkit.getWorld(event.getWorld()); RegionManager manager = PlotMain.worldGuard.getRegionManager(world); - manager.removeRegion(plot.x + ";" + plot.y); + manager.removeRegion(plot.x + "-" + plot.y); } }