diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index e6ff9fc8..4bea196f 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -148,21 +148,17 @@ public class FaweBukkit implements IFawe, Listener { @Override public CUI getCUI(FawePlayer player) { if (Settings.IMP.EXPERIMENTAL.VANILLA_CUI) { - switch (getVersion()) { - case v1_12_R1: { - if (listeningCui && cuiListener == null) return null; - listeningCui = true; - if (cuiListener == null) { - Plugin protocolLib = Bukkit.getPluginManager().getPlugin("ProtocolLib"); - if (protocolLib != null && protocolLib.isEnabled()) { - cuiListener = new CUIListener(plugin); - } else { - return null; - } - } - return new StructureCUI(player); + if (listeningCui && cuiListener == null) return null; + listeningCui = true; + if (cuiListener == null) { + Plugin protocolLib = Bukkit.getPluginManager().getPlugin("ProtocolLib"); + if (protocolLib != null && protocolLib.isEnabled()) { + cuiListener = new CUIListener(plugin); + } else { + return null; } } + return new StructureCUI(player); } return null; } diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java index 14bf7abf..42f6ad72 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java @@ -8,6 +8,7 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.injector.PacketConstructor; import com.comphenix.protocol.wrappers.BlockPosition; import com.comphenix.protocol.wrappers.nbt.NbtBase; import com.comphenix.protocol.wrappers.nbt.NbtCompound; @@ -105,16 +106,32 @@ public class StructureCUI extends CUI { return NbtFactory.fromNMSCompound(nmsTag); } - private void sendNbt(Vector pos, NbtCompound compound) { - ProtocolManager manager = ProtocolLibrary.getProtocolManager(); - PacketContainer containter = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA); - containter.getBlockPositionModifier().write(0, new BlockPosition(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ())); - containter.getIntegers().write(0, 7); - containter.getNbtModifier().write(0, compound); - + private void sendOp() { Player player = this.getPlayer().parent; + ProtocolManager manager = ProtocolLibrary.getProtocolManager(); + + PacketConstructor statusCtr = manager.createPacketConstructor(PacketType.Play.Server.ENTITY_STATUS, player, (byte) 28); + PacketContainer status = statusCtr.createPacket(player, (byte) 28); + try { - manager.sendServerPacket(player, containter); + manager.sendServerPacket(player, status); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + + private void sendNbt(Vector pos, NbtCompound compound) { + Player player = this.getPlayer().parent; + ProtocolManager manager = ProtocolLibrary.getProtocolManager(); + + PacketContainer blockNbt = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA); + blockNbt.getBlockPositionModifier().write(0, new BlockPosition(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ())); + blockNbt.getIntegers().write(0, 7); + blockNbt.getNbtModifier().write(0, compound); + + + try { + manager.sendServerPacket(player, blockNbt); } catch (InvocationTargetException e) { e.printStackTrace(); } @@ -123,6 +140,7 @@ public class StructureCUI extends CUI { public synchronized void update() { Player player = this.getPlayer().parent; Location playerLoc = player.getLocation(); + boolean setOp = remove == null && !player.isOp(); if (remove != null) { int cx = playerLoc.getBlockX() >> 4; int cz = playerLoc.getBlockZ() >> 4; @@ -172,6 +190,7 @@ public class StructureCUI extends CUI { Location blockLoc = new Location(player.getWorld(), x, y, z); player.sendBlockChange(blockLoc, Material.STRUCTURE_BLOCK, (byte) 0); + if (setOp) sendOp(); sendNbt(remove, compound); } } diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java index 279a1289..1932f6c6 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java @@ -233,10 +233,11 @@ public abstract class BukkitQueue_0 extends NMSMa @Override public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { - return world.regenerateChunk(x, z); + if (!keepLoaded.isEmpty()) keepLoaded.remove(MathMan.pairInt(x, z)); + boolean result = world.regenerateChunk(x, z); + return result; } - @Override public CharFaweChunk getPrevious(CharFaweChunk fs, CHUNKSECTIONS sections, Map tiles, Collection[] entities, Set createdEntities, boolean all) throws Exception { return fs; diff --git a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java index 83729d12..8c97d0c9 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java @@ -52,7 +52,7 @@ public class MCAQueue extends NMSMappedFaweQueue chunks = region.getChunks(); MutableBlockVector mutable = new MutableBlockVector(); MutableBlockVector2D mutable2D = new MutableBlockVector2D(); - for (Vector2D chunk : new FastChunkIterator(chunks, this)) { + for (Vector2D chunk : chunks) { final int cx = chunk.getBlockX(); final int cz = chunk.getBlockZ(); final int bx = cx << 4;