From dbd31ea3474544cdca516dc1d3b18f0447047b0b Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 24 Aug 2018 01:22:30 +1000 Subject: [PATCH] Fixes boy0001/FastAsyncWorldedit#1090 --- build.gradle | 3 -- .../com/thevoxelbox/voxelsniper/Message.java | 4 +-- .../thevoxelbox/voxelsniper/VoxelSniper.java | 4 +-- .../voxelsniper/VoxelSniperListener.java | 32 ++++++++++++++++++- .../voxelsniper/brush/ScannerBrush.java | 4 +-- .../voxelsniper/util/VoxelList.java | 2 +- worldedit-bukkit/build.gradle | 4 ++- .../sk89q/worldedit/bukkit/BukkitAdapter.java | 3 +- .../bukkit/BukkitServerInterface.java | 2 +- .../src/main/resources/plugin.yml | 2 +- .../worldedit/command/WorldEditCommands.java | 2 -- .../platform/AbstractPlayerActor.java | 3 +- .../extent/logging/AbstractLoggingExtent.java | 2 +- .../worldedit/function/mask/BlockMask.java | 6 ++++ 14 files changed, 54 insertions(+), 19 deletions(-) diff --git a/build.gradle b/build.gradle index e40acea66..d0a7d4a2d 100644 --- a/build.gradle +++ b/build.gradle @@ -65,9 +65,6 @@ subprojects { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 - version = rootProject.version - group = 'com.boydti.fawe' - compileJava { options.compilerArgs += ["-parameters"] } repositories { diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java index 193420707..d944bb206 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/Message.java @@ -91,7 +91,7 @@ public class Message @SuppressWarnings("deprecation") public void replace() { - snipeData.sendMessage(ChatColor.AQUA + "Replace Material: " + ChatColor.RED + snipeData.getReplaceId() + ChatColor.GRAY + " (" + BlockTypes.get(snipeData.getReplaceId()).toString() + ")"); + snipeData.sendMessage(ChatColor.AQUA + "Replace Material: " + BlockTypes.getFromStateId(snipeData.getReplaceId())); } /** @@ -144,7 +144,7 @@ public class Message @SuppressWarnings("deprecation") public void voxel() { - snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + snipeData.getVoxelId() + ChatColor.GRAY + " (" + BlockTypes.get(snipeData.getVoxelId()).toString() + ")"); + snipeData.sendMessage(ChatColor.GOLD + "Voxel: " + ChatColor.RED + BlockTypes.getFromStateId(snipeData.getVoxelId())); } /** diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java index 0f6f9d493..f86410a6f 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java @@ -112,7 +112,7 @@ public class VoxelSniper extends JavaPlugin @Override public boolean execute(FawePlayer fp, String... args) { Player player = (Player) fp.parent; - return (Bukkit.getPluginManager().getPlugin("VoxelSniper")).onCommand(player, new Command("p") { + return onCommand(player, new Command("p") { @Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { return false; @@ -125,7 +125,7 @@ public class VoxelSniper extends JavaPlugin @Override public boolean execute(FawePlayer fp, String... args) { Player player = (Player) fp.parent; - return (Bukkit.getPluginManager().getPlugin("VoxelSniper")).onCommand(player, new Command("d") { + return onCommand(player, new Command("d") { @Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { return false; diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java index 88c85e5b2..aef0ce931 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/VoxelSniperListener.java @@ -1,5 +1,9 @@ package com.thevoxelbox.voxelsniper; +import com.boydti.fawe.object.FawePlayer; +import com.sk89q.minecraft.util.commands.CommandException; +import com.sk89q.worldedit.extension.platform.CommandManager; +import com.sk89q.worldedit.util.command.parametric.ExceptionConverter; import com.thevoxelbox.voxelsniper.api.command.VoxelCommand; import com.thevoxelbox.voxelsniper.command.*; import org.bukkit.ChatColor; @@ -11,6 +15,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import java.util.HashMap; import java.util.Map; +import java.util.logging.Level; /** * @author Voxel @@ -72,7 +77,32 @@ public class VoxelSniperListener implements Listener return true; } - return found.onCommand(player, split); + FawePlayer fp = FawePlayer.wrap(player); + ExceptionConverter exceptionConverter = CommandManager.getInstance().getExceptionConverter(); + try { + try { + return found.onCommand(player, split); + } catch (Throwable t) { + Throwable next = t; + exceptionConverter.convert(next); + while (next.getCause() != null) { + next = next.getCause(); + exceptionConverter.convert(next); + } + throw next; + } + } catch (CommandException e) { + String message = e.getMessage(); + if (message != null) { + fp.sendMessage(e.getMessage()); + return true; + } + e.printStackTrace(); + } catch (Throwable e) { + e.printStackTrace(); + } + fp.sendMessage("An unknown FAWE error has occurred! Please see console."); + return true; } private boolean hasPermission(final VoxelCommand command, final Player player) diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java index a21c6d846..989501e01 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/brush/ScannerBrush.java @@ -149,7 +149,7 @@ public class ScannerBrush extends Brush @Override protected final void arrow(final SnipeData v) { - this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); + this.checkFor = BukkitAdapter.adapt(BlockTypes.getFromStateId(v.getVoxelId())); this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); } @@ -157,7 +157,7 @@ public class ScannerBrush extends Brush @Override protected final void powder(final SnipeData v) { - this.checkFor = BukkitAdapter.adapt(BlockTypes.get(v.getVoxelId())); + this.checkFor = BukkitAdapter.adapt(BlockTypes.getFromStateId(v.getVoxelId())); this.scan(v, this.getTargetBlock().getFace(this.getLastBlock())); } diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java index 1e34d5812..c6fc4be4e 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/util/VoxelList.java @@ -19,7 +19,7 @@ import java.util.List; public class VoxelList { - private BlockMask mask = new BlockMask(NullExtent.INSTANCE); + private BlockMask mask = new BlockMask(); /** * Adds the specified id, data value pair to the VoxelList. A data value of -1 will operate on all data values of that id. diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index caee7b038..2b87640d5 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -35,12 +35,14 @@ dependencies { processResources { from (sourceSets.main.resources.srcDirs) { - expand 'internalVersion': project.internalVersion + expand 'version': project.internalVersion include 'plugin.yml' + include 'fawe.properties' } from (sourceSets.main.resources.srcDirs) { exclude 'plugin.yml' + exclude 'fawe.properties' } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java index d04725160..b61eee7dc 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit; import static com.google.common.base.Preconditions.checkNotNull; import com.bekvon.bukkit.residence.commands.material; +import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.Entity; @@ -336,7 +337,7 @@ public class BukkitAdapter { if (itemStack.getType().isBlock()) { return adapt(itemStack.getType().createBlockData()); } else { - return BlockTypes.AIR.getDefaultState(); + throw new NotABlockException(); } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java index 4db6408f1..bf460997e 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java @@ -149,7 +149,7 @@ public class BukkitServerInterface implements MultiUserPlatform { @Override public String getPlatformName() { - return "Bukkit-Official"; + return "bukkit"; } @Override diff --git a/worldedit-bukkit/src/main/resources/plugin.yml b/worldedit-bukkit/src/main/resources/plugin.yml index b62b370f3..745356577 100644 --- a/worldedit-bukkit/src/main/resources/plugin.yml +++ b/worldedit-bukkit/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: WorldEdit main: com.sk89q.worldedit.bukkit.WorldEditPlugin -version: "${internalVersion}" +version: "${version}" api-version: 1.13 description: Fast Async WorldEdit plugin authors: [Empire92] diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 7a6a859bf..e04b5d5d9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -83,9 +83,7 @@ public class WorldEditCommands { } actor.printDebug("------------------------------------"); } - actor.print(BBC.getPrefix() + "WorldEdit " + WorldEdit.getVersion() + " by sk89q"); PlatformManager pm = we.getPlatformManager(); - actor.printDebug("------------------------------------"); actor.printDebug("Platforms:"); for (Platform platform : pm.getPlatforms()) { actor.printDebug(String.format(" - %s (%s)", platform.getPlatformName(), platform.getPlatformVersion())); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 7d301642a..e214d2e5f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.extension.platform; +import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.PlayerDirection; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; @@ -394,7 +395,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (typeId.hasBlockType()) { return typeId.getBlockType().getDefaultState(); } else { - return BlockTypes.AIR.getDefaultState(); + throw new NotABlockException(); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/logging/AbstractLoggingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/logging/AbstractLoggingExtent.java index cbe5e256e..2037be7e2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/logging/AbstractLoggingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/logging/AbstractLoggingExtent.java @@ -37,7 +37,7 @@ public abstract class AbstractLoggingExtent extends AbstractDelegateExtent { * * @param extent the extent */ - protected AbstractLoggingExtent(Extent extent) { + public AbstractLoggingExtent(Extent extent) { super(extent); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index 7e1f832d5..ef6a9e914 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -7,6 +7,7 @@ import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.StringMan; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; +import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.registry.state.AbstractProperty; @@ -40,6 +41,11 @@ public class BlockMask extends AbstractExtentMask { this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits(); } + public BlockMask() { + super(NullExtent.INSTANCE); + this.bitSets = new long[BlockTypes.size()][]; + } + protected BlockMask(Extent extent, long[][] bitSets) { super(extent); this.bitSets = bitSets;