diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 07e42ca7c..8925bb2bd 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -319,11 +319,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { final Location loc = entity.getLocation(); if (BukkitUtil.getLocation(loc).isPlotRoad()) { final Entity passenger = entity.getPassenger(); - if (!(passenger instanceof Player)) { - if (entity.getMetadata("keep").isEmpty()) { - iter.remove(); - entity.remove(); - } + if (!(passenger instanceof Player) && entity.getMetadata("keep").isEmpty()) { + iter.remove(); + entity.remove(); } } } @@ -585,15 +583,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if (world == null) { // create world final ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldname); - String manager = worldConfig.getString("generator.plugin"); - if (manager == null) { - manager = "PlotSquared"; - } - String generator = worldConfig.getString("generator.init"); - if (generator == null) { - generator = manager; - } - + String manager = worldConfig.getString("generator.plugin", "PlotSquared"); + String generator = worldConfig.getString("generator.init", manager); final int type = worldConfig.getInt("generator.type"); final int terrain = worldConfig.getInt("generator.terrain"); final SetupObject setup = new SetupObject(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java index eed7c47f4..8e4a2ece9 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java @@ -105,13 +105,7 @@ public final class Reflection { public synchronized static Object getHandle(final Object obj) { try { return getMethod(obj.getClass(), "getHandle").invoke(obj); - } catch (IllegalAccessException e) { - e.printStackTrace(); - return null; - } catch (IllegalArgumentException e) { - e.printStackTrace(); - return null; - } catch (InvocationTargetException e) { + } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException e) { e.printStackTrace(); return null; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java index d1c9396ab..b6f857aa6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java @@ -168,8 +168,7 @@ public class LikePlotMeConverter { mergeWorldYml(plugin, plotConfig); sendMessage("Connecting to " + plugin + " DB"); - - int plotCount = 0; + final ArrayList createdPlots = new ArrayList<>(); sendMessage("Collecting plot data"); @@ -195,6 +194,7 @@ public class LikePlotMeConverter { } } final HashMap> plots = connector.getPlotMePlots(connection); + int plotCount = 0; for (final Entry> entry : plots.entrySet()) { plotCount += entry.getValue().size(); } @@ -234,25 +234,13 @@ public class LikePlotMeConverter { plotsize = 32; } PS.get().config.set("worlds." + world + ".plot.size", plotsize); - String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); // - if (wallblock == null) { - wallblock = "44"; - } + String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock", "44"); // PS.get().config.set("worlds." + world + ".wall.block", wallblock); - String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); // - if (floor == null) { - floor = "2"; - } + String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); // PS.get().config.set("worlds." + world + ".plot.floor", Collections.singletonList(floor)); - String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); // - if (filling == null) { - filling = "3"; - } + String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock", "3"); // PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling)); - String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock"); - if (road == null) { - road = "5"; - } + String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock", "5"); PS.get().config.set("worlds." + world + ".road.block", road); Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // if (height == 0) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java index 881da8a30..d21dbaab4 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java @@ -71,14 +71,12 @@ public class PlotMeConnector_017 extends APlotMeConnector { final PlotId id = new PlotId(r.getInt("plotX"), r.getInt("plotZ")); final String name = r.getString("owner"); final String world = LikePlotMeConverter.getWorld(r.getString("world")); - if (!plots.containsKey(world)) { - if (merge) { - final int plot = PS.get().config.getInt("worlds." + world + ".plot.size"); - final int path = PS.get().config.getInt("worlds." + world + ".road.width"); - plotWidth.put(world, plot); - roadWidth.put(world, path); - merges.put(world, new HashMap()); - } + if (!plots.containsKey(world) && merge) { + final int plot = PS.get().config.getInt("worlds." + world + ".plot.size"); + final int path = PS.get().config.getInt("worlds." + world + ".road.width"); + plotWidth.put(world, plot); + roadWidth.put(world, path); + merges.put(world, new HashMap()); } if (merge) { final int tx = r.getInt("topX"); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java index 66f269d4b..e4bcafbd5 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java @@ -1,5 +1,7 @@ package com.plotsquared.bukkit.util.block; +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; + import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.util.ChunkManager; @@ -15,6 +17,12 @@ import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.SendChunk; +import org.bukkit.Chunk; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.block.Biome; + import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -24,35 +32,13 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; -import org.bukkit.Chunk; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.block.Biome; - - -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; public class FastQueue_1_9 extends SlowQueue { - final Object air; + private final Object air; private final SendChunk chunksender; - private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer"); - private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk"); - private final RefClass classPacket = getRefClass("{nms}.Packet"); - private final RefClass classConnection = getRefClass("{nms}.PlayerConnection"); - private final RefClass classChunk = getRefClass("{nms}.Chunk"); - private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer"); - private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); - private final RefClass classWorld = getRefClass("{nms}.World"); - private final RefField mustSave = classChunk.getField("mustSave"); - private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition"); - private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection"); - private final RefClass classBlock = getRefClass("{nms}.Block"); - private final RefClass classIBlockData = getRefClass("{nms}.IBlockData"); private final HashMap toUpdate = new HashMap<>(); private final RefMethod methodGetHandleChunk; - private final RefConstructor MapChunk; private final RefMethod methodInitLighting; private final RefConstructor classBlockPositionConstructor; private final RefConstructor classChunkSectionConstructor; @@ -68,15 +54,21 @@ public class FastQueue_1_9 extends SlowQueue { public FastQueue_1_9() throws RuntimeException { + RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); + RefClass classChunk = getRefClass("{nms}.Chunk"); methodInitLighting = classChunk.getMethod("initLighting"); - MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class); + RefClass classBlockPosition = getRefClass("{nms}.BlockPosition"); classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class); + RefClass classWorld = getRefClass("{nms}.World"); methodW = classWorld.getMethod("w", classBlockPosition.getRealClass()); fieldSections = classChunk.getField("sections"); fieldWorld = classChunk.getField("world"); + RefClass classBlock = getRefClass("{nms}.Block"); + RefClass classIBlockData = getRefClass("{nms}.IBlockData"); methodGetCombinedId = classBlock.getMethod("getCombinedId", classIBlockData.getRealClass()); methodGetByCombinedId = classBlock.getMethod("getByCombinedId", int.class); + RefClass classChunkSection = getRefClass("{nms}.ChunkSection"); methodGetBlocks = classChunkSection.getMethod("getBlocks"); methodGetType = classChunkSection.getMethod("getType", int.class, int.class, int.class); methodSetType = classChunkSection.getMethod("setType", int.class, int.class, int.class, classIBlockData.getRealClass()); @@ -91,7 +83,7 @@ public class FastQueue_1_9 extends SlowQueue { return; } int count = 0; - final ArrayList chunks = new ArrayList(); + final ArrayList chunks = new ArrayList<>(); final Iterator> i = toUpdate.entrySet().iterator(); while (i.hasNext() && (count < 128)) { chunks.add(i.next().getValue()); diff --git a/Core/src/main/java/com/intellectualcrafters/json/Cookie.java b/Core/src/main/java/com/intellectualcrafters/json/Cookie.java index ee4def328..6e1cbfa46 100644 --- a/Core/src/main/java/com/intellectualcrafters/json/Cookie.java +++ b/Core/src/main/java/com/intellectualcrafters/json/Cookie.java @@ -110,20 +110,15 @@ public class Cookie { */ public static String toString(final JSONObject jo) throws JSONException { final StringBuilder sb = new StringBuilder(); - sb.append(escape(jo.getString("name"))); - sb.append("="); - sb.append(escape(jo.getString("value"))); + sb.append(escape(jo.getString("name"))).append("=").append(escape(jo.getString("value"))); if (jo.has("expires")) { - sb.append(";expires="); - sb.append(jo.getString("expires")); + sb.append(";expires=").append(jo.getString("expires")); } if (jo.has("domain")) { - sb.append(";domain="); - sb.append(escape(jo.getString("domain"))); + sb.append(";domain=").append(escape(jo.getString("domain"))); } if (jo.has("path")) { - sb.append(";path="); - sb.append(escape(jo.getString("path"))); + sb.append(";path=").append(escape(jo.getString("path"))); } if (jo.optBoolean("secure")) { sb.append(";secure"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index c3c49d344..79277a56e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -925,7 +925,6 @@ public class PS { @Deprecated public ArrayList sortPlotsByTimestamp(final Collection plots) { - List unknown = new ArrayList<>(); int hardmax = 256000; int max = 0; int overflowSize = 0; @@ -1351,25 +1350,21 @@ public class PS { IndependentPlotGenerator pg; if (baseGenerator != null && baseGenerator.isFull()) { pg = baseGenerator.getPlotGenerator(); - } - else if (worldSection != null) { + } else if (worldSection != null) { String secondaryGeneratorName = worldSection.getString("generator.plugin"); GeneratorWrapper secondaryGenerator = IMP.getGenerator(world, secondaryGeneratorName); if (secondaryGenerator != null && secondaryGenerator.isFull()) { pg = secondaryGenerator.getPlotGenerator(); - } - else { + } else { String primaryGeneratorName = worldSection.getString("generator.init"); GeneratorWrapper primaryGenerator = IMP.getGenerator(world, primaryGeneratorName); if (primaryGenerator != null && primaryGenerator.isFull()) { pg = primaryGenerator.getPlotGenerator(); - } - else { + } else { return; } } - } - else { + } else { return; } // Conventional plot generator @@ -1405,10 +1400,7 @@ public class PS { return; } log(C.PREFIX.s() + "&aDetected world load for '" + world + "'"); - String gen_string = worldSection.getString("generator.plugin"); - if (gen_string == null) { - gen_string = "PlotSquared"; - } + String gen_string = worldSection.getString("generator.plugin", "PlotSquared"); if (type == 2) { Set clusters = clusters_tmp != null ? clusters_tmp.get(world) : new HashSet(); if (clusters == null) { @@ -1505,10 +1497,7 @@ public class PS { clone.set(key, worldSection.get(key)); } } - String gen_string = clone.getString("generator.plugin"); - if (gen_string == null) { - gen_string = "PlotSquared"; - } + String gen_string = clone.getString("generator.plugin", "PlotSquared"); GeneratorWrapper areaGen = IMP.getGenerator(world, gen_string); if (areaGen == null) { throw new IllegalArgumentException("Invalid Generator: " + gen_string); 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 835789061..c1b53435c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -75,8 +75,7 @@ public class Claim extends SubCommand { if (grants > 0) { if (grants == 1) { plr.removePersistentMeta("grantedPlots"); - } - else { + } else { plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(grants - 1)); } sendMessage(plr, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1)); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index d69576576..0fe24c8d9 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -464,12 +464,12 @@ public class Cluster extends SubCommand { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]); return false; } - if (args[1].toLowerCase().equals("add")) { + if (args[1].equalsIgnoreCase("add")) { cluster.helpers.add(uuid); DBFunc.setHelper(cluster, uuid); return MainUtil.sendMessage(plr, C.CLUSTER_ADDED_HELPER); } - if (args[1].toLowerCase().equals("remove")) { + if (args[1].equalsIgnoreCase("remove")) { cluster.helpers.remove(uuid); DBFunc.removeHelper(cluster, uuid); return MainUtil.sendMessage(plr, C.CLUSTER_REMOVED_HELPER); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java index edf7c3b15..8b6423193 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java @@ -12,15 +12,9 @@ import com.plotsquared.general.commands.CommandDeclaration; import java.io.File; import java.io.IOException; -import java.util.Arrays; -@CommandDeclaration( -command = "debugpaste", -aliases = { "dp" }, -usage = "/plot debugpaste", -description = "Upload settings.yml & latest.log to HasteBin", -permission = "plots.debugpaste", -category = CommandCategory.DEBUG) +@CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste", description = "Upload settings.yml & latest.log to HasteBin", + permission = "plots.debugpaste", category = CommandCategory.DEBUG) public class DebugPaste extends SubCommand { @Override @@ -39,11 +33,12 @@ public class DebugPaste extends SubCommand { } final StringBuilder b = new StringBuilder(); b.append("# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your problem\n\n# We will start with some informational files\n"); - b.append("links.settings_yml: '").append(settingsYML).append("'\n"); - b.append("links.latest_log: '").append(latestLOG).append("'\n"); - b.append("\n# YAAAS! Now let us move on to the server info\n"); - b.append("version.server: '").append(Arrays.toString(PS.get().IMP.getServerVersion())).append("'\n"); - b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper() + ";" + !Settings.OFFLINE_MODE).append("\n"); + b.append("links.settings_yml: ").append(settingsYML).append("\n"); + b.append("links.latest_log: ").append(latestLOG).append("\n"); + b.append("\n# Server Information\n"); + int[] sVersion = PS.get().IMP.getServerVersion(); + b.append("version.server: ").append(sVersion[0]).append('.').append(sVersion[1]).append('.').append(sVersion[2]).append("\n"); + b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(";").append(!Settings.OFFLINE_MODE).append("\n"); b.append("plugins:"); for (String id : PS.get().IMP.getPluginIds()) { String[] split = id.split(":"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java index f9d2e8e29..f6110e670 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java @@ -1,5 +1,10 @@ package com.intellectualcrafters.plot.commands; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.StringMan; +import com.plotsquared.general.commands.Command; + import java.io.File; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -11,11 +16,6 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.StringMan; -import com.plotsquared.general.commands.Command; - public class GenerateDocs { public static void main(final String[] args) { MainCommand.getInstance().addCommand(new WE_Anywhere()); @@ -145,7 +145,7 @@ public class GenerateDocs { split = Arrays.copyOfRange(split, 1, split.length); for (String method : split) { String perm = method.split("[,|)]")[1].trim(); - if (!perm.toLowerCase().equals(perm)) { + if (!perm.equalsIgnoreCase(perm)) { if (perm.startsWith("C.")) { perm = C.valueOf(perm.split("\\.")[1]).s(); } @@ -178,7 +178,7 @@ public class GenerateDocs { split = Arrays.copyOfRange(split, 1, split.length); for (String method : split) { String perm = method.split("[,|)]")[1].trim(); - if (!perm.toLowerCase().equals(perm)) { + if (!perm.equalsIgnoreCase(perm)) { if (perm.startsWith("C.")) { perm = C.valueOf(perm.split("\\.")[1]).s(); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Template.java index 330234c58..9c2e3f9bb 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -20,16 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Set; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - import com.intellectualcrafters.configuration.ConfigurationSection; import com.intellectualcrafters.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.PS; @@ -47,6 +37,16 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.general.commands.CommandDeclaration; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + @CommandDeclaration( command = "template", permission = "plots.admin", @@ -161,19 +161,12 @@ public class Template extends SubCommand { } catch (final Exception e) { e.printStackTrace(); } - String manager = worldConfig.getString("generator.plugin"); - if (manager == null) { - manager = "PlotSquared"; - } - String generator = worldConfig.getString("generator.init"); - if (generator == null) { - generator = manager; - } - - final int type = worldConfig.getInt("generator.type"); - final int terrain = worldConfig.getInt("generator.terrain"); - - final SetupObject setup = new SetupObject(); + String manager = worldConfig.getString("generator.plugin", "PlotSquared"); + String generator = worldConfig.getString("generator.init", manager); + int type = worldConfig.getInt("generator.type"); + int terrain = worldConfig.getInt("generator.terrain"); + + SetupObject setup = new SetupObject(); setup.plotManager = manager; setup.setupGenerator = generator; setup.type = type; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java index aa2f078ac..813849b91 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java @@ -22,7 +22,6 @@ package com.intellectualcrafters.plot.object; import com.intellectualcrafters.configuration.ConfigurationSection; import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; @@ -30,11 +29,24 @@ import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.generator.GridPlotWorld; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; -import com.intellectualcrafters.plot.util.*; +import com.intellectualcrafters.plot.util.EconHandler; +import com.intellectualcrafters.plot.util.EventUtil; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.PlotGamemode; +import com.intellectualcrafters.plot.util.StringMan; +import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.area.QuadMap; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; /** @@ -128,7 +140,7 @@ public abstract class PlotArea { /** * Returns the region for this PlotArea - * @Nullable + * * @return RegionWrapper or null if no applicable region */ public RegionWrapper getRegionAbs() { @@ -160,7 +172,7 @@ public abstract class PlotArea { /** * Get the implementation independent generator for this area - * @Nullable + * * @return */ public IndependentPlotGenerator getGenerator() { @@ -230,8 +242,11 @@ public abstract class PlotArea { SCHEMATICS = config.getStringList("schematic.schematics"); USE_ECONOMY = config.getBoolean("economy.use") && EconHandler.manager != null; ConfigurationSection priceSection = config.getConfigurationSection("economy.prices"); - for (String key : priceSection.getKeys(false)) { - PRICES.put(key, priceSection.getDouble(key)); + if (USE_ECONOMY) { + PRICES = new HashMap<>(); + for (String key : priceSection.getKeys(false)) { + PRICES.put(key, priceSection.getDouble(key)); + } } PLOT_CHAT = config.getBoolean("chat.enabled"); WORLD_BORDER = config.getBoolean("world.border"); @@ -743,22 +758,7 @@ public abstract class PlotArea { } return true; } - - public boolean mergePlots(final PlotPlayer player, final ArrayList plotIds) { - if (EconHandler.manager != null && USE_ECONOMY) { - final double cost = plotIds.size() * (PRICES.containsKey("merge") ? PRICES.get("merge") : 0); - if (cost > 0d) { - if (EconHandler.manager.getMoney(player) < cost) { - MainUtil.sendMessage(player, C.CANNOT_AFFORD_MERGE, "" + cost); - return false; - } - EconHandler.manager.withdrawMoney(player, cost); - MainUtil.sendMessage(player, C.REMOVED_BALANCE, cost + ""); - } - } - return mergePlots(plotIds, true, true); - } - + public boolean removePlot(PlotId id) { return plots.remove(id) != null; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/PlotChunk.java b/Core/src/main/java/com/intellectualcrafters/plot/util/PlotChunk.java index dfb63e892..5663ad2e0 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/PlotChunk.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/PlotChunk.java @@ -20,16 +20,16 @@ public abstract class PlotChunk implements Cloneable { public PlotChunk(final ChunkWrapper chunk) { this.chunk = chunk; } + + public ChunkWrapper getChunkWrapper() { + return this.chunk; + } public void setChunkWrapper(final ChunkWrapper loc) { this.chunk = loc; this.objChunk = null; } - public ChunkWrapper getChunkWrapper() { - return this.chunk; - } - public int getX() { return chunk.x; } @@ -194,7 +194,7 @@ public abstract class PlotChunk implements Cloneable { @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof PlotChunk)) { + if (!(obj instanceof PlotChunk)) { return false; } return chunk.equals(((PlotChunk) obj).chunk); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java b/Core/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java index fd186eecd..e7d45bd00 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/ReflectionUtils.java @@ -316,7 +316,7 @@ public class ReflectionUtils { } catch (final NoSuchMethodException ignored) { return new RefMethod(clazz.getDeclaredMethod(name, classes)); } - } catch (final Exception e) { + } catch (NoSuchMethodException | SecurityException e) { throw new RuntimeException(e); } } @@ -348,7 +348,7 @@ public class ReflectionUtils { } catch (final NoSuchMethodException ignored) { return new RefConstructor(clazz.getDeclaredConstructor(classes)); } - } catch (final Exception e) { + } catch (NoSuchMethodException | SecurityException e) { throw new RuntimeException(e); } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 836c1aec4..12e36ead1 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -317,15 +317,9 @@ public class SpongeMain implements IPlotMain { if (world == null) { // create world final ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldname); - String manager = worldConfig.getString("generator.plugin"); - if (manager == null) { - manager = "PlotSquared"; - } - String generator = worldConfig.getString("generator.init"); - if (generator == null) { - generator = manager; - } - + String manager = worldConfig.getString("generator.plugin", "PlotSquared"); + String generator = worldConfig.getString("generator.init", manager); + final int type = worldConfig.getInt("generator.type"); final int terrain = worldConfig.getInt("generator.terrain"); final SetupObject setup = new SetupObject(); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java index 3fc0b1a2c..29a6d7e94 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java @@ -97,14 +97,9 @@ public class SpongeChunkManager extends ChunkManager { } Field fieldDroppedChunksSet; try { - fieldDroppedChunksSet = chunkServer.getClass().getField("field_73248_b"); + fieldDroppedChunksSet = chunkServer.getClass().getField("droppedChunksSet"); } catch (Throwable t) { - try { - fieldDroppedChunksSet = chunkServer.getClass().getField("droppedChunksSet"); - } - catch (Throwable t2) { - fieldDroppedChunksSet = ReflectionUtils.findField(chunkServer.getClass(), Set.class); - } + fieldDroppedChunksSet = ReflectionUtils.findField(chunkServer.getClass(), Set.class); } Set set = (Set) fieldDroppedChunksSet.get(chunkServer); set.remove(pos); @@ -178,4 +173,4 @@ public class SpongeChunkManager extends ChunkManager { throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); } -} \ No newline at end of file +}