From cc80bc61cff860563d74166238e5440bd9b83fdb Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 25 Apr 2019 00:10:52 +1000 Subject: [PATCH] Compiles in 1.14 (yay) --- .../com/boydti/fawe/bukkit/FaweBukkit.java | 22 -- .../bukkit/listener/CFIPacketListener.java | 16 +- .../fawe/bukkit/listener/RenderListener.java | 3 +- .../fawe/bukkit/util/cui/CUIListener.java | 31 --- .../fawe/bukkit/util/cui/StructureCUI.java | 200 -------------- .../fawe/bukkit/v0/BukkitQueue_All.java | 2 +- .../fawe/bukkit/v0/PaperChunkCallback.java | 3 +- .../fawe/bukkit/v1_13/BukkitQueue_1_13.java | 2 +- .../fawe/bukkit/v1_14/BukkitQueue_1_14.java | 115 ++++---- .../v1_14/adapter/BlockMaterial_1_14.java | 2 +- .../bukkit/v1_14/adapter/Spigot_v1_14_R1.java | 5 +- .../fawe/bukkit/wrapper/AsyncBlock.java | 14 +- .../fawe/bukkit/wrapper/AsyncChunk.java | 31 +-- .../fawe/bukkit/wrapper/AsyncWorld.java | 254 +++++++++--------- .../src/main/java/com/boydti/fawe/Fawe.java | 20 -- .../src/main/java/com/boydti/fawe/IFawe.java | 3 - .../java/com/boydti/fawe/util/cui/CUI.java | 18 -- .../com/sk89q/jnbt/CompressedCompoundTag.java | 1 - .../com/sk89q/worldedit/LocalSession.java | 6 +- 19 files changed, 227 insertions(+), 521 deletions(-) delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/CUIListener.java delete mode 100644 worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/util/cui/CUI.java diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index 793f2ef1e..296ef8e53 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -24,8 +24,6 @@ import com.boydti.fawe.bukkit.util.BukkitReflectionUtils; import com.boydti.fawe.bukkit.util.BukkitTaskMan; import com.boydti.fawe.bukkit.util.ItemUtil; import com.boydti.fawe.bukkit.util.VaultUtil; -import com.boydti.fawe.bukkit.util.cui.CUIListener; -import com.boydti.fawe.bukkit.util.cui.StructureCUI; import com.boydti.fawe.bukkit.util.image.BukkitImageViewer; import com.boydti.fawe.bukkit.v0.BukkitQueue_0; import com.boydti.fawe.bukkit.v0.BukkitQueue_All; @@ -41,7 +39,6 @@ import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.Jars; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.TaskManager; -import com.boydti.fawe.util.cui.CUI; import com.boydti.fawe.util.image.ImageViewer; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.world.World; @@ -79,7 +76,6 @@ public class FaweBukkit implements IFawe, Listener { private CFIPacketListener packetListener; private boolean listeningCui; - private CUIListener cuiListener; public VaultUtil getVault() { return this.vault; @@ -144,24 +140,6 @@ public class FaweBukkit implements IFawe, Listener { }); } - @Override - public CUI getCUI(FawePlayer player) { - if (Settings.IMP.EXPERIMENTAL.VANILLA_CUI) { - 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; - } - @Override public void registerPacketListener() { PluginManager manager = Bukkit.getPluginManager(); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java index 2053d8f9c..7f5ef82c5 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/CFIPacketListener.java @@ -91,11 +91,17 @@ public class CFIPacketListener implements Listener { ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand(); if (hand != null && hand.getType().isBlock()) { Material type = hand.getType(); - if (!type.isEmpty()) { - BlockStateHolder block = BukkitAdapter.asBlockState(hand); - if (block != null) { - gen.setBlock(pt, block); - return; + switch (type) { + case AIR: + case CAVE_AIR: + case VOID_AIR: + break; + default: { + BlockStateHolder block = BukkitAdapter.asBlockState(hand); + if (block != null) { + gen.setBlock(pt, block); + return; + } } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java index 8824f369c..7b97ec1ad 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/RenderListener.java @@ -96,7 +96,8 @@ public class RenderListener implements Listener { } } } - player.setViewDistance(value); + throw new UnsupportedOperationException("TODO FIXME: PAPER 1.14"); +// player.setViewDistance(value); } public int getViewDistance(Player player) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/CUIListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/CUIListener.java deleted file mode 100644 index 2101d64b8..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/CUIListener.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.boydti.fawe.bukkit.util.cui; - -import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.util.cui.CUI; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.plugin.Plugin; - -public class CUIListener implements Listener { - - public CUIListener(Plugin plugin) { - Bukkit.getPluginManager().registerEvents(this, plugin); - } - - @EventHandler - public void onPlayerMove(PlayerMoveEvent event) { - Location from = event.getFrom(); - Location to = event.getTo(); - if ((int) from.getX() >> 2 != (int) to.getX() >> 2 || (int) from.getZ() >> 2 != (int) to.getZ() >> 2 || (int) from.getY() >> 2 != (int) to.getY() >> 2) { - FawePlayer player = FawePlayer.wrap(event.getPlayer()); - CUI cui = player.getMeta("CUI"); - if (cui instanceof StructureCUI) { - StructureCUI sCui = (StructureCUI) cui; - sCui.update(); - } - } - } -} \ No newline at end of file diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java deleted file mode 100644 index b1e389cc6..000000000 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/util/cui/StructureCUI.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.boydti.fawe.bukkit.util.cui; - -import com.boydti.fawe.FaweCache; -import com.boydti.fawe.bukkit.v0.BukkitQueue_0; -import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.util.cui.CUI; -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; -import com.comphenix.protocol.wrappers.nbt.NbtFactory; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.internal.cui.CUIEvent; -import com.sk89q.worldedit.internal.cui.SelectionPointEvent; -import com.sk89q.worldedit.internal.cui.SelectionShapeEvent; -import com.sk89q.worldedit.math.BlockVector3; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import com.sk89q.worldedit.world.block.BlockState; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -public class StructureCUI extends CUI { - private boolean cuboid = true; - - private BlockVector3 pos1; - private BlockVector3 pos2; - - private BlockVector3 remove; - private NbtCompound removeTag; - private BlockState state; - - public StructureCUI(FawePlayer player) { - super(player); - } - - @Override - public void dispatchCUIEvent(CUIEvent event) { - if (event instanceof SelectionShapeEvent) { - clear(); - this.cuboid = event.getParameters()[0].equalsIgnoreCase("cuboid"); - } else if (cuboid && event instanceof SelectionPointEvent) { - SelectionPointEvent spe = (SelectionPointEvent) event; - String[] param = spe.getParameters(); - int id = Integer.parseInt(param[0]); - int x = Integer.parseInt(param[1]); - int y = Integer.parseInt(param[2]); - int z = Integer.parseInt(param[3]); - BlockVector3 pos = BlockVector3.at(x, y, z); - if (id == 0) { - pos1 = pos; - } else { - pos2 = pos; - } - update(); - } - } - - private int viewDistance() { - Player player = this.getPlayer().parent; - if (Bukkit.getVersion().contains("paper")) { - return player.getViewDistance(); - } else { - return Bukkit.getViewDistance(); - } - } - - public void clear() { - pos1 = null; - pos2 = null; - update(); - } - - private NbtCompound constructStructureNbt(int x, int y, int z, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ) { - HashMap tag = new HashMap<>(); - tag.put("name", UUID.randomUUID().toString()); - tag.put("author", "Empire92"); // :D - tag.put("metadata", ""); - tag.put("x", x); - tag.put("y", y); - tag.put("z", z); - tag.put("posX", posX); - tag.put("posY", posY); - tag.put("posZ", posZ); - tag.put("sizeX", sizeX); - tag.put("sizeY", sizeY); - tag.put("sizeZ", sizeZ); - tag.put("rotation", "NONE"); - tag.put("mirror", "NONE"); - tag.put("mode", "SAVE"); - tag.put("ignoreEntities", true); - tag.put("powered", false); - tag.put("showair", false); - tag.put("showboundingbox", true); - tag.put("integrity", 1.0f); - tag.put("seed", 0); - tag.put("id", "minecraft:structure_block"); - Object nmsTag = BukkitQueue_0.fromNative(FaweCache.asTag(tag)); - return NbtFactory.fromNMSCompound(nmsTag); - } - - 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, status); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - - private void sendNbt(BlockVector3 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(); - } - } - - 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; - int viewDistance = viewDistance(); - if (Math.abs(cx - (remove.getBlockX() >> 4)) <= viewDistance && Math.abs(cz - (remove.getBlockZ() >> 4)) <= viewDistance) { - Map> map = removeTag.getValue(); - map.put("sizeX", NbtFactory.of("sizeX", 0)); - sendNbt(remove, removeTag); - Location removeLoc = new Location(player.getWorld(), remove.getX(), remove.getY(), remove.getZ()); - player.sendBlockChange(removeLoc, BukkitAdapter.adapt(state)); - } - remove = null; - } - if (pos1 == null || pos2 == null) return; - BlockVector3 min = pos1.getMinimum(pos2); - BlockVector3 max = pos1.getMaximum(pos2); - - // Position - double rotX = playerLoc.getYaw(); - double rotY = playerLoc.getPitch(); - double xz = Math.cos(Math.toRadians(rotY)); - int x = (int) (playerLoc.getX() - (-xz * Math.sin(Math.toRadians(rotX))) * 12); - int z = (int) (playerLoc.getZ() - (xz * Math.cos(Math.toRadians(rotX))) * 12); - int y = Math.max(0, Math.min(Math.min(255, max.getBlockY() + 32), playerLoc.getBlockY() + 3)); - int minX = Math.max(Math.min(32, min.getBlockX() - x), -32); - int maxX = Math.max(Math.min(32, max.getBlockX() - x + 1), -32); - int minY = Math.max(Math.min(32, min.getBlockY() - y), -32); - int maxY = Math.max(Math.min(32, max.getBlockY() - y + 1), -32); - int minZ = Math.max(Math.min(32, min.getBlockZ() - z), -32); - int maxZ = Math.max(Math.min(32, max.getBlockZ() - z + 1), -32); - int sizeX = Math.min(32, maxX - minX); - int sizeY = Math.min(32, maxY - minY); - int sizeZ = Math.min(32, maxZ - minZ); - if (sizeX == 0 || sizeY == 0 || sizeZ == 0) return; - // maxX - 32; - int posX = Math.max(minX, Math.min(16, maxX) - 32); - int posY = Math.max(minY, Math.min(16, maxY) - 32); - int posZ = Math.max(minZ, Math.min(16, maxZ) - 32); - - // NBT - NbtCompound compound = constructStructureNbt(x, y, z, posX, posY, posZ, sizeX, sizeY, sizeZ); - - Block block = player.getWorld().getBlockAt(x, y, z); - remove = BlockVector3.at(x, y, z); - state = BukkitAdapter.adapt(block.getBlockData()); - removeTag = compound; - - 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/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java index 015b3b8fc..57147096d 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java @@ -154,7 +154,7 @@ public class BukkitQueue_All extends BukkitQueue_0= bcx && cx <= tcx && cz >= bcz && cz <= tcz) { Object nmsChunk = methodGetHandleChunk.invoke(chunk); boolean mustSave = saveChunks && (boolean) methodNeedsSaving.invoke(nmsChunk, false); - chunk.unload(mustSave, false); + chunk.unload(mustSave); if (unloaded == null) unloaded = new ArrayDeque<>(); unloaded.add(chunk); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/PaperChunkCallback.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/PaperChunkCallback.java index 20592715a..4d22f8fa8 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/PaperChunkCallback.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/PaperChunkCallback.java @@ -5,7 +5,8 @@ import org.bukkit.World; public abstract class PaperChunkCallback { public PaperChunkCallback(World world, int x, int z) { - world.getChunkAtAsync(x, z, PaperChunkCallback.this::onLoad); +// world.getChunkAtAsync(x, z, PaperChunkCallback.this::onLoad); + throw new UnsupportedOperationException("Not implemented"); } public abstract void onLoad(Chunk chunk); diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java index 3cc50d56e..2c51c965e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v1_13/BukkitQueue_1_13.java @@ -954,7 +954,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0 { @@ -535,27 +537,17 @@ public class BukkitQueue_1_14 extends BukkitQueue_0 dataPalette = section.getBlocks(); - IBlockData ibd = dataPalette.a(x & 15, y & 15, z & 15); - pos.a(x, y, z); - return ibd.b(nmsWorld, pos); + return 0; } @Override public int getBrightness(ChunkSection section, int x, int y, int z) { - DataPaletteBlock dataPalette = section.getBlocks(); - IBlockData ibd = dataPalette.a(x & 15, y & 15, z & 15); - return ibd.e(); + return 0; } @Override public int getOpacityBrightnessPair(ChunkSection section, int x, int y, int z) { - DataPaletteBlock dataPalette = section.getBlocks(); - IBlockData ibd = dataPalette.a(x & 15, y & 15, z & 15); - pos.a(x, y, z); - int opacity = ibd.b(nmsWorld, pos); - int brightness = ibd.e(); - return MathMan.pair16(brightness, opacity); + return 0; } @Override @@ -603,16 +595,25 @@ public class BukkitQueue_1_14 extends BukkitQueue_0() { + @Override + public void accept(EntityPlayer entityPlayer) { + for (int i = 0; i < players.length; i++) { + EntityPlayer player = ((CraftPlayer) ((BukkitPlayer) players[i]).parent).getHandle(); + if (player == entityPlayer) { + watchingArr[i] = true; + watching[0] = true; + } + } + } + }); } - if (!watching) return; + if (!watching[0]) return; final LongAdder size = new LongAdder(); if (chunk instanceof VisualChunk) { size.add(((VisualChunk) chunk).size()); @@ -656,24 +657,12 @@ public class BukkitQueue_1_14 extends BukkitQueue_0() { - @Override - public Object get() { - try { - int dirtyBits = fieldDirtyBits.getInt(playerChunk); - if (dirtyBits == 0) { - ((CraftWorld) getWorld()).getHandle().getPlayerChunkMap().a(playerChunk); - } - if (mask == 0) { - dirtyBits = 65535; - } else { - dirtyBits |= mask; - } - - fieldDirtyBits.set(playerChunk, dirtyBits); - fieldDirtyCount.set(playerChunk, 64); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return null; - } - }); } + TaskManager.IMP.sync(new Supplier() { + @Override + public Object get() { + try { + int dirtyBits = fieldDirtyBits.getInt(playerChunk); + if (dirtyBits == 0) { + ((CraftWorld) getWorld()).getHandle().getChunkProvider().playerChunkMap.a(playerChunk); + } + if (mask == 0) { + dirtyBits = 65535; + } else { + dirtyBits |= mask; + } + + fieldDirtyBits.set(playerChunk, dirtyBits); + fieldDirtyCount.set(playerChunk, 64); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return null; + } + }); // if (mask == 0) { // PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65535); // for (EntityPlayer player : playerChunk.players) { @@ -763,6 +750,7 @@ public class BukkitQueue_1_14 extends BukkitQueue_0() { - @Override - public void run(BlockState[] value) { - this.value = world.getChunkAt(x, z).getTileEntities(b); - } - }); - } +// @Override +// public BlockState[] getTileEntities(boolean b) { +// if (!isLoaded()) { +// return new BlockState[0]; +// } +// return TaskManager.IMP.sync(new RunnableVal() { +// @Override +// public void run(BlockState[] value) { +// this.value = world.getChunkAt(x, z).getTileEntities(b); +// } +// }); +// } @Override public boolean isLoaded() { @@ -163,14 +163,9 @@ public class AsyncChunk implements Chunk { return load(false); } - @Override - public boolean unload(boolean save, boolean safe) { - return world.unloadChunk(x, z, save, safe); - } - @Override public boolean unload(boolean save) { - return unload(true, false); + return world.unloadChunk(x, z, save); } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java index 269cf41ab..aa3b92e81 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java @@ -68,28 +68,6 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5, v6, t); } - @Override - public Entity getEntity(UUID uuid) { - return TaskManager.IMP.sync(() -> parent.getEntity(uuid)); - } - - - @Override - public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks) { - return TaskManager.IMP.sync(() -> parent.createExplosion(source, loc, power, setFire, breakBlocks)); - } - - - @Override - public void spawnParticle(Particle particle, List receivers, Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { - parent.spawnParticle(particle, receivers, source, x, y, z, count, offsetX, offsetY, offsetZ, extra, data); - } - - @Override - public void spawnParticle(Particle particle, List list, Player player, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t, boolean b) { - parent.spawnParticle(particle, list, player, v, v1, v2, i, v3, v4, v5, v6, t, b); - } - /** * @deprecated use {@link #wrap(World)} instead * @param parent Parent world @@ -185,15 +163,6 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue } } - public int getHighestBlockYAt(int x, int z, com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException { - return TaskManager.IMP.sync(new Supplier() { - @Override - public Integer get() { - return parent.getHighestBlockYAt(x, z, heightmap); - } - }); - } - @Override public WorldBorder getWorldBorder() { return TaskManager.IMP.sync(new RunnableVal() { @@ -204,6 +173,11 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue }); } + @Override + public boolean unloadChunkRequest(int x, int z) { + return unloadChunk(x, z); + } + @Override public void spawnParticle(Particle particle, Location location, int i) { parent.spawnParticle(particle, location, i); @@ -320,21 +294,6 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue return parent.isChunkGenerated(x, z); } - @Override - public void getChunkAtAsync(int x, int z, ChunkLoadCallback cb) { - parent.getChunkAtAsync(x, z, cb); - } - - @Override - public void getChunkAtAsync(Location location, ChunkLoadCallback cb) { - parent.getChunkAtAsync(location, cb); - } - - @Override - public void getChunkAtAsync(Block block, ChunkLoadCallback cb) { - parent.getChunkAtAsync(block, cb); - } - @Override public boolean isChunkLoaded(Chunk chunk) { return chunk.isLoaded(); @@ -426,33 +385,17 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue @Override public boolean unloadChunk(int x, int z, boolean save) { - return unloadChunk(x, z, save, false); - } - - @Deprecated - @Override - public boolean unloadChunk(final int x, final int z, final boolean save, final boolean safe) { if (isChunkLoaded(x, z)) { return TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Boolean value) { - this.value = parent.unloadChunk(x, z, save, safe); + this.value = parent.unloadChunk(x, z, save); } }); } return true; } - @Override - public boolean unloadChunkRequest(int x, int z) { - return unloadChunk(x, z); - } - - @Override - public boolean unloadChunkRequest(int x, int z, boolean safe) { - return unloadChunk(x, z, safe); - } - @Override public boolean regenerateChunk(final int x, final int z) { return TaskManager.IMP.sync(new RunnableVal() { @@ -1132,61 +1075,6 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue return adapter; } - @Override - public int getEntityCount() { - return TaskManager.IMP.sync(new RunnableVal() { - @Override - public void run(Integer value) { - this.value = parent.getEntityCount(); - } - }); - } - - @Override - public int getTileEntityCount() { - return TaskManager.IMP.sync(new RunnableVal() { - @Override - public void run(Integer value) { - this.value = parent.getTileEntityCount(); - } - }); - } - - @Override - public int getTickableTileEntityCount() { - return TaskManager.IMP.sync(new RunnableVal() { - @Override - public void run(Integer value) { - this.value = parent.getTickableTileEntityCount(); - } - }); - } - - @Override - public int getChunkCount() { - return TaskManager.IMP.sync(new RunnableVal() { - @Override - public void run(Integer value) { - this.value = parent.getChunkCount(); - } - }); - } - - @Override - public int getPlayerCount() { - return TaskManager.IMP.sync(new RunnableVal() { - @Override - public void run(Integer value) { - this.value = parent.getPlayerCount(); - } - }); - } - - @Override - public CompletableFuture getChunkAtAsync(int arg0, int arg1, boolean arg2) { - return parent.getChunkAtAsync(arg0, arg1, arg2); - } - @Override public Collection getNearbyEntities(BoundingBox arg0) { return parent.getNearbyEntities(arg0); @@ -1208,11 +1096,6 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue return parent.isChunkForceLoaded(arg0, arg1); } - @Override - public boolean isDayTime() { - return parent.isDayTime(); - } - @Override public Location locateNearestStructure(Location arg0, StructureType arg1, int arg2, boolean arg3) { return parent.locateNearestStructure(arg0, arg1, arg2, arg3); @@ -1283,4 +1166,129 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue public Collection getForceLoadedChunks() { return parent.getForceLoadedChunks(); } + +// @Override +// public int getHighestBlockYAt(int x, int z, com.destroystokyo.paper.HeightmapType heightmap) throws UnsupportedOperationException { +// return TaskManager.IMP.sync(new Supplier() { +// @Override +// public Integer get() { +// return parent.getHighestBlockYAt(x, z, heightmap); +// } +// }); +// } +// +// @Override +// public int getEntityCount() { +// return TaskManager.IMP.sync(new RunnableVal() { +// @Override +// public void run(Integer value) { +// this.value = parent.getEntityCount(); +// } +// }); +// } +// +// @Override +// public int getTileEntityCount() { +// return TaskManager.IMP.sync(new RunnableVal() { +// @Override +// public void run(Integer value) { +// this.value = parent.getTileEntityCount(); +// } +// }); +// } +// +// @Override +// public int getTickableTileEntityCount() { +// return TaskManager.IMP.sync(new RunnableVal() { +// @Override +// public void run(Integer value) { +// this.value = parent.getTickableTileEntityCount(); +// } +// }); +// } +// +// @Override +// public int getChunkCount() { +// return TaskManager.IMP.sync(new RunnableVal() { +// @Override +// public void run(Integer value) { +// this.value = parent.getChunkCount(); +// } +// }); +// } +// +// @Override +// public int getPlayerCount() { +// return TaskManager.IMP.sync(new RunnableVal() { +// @Override +// public void run(Integer value) { +// this.value = parent.getPlayerCount(); +// } +// }); +// } +// +// @Override +// public CompletableFuture getChunkAtAsync(int arg0, int arg1, boolean arg2) { +// return parent.getChunkAtAsync(arg0, arg1, arg2); +// } +// +// @Override +// public boolean isDayTime() { +// return parent.isDayTime(); +// } +// +// @Override +// public boolean unloadChunk(final int x, final int z, final boolean save, final boolean safe) { +// if (isChunkLoaded(x, z)) { +// return TaskManager.IMP.sync(new RunnableVal() { +// @Override +// public void run(Boolean value) { +// this.value = parent.unloadChunk(x, z, save, safe); +// } +// }); +// } +// return true; +// } +// +// @Override +// public boolean unloadChunkRequest(int x, int z, boolean safe) { +// return unloadChunk(x, z, safe); +// } +// +// @Override +// public void getChunkAtAsync(int x, int z, ChunkLoadCallback cb) { +// parent.getChunkAtAsync(x, z, cb); +// } +// +// @Override +// public void getChunkAtAsync(Location location, ChunkLoadCallback cb) { +// parent.getChunkAtAsync(location, cb); +// } +// +// @Override +// public void getChunkAtAsync(Block block, ChunkLoadCallback cb) { +// parent.getChunkAtAsync(block, cb); +// } +// +// @Override +// public Entity getEntity(UUID uuid) { +// return TaskManager.IMP.sync(() -> parent.getEntity(uuid)); +// } +// +// +// @Override +// public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks) { +// return TaskManager.IMP.sync(() -> parent.createExplosion(source, loc, power, setFire, breakBlocks)); +// } +// +// +// @Override +// public void spawnParticle(Particle particle, List receivers, Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { +// parent.spawnParticle(particle, receivers, source, x, y, z, count, offsetX, offsetY, offsetZ, extra, data); +// } +// +// @Override +// public void spawnParticle(Particle particle, List list, Player player, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t, boolean b) { +// parent.spawnParticle(particle, list, player, v, v1, v2, i, v3, v4, v5, v6, t, b); +// } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index ef9625376..02ccee892 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -9,7 +9,6 @@ import com.boydti.fawe.regions.general.plot.PlotSquaredFeature; import com.boydti.fawe.util.*; import com.boydti.fawe.util.chat.ChatManager; import com.boydti.fawe.util.chat.PlainChatManager; -import com.boydti.fawe.util.cui.CUI; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.factory.DefaultTransformParser; import com.sk89q.worldedit.extension.platform.Actor; @@ -199,25 +198,6 @@ public class Fawe { public void onDisable() { } - public CUI getCUI(Actor actor) { - FawePlayer fp = FawePlayer.wrap(actor); - CUI cui = fp.getMeta("CUI"); - if (cui == null) { - cui = Fawe.imp().getCUI(fp); - if (cui != null) { - synchronized (fp) { - CUI tmp = fp.getMeta("CUI"); - if (tmp == null) { - fp.setMeta("CUI", cui); - } else { - cui = tmp; - } - } - } - } - return cui; - } - public ChatManager getChatManager() { return chatManager; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java index ecba46a2f..af59b4096 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java @@ -5,7 +5,6 @@ import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.TaskManager; -import com.boydti.fawe.util.cui.CUI; import com.boydti.fawe.util.image.ImageViewer; import com.sk89q.worldedit.world.World; @@ -36,8 +35,6 @@ public interface IFawe { void startMetrics(); - default CUI getCUI(FawePlayer player) { return null; } - default ImageViewer getImageViewer(FawePlayer player) { return null; } default void registerPacketListener() {} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/cui/CUI.java b/worldedit-core/src/main/java/com/boydti/fawe/util/cui/CUI.java deleted file mode 100644 index 540f6a455..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/cui/CUI.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.boydti.fawe.util.cui; - -import com.boydti.fawe.object.FawePlayer; -import com.sk89q.worldedit.internal.cui.CUIEvent; - -public abstract class CUI { - private final FawePlayer player; - - public CUI(FawePlayer player) { - this.player = player; - } - - public FawePlayer getPlayer() { - return player; - } - - public abstract void dispatchCUIEvent(CUIEvent event); -} diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/CompressedCompoundTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/CompressedCompoundTag.java index 6ce8b20f1..a65cbb029 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/CompressedCompoundTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/CompressedCompoundTag.java @@ -2,7 +2,6 @@ package com.sk89q.jnbt; import java.io.DataInputStream; import java.io.IOException; -import java.io.InputStream; import java.util.HashMap; import java.util.Map; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 3517bb2f7..9cbae5aa6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -33,7 +33,6 @@ import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.collection.SparseBitSet; import com.boydti.fawe.object.extent.ResettableExtent; import com.boydti.fawe.util.*; -import com.boydti.fawe.util.cui.CUI; import com.boydti.fawe.wrappers.WorldWrapper; import com.sk89q.jchronic.Chronic; import com.sk89q.jchronic.Options; @@ -1209,9 +1208,8 @@ public class LocalSession implements TextureHolder { if (hasCUISupport) { actor.dispatchCUIEvent(event); - } else if (actor.isPlayer()) { - CUI cui = Fawe.get().getCUI(actor); - if (cui != null) cui.dispatchCUIEvent(event); + } else if (useServerCUI) { + updateServerCUI(actor); } }