From d52e9b4c8cba2bbfcd621d5563d3806700162905 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 23 Aug 2015 22:04:17 +1000 Subject: [PATCH] Minor fixes --- .../plot/commands/DebugExec.java | 20 +++++++++---------- .../plot/commands/Unclaim.java | 3 +++ .../plotsquared/bukkit/util/SendChunk.java | 19 +++++++++--------- .../plotsquared/bukkit/util/SetBlockFast.java | 1 + .../bukkit/util/SetBlockFast_1_8.java | 1 + .../plotsquared/general/commands/Command.java | 3 +++ .../com/plotsquared/sponge/SpongeMain.java | 2 -- .../sponge/generator/WorldModify.java | 2 ++ 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index fe844b5fd..b68b7155d 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -89,17 +89,17 @@ public class DebugExec extends SubCommand { private Bindings scope; public DebugExec() { - File file = new File(PS.get().IMP.getDirectory(), "scripts" + File.separator + "start.js"); - if (file.exists()) { - init(); - try { - String script = StringMan.join(Files.readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), "start.js"), StandardCharsets.UTF_8), System.getProperty("line.separator")); - scope.put("THIS", this); - scope.put("PlotPlayer", ConsolePlayer.getConsole()); - engine.eval(script, scope); - } catch (Exception e) { - e.printStackTrace(); + try { + File file = new File(PS.get().IMP.getDirectory(), "scripts" + File.separator + "start.js"); + if (file.exists()) { + init(); + String script = StringMan.join(Files.readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), "start.js"), StandardCharsets.UTF_8), System.getProperty("line.separator")); + scope.put("THIS", this); + scope.put("PlotPlayer", ConsolePlayer.getConsole()); + engine.eval(script, scope); } + } catch (Exception e) { + e.printStackTrace(); } } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java index d08d7d4aa..e105ff408 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -47,6 +47,9 @@ public class Unclaim extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } + if (!plot.hasOwner()) { + return !sendMessage(plr, C.PLOT_NOT_CLAIMED); + } if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } diff --git a/src/main/java/com/plotsquared/bukkit/util/SendChunk.java b/src/main/java/com/plotsquared/bukkit/util/SendChunk.java index df62eb10b..d88a6970b 100644 --- a/src/main/java/com/plotsquared/bukkit/util/SendChunk.java +++ b/src/main/java/com/plotsquared/bukkit/util/SendChunk.java @@ -42,7 +42,9 @@ public class SendChunk { 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 RefMethod methodGetHandlePlayer; + private RefMethod methodGetHandleChunk; private RefConstructor MapChunk; private RefField connection; private RefMethod send; @@ -54,6 +56,7 @@ public class SendChunk { */ public SendChunk() throws NoSuchMethodException { methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle"); + methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class); connection = classEntityPlayer.getField("playerConnection"); send = classConnection.getMethod("sendPacket", classPacket.getRealClass()); @@ -101,19 +104,15 @@ public class SendChunk { if (dx > view || dz > view) { continue; } + Object c = methodGetHandleChunk.of(chunk).call(); chunks.remove(chunk); - - Object packet = MapChunk.create(chunk, true, 0); Object con = connection.of(entity).get(); + if (dx != 0 || dz != 0) { + Object packet = MapChunk.create(c, true, 1); + send.of(con).call(packet); + } + Object packet = MapChunk.create(c, true, 65565); send.of(con).call(packet); - packet = MapChunk.create(chunk, true, 65565); - send.of(con).call(packet); -// Object packet = MapChunk.create(chunk, true, 0); -// -// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(chunk, true, 0); -// entity.playerConnection.sendPacket(packet); -// packet = new PacketPlayOutMapChunk(chunk, true, 65565); -// entity.playerConnection.sendPacket(packet); } } for (final Chunk chunk : chunks) { diff --git a/src/main/java/com/plotsquared/bukkit/util/SetBlockFast.java b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast.java index 72229947d..08d70e25e 100644 --- a/src/main/java/com/plotsquared/bukkit/util/SetBlockFast.java +++ b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast.java @@ -131,6 +131,7 @@ public class SetBlockFast extends BukkitSetBlockManager { try { chunksender.sendChunk(chunks); } catch (final Throwable e) { + e.printStackTrace(); MainUtil.canSendChunk = false; } } diff --git a/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java index ba2a7ae52..7abe9e53f 100644 --- a/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java +++ b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java @@ -349,6 +349,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager { try { chunksender.sendChunk(chunks); } catch (final Throwable e) { + e.printStackTrace(); MainUtil.canSendChunk = false; } } diff --git a/src/main/java/com/plotsquared/general/commands/Command.java b/src/main/java/com/plotsquared/general/commands/Command.java index 1e78c4d9b..99f3b8523 100644 --- a/src/main/java/com/plotsquared/general/commands/Command.java +++ b/src/main/java/com/plotsquared/general/commands/Command.java @@ -136,6 +136,9 @@ public abstract class Command extends CommandManager { } final public Argument[] getRequiredArguments() { + if (this.requiredArguments == null) { + return new Argument[0]; + } return this.requiredArguments; } diff --git a/src/main/java/com/plotsquared/sponge/SpongeMain.java b/src/main/java/com/plotsquared/sponge/SpongeMain.java index ac78bb838..3422761c2 100644 --- a/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -12,7 +12,6 @@ import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.spongepowered.api.CatalogType; @@ -21,7 +20,6 @@ import org.spongepowered.api.Server; import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockType; import org.spongepowered.api.block.BlockTypes; -import org.spongepowered.api.data.manipulator.mutable.block.StoneData; import org.spongepowered.api.entity.player.Player; import org.spongepowered.api.event.Subscribe; import org.spongepowered.api.event.entity.player.PlayerChatEvent; diff --git a/src/main/java/com/plotsquared/sponge/generator/WorldModify.java b/src/main/java/com/plotsquared/sponge/generator/WorldModify.java index c5e458a63..dd6721d5d 100644 --- a/src/main/java/com/plotsquared/sponge/generator/WorldModify.java +++ b/src/main/java/com/plotsquared/sponge/generator/WorldModify.java @@ -34,6 +34,8 @@ public class WorldModify implements WorldGeneratorModifier { } } else { + gen.getGeneratorPopulators().clear(); + gen.getPopulators().clear(); gen.setBaseGeneratorPopulator(plotgen.getBaseGeneratorPopulator()); gen.setBiomeGenerator(plotgen.getBiomeGenerator()); }