diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 4e0ee4ee9..aada4e34c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -153,7 +153,7 @@ public class Auto extends SubCommand { Plot plot = PlotHelper.getPlot(world, Auto.lastPlot); if ((plot == null) || (plot.owner == null)) { plot = PlotHelper.getPlot(world, Auto.lastPlot); - Claim.claimPlot(plr, plot, true); + Claim.claimPlot(plr, plot, true, true); br = true; final PlotWorld pw = PlotMain.getWorldSettings(world); final Plot plot2 = PlotMain.getPlots(world).get(plot.id); @@ -187,7 +187,7 @@ public class Auto extends SubCommand { for (int j = start.y; j <= end.y; j++) { final Plot plot = PlotHelper.getPlot(world, new PlotId(i, j)); final boolean teleport = ((i == end.x) && (j == end.y)); - Claim.claimPlot(plr, plot, teleport); + Claim.claimPlot(plr, plot, teleport, true); } } if (!PlotHelper.mergePlots(plr, world, PlayerFunctions.getPlotSelectionIds(world, start, end))) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index dd9481924..eb5d40038 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -47,12 +47,12 @@ public class Claim extends SubCommand { super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING, true); } - public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport) { - return claimPlot(player, plot, teleport, ""); + public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, boolean auto) { + return claimPlot(player, plot, teleport, "", auto); } - public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic) { - final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot); + public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, final String schematic, boolean auto) { + final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { PlotHelper.createPlot(player, plot); @@ -134,6 +134,6 @@ public class Claim extends SubCommand { } } - return !claimPlot(plr, plot, false, schematic) || sendMessage(plr, C.PLOT_NOT_CLAIMED); + return !claimPlot(plr, plot, false, schematic, false) || sendMessage(plr, C.PLOT_NOT_CLAIMED); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index da5351b05..465b6aa6f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -57,7 +57,7 @@ public class DebugClaimTest extends SubCommand { } public static boolean claimPlot(final Player player, final Plot plot, final boolean teleport, @SuppressWarnings("unused") final String schematic) { - final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot); + final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, true); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { PlotHelper.createPlot(player, plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java index 8cca73343..a11660b37 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java @@ -28,22 +28,26 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; /** - * Created by Citymonstret on 2014-08-09. + * @author Citymonstret + * @author Empire92 */ +@SuppressWarnings("unused") public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { private static HandlerList handlers = new HandlerList(); private final Plot plot; + private final boolean auto; private boolean cancelled; /** * PlayerClaimPlotEvent: Called when a plot is claimed * - * @param player - * @param plot + * @param player Player that claimed the plot + * @param plot Plot that was claimed */ - public PlayerClaimPlotEvent(final Player player, final Plot plot) { + public PlayerClaimPlotEvent(final Player player, final Plot plot, boolean auto) { super(player); this.plot = plot; + this.auto = auto; } public static HandlerList getHandlerList() { @@ -59,6 +63,13 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { return this.plot; } + /** + * @return true if it was an automated claim, else false + */ + public boolean wasAuto() { + return this.auto; + } + @Override public HandlerList getHandlers() { return handlers; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java index 6b7256976..25698112b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerEnterPlotEvent.java @@ -27,7 +27,8 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; /** - * Created by Citymonstret on 2014-08-16. + * @author Citymonstret + * @author Empire92 */ public class PlayerEnterPlotEvent extends PlayerEvent { @@ -38,8 +39,8 @@ public class PlayerEnterPlotEvent extends PlayerEvent { /** * PlayerEnterPlotEvent: Called when a player leaves a plot * - * @param player - * @param plot + * @param player Player that entered the plot + * @param plot Plot that was entered */ public PlayerEnterPlotEvent(final Player player, final Plot plot) { super(player); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java index 3193f98d7..0414b0dda 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerLeavePlotEvent.java @@ -27,7 +27,8 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; /** - * Created by Citymonstret on 2014-08-16. + * @author Citymonstret + * @author Empire92 */ public class PlayerLeavePlotEvent extends PlayerEvent { private static HandlerList handlers = new HandlerList(); @@ -37,8 +38,8 @@ public class PlayerLeavePlotEvent extends PlayerEvent { /** * PlayerLeavePlotEvent: Called when a player leaves a plot * - * @param player - * @param plot + * @param player Player that left the plot + * @param plot Plot that was left */ public PlayerLeavePlotEvent(final Player player, final Plot plot) { super(player); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java index b1f4598ee..7f1229c54 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java @@ -29,7 +29,8 @@ import org.bukkit.event.HandlerList; import java.util.UUID; /** - * Created by Citymonstret on 2014-08-16. + * @author Citymonstret + * @author Empire92 */ public class PlayerPlotDeniedEvent extends Event { private static HandlerList handlers = new HandlerList(); @@ -43,10 +44,10 @@ public class PlayerPlotDeniedEvent extends Event { * PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a * plot * - * @param initiator - * @param plot - * @param player - * @param added + * @param initiator Player that initiated the event + * @param plot Plot in which the event occurred + * @param player Player that was denied/un-denied + * @param added true of add to deny list, false if removed */ public PlayerPlotDeniedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) { this.initiator = initiator; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java index 483fa0dba..ea6412512 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java @@ -29,7 +29,8 @@ import org.bukkit.event.HandlerList; import java.util.UUID; /** - * Created by Citymonstret on 2014-08-16. + * @author Empire92 + * @author Citymonstret */ public class PlayerPlotHelperEvent extends Event { private static HandlerList handlers = new HandlerList(); @@ -42,10 +43,10 @@ public class PlayerPlotHelperEvent extends Event { /** * PlayerPlotHelperEvent: Called when a plot helper is added/removed * - * @param initiator - * @param plot - * @param player - * @param added + * @param initiator Player that initiated the event + * @param plot Plot in which the event occurred + * @param player Player that was added/removed from the helper list + * @param added true of the player was added, false if the player was removed */ public PlayerPlotHelperEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) { this.initiator = initiator; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java index 74040ab50..eb608505c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java @@ -29,7 +29,8 @@ import org.bukkit.event.HandlerList; import java.util.UUID; /** - * Created by Citymonstret on 2014-08-16. + * @author Citymonstret + * @author Empire92 */ public class PlayerPlotTrustedEvent extends Event { private static HandlerList handlers = new HandlerList(); @@ -42,10 +43,10 @@ public class PlayerPlotTrustedEvent extends Event { /** * PlayerPlotTrustedEvent: Called when a plot trusted user is added/removed * - * @param initiator - * @param plot - * @param player - * @param added + * @param initiator Player that initiated the event + * @param plot Plot in which the event occurred + * @param player Player that was added/removed from the trusted list + * @param added true of the player was added, false if the player was removed */ public PlayerPlotTrustedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) { this.initiator = initiator; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java index 14926ad5e..4dab9fd13 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java @@ -30,6 +30,9 @@ import org.bukkit.event.player.PlayerEvent; /** * Called when a player teleports to a plot + * + * @author Citymonstret + * @author Empire92 */ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); @@ -42,9 +45,9 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl /** * PlayerTeleportToPlotEvent: Called when a player teleports to a plot * - * @param player - * @param from - * @param plot + * @param player That was teleported + * @param from Start location + * @param plot Plot to which the player was teleported */ public PlayerTeleportToPlotEvent(final Player player, final Location from, final Plot plot) { super(player); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java index bf22e72a8..bf5886614 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotClearEvent.java @@ -28,6 +28,9 @@ import org.bukkit.event.HandlerList; /** * Called when a plot is cleared + * + * @author Citymonstret + * @author Empire92 */ public class PlotClearEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); @@ -38,8 +41,8 @@ public class PlotClearEvent extends Event implements Cancellable { /** * PlotDeleteEvent: Called when a plot is cleared * - * @param world - * @param id + * @param world The world in which the plot was cleared + * @param id The plot that was cleared */ public PlotClearEvent(final String world, final PlotId id) { this.id = id; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java index 5358c3469..269dc6ab8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotDeleteEvent.java @@ -28,6 +28,9 @@ import org.bukkit.event.HandlerList; /** * Called when a plot is deleted + * + * @author Citymonstret + * @author Empire92 */ public class PlotDeleteEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); @@ -38,8 +41,8 @@ public class PlotDeleteEvent extends Event implements Cancellable { /** * PlotDeleteEvent: Called when a plot is deleted * - * @param world - * @param id + * @param world The world in which the plot was deleted + * @param id The ID of the plot that was deleted */ public PlotDeleteEvent(final String world, final PlotId id) { this.id = id; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java index 82b63527f..89505350a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java @@ -29,6 +29,9 @@ import org.bukkit.event.HandlerList; /** * Called when a Flag is added to a plot + * + * @author Citymonstret + * @author Empire92 */ public class PlotFlagAddEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); @@ -39,8 +42,8 @@ public class PlotFlagAddEvent extends Event implements Cancellable { /** * PlotFlagAddEvent: Called when a Flag is added to a plot * - * @param flag - * @param plot + * @param flag Flag that was added + * @param plot Plot to which the flag was added */ public PlotFlagAddEvent(final Flag flag, final Plot plot) { this.plot = plot; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java index 84923d1fa..23e99bef4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java @@ -29,6 +29,9 @@ import org.bukkit.event.HandlerList; /** * Called when a flag is removed from a plot + * + * @author Citymonstret + * @author Empire92 */ public class PlotFlagRemoveEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); @@ -39,8 +42,8 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable { /** * PlotFlagRemoveEvent: Called when a flag is removed from a plot * - * @param flag - * @param plot + * @param flag Flag that was removed + * @param plot Plot from which the flag was removed */ public PlotFlagRemoveEvent(final Flag flag, final Plot plot) { this.plot = plot; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java index 155557c75..4ae4fce83 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotMergeEvent.java @@ -31,7 +31,7 @@ import org.bukkit.event.HandlerList; import java.util.ArrayList; /** - * Created by Citymonstret on 2014-08-09. + * @author Empire92 */ public class PlotMergeEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); @@ -43,8 +43,9 @@ public class PlotMergeEvent extends Event implements Cancellable { /** * PlotMergeEvent: Called when plots are merged * - * @param player - * @param plot + * @param world World in which the event occurred + * @param plot Plot that was merged + * @param plots A list of plots involved in the event */ public PlotMergeEvent(final World world, final Plot plot, final ArrayList plots) { this.plots = plots; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java index 40d70b3a1..6727ab007 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java @@ -30,7 +30,7 @@ import org.bukkit.event.HandlerList; import java.util.ArrayList; /** - * Created by Citymonstret on 2014-08-09. + * @author Empire92 */ public class PlotUnlinkEvent extends Event implements Cancellable { private static HandlerList handlers = new HandlerList(); @@ -41,8 +41,8 @@ public class PlotUnlinkEvent extends Event implements Cancellable { /** * Called when a mega-plot is unlinked. * - * @param world - * @param plots + * @param world World in which the event occurred + * @param plots Plots that are involved in the event */ public PlotUnlinkEvent(final World world, final ArrayList plots) { this.plots = plots; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java index fea1d482e..878c9a5d1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java @@ -52,11 +52,15 @@ public class AbstractFlag { throw new IllegalArgumentException("Key must be <= 16 characters"); } this.key = key.toLowerCase(); - this.value = new FlagValue.StringValue(); + if (value == null) { + this.value = new FlagValue.StringValue(); + } else { + this.value = value; + } } public String parseValue(final String value) { - return this.value.parse(value).toString(); + return this.value.parse(value); } public String getValueDesc() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/XPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/XPopulator.java index d4fa33c1a..95c0179b7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/XPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/XPopulator.java @@ -33,6 +33,7 @@ import java.util.Random; /** * @author Citymonstret */ +@SuppressWarnings("unused") public class XPopulator extends BlockPopulator { /* @@ -237,7 +238,6 @@ public class XPopulator extends BlockPopulator { setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); // } if ((roadStartZ <= 16) && (roadStartZ > 1)) { - final int val = roadStartZ; int start, end; if ((plotMinX + 2) <= 16) { start = 16 - plotMinX - 1; @@ -252,11 +252,10 @@ public class XPopulator extends BlockPopulator { if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { start = 0; } - setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2, w); - setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2, w); + setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2, w); + setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, (16 - roadStartZ) + 1, (16 - roadStartZ) + 2, this.floor2, w); } if ((roadStartX <= 16) && (roadStartX > 1)) { - final int val = roadStartX; int start, end; if ((plotMinZ + 2) <= 16) { start = 16 - plotMinZ - 1; @@ -271,8 +270,8 @@ public class XPopulator extends BlockPopulator { if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { start = 0; } - setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); // - setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); // + setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); // + setCuboidRegion((16 - roadStartX) + 1, (16 - roadStartX) + 2, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); // } } // WALLS @@ -460,6 +459,7 @@ public class XPopulator extends BlockPopulator { } } + @SuppressWarnings("deprecation") private void setBlock(final World w, final int x, final int y, final int z, final short id, final byte val) { w.getBlockAt(this.X + x, y, this.Z + z).setData(val, false); } 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 5eff5912d..831622c19 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -15,6 +15,7 @@ import org.bukkit.inventory.Inventory; * * @author Citymonstret */ +@SuppressWarnings("unused") public class InventoryListener implements Listener { @EventHandler diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java index 4b44bbc84..1e0055842 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BlockWrapper.java @@ -21,6 +21,10 @@ package com.intellectualcrafters.plot.object; +import com.sun.istack.internal.NotNull; +import org.bukkit.World; +import org.bukkit.block.Block; + /** * Wrapper class for blocks, using * pure data rather than the object. @@ -28,16 +32,34 @@ package com.intellectualcrafters.plot.object; * Useful for NMS * * @author Empire92 + * @author Citymonstret */ public class BlockWrapper { - // Public Final ////////////////////////// - public final int x; // - public final int y; // - public final int z; // - public final int id; // - public final byte data; // - ////////////////////////////////////////// + /** + * X Coordinate + */ + public final int x; + + /** + * Y Coordinate + */ + public final int y; + + /** + * Z Coordinate + */ + public final int z; + + /** + * Block ID + */ + public final int id; + + /** + * Block Data Value + */ + public final byte data; /** * Constructor @@ -48,11 +70,39 @@ public class BlockWrapper { * @param id Material ID * @param data Data Value */ - public BlockWrapper(int x, int y, int z, short id, byte data) { + public BlockWrapper(final int x, final int y, final int z, final short id, final byte data) { this.x = x; this.y = y; this.z = z; this.id = id; this.data = data; } + + /** + * Alternative Constructor + * Uses block data, rather than typed data + * + * @param block Block from which we get the data + */ + @SuppressWarnings({"deprecation", "unused"}) + public BlockWrapper(@NotNull final Block block) { + this.x = block.getX(); + this.y = block.getY(); + this.z = block.getZ(); + this.id = block.getTypeId(); + this.data = block.getData(); + } + + /** + * Get a block based on the block wrapper + * + * @param world World in which the block is/will be, located + * @return block created/fetched from settings + */ + @SuppressWarnings({"unused", "deprecation"}) + public Block toBlock(@NotNull final World world) { + Block block = world.getBlockAt(x, y, z); + block.setTypeIdAndData(id, data, true); + return block; + } }