SteamWar/FightSystem
Archiviert
13
1

Fix HullHider
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2024-03-22 20:36:27 +01:00
Ursprung f5a150c203
Commit b9f0039025
2 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -28,18 +28,20 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Map;
public class BlockIdWrapper14 implements BlockIdWrapper { public class BlockIdWrapper14 implements BlockIdWrapper {
private static final Class<?> chunkProviderServer = Reflection.getClass("{nms.server.level}.ChunkProviderServer"); private static final Class<?> chunkProviderServer = Reflection.getClass("{nms.server.level}.ChunkProviderServer");
private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer); private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
private static final Class<?> playerChunkMap = Reflection.getClass("{nms.server.level}.PlayerChunkMap"); private static final Class<?> playerChunkMap = Reflection.getClass("{nms.server.level}.PlayerChunkMap");
private static final Reflection.FieldAccessor<?> getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0); private static final Reflection.FieldAccessor<?> getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0);
private static final Reflection.FieldAccessor<Int2ObjectMap> entityTrackers = Reflection.getField(playerChunkMap, Int2ObjectMap.class, 0); private static final Reflection.FieldAccessor<? extends Map> entityTrackers = Core.getVersion() > 15 ? Reflection.getField(playerChunkMap, Int2ObjectMap.class, 0) : Reflection.getField(playerChunkMap, org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap.class, 0);
private static final Class<?> block = Reflection.getClass("{nms.world.level.block}.Block"); private static final Class<?> block = Reflection.getClass("{nms.world.level.block}.Block");
private static final Class<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData"); private static final Class<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition"); private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
private final Int2ObjectMap trackers; private final Map trackers;
public BlockIdWrapper14() { public BlockIdWrapper14() {
trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world)))); trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world))));
} }
@ -71,13 +73,17 @@ public class BlockIdWrapper14 implements BlockIdWrapper {
private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer); private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer);
@Override @Override
public void trackEntity(Player player, int entity) { public void trackEntity(Player player, int entity) {
updatePlayer.invoke(trackers.get(entity), getPlayer.invoke(player)); Object tracker = trackers.get(entity);
if(tracker != null)
updatePlayer.invoke(tracker, getPlayer.invoke(player));
} }
private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer); private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer);
@Override @Override
public void untrackEntity(Player player, int entity) { public void untrackEntity(Player player, int entity) {
clearPlayer.invoke(trackers.get(entity), getPlayer.invoke(player)); Object tracker = trackers.get(entity);
if(tracker != null)
clearPlayer.invoke(tracker, getPlayer.invoke(player));
} }
private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("{obc}.util.CraftMagicNumbers"), "getMaterial", Material.class, block); private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("{obc}.util.CraftMagicNumbers"), "getMaterial", Material.class, block);

Datei anzeigen

@ -58,13 +58,17 @@ public class BlockIdWrapper8 implements BlockIdWrapper {
private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTrackerEntry, "updatePlayer", entityPlayer); private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTrackerEntry, "updatePlayer", entityPlayer);
@Override @Override
public void trackEntity(Player player, int entity) { public void trackEntity(Player player, int entity) {
updatePlayer.invoke(get.invoke(trackers, entity), getPlayer.invoke(player)); Object tracker = get.invoke(trackers, entity);
if(tracker != null)
updatePlayer.invoke(tracker, getPlayer.invoke(player));
} }
private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTrackerEntry, "a", entityPlayer); private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTrackerEntry, "a", entityPlayer);
@Override @Override
public void untrackEntity(Player player, int entity) { public void untrackEntity(Player player, int entity) {
clearPlayer.invoke(get.invoke(trackers, entity), getPlayer.invoke(player)); Object tracker = get.invoke(trackers, entity);
if(tracker != null)
clearPlayer.invoke(tracker, getPlayer.invoke(player));
} }
@Override @Override