From 8597117d7aae0d42d01d34b6bb707449796e17e6 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 3 Oct 2014 14:01:01 +1000 Subject: [PATCH] Fixed large roads, server crashes, and DB upgrades Roads of 100 blocks or more will now work (WHO HAS ROADS THAT LARGE THOUGH!?) - We could see if we could block beacon effects from other plots... *The crash was due to a misconstructed for loop. Older databases will now add the missing table plot_ratings --- .../com/intellectualcrafters/plot/PWE.java | 6 ---- .../intellectualcrafters/plot/PlotHelper.java | 28 +++++-------------- .../intellectualcrafters/plot/PlotMain.java | 17 +++++++++++ .../plot/WorldGenerator.java | 5 ++++ .../intellectualcrafters/plot/XPopulator.java | 5 ++++ .../plot/database/DBFunc.java | 1 - 6 files changed, 34 insertions(+), 28 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PWE.java b/PlotSquared/src/com/intellectualcrafters/plot/PWE.java index c2cfd10b2..fe3789d37 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PWE.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PWE.java @@ -84,18 +84,12 @@ public class PWE { } public static void removeMask(Player p, LocalSession s) { - System.out.print(0); try { - System.out.print(1); s.setMask(null); - System.out.print(2); } catch (Throwable e) { - System.out.print(3); com.sk89q.worldedit.masks.Mask mask = null; s.setMask(mask); - System.out.print(4); } - System.out.print(5); } public static void removeMask(Player p) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java index 0ccdd891b..653abf1c5 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java @@ -739,23 +739,6 @@ public class PlotHelper { return new short[] { Short.parseShort(block), 0 }; } - public static void teleportPlayers(World world, Plot plot, boolean tile) { - final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final Location pos2 = getPlotTopLoc(world, plot.id); - for (int i = (pos2.getBlockX() / 16) * 16; i < (16 + ((pos2.getBlockX() / 16) * 16)); i = 16) { - for (int j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2.getBlockZ() / 16) * 16)); j += 16) { - Chunk chunk = world.getChunkAt(i, j); - for (Entity entity : chunk.getEntities()) { - PlotId id = PlayerFunctions.getPlot(entity.getLocation()); - if ((id != null) && id.equals(plot.id) && (entity.getType() == EntityType.PLAYER)) { - entity.teleport(world.getSpawnLocation()); - // Should this teleport them to floor instead? - } - } - } - } - } - public static void clearAllEntities(World world, Plot plot, boolean tile) { final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos2 = getPlotTopLoc(world, plot.id); @@ -765,7 +748,12 @@ public class PlotHelper { for (Entity entity : chunk.getEntities()) { PlotId id = PlayerFunctions.getPlot(entity.getLocation()); if ((id != null) && id.equals(plot.id)) { - entity.remove(); + if (entity instanceof Player) { + PlotMain.teleportPlayer((Player) entity, entity.getLocation(), plot); + } + else { + entity.remove(); + } } } if (tile) { @@ -788,10 +776,8 @@ public class PlotHelper { final long start = System.nanoTime(); final World world = requester.getWorld(); - // clear entities: + // clear entities/teleport players clearAllEntities(world, plot, false); - // teleport players - teleportPlayers(world, plot, false); final PlotWorld plotworld = PlotMain.getWorldSettings(world); PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index 5f2e8aea3..ddfff38c2 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -608,6 +608,12 @@ public class PlotMain extends JavaPlugin { if (!res.next()) { DBFunc.createTables("mysql", false); } + else { + res = meta.getTables(null, null, "plot_ratings", null); + if (!res.next()) { + DBFunc.createTables("mysql", false); + } + } } } } catch (ClassNotFoundException | SQLException e) { @@ -630,6 +636,17 @@ public class PlotMain extends JavaPlugin { ResultSet res = meta.getTables(null, null, "plot", null); if (!res.next()) { DBFunc.createTables("sqlite", true); + } else { + res = meta.getTables(null, null, "plot_trusted", null); + if (!res.next()) { + DBFunc.createTables("sqlite", false); + } + else { + res = meta.getTables(null, null, "plot_ratings", null); + if (!res.next()) { + DBFunc.createTables("sqlite", false); + } + } } } } catch (ClassNotFoundException | SQLException e) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java index 085c2578a..23933bf22 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java @@ -287,6 +287,11 @@ public class WorldGenerator extends ChunkGenerator { // ROAD (0/24) The following is an inefficient placeholder as it is too // much work to finish it + if (pathsize>16 && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !(roadStartX<16 && roadStartZ<16) && ((roadStartX>16 && roadStartZ>16) || (plotMinX > roadStartX) && (plotMinZ > roadStartZ))) { + setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1); + return this.result; + } + if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) { int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1); int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/XPopulator.java b/PlotSquared/src/com/intellectualcrafters/plot/XPopulator.java index f7b47bf15..db8bf1575 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/XPopulator.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/XPopulator.java @@ -159,6 +159,11 @@ public class XPopulator extends BlockPopulator { // ROADS + if (pathsize>16 && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !(roadStartX<16 && roadStartZ<16) && ((roadStartX>16 && roadStartZ>16) || (plotMinX > roadStartX) && (plotMinZ > roadStartZ))) { + setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.f1_id, this.f1_v, w); + return; + } + if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) { int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1); int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java index 93cae208e..95d353842 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java @@ -240,7 +240,6 @@ public class DBFunc { stmt.executeBatch(); stmt.clearBatch(); stmt.close(); - } /**