From 57e8563b31b99175c548ed1616da5b062cd19742 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 1 Apr 2015 23:36:46 +1100 Subject: [PATCH] Multiple fixe --- .../plot/commands/Move.java | 2 - .../plot/generator/HybridGen.java | 6 +-- .../plot/generator/HybridPop.java | 42 +++++++------------ .../plot/object/BukkitPlayer.java | 3 -- .../plot/object/PlotGenerator.java | 4 +- .../plot/object/PlotPopulator.java | 4 +- .../plot/util/BukkitSchematicHandler.java | 2 +- .../plot/util/MainUtil.java | 9 ++-- .../plot/util/SchematicHandler.java | 1 - .../plot/util/bukkit/BukkitChunkManager.java | 11 ++++- 10 files changed, 37 insertions(+), 47 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 29e20489f..20b322201 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -79,8 +79,6 @@ public class Move extends SubCommand { } Plot plot2 = MainUtil.getPlot(world2, plot2id); - System.out.print(plot1 + " | " + plot2); - if (plot1.equals(plot2)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move "); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 33369253c..10a6b5991 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -111,7 +111,6 @@ public class HybridGen extends PlotGenerator { if (this.maxY == 0) { this.maxY = 256; } - } /** @@ -190,14 +189,15 @@ public class HybridGen extends PlotGenerator { } return; } - int sx = ((cx << 4) % this.size); - int sz = ((cz << 4) % this.size); + int sx = (short) ((this.X) % this.size); + int sz = (short) ((this.Z) % this.size); if (sx < 0) { sx += this.size; } if (sz < 0) { sz += this.size; } + for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { if (biomes != null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java index 4f8d467ef..f0e056e6d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPop.java @@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.generator; import java.util.HashMap; import java.util.HashSet; +import java.util.Map.Entry; import org.bukkit.World; import org.bukkit.block.Biome; @@ -39,8 +40,6 @@ public class HybridPop extends PlotPopulator { final short pathWidthLower; final short pathWidthUpper; Biome biome; - private int X; - private int Z; private long state; private boolean doFilling = false; private boolean doFloor = false; @@ -107,8 +106,6 @@ public class HybridPop extends PlotPopulator { @Override public void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz) { - this.X = cx << 4; - this.Z = cz << 4; PlotSquared.getPlotManager(world.getName()); if (requiredRegion != null) { short sx = (short) ((this.X) % this.size); @@ -119,6 +116,7 @@ public class HybridPop extends PlotPopulator { if (sz < 0) { sz += this.size; } + for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { if (contains(requiredRegion, this.X + x, this.Z + z)) { @@ -152,33 +150,29 @@ public class HybridPop extends PlotPopulator { } return; } - short sx = (short) ((this.X) % this.size); - short sz = (short) ((this.Z) % this.size); + int sx = (short) ((this.X) % this.size); + int sz = (short) ((this.Z) % this.size); if (sx < 0) { sx += this.size; } if (sz < 0) { sz += this.size; } - // Setting biomes + for (short x = 0; x < 16; x++) { for (short z = 0; z < 16; z++) { - final short absX = (short) ((sx + x) % this.size); - final short absZ = (short) ((sz + z) % this.size); + final int absX = ((sx + x) % this.size); + final int absZ = ((sz + z) % this.size); final boolean gx = absX > this.pathWidthLower; final boolean gz = absZ > this.pathWidthLower; final boolean lx = absX < this.pathWidthUpper; final boolean lz = absZ < this.pathWidthUpper; // inside plot if (gx && gz && lx && lz) { - if (this.doFilling) { - for (short y = 1; y < this.plotheight; y++) { - setBlock(x, y, z, this.filling); - } - } - if (this.doFloor) { - setBlock(x, (short) this.plotheight, z, this.plotfloors); + for (short y = 1; y < this.plotheight; y++) { + setBlock(x, y, z, this.filling); } + setBlock(x, (short) this.plotheight, z, this.plotfloors); if (this.plotworld.PLOT_SCHEMATIC) { final PlotLoc loc = new PlotLoc(absX, absZ); final HashMap blocks = this.plotworld.G_SCH_DATA.get(loc); @@ -201,21 +195,17 @@ public class HybridPop extends PlotPopulator { } else { // wall if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) { - if (this.wallfilling != 0) { - for (short y = 1; y <= this.wallheight; y++) { - setBlock(x, y, z, this.wallfilling); - } + for (short y = 1; y <= this.wallheight; y++) { + setBlock(x, y, z, this.wallfilling); } - if ((this.wall != 0) && !this.plotworld.ROAD_SCHEMATIC_ENABLED) { - setBlock(x, (short) (this.wallheight + 1), z, this.wall); + if (!this.plotworld.ROAD_SCHEMATIC_ENABLED) { + setBlock(x, this.wallheight + 1, z, this.wall); } } // road else { - if (this.roadblock != 0) { - for (short y = 1; y <= this.roadheight; y++) { - setBlock(x, y, z, this.roadblock); - } + for (short y = 1; y <= this.roadheight; y++) { + setBlock(x, y, z, this.roadblock); } } if (this.plotworld.ROAD_SCHEMATIC_ENABLED) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index 5cc267c79..dc7c85592 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -23,9 +23,6 @@ public class BukkitPlayer implements PlotPlayer { * @param player */ public BukkitPlayer(final Player player) { - if (player == null) { - System.out.print("=================== NULL PLAYER ========================="); - } this.player = player; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index cc38daa92..f38c8731e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -36,8 +36,8 @@ import com.intellectualcrafters.plot.util.ChunkManager; public abstract class PlotGenerator extends ChunkGenerator { private short[][] result; - private int X; - private int Z; + public int X; + public int Z; private PseudoRandom random = new PseudoRandom(); @SuppressWarnings("unchecked") diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java index 436318eed..15852aea6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPopulator.java @@ -15,8 +15,8 @@ public abstract class PlotPopulator extends BlockPopulator { private PseudoRandom random = new PseudoRandom(); - private int X; - private int Z; + public int X; + public int Z; private World world; @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java index a6f2bfa83..f7c8ede99 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BukkitSchematicHandler.java @@ -61,7 +61,7 @@ public class BukkitSchematicHandler extends SchematicHandler { for (j = (pos1.getZ() / 16) * 16; j < (16 + ((pos2.getZ() / 16) * 16)); j += 16) { boolean result = ChunkManager.manager.loadChunk(world, new ChunkLoc(i, j)); if (!result) { - System.out.print("&cIllegal selection. Cannot save non-existent chunk at " + (i / 16) + ", " + (j / 16)); + PlotSquared.log("&cIllegal selection. Cannot save non-existent chunk at " + (i / 16) + ", " + (j / 16)); return null; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index fe1bb8fbd..28848045d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -859,7 +859,7 @@ public class MainUtil { public static boolean move(final Plot plot1, final Plot plot2, final Runnable whenDone) { final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(plot1.world, plot1.id); - final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot2.world, plot1.id); + final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot2.world, plot2.id); final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id); if (plot1.owner == null) { TaskManager.runTaskLater(whenDone, 1); @@ -876,16 +876,15 @@ public class MainUtil { final int offset_y = plot2.id.y - pos1.id.y; final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); for (final PlotId id : selection) { - DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y))); + String worldOriginal = plot1.world; + PlotId idOriginal = new PlotId(id.x, id.y); final Plot plot = PlotSquared.getPlots(plot1.world).get(id); PlotSquared.getPlots(plot1.world).remove(id); plot.id.x += offset_x; plot.id.y += offset_y; PlotSquared.getPlots(plot2.world).put(plot.id, plot); + DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y))); } - System.out.print("BOT: " + bot1); - System.out.print("TOP: " + top); - System.out.print(" -> " + bot2); ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() { @Override public void run() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index ff82d9fe3..ce35aab44 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -214,7 +214,6 @@ public abstract class SchematicHandler { } try { final File tmp = new File(path); - System.out.print("ABS: " + tmp.getAbsolutePath()); tmp.getParentFile().mkdirs(); final OutputStream stream = new FileOutputStream(path); final NBTOutputStream output = new NBTOutputStream(new GZIPOutputStream(stream)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java index ffd46cbde..de33208f7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitChunkManager.java @@ -200,10 +200,8 @@ public class BukkitChunkManager extends ChunkManager { final Chunk chunk = oldWorld.getChunkAt(x, z); chunks.add(chunk); chunk.load(false); - saveEntitiesIn(chunk, region); } } - restoreEntities(newWorld, relX, relZ); // Copy blocks final MutableInt mx = new MutableInt(sx); final Integer currentIndex = TaskManager.index.toInteger(); @@ -225,7 +223,16 @@ public class BukkitChunkManager extends ChunkManager { } mx.increment(); if (xv == ex) { // done! + for (int x = c1x; x <= c2x; x++) { + for (int z = c1z; z <= c2z; z++) { + final Chunk chunk = oldWorld.getChunkAt(x, z); + chunks.add(chunk); + chunk.load(false); + saveEntitiesIn(chunk, region); + } + } restoreBlocks(newWorld, relX, relZ); + restoreEntities(newWorld, relX, relZ); BukkitSetBlockManager.setBlockManager.update(chunks); for (final Chunk chunk : chunks) { chunk.unload(true, true);