From 747ec85a0cb24b206f6d907beeaa330612f7cd0f Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Mon, 18 May 2020 22:07:35 -0500 Subject: [PATCH] Clean up 1.14.4 compile errors --- .../org/dynmap/forge_1_14_4/DynmapPlugin.java | 260 +++++++++--------- .../forge_1_14_4/ForgeMapChunkCache.java | 175 ++++-------- .../org/dynmap/forge_1_14_4/ForgeWorld.java | 13 +- .../permissions/FilePermissions.java | 6 +- .../permissions/OpPermissions.java | 6 +- .../permissions/PermissionProvider.java | 6 +- settings.gradle | 4 +- 7 files changed, 206 insertions(+), 264 deletions(-) diff --git a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java index e931d11b..ed465edc 100644 --- a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java +++ b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java @@ -33,10 +33,15 @@ import net.minecraft.command.CommandException; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.Item; import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.ServerPlayNetHandler; import net.minecraft.particles.IParticleData; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.management.BanList; +import net.minecraft.server.management.IPBanList; import net.minecraft.server.management.PlayerProfileCache; import net.minecraft.util.ObjectIntIdentityMap; import net.minecraft.util.ResourceLocation; @@ -44,7 +49,9 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.registry.Registry; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; @@ -52,8 +59,14 @@ import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkSection; import net.minecraft.world.chunk.IChunk; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ServerChatEvent; +import net.minecraftforge.event.TickEvent; +import net.minecraftforge.event.entity.player.PlayerEvent.PlayerChangedDimensionEvent; +import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent; +import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedOutEvent; +import net.minecraftforge.event.entity.player.PlayerEvent.PlayerRespawnEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.ModList; @@ -145,7 +158,6 @@ public class DynmapPlugin private long perTickLimit = (50000000); // 50 ms private boolean isMCPC = false; private boolean useSaveFolder = true; - private Field displayName = null; // MCPC+ display name private static final int SIGNPOST_ID = 63; private static final int WALLSIGN_ID = 68; @@ -178,7 +190,7 @@ public class DynmapPlugin Iterator iter = bsids.iterator(); while (iter.hasNext()) { - IBlockState bs = iter.next(); + BlockState bs = iter.next(); int idx = bsids.get(bs); if (idx >= stateByID.length) { int plen = stateByID.length; @@ -248,7 +260,7 @@ public class DynmapPlugin Iterator iter = ForgeRegistries.BIOMES.iterator(); while (iter.hasNext()) { Biome b = iter.next(); - int bidx = RegistryNamespaced.BIOME.getId(b); + int bidx = Registry.BIOME.getId(b); if (bidx >= biomelist.length) { biomelist = Arrays.copyOf(biomelist, bidx + biomelist.length); } @@ -257,11 +269,11 @@ public class DynmapPlugin } return biomelist; } - public static final NetworkManager getNetworkManager(NetHandlerPlayServer nh) { + public static final NetworkManager getNetworkManager(ServerPlayNetHandler nh) { return nh.netManager; } - private ForgePlayer getOrAddPlayer(EntityPlayer p) { + private ForgePlayer getOrAddPlayer(PlayerEntity p) { String name = p.getEntity().getName().getString(); ForgePlayer fp = players.get(name); if(fp != null) { @@ -309,7 +321,7 @@ public class DynmapPlugin private class ChatMessage { String message; - EntityPlayer sender; + PlayerEntity sender; } private ConcurrentLinkedQueue msgqueue = new ConcurrentLinkedQueue(); @@ -419,13 +431,6 @@ public class DynmapPlugin { plugin = this; this.server = srv; - - displayName = null; - try { - displayName = EntityPlayerMP.class.getField("displayName"); - } catch (SecurityException e) { - } catch (NoSuchFieldException e) { - } } public boolean isOp(String player) { @@ -438,7 +443,7 @@ public class DynmapPlugin return (server.isSinglePlayer() && player.equalsIgnoreCase(server.getServerOwner())); } - private boolean hasPerm(EntityPlayer psender, String permission) { + private boolean hasPerm(PlayerEntity psender, String permission) { PermissionsHandler ph = PermissionsHandler.getHandler(); if((psender != null) && ph.hasPermission(psender.getEntity().getName().getString(), permission)) { return true; @@ -446,7 +451,7 @@ public class DynmapPlugin return permissions.has(psender, permission); } - private boolean hasPermNode(EntityPlayer psender, String permission) { + private boolean hasPermNode(PlayerEntity psender, String permission) { PermissionsHandler ph = PermissionsHandler.getHandler(); if((psender != null) && ph.hasPermissionNode(psender.getEntity().getName().getString(), permission)) { return true; @@ -536,7 +541,7 @@ public class DynmapPlugin for (int i = 0; i < pcnt; i++) { - EntityPlayer p = (EntityPlayer)playlist.get(i); + PlayerEntity p = (PlayerEntity)playlist.get(i); dplay[i] = getOrAddPlayer(p); } @@ -556,7 +561,7 @@ public class DynmapPlugin for (Object o : players) { - EntityPlayer p = (EntityPlayer)o; + PlayerEntity p = (PlayerEntity)o; if (p.getEntity().getName().getString().equalsIgnoreCase(name)) { @@ -569,7 +574,7 @@ public class DynmapPlugin @Override public Set getIPBans() { - UserListIPBans bl = server.getPlayerList().getBannedIPs(); + IPBanList bl = server.getPlayerList().getBannedIPs(); Set ips = new HashSet(); for (String s : bl.getKeys()) { @@ -612,7 +617,7 @@ public class DynmapPlugin @Override public boolean isPlayerBanned(String pid) { - UserListBans bl = server.getPlayerList().getBannedPlayers(); + BanList bl = server.getPlayerList().getBannedPlayers(); return bl.isBanned(getProfileByName(pid)); } @@ -724,7 +729,7 @@ public class DynmapPlugin @Override public void broadcastMessage(String msg) { - ITextComponent component = new TextComponentString(msg); + ITextComponent component = new StringTextComponent(msg); server.getPlayerList().sendMessage(component); Log.info(stripChatColor(msg)); } @@ -775,7 +780,7 @@ public class DynmapPlugin { net.minecraft.server.management.PlayerList scm = server.getPlayerList(); if (scm == null) return Collections.emptySet(); - UserListBans bl = scm.getBannedPlayers(); + BanList bl = scm.getBannedPlayers(); if (bl == null) return Collections.emptySet(); if(bl.isBanned(getProfileByName(player))) { return Collections.emptySet(); @@ -794,7 +799,7 @@ public class DynmapPlugin { net.minecraft.server.management.PlayerList scm = server.getPlayerList(); if (scm == null) return false; - UserListBans bl = scm.getBannedPlayers(); + BanList bl = scm.getBannedPlayers(); if (bl == null) return false; if(bl.isBanned(getProfileByName(player))) { return false; @@ -908,7 +913,7 @@ public class DynmapPlugin while(!blockupdatequeue.isEmpty()) { BlockUpdateRec r = blockupdatequeue.remove(); - IBlockState bs = r.w.getBlockState(new BlockPos(r.x, r.y, r.z)); + BlockState bs = r.w.getBlockState(new BlockPos(r.x, r.y, r.z)); int idx = Block.BLOCK_STATE_IDS.get(bs); if(!org.dynmap.hdmap.HDBlockModels.isChangeIgnoredBlock(stateByID[idx])) { if(onblockchange_with_id) @@ -1079,12 +1084,12 @@ public class DynmapPlugin */ public class ForgePlayer extends ForgeCommandSender implements DynmapPlayer { - private EntityPlayer player; + private PlayerEntity player; private final String skinurl; private final UUID uuid; - public ForgePlayer(EntityPlayer p) + public ForgePlayer(PlayerEntity p) { player = p; String url = null; @@ -1120,8 +1125,10 @@ public class DynmapPlugin @Override public String getName() { - if(player != null) - return player.getEntity().getName().getString(); + if(player != null) { + String n = player.getEntity().getName().getString();; + return n; + } else return "[Server]"; } @@ -1129,14 +1136,8 @@ public class DynmapPlugin public String getDisplayName() { if(player != null) { - if (displayName != null) { - try { - return (String) displayName.get(player); - } catch (IllegalArgumentException e) { - } catch (IllegalAccessException e) { - } - } - return player.getDisplayName().getUnformattedComponentText(); + String n = player.getDisplayName().getString(); + return n; } else return "[Server]"; @@ -1174,8 +1175,8 @@ public class DynmapPlugin @Override public InetSocketAddress getAddress() { - if((player != null) && (player instanceof EntityPlayerMP)) { - NetHandlerPlayServer nsh = ((EntityPlayerMP)player).connection; + if((player != null) && (player instanceof ServerPlayerEntity)) { + ServerPlayNetHandler nsh = ((ServerPlayerEntity)player).connection; if((nsh != null) && (getNetworkManager(nsh) != null)) { SocketAddress sa = getNetworkManager(nsh).getRemoteAddress(); if(sa instanceof InetSocketAddress) { @@ -1251,7 +1252,7 @@ public class DynmapPlugin @Override public void sendMessage(String msg) { - ITextComponent ichatcomponent = new TextComponentString(msg); + ITextComponent ichatcomponent = new StringTextComponent(msg); player.sendMessage(ichatcomponent); } @Override @@ -1316,7 +1317,7 @@ public class DynmapPlugin public void sendMessage(String msg) { if(sender != null) { - ITextComponent ichatcomponent = new TextComponentString(msg); + ITextComponent ichatcomponent = new StringTextComponent(msg); sender.sendFeedback(ichatcomponent, false); } } @@ -1484,7 +1485,7 @@ public class DynmapPlugin /* Initialized the currently loaded worlds */ if(server.getWorlds() != null) { - for (WorldServer world : server.getWorlds()) { + for (ServerWorld world : server.getWorlds()) { ForgeWorld w = this.getWorld(world); /*NOTYET - need rest of forge if(DimensionManager.getWorld(world.provider.getDimensionId()) == null) { // If not loaded @@ -1544,7 +1545,7 @@ public class DynmapPlugin void onCommand(CommandSource sender, String cmd, String[] args) { DynmapCommandSender dsender; - EntityPlayer psender; + PlayerEntity psender; try { psender = sender.asPlayer(); } catch (com.mojang.brigadier.exceptions.CommandSyntaxException x) { @@ -1619,7 +1620,7 @@ public class DynmapPlugin public void handleWorldLoad(WorldEvent.Load event) { if(!core_enabled) return; IWorld w = event.getWorld(); - if(!(w instanceof WorldServer)) return; + if(!(w instanceof ServerWorld)) return; final ForgeWorld fw = getWorld(w); // This event can be called from off server thread, so push processing there core.getServer().scheduleServerTask(new Runnable() { @@ -1633,7 +1634,7 @@ public class DynmapPlugin public void handleWorldUnload(WorldEvent.Unload event) { if(!core_enabled) return; IWorld w = event.getWorld(); - if(!(w instanceof WorldServer)) return; + if(!(w instanceof ServerWorld)) return; final ForgeWorld fw = getWorld(w); if(fw != null) { // This event can be called from off server thread, so push processing there @@ -1646,8 +1647,8 @@ public class DynmapPlugin // Set world unloaded (needs to be immediate, since it may be invalid after event) fw.setWorldUnloaded(); // Clean up tracker - WorldUpdateTracker wut = updateTrackers.remove(fw.getName()); - if(wut != null) wut.world = null; + //WorldUpdateTracker wut = updateTrackers.remove(fw.getName()); + //if(wut != null) wut.world = null; } } @@ -1656,7 +1657,7 @@ public class DynmapPlugin if(!core_enabled) return; if(!onchunkgenerate) return; IWorld w = event.getWorld(); - if(!(w instanceof WorldServer)) return; + if(!(w instanceof ServerWorld)) return; IChunk c = event.getChunk(); if((c != null) /*TODO && (!c.isTerrainPopulated())*/) { // If new chunk? ForgeWorld fw = getWorld(w, false); @@ -1685,7 +1686,7 @@ public class DynmapPlugin if(!core_enabled) return; if(!onchunkpopulate) return; World w = event.getWorld(); - if(!(w instanceof WorldServer)) return; + if(!(w instanceof ServerWorld)) return; Chunk c = w.getChunkFromChunkCoords(event.getChunkX(), event.getChunkZ()); int ymin = 0, ymax = 0; if(c != null) { @@ -1713,82 +1714,83 @@ public class DynmapPlugin private boolean onchunkgenerate = false; private boolean onblockchange_with_id = false; + +// TODO: Not in 1.14.4 - need to find equivalent +// public class WorldUpdateTracker implements IWorldEventListener { +// String worldid; +// IWorld world; +// @Override +// public void notifyLightSet(BlockPos pos) { +// if(sscache != null) +// sscache.invalidateSnapshot(worldid, pos.getX(), pos.getY(), pos.getZ()); +// if(onlightingchange) { +// mapManager.touch(worldid, pos.getX(), pos.getY(), pos.getZ(), "lightingchange"); +// } +// } +// @Override +// public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) { +// } +// @Override +// public void onEntityAdded(Entity entityIn) { +// } +// @Override +// public void onEntityRemoved(Entity entityIn) { +// } +// @Override +// public void sendBlockBreakProgress(int breakerId, BlockPos pos, +// int progress) { +// } +// @Override +// public void broadcastSound(int p_180440_1_, BlockPos p_180440_2_, +// int p_180440_3_) { +// } +// @Override +// public void playSoundToAllNearExcept(PlayerEntity player, +// SoundEvent soundIn, SoundCategory category, double x, double y, +// double z, float volume, float pitch) { +// } +// @Override +// public void playRecord(SoundEvent soundIn, BlockPos pos) { +// } +// @Override +// public void playEvent(PlayerEntity arg0, int arg1, BlockPos arg2, int arg3) { +// } +// @Override +// public void notifyBlockUpdate(IBlockReader worldIn, BlockPos pos, BlockState oldState, BlockState newState, +// int flags) { +// if(sscache != null) +// sscache.invalidateSnapshot(worldid, pos.getX(), pos.getY(), pos.getZ()); +// if(onblockchange) { +// BlockUpdateRec r = new BlockUpdateRec(); +// r.w = world; +// r.wid = worldid; +// r.x = pos.getX(); r.y = pos.getY(); r.z = pos.getZ(); +// blockupdatequeue.add(r); +// } +// } +// @Override +// public void addParticle(IParticleData particleData, boolean alwaysRender, double x, double y, double z, +// double xSpeed, double ySpeed, double zSpeed) { +// // TODO Auto-generated method stub +// +// } +// @Override +// public void addParticle(IParticleData particleData, boolean ignoreRange, boolean minimizeLevel, double x, +// double y, double z, double xSpeed, double ySpeed, double zSpeed) { +// // TODO Auto-generated method stub +// +// } +// } - public class WorldUpdateTracker implements IWorldEventListener { - String worldid; - IWorld world; - @Override - public void notifyLightSet(BlockPos pos) { - if(sscache != null) - sscache.invalidateSnapshot(worldid, pos.getX(), pos.getY(), pos.getZ()); - if(onlightingchange) { - mapManager.touch(worldid, pos.getX(), pos.getY(), pos.getZ(), "lightingchange"); - } - } - @Override - public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) { - } - @Override - public void onEntityAdded(Entity entityIn) { - } - @Override - public void onEntityRemoved(Entity entityIn) { - } - @Override - public void sendBlockBreakProgress(int breakerId, BlockPos pos, - int progress) { - } - @Override - public void broadcastSound(int p_180440_1_, BlockPos p_180440_2_, - int p_180440_3_) { - } - @Override - public void playSoundToAllNearExcept(EntityPlayer player, - SoundEvent soundIn, SoundCategory category, double x, double y, - double z, float volume, float pitch) { - } - @Override - public void playRecord(SoundEvent soundIn, BlockPos pos) { - } - @Override - public void playEvent(EntityPlayer arg0, int arg1, BlockPos arg2, int arg3) { - } - @Override - public void notifyBlockUpdate(IBlockReader worldIn, BlockPos pos, IBlockState oldState, IBlockState newState, - int flags) { - if(sscache != null) - sscache.invalidateSnapshot(worldid, pos.getX(), pos.getY(), pos.getZ()); - if(onblockchange) { - BlockUpdateRec r = new BlockUpdateRec(); - r.w = world; - r.wid = worldid; - r.x = pos.getX(); r.y = pos.getY(); r.z = pos.getZ(); - blockupdatequeue.add(r); - } - } - @Override - public void addParticle(IParticleData particleData, boolean alwaysRender, double x, double y, double z, - double xSpeed, double ySpeed, double zSpeed) { - // TODO Auto-generated method stub - - } - @Override - public void addParticle(IParticleData particleData, boolean ignoreRange, boolean minimizeLevel, double x, - double y, double z, double xSpeed, double ySpeed, double zSpeed) { - // TODO Auto-generated method stub - - } - } - - private WorldTracker worldTracker = null; - private HashMap updateTrackers = new HashMap(); +// private WorldTracker worldTracker = null; +// private HashMap updateTrackers = new HashMap(); private void registerEvents() { - if(worldTracker == null) { - worldTracker = new WorldTracker(); - MinecraftForge.EVENT_BUS.register(worldTracker); - } +// if(worldTracker == null) { +// worldTracker = new WorldTracker(); +// MinecraftForge.EVENT_BUS.register(worldTracker); +// } // To trigger rendering. onblockchange = core.isTrigger("blockupdate"); onlightingchange = core.isTrigger("lightingupdate"); @@ -1820,11 +1822,11 @@ public class DynmapPlugin if(fw.isLoaded() == false) { fw.setWorldLoaded(w); // Add tracker - WorldUpdateTracker wit = new WorldUpdateTracker(); - wit.worldid = fw.getName(); - wit.world = w; - updateTrackers.put(fw.getName(), wit); - w.getWorld().addEventListener(wit); +// WorldUpdateTracker wit = new WorldUpdateTracker(); +// wit.worldid = fw.getName(); +// wit.world = w; +// updateTrackers.put(fw.getName(), wit); +// w.getWorld().addEventListener(wit); } return fw; } @@ -1835,11 +1837,11 @@ public class DynmapPlugin fw = new ForgeWorld(w); worlds.put(fw.getName(), fw); // Add tracker - WorldUpdateTracker wit = new WorldUpdateTracker(); - wit.worldid = fw.getName(); - wit.world = w; - updateTrackers.put(fw.getName(), wit); - w.getWorld().addEventListener(wit); +// WorldUpdateTracker wit = new WorldUpdateTracker(); +// wit.worldid = fw.getName(); +// wit.world = w; +// updateTrackers.put(fw.getName(), wit); +// w.getWorld().addEventListener(wit); } last_world = w; last_fworld = fw; diff --git a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/ForgeMapChunkCache.java b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/ForgeMapChunkCache.java index 2d6e1903..8d52832a 100644 --- a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/ForgeMapChunkCache.java +++ b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/ForgeMapChunkCache.java @@ -11,30 +11,30 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; +import net.minecraft.nbt.ByteArrayNBT; +import net.minecraft.nbt.ByteNBT; +import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.INBTBase; -import net.minecraft.nbt.NBTTagByte; -import net.minecraft.nbt.NBTTagByteArray; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagDouble; -import net.minecraft.nbt.NBTTagFloat; -import net.minecraft.nbt.NBTTagInt; -import net.minecraft.nbt.NBTTagIntArray; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagLong; -import net.minecraft.nbt.NBTTagShort; -import net.minecraft.nbt.NBTTagString; +import net.minecraft.nbt.DoubleNBT; +import net.minecraft.nbt.FloatNBT; +import net.minecraft.nbt.INBT; +import net.minecraft.nbt.IntArrayNBT; +import net.minecraft.nbt.IntNBT; +import net.minecraft.nbt.ListNBT; +import net.minecraft.nbt.LongNBT; +import net.minecraft.nbt.ShortNBT; +import net.minecraft.nbt.StringNBT; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.AbstractChunkProvider; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkStatus; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.chunk.storage.AnvilChunkLoader; -import net.minecraft.world.chunk.storage.IChunkLoader; +import net.minecraft.world.chunk.storage.ChunkSerializer; import net.minecraft.world.chunk.storage.RegionFileCache; -import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraft.world.server.ChunkManager; +import net.minecraft.world.server.ServerChunkProvider; +import net.minecraft.world.server.ServerWorld; import org.dynmap.DynmapChunk; import org.dynmap.DynmapCore; @@ -58,20 +58,19 @@ public class ForgeMapChunkCache extends MapChunkCache { private static boolean init = false; private static Field unloadqueue = null; - private static Field currentchunkloader = null; private static Field updateEntityTick = null; - /* AnvilChunkLoader fields */ + /* ChunkManager fields */ private static Field chunksToRemove = null; // Map //private static Field pendingAnvilChunksCoordinates = null; // Set - private static Method writechunktonbt = null; // writeChunkToNBT(Chunk c, World w, NBTTagCompound nbt) + private static Method writechunktonbt = null; // writeChunkToNBT(Chunk c, World w, CompoundNBT nbt) - /* AnvilChunkLoaderPending fields */ + /* ChunjManager Pending fields */ private static Field chunkCoord = null; private static Field nbtTag = null; private World w; private DynmapWorld dw; - private ChunkProviderServer cps; + private ServerChunkProvider cps; private int nsect; private List chunks; private ListIterator iterator; @@ -885,7 +884,7 @@ public class ForgeMapChunkCache extends MapChunkCache public static void init() { if (!init) { - Field[] f = ChunkProviderServer.class.getDeclaredFields(); + Field[] f = ServerChunkProvider.class.getDeclaredFields(); for(int i = 0; i < f.length; i++) { if((unloadqueue == null) && f[i].getType().isAssignableFrom(it.unimi.dsi.fastutil.longs.LongSet.class)) { @@ -893,14 +892,9 @@ public class ForgeMapChunkCache extends MapChunkCache //Log.info("Found unloadqueue - " + f[i].getName()); unloadqueue.setAccessible(true); } - else if((currentchunkloader == null) && f[i].getType().isAssignableFrom(IChunkLoader.class)) { - currentchunkloader = f[i]; - //Log.info("Found currentchunkprovider - " + f[i].getName()); - currentchunkloader.setAccessible(true); - } } - f = WorldServer.class.getDeclaredFields(); + f = ServerWorld.class.getDeclaredFields(); for(int i = 0; i < f.length; i++) { if((updateEntityTick == null) && f[i].getType().isAssignableFrom(int.class)) { updateEntityTick = f[i]; @@ -909,7 +903,7 @@ public class ForgeMapChunkCache extends MapChunkCache } } - f = AnvilChunkLoader.class.getDeclaredFields(); + f = ChunkManager.class.getDeclaredFields(); for(int i = 0; i < f.length; i++) { if((chunksToRemove == null) && (f[i].getType().equals(Map.class))) { chunksToRemove = f[i]; @@ -923,10 +917,10 @@ public class ForgeMapChunkCache extends MapChunkCache // } } // Get writeChunkToNBT method - Method[] ma = AnvilChunkLoader.class.getDeclaredMethods(); + Method[] ma = ChunkManager.class.getDeclaredMethods(); for (Method m : ma) { Class[] p = m.getParameterTypes(); - if ((p.length == 3) && (p[0].equals(Chunk.class)) && (p[1].equals(World.class)) && (p[2].equals(NBTTagCompound.class))) { + if ((p.length == 3) && (p[0].equals(Chunk.class)) && (p[1].equals(World.class)) && (p[2].equals(CompoundNBT.class))) { writechunktonbt = m; Log.info("Found writechunktonbt- " + m.getName()); m.setAccessible(true); @@ -934,7 +928,7 @@ public class ForgeMapChunkCache extends MapChunkCache } } - if ((unloadqueue == null) || (currentchunkloader == null) || (writechunktonbt == null)) + if ((unloadqueue == null) || (writechunktonbt == null)) { Log.severe("ERROR: cannot find unload queue or chunk provider field - dynmap cannot load chunks"); } @@ -959,12 +953,12 @@ public class ForgeMapChunkCache extends MapChunkCache this.dw = dw; this.w = dw.getWorld(); if(dw.isLoaded()) { - /* Check if world's provider is ChunkProviderServer */ - IChunkProvider cp = this.w.getChunkProvider(); + /* Check if world's provider is ServerChunkProvider */ + AbstractChunkProvider cp = this.w.getChunkProvider(); - if (cp instanceof ChunkProviderServer) + if (cp instanceof ServerChunkProvider) { - cps = (ChunkProviderServer)cp; + cps = (ServerChunkProvider)cp; } else { @@ -1040,71 +1034,24 @@ public class ForgeMapChunkCache extends MapChunkCache private static boolean didError = false; - public NBTTagCompound readChunk(int x, int z) { - if((cps == null) || (!(cps.chunkLoader instanceof AnvilChunkLoader)) || - (((chunksToRemove == null) /*|| (pendingAnvilChunksCoordinates == null) */))) { - if (!didError) { - Log.severe("**** DYNMAP CANNOT READ CHUNKS (UNSUPPORTED CHUNK LOADER) ****"); - didError = true; - } - return null; - } + public CompoundNBT readChunk(int x, int z) { try { - AnvilChunkLoader acl = (AnvilChunkLoader)cps.chunkLoader; - Map chunkstoremove = null; - //it.unimi.dsi.fastutil.longs.LongSet pendingcoords; - - chunkstoremove = (Map)chunksToRemove.get(acl); - //pendingcoords = (it.unimi.dsi.fastutil.longs.LongSet) pendingAnvilChunksCoordinates.get(acl); + ChunkManager acl = cps.chunkManager; - NBTTagCompound rslt = null; + CompoundNBT rslt = null; ChunkPos coord = new ChunkPos(x, z); - //} - // if (pendingcoords.contains(coord.asLong()) { - // for (Object o : chunkstoremove.values()) { - // if (chunkCoord == null) { - // Field[] f = o.getClass().getDeclaredFields(); - // for(Field ff : f) { - // if((chunkCoord == null) && (ff.getType().equals(ChunkPos.class))) { - // chunkCoord = ff; - // chunkCoord.setAccessible(true); - // } - // else if((nbtTag == null) && (ff.getType().equals(NBTTagCompound.class))) { - // nbtTag = ff; - // nbtTag.setAccessible(true); - // } - // } - // if ((chunkCoord == null) || (nbtTag == null)) { - // Log.severe("Error getting chunkCoord and nbtTag for Forge"); - // return null; - // } - // } - // ChunkPos occ = (ChunkPos)chunkCoord.get(o); - - // if (occ.equals(coord)) { - // rslt = (NBTTagCompound)nbtTag.get(o); - // break; - // } - // } - // } - if (rslt == null) { - DataInputStream str = RegionFileCache.getChunkInputStream(acl.chunkSaveLocation, x, z); - - if (str == null) { - return null; - } - rslt = CompressedStreamTools.read(str); + rslt = acl.readChunk(coord); } if(rslt != null) { rslt = rslt.getCompound("Level"); // Don't load uncooked chunks String stat = rslt.getString("Status"); - ChunkStatus cs = ChunkStatus.getByName(stat); + ChunkStatus cs = ChunkStatus.byName(stat); if ((stat == null) || // Needs to be at least lighted - (!cs.isAtLeast(ChunkStatus.LIGHTED))) { + (!cs.isAtLeast(ChunkStatus.LIGHT))) { rslt = null; } } @@ -1116,35 +1063,35 @@ public class ForgeMapChunkCache extends MapChunkCache } } - private Object getNBTValue(INBTBase v) { + private Object getNBTValue(INBT v) { Object val = null; switch(v.getId()) { case 1: // Byte - val = Byte.valueOf(((NBTTagByte)v).getByte()); + val = Byte.valueOf(((ByteNBT)v).getByte()); break; case 2: // Short - val = Short.valueOf(((NBTTagShort)v).getShort()); + val = Short.valueOf(((ShortNBT)v).getShort()); break; case 3: // Int - val = Integer.valueOf(((NBTTagInt)v).getInt()); + val = Integer.valueOf(((IntNBT)v).getInt()); break; case 4: // Long - val = Long.valueOf(((NBTTagLong)v).getLong()); + val = Long.valueOf(((LongNBT)v).getLong()); break; case 5: // Float - val = Float.valueOf(((NBTTagFloat)v).getFloat()); + val = Float.valueOf(((FloatNBT)v).getFloat()); break; case 6: // Double - val = Double.valueOf(((NBTTagDouble)v).getDouble()); + val = Double.valueOf(((DoubleNBT)v).getDouble()); break; case 7: // Byte[] - val = ((NBTTagByteArray)v).getByteArray(); + val = ((ByteArrayNBT)v).getByteArray(); break; case 8: // String - val = ((NBTTagString)v).getString(); + val = ((StringNBT)v).getString(); break; case 9: // List - NBTTagList tl = (NBTTagList) v; + ListNBT tl = (ListNBT) v; ArrayList vlist = new ArrayList(); int type = tl.getTagType(); for (int i = 0; i < tl.size(); i++) { @@ -1162,7 +1109,7 @@ public class ForgeMapChunkCache extends MapChunkCache vlist.add(sv); break; case 10: - NBTTagCompound tc = tl.getCompound(i); + CompoundNBT tc = tl.getCompound(i); vlist.add(getNBTValue(tc)); break; case 11: @@ -1174,17 +1121,17 @@ public class ForgeMapChunkCache extends MapChunkCache val = vlist; break; case 10: // Map - NBTTagCompound tc = (NBTTagCompound) v; + CompoundNBT tc = (CompoundNBT) v; HashMap vmap = new HashMap(); for (Object t : tc.keySet()) { String st = (String) t; - INBTBase tg = tc.get(st); + INBT tg = tc.get(st); vmap.put(st, getNBTValue(tg)); } val = vmap; break; case 11: // Int[] - val = ((NBTTagIntArray)v).getIntArray(); + val = ((IntArrayNBT)v).getIntArray(); break; } return val; @@ -1252,16 +1199,16 @@ public class ForgeMapChunkCache extends MapChunkCache } // Prep snapshot and add to cache - private SnapshotRec prepChunkSnapshot(DynmapChunk chunk, NBTTagCompound nbt) { + private SnapshotRec prepChunkSnapshot(DynmapChunk chunk, CompoundNBT nbt) { ChunkSnapshot ss = new ChunkSnapshot(nbt, dw.worldheight); DynIntHashMap tileData = new DynIntHashMap(); - NBTTagList tiles = nbt.getList("TileEntities", 10); - if(tiles == null) tiles = new NBTTagList(); + ListNBT tiles = nbt.getList("TileEntities", 10); + if(tiles == null) tiles = new ListNBT(); /* Get tile entity data */ List vals = new ArrayList(); for(int tid = 0; tid < tiles.size(); tid++) { - NBTTagCompound tc = tiles.getCompound(tid); + CompoundNBT tc = tiles.getCompound(tid); int tx = tc.getInt("x"); int ty = tc.getInt("y"); int tz = tc.getInt("z"); @@ -1272,7 +1219,7 @@ public class ForgeMapChunkCache extends MapChunkCache if(te_fields != null) { vals.clear(); for(String id: te_fields) { - INBTBase v = tc.get(id); /* Get field */ + INBT v = tc.get(id); /* Get field */ if(v != null) { Object val = getNBTValue(v); if(val != null) { @@ -1325,13 +1272,7 @@ public class ForgeMapChunkCache extends MapChunkCache ChunkSnapshot ss; DynIntHashMap tileData; if (vis) { // If visible - NBTTagCompound nbt = new NBTTagCompound(); - try { - writechunktonbt.invoke(cps.chunkLoader, cps.getChunk(chunk.x, chunk.z, false, false), w, nbt); - } catch (IllegalAccessException e) { - } catch (IllegalArgumentException e) { - } catch (InvocationTargetException e) { - } + CompoundNBT nbt = ChunkSerializer.write((ServerWorld)w, cps.getChunk(chunk.x, chunk.z, false)); SnapshotRec ssr = prepChunkSnapshot(chunk, nbt); ss = ssr.ss; tileData = ssr.tileData; @@ -1399,7 +1340,7 @@ public class ForgeMapChunkCache extends MapChunkCache endChunkLoad(startTime, ChunkStats.CACHED_SNAPSHOT_HIT); } else { - NBTTagCompound nbt = readChunk(chunk.x, chunk.z); + CompoundNBT nbt = readChunk(chunk.x, chunk.z); // If read was good if (nbt != null) { ChunkSnapshot ss; diff --git a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/ForgeWorld.java b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/ForgeWorld.java index 7307555b..505a4160 100644 --- a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/ForgeWorld.java +++ b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/ForgeWorld.java @@ -10,8 +10,8 @@ import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.EndDimension; import net.minecraft.world.dimension.NetherDimension; import net.minecraft.world.gen.Heightmap.Type; -import net.minecraft.world.EnumLightType; import net.minecraft.world.IWorld; +import net.minecraft.world.LightType; import net.minecraft.world.World; import net.minecraft.world.border.WorldBorder; @@ -124,10 +124,9 @@ public class ForgeWorld extends DynmapWorld public DynmapLocation getSpawnLocation() { if(world != null) { - BlockPos sloc = world.getSpawnPoint(); - spawnloc.x = sloc.getX(); - spawnloc.y = sloc.getY(); - spawnloc.z = sloc.getZ(); + spawnloc.x = world.getWorldInfo().getSpawnX(); + spawnloc.y = world.getWorldInfo().getSpawnY(); + spawnloc.z = world.getWorldInfo().getSpawnZ(); spawnloc.world = this.getName(); } return spawnloc; @@ -196,7 +195,7 @@ public class ForgeWorld extends DynmapWorld public int getHighestBlockYAt(int x, int z) { if(world != null) { - return world.getWorld().getChunk(x >> 4, z >> 4).getHeightmap(Type.LIGHT_BLOCKING).getHeight(x & 15, z & 15); + return world.getWorld().getChunk(x >> 4, z >> 4).func_217303_b(Type.MOTION_BLOCKING).getHeight(x & 15, z & 15); } else return -1; @@ -212,7 +211,7 @@ public class ForgeWorld extends DynmapWorld public int getSkyLightLevel(int x, int y, int z) { if(world != null) { - return world.getLightFor(EnumLightType.SKY, new BlockPos(x, y, z)); + return world.getLightFor(LightType.SKY, new BlockPos(x, y, z)); } else return -1; diff --git a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/FilePermissions.java b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/FilePermissions.java index e602c7ff..6d2a268a 100644 --- a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/FilePermissions.java +++ b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/FilePermissions.java @@ -6,7 +6,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import org.dynmap.ConfigurationNode; import org.dynmap.Log; @@ -84,7 +84,7 @@ public class FilePermissions implements PermissionProvider { } @Override - public boolean has(EntityPlayer psender, String permission) { + public boolean has(PlayerEntity psender, String permission) { if(psender != null) { String n = psender.getName().getString().toLowerCase(); return hasPerm(n, permission); @@ -92,7 +92,7 @@ public class FilePermissions implements PermissionProvider { return true; } @Override - public boolean hasPermissionNode(EntityPlayer psender, String permission) { + public boolean hasPermissionNode(PlayerEntity psender, String permission) { if(psender != null) { String player = psender.getName().getString().toLowerCase(); return DynmapPlugin.plugin.isOp(player); diff --git a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/OpPermissions.java b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/OpPermissions.java index db8a0168..b977d1e3 100644 --- a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/OpPermissions.java +++ b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/OpPermissions.java @@ -3,7 +3,7 @@ package org.dynmap.forge_1_14_4.permissions; import java.util.HashSet; import java.util.Set; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; import org.dynmap.Log; import org.dynmap.forge_1_14_4.DynmapPlugin; @@ -32,7 +32,7 @@ public class OpPermissions implements PermissionProvider { } @Override - public boolean has(EntityPlayer psender, String permission) { + public boolean has(PlayerEntity psender, String permission) { if(psender != null) { if(usrCommands.contains(permission)) { return true; @@ -42,7 +42,7 @@ public class OpPermissions implements PermissionProvider { return true; } @Override - public boolean hasPermissionNode(EntityPlayer psender, String permission) { + public boolean hasPermissionNode(PlayerEntity psender, String permission) { if(psender != null) { return DynmapPlugin.plugin.isOp(psender.getEntity().getName().getString()); } diff --git a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/PermissionProvider.java b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/PermissionProvider.java index 8473f99c..764c2f0f 100644 --- a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/PermissionProvider.java +++ b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/permissions/PermissionProvider.java @@ -2,11 +2,11 @@ package org.dynmap.forge_1_14_4.permissions; import java.util.Set; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.PlayerEntity; public interface PermissionProvider { - boolean has(EntityPlayer sender, String permission); - boolean hasPermissionNode(EntityPlayer sender, String permission); + boolean has(PlayerEntity sender, String permission); + boolean hasPermissionNode(PlayerEntity sender, String permission); Set hasOfflinePermissions(String player, Set perms); diff --git a/settings.gradle b/settings.gradle index 51785396..e7522ab2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,7 +7,7 @@ include ':bukkit-helper' include ':dynmap-api' include ':DynmapCore' include ':DynmapCoreAPI' -//include ':forge-1.14.4' +include ':forge-1.14.4' include ':forge-1.13.2' include ':forge-1.12.2' include ':forge-1.11.2' @@ -23,7 +23,7 @@ project(':bukkit-helper').projectDir = "$rootDir/bukkit-helper" as File project(':dynmap-api').projectDir = "$rootDir/dynmap-api" as File project(':DynmapCore').projectDir = "$rootDir/DynmapCore" as File project(':DynmapCoreAPI').projectDir = "$rootDir/DynmapCoreAPI" as File -//project(':forge-1.14.4').projectDir = "$rootDir/forge-1.14.4" as File +project(':forge-1.14.4').projectDir = "$rootDir/forge-1.14.4" as File project(':forge-1.13.2').projectDir = "$rootDir/forge-1.13.2" as File project(':forge-1.12.2').projectDir = "$rootDir/forge-1.12.2" as File project(':forge-1.11.2').projectDir = "$rootDir/forge-1.11.2" as File