From ae885eafcaac8368ec1faf8246794e641cc7aa67 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 13 Mar 2016 22:44:59 -0400 Subject: [PATCH] Various changes and Merge Economy Fix --- .../plotsquared/bukkit/util/BukkitUtil.java | 21 +++++++++++++++---- .../plot/commands/Auto.java | 12 +++-------- .../plot/commands/Claim.java | 12 +++-------- .../plot/commands/Merge.java | 5 ++--- .../plot/util/BO3Handler.java | 8 +++---- .../plotsquared/general/commands/Command.java | 3 --- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index 84c2e4b76..4a7c4b2be 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -5,9 +5,17 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.schematic.PlotItem; -import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.MathMan; +import com.intellectualcrafters.plot.util.StringComparison; +import com.intellectualcrafters.plot.util.StringMan; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.bukkit.object.BukkitPlayer; -import org.bukkit.*; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -17,7 +25,12 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; -import org.bukkit.material.*; +import org.bukkit.material.MaterialData; +import org.bukkit.material.Sandstone; +import org.bukkit.material.Step; +import org.bukkit.material.Tree; +import org.bukkit.material.WoodenStep; +import org.bukkit.material.Wool; import java.util.Arrays; import java.util.List; @@ -282,7 +295,7 @@ public class BukkitUtil extends WorldUtil { final World world = getWorld(loc.getWorld()); final Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); if (block == null) { - return new PlotBlock((short) 0, (byte) 0); + return PlotBlock.EVERYTHING; } return new PlotBlock((short) block.getTypeId(), block.getData()); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 6b183f904..7d2bef836 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -32,14 +32,8 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration( -command = "auto", -permission = "plots.auto", -category = CommandCategory.CLAIMING, -requiredType = RequiredType.NONE, -description = "Claim the nearest plot", -aliases = { "a" }, -usage = "/plot auto [length,width]") +@CommandDeclaration(command = "auto", permission = "plots.auto", category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE, + description = "Claim the nearest plot", aliases = "a", usage = "/plot auto [length,width]") public class Auto extends SubCommand { public static PlotId getNextPlotId(final PlotId id, final int step) { @@ -149,7 +143,7 @@ public class Auto extends SubCommand { sendMessage(plr, C.REMOVED_BALANCE, cost + ""); } } - if (schematic != null && !schematic.equals("")) { + if (schematic != null && !schematic.isEmpty()) { if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) { sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return true; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index 0dff579b2..835789061 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -31,14 +31,8 @@ import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.Permissions; import com.plotsquared.general.commands.CommandDeclaration; -@CommandDeclaration( -command = "claim", -aliases = { "c" }, -description = "Claim the current plot you're standing on", -category = CommandCategory.CLAIMING, -requiredType = RequiredType.NONE, -permission = "plots.claim", -usage = "/plot claim") +@CommandDeclaration(command = "claim", aliases = "c", description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING, + requiredType = RequiredType.NONE, permission = "plots.claim", usage = "/plot claim") public class Claim extends SubCommand { @Override public boolean onCommand(final PlotPlayer plr, final String... args) { @@ -87,7 +81,7 @@ public class Claim extends SubCommand { } sendMessage(plr, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1)); } - if (!schematic.equals("")) { + if (!schematic.isEmpty()) { if (world.SCHEMATIC_CLAIM_SPECIFY) { if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 381fcce4c..4d899277d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -89,8 +89,7 @@ public class Merge extends SubCommand { } final PlotArea plotworld = plot.getArea(); final double price = plotworld.PRICES.get("merge"); - if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d - && EconHandler.manager.getMoney(plr) < price) { + if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(plr) < price) { sendMessage(plr, C.CANNOT_AFFORD_MERGE, price + ""); return false; } @@ -123,7 +122,7 @@ public class Merge extends SubCommand { terrain = "true".equalsIgnoreCase(args[1]); } if (plot.autoMerge(-1, maxSize, uuid, terrain)) { - if (EconHandler.manager != null && price > 0d) { + if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) { EconHandler.manager.withdrawMoney(plr, price); sendMessage(plr, C.REMOVED_BALANCE, price + ""); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java index aa211fe51..2cefac90d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java @@ -95,7 +95,7 @@ public class BO3Handler { BO3 bo3 = map.get(loc); for (int y = 1; y < height; y++) { final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z)); - if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) { + if (!contains(cpw.MAIN_BLOCK, block)) { if (bo3 == null) { bo3 = new BO3(alias, loc); map.put(loc, bo3); @@ -105,7 +105,7 @@ public class BO3Handler { } } final PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, height, z)); - if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) { + if (!contains(cpw.TOP_BLOCK, floor)) { if (bo3 == null) { bo3 = new BO3(alias, loc); map.put(loc, bo3); @@ -115,7 +115,7 @@ public class BO3Handler { } for (int y = height + 1; y < 256; y++) { final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z)); - if ((block != null) && (block.id != 0)) { + if (block.id != 0) { if (bo3 == null) { bo3 = new BO3(alias, loc); map.put(loc, bo3); @@ -205,4 +205,4 @@ public class BO3Handler { } return base; } -} \ No newline at end of file +} diff --git a/Core/src/main/java/com/plotsquared/general/commands/Command.java b/Core/src/main/java/com/plotsquared/general/commands/Command.java index 771ac8469..d81e1d5a6 100644 --- a/Core/src/main/java/com/plotsquared/general/commands/Command.java +++ b/Core/src/main/java/com/plotsquared/general/commands/Command.java @@ -155,9 +155,6 @@ public abstract class Command extends CommandManager { if (this == obj) { return true; } - if (obj == null) { - return false; - } if (getClass() != obj.getClass()) { return false; }