Compiles in 1.14 (yay)

Dieser Commit ist enthalten in:
Jesse Boyd 2019-04-25 00:10:52 +10:00
Ursprung 3bf2ccdebc
Commit cc80bc61cf
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
19 geänderte Dateien mit 227 neuen und 521 gelöschten Zeilen

Datei anzeigen

@ -24,8 +24,6 @@ import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.bukkit.util.BukkitTaskMan; import com.boydti.fawe.bukkit.util.BukkitTaskMan;
import com.boydti.fawe.bukkit.util.ItemUtil; import com.boydti.fawe.bukkit.util.ItemUtil;
import com.boydti.fawe.bukkit.util.VaultUtil; 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.util.image.BukkitImageViewer;
import com.boydti.fawe.bukkit.v0.BukkitQueue_0; import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
import com.boydti.fawe.bukkit.v0.BukkitQueue_All; 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.Jars;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.cui.CUI;
import com.boydti.fawe.util.image.ImageViewer; import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -79,7 +76,6 @@ public class FaweBukkit implements IFawe, Listener {
private CFIPacketListener packetListener; private CFIPacketListener packetListener;
private boolean listeningCui; private boolean listeningCui;
private CUIListener cuiListener;
public VaultUtil getVault() { public VaultUtil getVault() {
return this.vault; 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 @Override
public void registerPacketListener() { public void registerPacketListener() {
PluginManager manager = Bukkit.getPluginManager(); PluginManager manager = Bukkit.getPluginManager();

Datei anzeigen

@ -91,7 +91,12 @@ public class CFIPacketListener implements Listener {
ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand(); ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand();
if (hand != null && hand.getType().isBlock()) { if (hand != null && hand.getType().isBlock()) {
Material type = hand.getType(); Material type = hand.getType();
if (!type.isEmpty()) { switch (type) {
case AIR:
case CAVE_AIR:
case VOID_AIR:
break;
default: {
BlockStateHolder block = BukkitAdapter.asBlockState(hand); BlockStateHolder block = BukkitAdapter.asBlockState(hand);
if (block != null) { if (block != null) {
gen.setBlock(pt, block); gen.setBlock(pt, block);
@ -99,6 +104,7 @@ public class CFIPacketListener implements Listener {
} }
} }
} }
}
pt = getRelPos(event, gen); pt = getRelPos(event, gen);
sendBlockChange(plr, gen, pt, Interaction.OPEN); sendBlockChange(plr, gen, pt, Interaction.OPEN);
} catch (WorldEditException e) { } catch (WorldEditException e) {

Datei anzeigen

@ -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) { public int getViewDistance(Player player) {

Datei anzeigen

@ -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<Object> player = FawePlayer.wrap(event.getPlayer());
CUI cui = player.getMeta("CUI");
if (cui instanceof StructureCUI) {
StructureCUI sCui = (StructureCUI) cui;
sCui.update();
}
}
}
}

Datei anzeigen

@ -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.<Player>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<String, Object> 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.<Player>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.<Player>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.<Player>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<String, NbtBase<?>> 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);
}
}

Datei anzeigen

@ -154,7 +154,7 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
if (cx >= bcx && cx <= tcx && cz >= bcz && cz <= tcz) { if (cx >= bcx && cx <= tcx && cz >= bcz && cz <= tcz) {
Object nmsChunk = methodGetHandleChunk.invoke(chunk); Object nmsChunk = methodGetHandleChunk.invoke(chunk);
boolean mustSave = saveChunks && (boolean) methodNeedsSaving.invoke(nmsChunk, false); boolean mustSave = saveChunks && (boolean) methodNeedsSaving.invoke(nmsChunk, false);
chunk.unload(mustSave, false); chunk.unload(mustSave);
if (unloaded == null) unloaded = new ArrayDeque<>(); if (unloaded == null) unloaded = new ArrayDeque<>();
unloaded.add(chunk); unloaded.add(chunk);
} }

Datei anzeigen

@ -5,7 +5,8 @@ import org.bukkit.World;
public abstract class PaperChunkCallback { public abstract class PaperChunkCallback {
public PaperChunkCallback(World world, int x, int z) { 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); public abstract void onLoad(Chunk chunk);

Datei anzeigen

@ -954,7 +954,7 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
net.minecraft.server.v1_13_R2.Chunk c = ((CraftChunk) chunk).getHandle(); net.minecraft.server.v1_13_R2.Chunk c = ((CraftChunk) chunk).getHandle();
c.mustSave = false; c.mustSave = false;
if (chunk.isLoaded()) { if (chunk.isLoaded()) {
chunk.unload(false, false); chunk.unload(false);
} }
return true; return true;
} }

Datei anzeigen

@ -28,6 +28,7 @@ import io.netty.buffer.ByteBufAllocator;
import net.minecraft.server.v1_14_R1.BiomeBase; import net.minecraft.server.v1_14_R1.BiomeBase;
import net.minecraft.server.v1_14_R1.Block; import net.minecraft.server.v1_14_R1.Block;
import net.minecraft.server.v1_14_R1.BlockPosition; import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.ChunkCoordIntPair;
import net.minecraft.server.v1_14_R1.ChunkProviderServer; import net.minecraft.server.v1_14_R1.ChunkProviderServer;
import net.minecraft.server.v1_14_R1.ChunkSection; import net.minecraft.server.v1_14_R1.ChunkSection;
import net.minecraft.server.v1_14_R1.ChunkStatus; import net.minecraft.server.v1_14_R1.ChunkStatus;
@ -66,6 +67,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.atomic.LongAdder;
import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R1.Chunk, ChunkSection[], ChunkSection> { public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R1.Chunk, ChunkSection[], ChunkSection> {
@ -535,27 +537,17 @@ public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R
@Override @Override
public int getOpacity(ChunkSection section, int x, int y, int z) { public int getOpacity(ChunkSection section, int x, int y, int z) {
DataPaletteBlock<IBlockData> dataPalette = section.getBlocks(); return 0;
IBlockData ibd = dataPalette.a(x & 15, y & 15, z & 15);
pos.a(x, y, z);
return ibd.b(nmsWorld, pos);
} }
@Override @Override
public int getBrightness(ChunkSection section, int x, int y, int z) { public int getBrightness(ChunkSection section, int x, int y, int z) {
DataPaletteBlock<IBlockData> dataPalette = section.getBlocks(); return 0;
IBlockData ibd = dataPalette.a(x & 15, y & 15, z & 15);
return ibd.e();
} }
@Override @Override
public int getOpacityBrightnessPair(ChunkSection section, int x, int y, int z) { public int getOpacityBrightnessPair(ChunkSection section, int x, int y, int z) {
DataPaletteBlock<IBlockData> dataPalette = section.getBlocks(); return 0;
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);
} }
@Override @Override
@ -603,16 +595,25 @@ public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R
public void sendBlockUpdate(FaweChunk chunk, FawePlayer... players) { public void sendBlockUpdate(FaweChunk chunk, FawePlayer... players) {
try { try {
PlayerChunkMap playerManager = ((CraftWorld) getWorld()).getHandle().getChunkProvider().playerChunkMap; PlayerChunkMap playerManager = ((CraftWorld) getWorld()).getHandle().getChunkProvider().playerChunkMap;
boolean watching = false; boolean[] watching = new boolean[1];
boolean[] watchingArr = new boolean[players.length]; boolean[] watchingArr = new boolean[players.length];
ChunkCoordIntPair pair = new ChunkCoordIntPair(chunk.getX(), chunk.getZ());
PlayerChunk plrChunk = playerManager.visibleChunks.get(pair.pair());
if (plrChunk != null) {
plrChunk.players.a(pair, false).forEach(new Consumer<EntityPlayer>() {
@Override
public void accept(EntityPlayer entityPlayer) {
for (int i = 0; i < players.length; i++) { for (int i = 0; i < players.length; i++) {
EntityPlayer player = ((CraftPlayer) ((BukkitPlayer) players[i]).parent).getHandle(); EntityPlayer player = ((CraftPlayer) ((BukkitPlayer) players[i]).parent).getHandle();
if (playerManager.visibleChunks.get(player, chunk.getX(), chunk.getZ())) { if (player == entityPlayer) {
watchingArr[i] = true; watchingArr[i] = true;
watching = true; watching[0] = true;
} }
} }
if (!watching) return; }
});
}
if (!watching[0]) return;
final LongAdder size = new LongAdder(); final LongAdder size = new LongAdder();
if (chunk instanceof VisualChunk) { if (chunk instanceof VisualChunk) {
size.add(((VisualChunk) chunk).size()); size.add(((VisualChunk) chunk).size());
@ -656,24 +657,12 @@ public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R
sendChunk(fc.getX(), fc.getZ(), fc.getBitMask()); sendChunk(fc.getX(), fc.getZ(), fc.getBitMask());
} }
public void sendPacket(int cx, int cz, Packet packet) {
PlayerChunk chunk = getPlayerChunk(nmsWorld, cx, cz);
if (chunk != null) {
for (EntityPlayer player : chunk.players) {
player.playerConnection.sendPacket(packet);
}
}
}
private PlayerChunk getPlayerChunk(WorldServer w, int cx, int cz) { private PlayerChunk getPlayerChunk(WorldServer w, int cx, int cz) {
PlayerChunkMap chunkMap = w.getChunkProvider().playerChunkMap; PlayerChunkMap chunkMap = w.getChunkProvider().playerChunkMap;
PlayerChunk playerChunk = chunkMap.getChunk(cx, cz); PlayerChunk playerChunk = chunkMap.visibleChunks.get(ChunkCoordIntPair.pair(cx, cz));
if (playerChunk == null) { if (playerChunk == null) {
return null; return null;
} }
if (playerChunk.players.isEmpty()) {
return null;
}
return playerChunk; return playerChunk;
} }
@ -681,11 +670,10 @@ public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R
if (playerChunk == null) { if (playerChunk == null) {
return false; return false;
} }
if (playerChunk.e()) {
ChunkSection[] sections = nmsChunk.getSections(); ChunkSection[] sections = nmsChunk.getSections();
for (int layer = 0; layer < 16; layer++) { for (int layer = 0; layer < 16; layer++) {
if (sections[layer] == null && (mask & (1 << layer)) != 0) { if (sections[layer] == null && (mask & (1 << layer)) != 0) {
sections[layer] = new ChunkSection(layer << 4, nmsWorld.worldProvider.g()); sections[layer] = new ChunkSection(layer << 4);
} }
} }
TaskManager.IMP.sync(new Supplier<Object>() { TaskManager.IMP.sync(new Supplier<Object>() {
@ -694,7 +682,7 @@ public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R
try { try {
int dirtyBits = fieldDirtyBits.getInt(playerChunk); int dirtyBits = fieldDirtyBits.getInt(playerChunk);
if (dirtyBits == 0) { if (dirtyBits == 0) {
((CraftWorld) getWorld()).getHandle().getPlayerChunkMap().a(playerChunk); ((CraftWorld) getWorld()).getHandle().getChunkProvider().playerChunkMap.a(playerChunk);
} }
if (mask == 0) { if (mask == 0) {
dirtyBits = 65535; dirtyBits = 65535;
@ -710,7 +698,6 @@ public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R
return null; return null;
} }
}); });
}
// if (mask == 0) { // if (mask == 0) {
// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65535); // PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65535);
// for (EntityPlayer player : playerChunk.players) { // for (EntityPlayer player : playerChunk.players) {
@ -763,6 +750,7 @@ public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R
@Override @Override
public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) { public boolean removeSectionLighting(ChunkSection section, int layer, boolean sky) {
return false;
} }
@Override @Override
@ -771,11 +759,12 @@ public class BukkitQueue_1_14 extends BukkitQueue_0<net.minecraft.server.v1_14_R
@Override @Override
public int getSkyLight(ChunkSection section, int x, int y, int z) { public int getSkyLight(ChunkSection section, int x, int y, int z) {
return 15;
} }
@Override @Override
public int getEmmittedLight(ChunkSection section, int x, int y, int z) { public int getEmmittedLight(ChunkSection section, int x, int y, int z) {
return 15;
} }
@Override @Override

Datei anzeigen

@ -91,7 +91,7 @@ public class BlockMaterial_1_14 implements BlockMaterial {
@Override @Override
public int getLightValue() { public int getLightValue() {
return defaultState.e(); return defaultState.h();
} }
@Override @Override

Datei anzeigen

@ -66,6 +66,7 @@ import net.minecraft.server.v1_14_R1.BlockStateEnum;
import net.minecraft.server.v1_14_R1.BlockStateInteger; import net.minecraft.server.v1_14_R1.BlockStateInteger;
import net.minecraft.server.v1_14_R1.BlockStateList; import net.minecraft.server.v1_14_R1.BlockStateList;
import net.minecraft.server.v1_14_R1.Chunk; import net.minecraft.server.v1_14_R1.Chunk;
import net.minecraft.server.v1_14_R1.ChunkCoordIntPair;
import net.minecraft.server.v1_14_R1.ChunkSection; import net.minecraft.server.v1_14_R1.ChunkSection;
import net.minecraft.server.v1_14_R1.Entity; import net.minecraft.server.v1_14_R1.Entity;
import net.minecraft.server.v1_14_R1.EntityTypes; import net.minecraft.server.v1_14_R1.EntityTypes;
@ -274,8 +275,8 @@ public final class Spigot_v1_14_R1 extends CachedBukkitAdapter implements Bukkit
@Override @Override
public boolean isChunkInUse(org.bukkit.Chunk chunk) { public boolean isChunkInUse(org.bukkit.Chunk chunk) {
CraftChunk craftChunk = (CraftChunk) chunk; CraftChunk craftChunk = (CraftChunk) chunk;
PlayerChunkMap chunkMap = ((WorldServer) craftChunk.getHandle().getWorld()).getPlayerChunkMap(); PlayerChunkMap chunkMap = ((WorldServer) craftChunk.getHandle().getWorld()).getChunkProvider().playerChunkMap;
return chunkMap.isChunkInUse(chunk.getX(), chunk.getZ()); return chunkMap.visibleChunks.containsKey(ChunkCoordIntPair.pair(chunk.getX(), chunk.getZ()));
} }
@Override @Override

Datei anzeigen

@ -230,11 +230,6 @@ public class AsyncBlock implements Block {
} }
} }
@Override
public AsyncBlockState getState(boolean useSnapshot) {
return getState();
}
@Override @Override
public Biome getBiome() { public Biome getBiome() {
return world.getAdapter().adapt(queue.getBiomeType(x, z)); return world.getAdapter().adapt(queue.getBiomeType(x, z));
@ -278,7 +273,14 @@ public class AsyncBlock implements Block {
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
return getType().isEmpty(); switch (getType()) {
case AIR:
case CAVE_AIR:
case VOID_AIR:
return true;
default:
return false;
}
} }
@Override @Override

Datei anzeigen

@ -130,18 +130,18 @@ public class AsyncChunk implements Chunk {
}); });
} }
@Override // @Override
public BlockState[] getTileEntities(boolean b) { // public BlockState[] getTileEntities(boolean b) {
if (!isLoaded()) { // if (!isLoaded()) {
return new BlockState[0]; // return new BlockState[0];
} // }
return TaskManager.IMP.sync(new RunnableVal<BlockState[]>() { // return TaskManager.IMP.sync(new RunnableVal<BlockState[]>() {
@Override // @Override
public void run(BlockState[] value) { // public void run(BlockState[] value) {
this.value = world.getChunkAt(x, z).getTileEntities(b); // this.value = world.getChunkAt(x, z).getTileEntities(b);
} // }
}); // });
} // }
@Override @Override
public boolean isLoaded() { public boolean isLoaded() {
@ -163,14 +163,9 @@ public class AsyncChunk implements Chunk {
return load(false); return load(false);
} }
@Override
public boolean unload(boolean save, boolean safe) {
return world.unloadChunk(x, z, save, safe);
}
@Override @Override
public boolean unload(boolean save) { public boolean unload(boolean save) {
return unload(true, false); return world.unloadChunk(x, z, save);
} }
@Override @Override

Datei anzeigen

@ -68,28 +68,6 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
parent.spawnParticle(particle, v, v1, v2, i, v3, v4, v5, v6, t); 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 <T> void spawnParticle(Particle particle, List<Player> 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 <T> void spawnParticle(Particle particle, List<Player> 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 * @deprecated use {@link #wrap(World)} instead
* @param parent Parent world * @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<Integer>() {
@Override
public Integer get() {
return parent.getHighestBlockYAt(x, z, heightmap);
}
});
}
@Override @Override
public WorldBorder getWorldBorder() { public WorldBorder getWorldBorder() {
return TaskManager.IMP.sync(new RunnableVal<WorldBorder>() { return TaskManager.IMP.sync(new RunnableVal<WorldBorder>() {
@ -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 @Override
public void spawnParticle(Particle particle, Location location, int i) { public void spawnParticle(Particle particle, Location location, int i) {
parent.spawnParticle(particle, location, i); parent.spawnParticle(particle, location, i);
@ -320,21 +294,6 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
return parent.isChunkGenerated(x, z); 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 @Override
public boolean isChunkLoaded(Chunk chunk) { public boolean isChunkLoaded(Chunk chunk) {
return chunk.isLoaded(); return chunk.isLoaded();
@ -426,33 +385,17 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
@Override @Override
public boolean unloadChunk(int x, int z, boolean save) { 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)) { if (isChunkLoaded(x, z)) {
return TaskManager.IMP.sync(new RunnableVal<Boolean>() { return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@Override @Override
public void run(Boolean value) { public void run(Boolean value) {
this.value = parent.unloadChunk(x, z, save, safe); this.value = parent.unloadChunk(x, z, save);
} }
}); });
} }
return true; 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 @Override
public boolean regenerateChunk(final int x, final int z) { public boolean regenerateChunk(final int x, final int z) {
return TaskManager.IMP.sync(new RunnableVal<Boolean>() { return TaskManager.IMP.sync(new RunnableVal<Boolean>() {
@ -1132,61 +1075,6 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
return adapter; return adapter;
} }
@Override
public int getEntityCount() {
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
@Override
public void run(Integer value) {
this.value = parent.getEntityCount();
}
});
}
@Override
public int getTileEntityCount() {
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
@Override
public void run(Integer value) {
this.value = parent.getTileEntityCount();
}
});
}
@Override
public int getTickableTileEntityCount() {
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
@Override
public void run(Integer value) {
this.value = parent.getTickableTileEntityCount();
}
});
}
@Override
public int getChunkCount() {
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
@Override
public void run(Integer value) {
this.value = parent.getChunkCount();
}
});
}
@Override
public int getPlayerCount() {
return TaskManager.IMP.sync(new RunnableVal<Integer>() {
@Override
public void run(Integer value) {
this.value = parent.getPlayerCount();
}
});
}
@Override
public CompletableFuture<Chunk> getChunkAtAsync(int arg0, int arg1, boolean arg2) {
return parent.getChunkAtAsync(arg0, arg1, arg2);
}
@Override @Override
public Collection<Entity> getNearbyEntities(BoundingBox arg0) { public Collection<Entity> getNearbyEntities(BoundingBox arg0) {
return parent.getNearbyEntities(arg0); return parent.getNearbyEntities(arg0);
@ -1208,11 +1096,6 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
return parent.isChunkForceLoaded(arg0, arg1); return parent.isChunkForceLoaded(arg0, arg1);
} }
@Override
public boolean isDayTime() {
return parent.isDayTime();
}
@Override @Override
public Location locateNearestStructure(Location arg0, StructureType arg1, int arg2, boolean arg3) { public Location locateNearestStructure(Location arg0, StructureType arg1, int arg2, boolean arg3) {
return parent.locateNearestStructure(arg0, arg1, arg2, arg3); return parent.locateNearestStructure(arg0, arg1, arg2, arg3);
@ -1283,4 +1166,129 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
public Collection<Chunk> getForceLoadedChunks() { public Collection<Chunk> getForceLoadedChunks() {
return parent.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<Integer>() {
// @Override
// public Integer get() {
// return parent.getHighestBlockYAt(x, z, heightmap);
// }
// });
// }
//
// @Override
// public int getEntityCount() {
// return TaskManager.IMP.sync(new RunnableVal<Integer>() {
// @Override
// public void run(Integer value) {
// this.value = parent.getEntityCount();
// }
// });
// }
//
// @Override
// public int getTileEntityCount() {
// return TaskManager.IMP.sync(new RunnableVal<Integer>() {
// @Override
// public void run(Integer value) {
// this.value = parent.getTileEntityCount();
// }
// });
// }
//
// @Override
// public int getTickableTileEntityCount() {
// return TaskManager.IMP.sync(new RunnableVal<Integer>() {
// @Override
// public void run(Integer value) {
// this.value = parent.getTickableTileEntityCount();
// }
// });
// }
//
// @Override
// public int getChunkCount() {
// return TaskManager.IMP.sync(new RunnableVal<Integer>() {
// @Override
// public void run(Integer value) {
// this.value = parent.getChunkCount();
// }
// });
// }
//
// @Override
// public int getPlayerCount() {
// return TaskManager.IMP.sync(new RunnableVal<Integer>() {
// @Override
// public void run(Integer value) {
// this.value = parent.getPlayerCount();
// }
// });
// }
//
// @Override
// public CompletableFuture<Chunk> 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<Boolean>() {
// @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 <T> void spawnParticle(Particle particle, List<Player> 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 <T> void spawnParticle(Particle particle, List<Player> 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);
// }
} }

Datei anzeigen

@ -9,7 +9,6 @@ import com.boydti.fawe.regions.general.plot.PlotSquaredFeature;
import com.boydti.fawe.util.*; import com.boydti.fawe.util.*;
import com.boydti.fawe.util.chat.ChatManager; import com.boydti.fawe.util.chat.ChatManager;
import com.boydti.fawe.util.chat.PlainChatManager; import com.boydti.fawe.util.chat.PlainChatManager;
import com.boydti.fawe.util.cui.CUI;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.factory.DefaultTransformParser; import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -199,25 +198,6 @@ public class Fawe {
public void onDisable() { public void onDisable() {
} }
public CUI getCUI(Actor actor) {
FawePlayer<Object> 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() { public ChatManager getChatManager() {
return chatManager; return chatManager;
} }

Datei anzeigen

@ -5,7 +5,6 @@ import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.cui.CUI;
import com.boydti.fawe.util.image.ImageViewer; import com.boydti.fawe.util.image.ImageViewer;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -36,8 +35,6 @@ public interface IFawe {
void startMetrics(); void startMetrics();
default CUI getCUI(FawePlayer player) { return null; }
default ImageViewer getImageViewer(FawePlayer player) { return null; } default ImageViewer getImageViewer(FawePlayer player) { return null; }
default void registerPacketListener() {} default void registerPacketListener() {}

Datei anzeigen

@ -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 <T> FawePlayer<T> getPlayer() {
return player;
}
public abstract void dispatchCUIEvent(CUIEvent event);
}

Datei anzeigen

@ -2,7 +2,6 @@ package com.sk89q.jnbt;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

Datei anzeigen

@ -33,7 +33,6 @@ import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.object.collection.SparseBitSet; import com.boydti.fawe.object.collection.SparseBitSet;
import com.boydti.fawe.object.extent.ResettableExtent; import com.boydti.fawe.object.extent.ResettableExtent;
import com.boydti.fawe.util.*; import com.boydti.fawe.util.*;
import com.boydti.fawe.util.cui.CUI;
import com.boydti.fawe.wrappers.WorldWrapper; import com.boydti.fawe.wrappers.WorldWrapper;
import com.sk89q.jchronic.Chronic; import com.sk89q.jchronic.Chronic;
import com.sk89q.jchronic.Options; import com.sk89q.jchronic.Options;
@ -1209,9 +1208,8 @@ public class LocalSession implements TextureHolder {
if (hasCUISupport) { if (hasCUISupport) {
actor.dispatchCUIEvent(event); actor.dispatchCUIEvent(event);
} else if (actor.isPlayer()) { } else if (useServerCUI) {
CUI cui = Fawe.get().getCUI(actor); updateServerCUI(actor);
if (cui != null) cui.dispatchCUIEvent(event);
} }
} }