From 333a23765599386168622aa2dc074d1c4c79dafb Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 22 Sep 2014 21:43:53 +1000 Subject: [PATCH] bug fixes --- .../src/com/intellectualcrafters/plot/C.java | 5 +++- .../com/intellectualcrafters/plot/Plot.java | 1 + .../intellectualcrafters/plot/PlotHelper.java | 18 ++++++++++----- .../intellectualcrafters/plot/PlotMain.java | 13 +++++------ .../intellectualcrafters/plot/PlotWorld.java | 4 ++-- .../plot/WorldGenerator.java | 6 ++--- .../plot/api/PlotAPI.java | 8 ++----- .../plot/commands/Auto.java | 23 ++++++++++++++++--- .../plot/commands/Debug.java | 4 ++-- 9 files changed, 51 insertions(+), 31 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/C.java b/PlotSquared/src/com/intellectualcrafters/plot/C.java index 9b4212a39..8d97ae7cd 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/C.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/C.java @@ -83,6 +83,8 @@ public enum C { */ NOT_IN_PLOT("&cYou're not in a plot"), NOT_IN_PLOT_WORLD("&cYou're not in a plot world"), + NOT_VALID_WORLD("&cThat is not a valid world (case sensitive)"), + NOT_VALID_PLOT_WORLD("&cThat is not a valid plot world (case sensitive)"), NO_PLOTS("&cYou don't have any plots"), /* Block List @@ -147,7 +149,8 @@ public enum C { Clearing */ CLEARING_PLOT("&cClearing plot."), - CLEARING_DONE("&aDone! Took %time% seconds"), + CLEARING_DONE("&6Done, took &a%time%&6 ms!"), + CLEARING_DONE_PACKETS("&6(&a%time% &6ms for packets)"), /* Claiming */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Plot.java b/PlotSquared/src/com/intellectualcrafters/plot/Plot.java index a0b8c0849..a13a8e96f 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Plot.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Plot.java @@ -10,6 +10,7 @@ package com.intellectualcrafters.plot; import com.intellectualcrafters.plot.database.DBFunc; + import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.Biome; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java index 8657989fe..0b8225fd2 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java @@ -50,8 +50,9 @@ public class PlotHelper { @SuppressWarnings("deprecation") public static void setSign(Player plr, Plot p) { - PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(p.world)); - Location pl = new Location(plr.getWorld(), getPlotBottomLoc(plr.getWorld(), p.id).getBlockX() , plotworld.ROAD_HEIGHT + 1, getPlotBottomLoc(plr.getWorld(), p.id).getBlockZ()); + World world = Bukkit.getWorld(p.world); + PlotWorld plotworld = PlotMain.getWorldSettings(world); + Location pl = new Location(world, getPlotBottomLoc(world, p.id).getBlockX() , plotworld.ROAD_HEIGHT + 1, getPlotBottomLoc(world, p.id).getBlockZ()); Block bs = pl.add(0,0,-1).getBlock(); bs.setType(Material.AIR); bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false); @@ -61,6 +62,7 @@ public class PlotHelper { sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); + System.out.print(10); sign.update(true); } @@ -440,7 +442,7 @@ public class PlotHelper { public static void clear(final Player requester, final Plot plot) { PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world)); - long start = System.currentTimeMillis(); + long start = System.nanoTime(); PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST); PlotHelper.removeSign(requester, plot); PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT); @@ -465,14 +467,21 @@ public class PlotHelper { filling[i] = result[0]; filling_data[i] = result[1]; } + + try { setBlockClass = new SetBlockFast(); regenerateCuboid(pos1, pos2,requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); + PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""+((System.nanoTime()-start)/1000000.0))); + SetBlockFast.update(requester); + PlayerFunctions.sendMessage(requester, C.CLEARING_DONE_PACKETS.s().replaceAll("%time%", ""+((System.nanoTime()-start)/1000000.0))); + return; } catch (NoClassDefFoundError e) { PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&cFast plot clearing is currently not enabled."); PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&c - Please get PlotSquared for "+Bukkit.getVersion()+" for improved performance"); } + if (pos2.getBlockX()-pos1.getBlockX()<16) { regenerateCuboid(pos1, pos2,requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); return; @@ -534,9 +543,6 @@ public class PlotHelper { regenerateCuboid(new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX, height, plotMaxZ),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //8 } PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""+((System.currentTimeMillis()-start)/1000.0))); - if (setBlockClass!=null) { - SetBlockFast.update(requester); - } } public static void regenerateCuboid(Location pos1, Location pos2,Player player, PlotWorld plotworld, Object[] plotfloors, Object[] filling) { World world = pos1.getWorld(); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index efc3754c7..c69877549 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -52,8 +52,7 @@ import java.util.UUID; import static org.bukkit.Material.*; /** - * @awesome @author Empire92 - * @author Citymonstret + * @awesome @author Citymonstret, Empire92 * PlotMain class. */ public class PlotMain extends JavaPlugin { @@ -175,8 +174,8 @@ public class PlotMain extends JavaPlugin { /** * get all plot worlds */ - public static World[] getPlotWorlds() { - return (worlds.keySet().toArray(new World[0])); + public static String[] getPlotWorlds() { + return (worlds.keySet().toArray(new String[0])); } public static String[] getPlotWorldsString() { return plots.keySet().toArray(new String[0]); @@ -209,6 +208,7 @@ public class PlotMain extends JavaPlugin { /** * Replace the plot object with an updated version * + * @param id plot Id * @param plot plot object */ public static void updatePlot(Plot plot) { @@ -327,7 +327,6 @@ public class PlotMain extends JavaPlugin { if (C.ENABLED.s().length() > 0) { Broadcast(C.ENABLED); } - if (Settings.DB.USE_MYSQL) { try { mySQL = new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, @@ -600,8 +599,8 @@ public class PlotMain extends JavaPlugin { long error = 0l; @Override public void run() { - for (World w: getPlotWorlds()) { - World world = w; + for (String w: getPlotWorlds()) { + World world = Bukkit.getWorld(w); try { if(world.getLoadedChunks().length < 1) { return; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java index 348e4ea2e..829a1f4af 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java @@ -65,7 +65,7 @@ public class PlotWorld { /** * Default main block: 1 */ - public static String[] MAIN_BLOCK_DEFAULT = new String[] {"1:0"}; + public static String[] MAIN_BLOCK_DEFAULT = new String[] {"1"}; /** * Top blocks */ @@ -73,7 +73,7 @@ public class PlotWorld { /** * Default top blocks: {"2"} */ - public static String[] TOP_BLOCK_DEFAULT = new String[] {"2:0"}; + public static String[] TOP_BLOCK_DEFAULT = new String[] {"2"}; /** * Wall block diff --git a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java index 0cfbc35a9..1833a6b5b 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java @@ -113,8 +113,6 @@ public class WorldGenerator extends ChunkGenerator { plotsize = plotworld.PLOT_WIDTH; pathsize = plotworld.ROAD_WIDTH; bottom = (short) Material.BEDROCK.getId(); - filling = new Short[plotworld.MAIN_BLOCK.length]; - plotfloors = new Short[plotworld.TOP_BLOCK.length]; floor1 = getBlock(plotworld.ROAD_BLOCK); // floor2 = getBlock(plotworld.ROAD_STRIPES); @@ -122,8 +120,8 @@ public class WorldGenerator extends ChunkGenerator { size = pathsize + plotsize; wall = getBlock(plotworld.WALL_BLOCK); - Short[] plotfloors = new Short[plotworld.TOP_BLOCK.length]; - Short[] plotfloors_data = new Short[plotworld.TOP_BLOCK.length]; + plotfloors = new Short[plotworld.TOP_BLOCK.length]; + filling = new Short[plotworld.TOP_BLOCK.length]; for (int i = 0; i < plotworld.TOP_BLOCK.length; i++) { plotfloors[i] = getBlock(plotworld.TOP_BLOCK[i]); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java index 5c7445f66..3d40c51ec 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java @@ -151,7 +151,7 @@ public class PlotAPI { * Get all plot worlds * @return World[] - array of plot worlds */ - public World[] getPlotWorlds() { + public String[] getPlotWorlds() { return PlotMain.getPlotWorlds(); } /** @@ -160,11 +160,7 @@ public class PlotAPI { * @return boolean (if plot world or not) */ public boolean isPlotWorld(World world) { - for (World w:PlotMain.getPlotWorlds()) { - if (w.equals(world)) - return true; - } - return false; + return PlotMain.isPlotWorld(world); } /** * Get the settings for a world (settings bundled in PlotWorld class) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java index a00842470..cb706fd3b 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java @@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.PlotHelper; import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.PlotMain; +import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; @@ -29,13 +30,29 @@ public class Auto extends SubCommand { public boolean execute(Player plr, String ... args) { World world; if (PlotMain.getPlotWorlds().length==1) - world = PlotMain.getPlotWorlds()[0]; + world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]); else { if (PlotMain.isPlotWorld(plr.getWorld())) world = plr.getWorld(); else { - PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); - return true; + if (args.length==1) { + world = Bukkit.getWorld(args[0]); + if (world!=null) { + if (!PlotMain.isPlotWorld(world)) { + PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); + return true; + } + + } + else { + PlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD); + return true; + } + } + else { + PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); + return true; + } } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java index d47acabce..ede12002a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java @@ -76,8 +76,8 @@ public class Debug extends SubCommand{ */ { StringBuilder worlds = new StringBuilder(""); - for (World world: PlotMain.getPlotWorlds()) - worlds.append(world.getName()+" "); + for (String world: PlotMain.getPlotWorlds()) + worlds.append(world+" "); information.append(header); information.append(getSection(section, "Lag / TPS")); information.append(getLine(line, "Ticks Per Second", Lag.getTPS()));