From 767607ea6873232719e0487e812ad7b690fe43cb Mon Sep 17 00:00:00 2001 From: IronApollo Date: Mon, 29 Oct 2018 06:39:40 -0400 Subject: [PATCH 1/3] Fix for '//mask ?' resulting in pattern error --- .../sk89q/worldedit/extension/factory/DefaultMaskParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java index fb0ac344d..95248cd5b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java @@ -86,7 +86,7 @@ public class DefaultMaskParser extends FaweParser { if (charMask && input.charAt(0) == '=') { return parseFromInput(char0 + "[" + input.substring(1) + "]", context); } - if (char0 == '#') { + if (char0 == '#' || char0 == '?') { throw new SuggestInputParseException(new NoMatchException("Unknown mask: " + full + ", See: //masks"), full, () -> { if (full.length() == 1) return new ArrayList<>(dispatcher.getPrimaryAliases()); From dcd041e84775a9c219199fd7c34640eae484c3a7 Mon Sep 17 00:00:00 2001 From: IronApollo Date: Thu, 1 Nov 2018 07:22:50 -0400 Subject: [PATCH 2/3] Potential fix for CommandSuggestionEvent errors --- .../boydti/fawe/bukkit/listener/ATabCompleteListener.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java index 9b772fc14..04a66c2c2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java @@ -6,6 +6,7 @@ import com.sk89q.worldedit.event.platform.CommandSuggestionEvent; import com.sk89q.worldedit.extension.platform.CommandManager; import com.sk89q.worldedit.util.command.CommandMapping; import com.sk89q.worldedit.util.command.Dispatcher; + import org.bukkit.command.CommandSender; import org.bukkit.event.Listener; @@ -23,11 +24,12 @@ public class ATabCompleteListener implements Listener { MutableCharSequence mBuffer = MutableCharSequence.getTemporal(); mBuffer.setString(buffer); mBuffer.setSubstring(0, firstSpace); - String label = buffer.substring(mBuffer.indexOf(':') + 1, firstSpace); + int index; + String label = buffer.substring(index = (mBuffer.indexOf(':') == -1 ? 1 : mBuffer.indexOf(':') + 1), firstSpace); Dispatcher dispatcher = CommandManager.getInstance().getDispatcher(); CommandMapping weCommand = dispatcher.get(label); if (weCommand != null) { - CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer); + CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer.substring(index, buffer.length())); worldEdit.getWorldEdit().getEventBus().post(event); List suggestions = event.getSuggestions(); if (suggestions != null) { From 9896a1339ef7a5aa3fa4565acdfdf8b517021175 Mon Sep 17 00:00:00 2001 From: IronApollo Date: Thu, 1 Nov 2018 07:24:56 -0400 Subject: [PATCH 3/3] Updates to FaweLocalBlockQueue to allow FAWE-P2 compatibility --- .../boydti/fawe/bukkit/v0/BukkitQueue_0.java | 7 ++++- .../general/plot/FaweLocalBlockQueue.java | 31 ++++++++++--------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java index 3ab621d64..ac294817f 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java @@ -278,7 +278,12 @@ public abstract class BukkitQueue_0 extends NMSMa public void sendChunk(int x, int z, int bitMask) {} @Override - public void refreshChunk(FaweChunk fs) {} + public void refreshChunk(FaweChunk fs) { + World world = getWorld(); + if(world != null) { + world.refreshChunk(fs.getX(), fs.getZ()); + } + } @Override public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java index 6e86a7dd9..bf1b4a0cf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/FaweLocalBlockQueue.java @@ -8,10 +8,15 @@ import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.block.LocalBlockQueue; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.Biomes; +import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.registry.BiomeRegistry; +import com.sk89q.worldedit.world.registry.LegacyMapper; + import java.util.List; // TODO FIXME @@ -61,15 +66,14 @@ public class FaweLocalBlockQueue extends LocalBlockQueue { @Override public boolean setBlock(int x, int y, int z, int id, int data) { - return false; -// return IMP.setBlock(x, y, z, (short) id, (byte) data); + return IMP.setBlock(x, y, z, LegacyMapper.getInstance().getBlockFromLegacy(id, data)); } @Override public PlotBlock getBlock(int x, int y, int z) { -// int combined = IMP.getCombinedId4Data(x, y, z); -// return PlotBlock.get(FaweCache.getId(combined), FaweCache.getData(combined)); - return null; + int combined = IMP.getCombinedId4Data(x, y, z); + com.sk89q.worldedit.world.block.BlockState state = com.sk89q.worldedit.world.block.BlockState.getFromInternalId(combined); + return PlotBlock.get(state.getInternalBlockTypeId(), state.getInternalPropertiesId()); } private BaseBiome biome; @@ -78,15 +82,14 @@ public class FaweLocalBlockQueue extends LocalBlockQueue { @Override public boolean setBiome(int x, int z, String biome) { -// if (!StringMan.isEqual(biome, lastBiome)) { -// if (reg == null) { -// World weWorld = IMP.getWEWorld(); -// reg = weWorld.getWorldData().getBiomeRegistry(); -// } -// List biomes = reg.getBiomes(); -// lastBiome = biome; -// this.biome = Biomes.findBiomeByName(biomes, biome, reg); -// } + if (!StringMan.isEqual(biome, lastBiome)) { + if (reg == null) { + reg = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS).getRegistries().getBiomeRegistry(); + } + List biomes = reg.getBiomes(); + lastBiome = biome; + this.biome = Biomes.findBiomeByName(biomes, biome, reg); + } return IMP.setBiome(x, z, this.biome); }