Fixed invalid methods when using Spigot

This commit is contained in:
OmerBenGera 2022-01-29 12:34:10 +02:00
parent 98020c02f2
commit 0a2fbde412

View File

@ -34,7 +34,7 @@ public final class ChunkLoaderNPC_v1_16_R3 extends EntityPlayer implements Chunk
private boolean dieCall = false; private boolean dieCall = false;
public ChunkLoaderNPC_v1_16_R3(Location location, UUID uuid){ public ChunkLoaderNPC_v1_16_R3(Location location, UUID uuid) {
super(((CraftServer) Bukkit.getServer()).getServer(), super(((CraftServer) Bukkit.getServer()).getServer(),
((CraftWorld) location.getWorld()).getHandle(), ((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())), new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
@ -60,12 +60,11 @@ public final class ChunkLoaderNPC_v1_16_R3 extends EntityPlayer implements Chunk
@Override @Override
public void die() { public void die() {
if(!dieCall) { if (!dieCall) {
dieCall = true; dieCall = true;
removePlayer(getWorldServer(), this); removePlayer(getWorldServer(), this);
dieCall = false; dieCall = false;
} } else {
else {
super.die(); super.die();
} }
} }
@ -75,17 +74,21 @@ public final class ChunkLoaderNPC_v1_16_R3 extends EntityPlayer implements Chunk
return getBukkitEntity().getLocation(); return getBukkitEntity().getLocation();
} }
private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer){ private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer) {
Chunk currentChunk = entityPlayer.getCurrentChunk(); Chunk currentChunk = worldServer.getChunkIfLoaded((int) entityPlayer.locX() >> 4,
(int) entityPlayer.locZ() >> 4);
if (currentChunk != null) if (currentChunk != null)
currentChunk.b(entityPlayer); currentChunk.b(entityPlayer);
worldServer.entitiesById.remove(entityPlayer.getId()); worldServer.entitiesById.remove(entityPlayer.getId());
worldServer.unregisterEntity(entityPlayer); worldServer.unregisterEntity(entityPlayer);
entityPlayer.shouldBeRemoved = true; try {
entityPlayer.shouldBeRemoved = true;
} catch (Throwable ignored) {
}
} }
public static class DummyNetworkManager extends NetworkManager{ public static class DummyNetworkManager extends NetworkManager {
private static Field channelField; private static Field channelField;
private static Field socketAddressField; private static Field socketAddressField;
@ -101,7 +104,7 @@ public final class ChunkLoaderNPC_v1_16_R3 extends EntityPlayer implements Chunk
} }
} }
DummyNetworkManager(){ DummyNetworkManager() {
super(EnumProtocolDirection.SERVERBOUND); super(EnumProtocolDirection.SERVERBOUND);
updateFields(); updateFields();
} }