Replace {nms} and {obc} tags

This commit is contained in:
Lixfel
2025-01-06 10:15:48 +01:00
parent ab34d86da4
commit da148c0e9f
60 changed files with 182 additions and 182 deletions
@@ -43,18 +43,18 @@ import java.util.logging.Level;
public class TinyProtocol implements Listener {
private static final Class<?> craftServer = Reflection.getClass("{obc}.CraftServer");
private static final Class<?> dedicatedPlayerList = Reflection.getClass("{nms.server.dedicated}.DedicatedPlayerList");
private static final Class<?> craftServer = Reflection.getClass("org.bukkit.craftbukkit.CraftServer");
private static final Class<?> dedicatedPlayerList = Reflection.getClass("net.minecraft.server.dedicated.DedicatedPlayerList");
private static final Field<?> getPlayerList = Reflection.getField(craftServer, dedicatedPlayerList, 0);
private static final Class<?> playerList = Reflection.getClass("{nms.server.players}.PlayerList");
private static final Class<?> minecraftServer = Reflection.getClass("{nms.server}.MinecraftServer");
private static final Class<?> playerList = Reflection.getClass("net.minecraft.server.players.PlayerList");
private static final Class<?> minecraftServer = Reflection.getClass("net.minecraft.server.MinecraftServer");
private static final Field<?> getMinecraftServer = Reflection.getField(playerList, minecraftServer, 0);
public static final Class<?> serverConnection = Reflection.getClass("{nms.server.network}.ServerConnection");
public static final Class<?> serverConnection = Reflection.getClass("net.minecraft.server.network.ServerConnection");
private static final Field<?> getServerConnection = Reflection.getField(minecraftServer, serverConnection, 0);
public static Object getServerConnection(Plugin plugin) {
return getServerConnection.get(getMinecraftServer.get(getPlayerList.get(plugin.getServer())));
}
private static final Class<?> networkManager = Reflection.getClass("{nms.network}.NetworkManager");
private static final Class<?> networkManager = Reflection.getClass("net.minecraft.network.NetworkManager");
public static final Field<List> networkManagers = Reflection.getField(serverConnection, List.class, 0, networkManager);
public static final TinyProtocol instance = new TinyProtocol(Core.getInstance());
@@ -29,7 +29,7 @@ import java.util.Map;
@UtilityClass
public class CommandRemover {
private static final Reflection.Field<SimpleCommandMap> commandMap = Reflection.getField("{obc}.CraftServer", "commandMap", SimpleCommandMap.class);
private static final Reflection.Field<SimpleCommandMap> commandMap = Reflection.getField("org.bukkit.craftbukkit.CraftServer", "commandMap", SimpleCommandMap.class);
private static final Reflection.Field<Map> knownCommands = Reflection.getField(SimpleCommandMap.class, "knownCommands", Map.class);
public static void removeAll(String... cmds) {
Map<String, Command> knownCmds = knownCommands.get(commandMap.get(Bukkit.getServer()));
@@ -29,8 +29,8 @@ import org.bukkit.inventory.ItemStack;
public class FlatteningWrapper {
private FlatteningWrapper() {}
public static final Class<?> scoreboardObjective = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutScoreboardObjective");
public static final Class<?> scoreboardScore = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutScoreboardScore");
public static final Class<?> scoreboardObjective = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutScoreboardObjective");
public static final Class<?> scoreboardScore = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutScoreboardScore");
public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
@@ -27,16 +27,16 @@ import java.util.function.LongSupplier;
public interface ProtocolWrapper {
Class<?> itemStack = Reflection.getClass("{nms.world.item}.ItemStack");
Class<?> spawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutSpawnEntity");
Class<?> spawnLivingPacket = Core.getVersion() > 18 ? ProtocolWrapper.spawnPacket : Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutSpawnEntityLiving");
Class<?> equipmentPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityEquipment");
Class<?> itemStack = Reflection.getClass("net.minecraft.world.item.ItemStack");
Class<?> spawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity");
Class<?> spawnLivingPacket = Core.getVersion() > 18 ? ProtocolWrapper.spawnPacket : Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving");
Class<?> equipmentPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment");
Class<?> enumGamemode = Reflection.getClass(Core.getVersion() > 9 ? "{nms.world.level}.EnumGamemode" : "{nms}.WorldSettings$EnumGamemode");
Class<?> enumGamemode = Reflection.getClass(Core.getVersion() > 9 ? "net.minecraft.world.level.EnumGamemode" : "net.minecraft.WorldSettings$EnumGamemode");
Reflection.Method getGameModeById = Reflection.getTypedMethod(enumGamemode, null, enumGamemode, int.class);
// 0: hand, 1: offhand, 2: feet, 3: legs, 4: chest, 5: head
Object[] itemSlots = Core.getVersion() > 8 ? Reflection.getClass("{nms.world.entity}.EnumItemSlot").getEnumConstants() : new Integer[]{0, 0, 1, 2, 3, 4};
Object[] itemSlots = Core.getVersion() > 8 ? Reflection.getClass("net.minecraft.world.entity.EnumItemSlot").getEnumConstants() : new Integer[]{0, 0, 1, 2, 3, 4};
ProtocolWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
@@ -45,7 +45,7 @@ public interface ProtocolWrapper {
Object playerInfoPacketConstructor(PlayerInfoAction action, GameProfile profile, GameMode mode);
default void initTPSWarp(LongSupplier longSupplier) {
Class systemUtils = Reflection.getClass("{nms}.SystemUtils");
Class systemUtils = Reflection.getClass("net.minecraft.SystemUtils");
Reflection.getField(systemUtils, LongSupplier.class, 0).set(systemUtils, (LongSupplier) () -> System.nanoTime() + longSupplier.getAsLong());
}
@@ -79,7 +79,7 @@ public class TPSWatcher {
}
}
private static final Class<?> minecraftServer = Reflection.getClass("{nms.server}.MinecraftServer");
private static final Class<?> minecraftServer = Reflection.getClass("net.minecraft.server.MinecraftServer");
private static final Reflection.Method getServer = Reflection.getTypedMethod(minecraftServer, "getServer", minecraftServer);
private static final Reflection.Field<double[]> recentTps = Reflection.getField(minecraftServer, "recentTps", double[].class);
private static double[] getSpigotTPS() {
@@ -27,7 +27,7 @@ public class AuthlibInjector {
private AuthlibInjector() {}
public static void inject() {
Class<?> minecraftServerClass = Reflection.getClass("{nms.server}.MinecraftServer");
Class<?> minecraftServerClass = Reflection.getClass("net.minecraft.server.MinecraftServer");
Reflection.Field<GameProfileRepository> gameProfile = Reflection.getField(minecraftServerClass, GameProfileRepository.class, 0);
Object minecraftServer = Reflection.getTypedMethod(minecraftServerClass, "getServer", minecraftServerClass).invoke(null);
gameProfile.set(minecraftServer, new SteamwarGameProfileRepository((YggdrasilGameProfileRepository) gameProfile.get(minecraftServer)));
@@ -54,11 +54,11 @@ public class AntiNocom implements Listener {
}
private void registerUseItem() {
Class<?> useItem = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem");
Class<?> useItem = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayInUseItem");
Function<Object, Object> getPosition;
if(Core.getVersion() > 12) {
Class<?> movingObjectPositionBlock = Reflection.getClass("{nms.world.phys}.MovingObjectPositionBlock");
Class<?> movingObjectPositionBlock = Reflection.getClass("net.minecraft.world.phys.MovingObjectPositionBlock");
Reflection.Field<?> useItemPosition = Reflection.getField(useItem, movingObjectPositionBlock, 0);
Reflection.Field<?> movingBlockPosition = Reflection.getField(movingObjectPositionBlock, TechHider.blockPosition, 0);
@@ -73,7 +73,7 @@ public class AntiNocom implements Listener {
});
}
private static final Class<?> blockDig = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInBlockDig");
private static final Class<?> blockDig = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayInBlockDig");
private static final Reflection.Field<?> digPosition = Reflection.getField(blockDig, TechHider.blockPosition, 0);
private Object onDig(Player player, Object packet) {
Object pos = digPosition.get(packet);
@@ -160,7 +160,7 @@ public class REntity {
server.postEntityMove(this, fromX, fromZ);
}
private static final Class<?> animationPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutAnimation");
private static final Class<?> animationPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutAnimation");
private static final Reflection.Field<Integer> animationEntity = Reflection.getField(animationPacket, int.class, Core.getVersion() > 15 ? (Core.getVersion() > 19 ? 5 : 6) : 0);
private static final Reflection.Field<Integer> animationAnimation = Reflection.getField(animationPacket, int.class, Core.getVersion() > 15 ? (Core.getVersion() > 19 ? 6 : 7) : 1);
public void showAnimation(byte animation) {
@@ -170,7 +170,7 @@ public class REntity {
server.updateEntity(this, packet);
}
private static final Class<?> velocityPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityVelocity");
private static final Class<?> velocityPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntityVelocity");
private static final Reflection.Field<Integer> velocityEntity = Reflection.getField(velocityPacket, int.class, 0);
private static final Reflection.Field<Integer> velocityX = Reflection.getField(velocityPacket, int.class, 1);
private static final Reflection.Field<Integer> velocityY = Reflection.getField(velocityPacket, int.class, 2);
@@ -184,7 +184,7 @@ public class REntity {
server.updateEntity(this, packet);
}
private static final Class<?> statusPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityStatus");
private static final Class<?> statusPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntityStatus");
private static final Reflection.Field<Integer> statusEntity = Reflection.getField(statusPacket, int.class, 0);
private static final Reflection.Field<Byte> statusStatus = Reflection.getField(statusPacket, byte.class, 0);
public void showDamage() {
@@ -346,7 +346,7 @@ public class REntity {
}
}
private static final Class<?> destroyPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityDestroy");
private static final Class<?> destroyPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy");
private static final Reflection.Field<?> destroyEntities;
static {
if(Core.getVersion() > 15)
@@ -393,7 +393,7 @@ public class REntity {
return ChatWrapper.impl.getDataWatcherPacket(entityId, dataWatcherKeyValues);
}
public static final Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
public static final Class<?> teleportPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntityTeleport");
public static final Reflection.Field<Integer> teleportEntity = Reflection.getField(teleportPacket, int.class, 0);
public static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0);
private Object getTeleportPacket(){
@@ -403,12 +403,12 @@ public class REntity {
return packet;
}
private static final Class<?> entityPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity");
private static final Class<?> entityPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntity");
private static final Reflection.Field<Integer> moveEntityId = Reflection.getField(entityPacket, int.class, 0);
private static final BountifulWrapper.PositionSetter movePosition = BountifulWrapper.impl.getRelMoveSetter(entityPacket);
private static final Class<?> lookPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutEntityLook");
private static final Class<?> movePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMove");
private static final Class<?> moveLookPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMoveLook");
private static final Class<?> lookPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntity$PacketPlayOutEntityLook");
private static final Class<?> movePacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntity$PacketPlayOutRelEntityMove");
private static final Class<?> moveLookPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntity$PacketPlayOutRelEntityMoveLook");
private Object getMoveLookPacket(double diffX, double diffY, double diffZ, boolean rotEq) {
Class<?> clazz;
if(diffX == 0 && diffY == 0 && diffZ == 0) {
@@ -428,7 +428,7 @@ public class REntity {
return packet;
}
private static final Class<?> headRotationPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityHeadRotation");
private static final Class<?> headRotationPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation");
private static final Reflection.Field<Integer> headRotationEntity = Reflection.getField(headRotationPacket, int.class, 0);
private static final Reflection.Field<Byte> headRotationYaw = Reflection.getField(headRotationPacket, byte.class, 0);
private Object getHeadRotationPacket(){
@@ -440,7 +440,7 @@ public class REntity {
private static final Reflection.Field<Integer> equipmentEntity = Reflection.getField(ProtocolWrapper.equipmentPacket, int.class, 0);
private static final Class<?> craftItemStack = Reflection.getClass("{obc}.inventory.CraftItemStack");
private static final Class<?> craftItemStack = Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack");
private static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(REntity.craftItemStack, "asNMSCopy", ProtocolWrapper.itemStack, ItemStack.class);
protected Object getEquipmentPacket(Object slot, ItemStack stack){
Object packet = Reflection.newInstance(ProtocolWrapper.equipmentPacket);
@@ -47,9 +47,9 @@ public class REntityServer implements Listener {
private static final HashSet<REntity> emptyEntities = new HashSet<>(0);
private static final HashSet<Player> emptyPlayers = new HashSet<>(0);
private static final Class<?> useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity");
private static final Class<?> useEntity = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayInUseEntity");
private static final Reflection.Field<Integer> useEntityTarget = Reflection.getField(useEntity, int.class, 0);
private static final Class<?> useEntityEnumAction = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity$EnumEntityUseAction");
private static final Class<?> useEntityEnumAction = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayInUseEntity$EnumEntityUseAction");
private static final Reflection.Field<?> useEntityAction = Reflection.getField(useEntity, useEntityEnumAction, 0);
private static final Function<Object, Integer> getEntityAction;
static {
@@ -91,7 +91,7 @@ public class RPlayer extends REntity {
packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, new GameProfile(uuid, name), GameMode.CREATIVE));
}
private static final Class<?> namedSpawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutNamedEntitySpawn");
private static final Class<?> namedSpawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutNamedEntitySpawn");
private static final Function<REntity, Object> namedSpawnPacketGenerator = spawnPacketGenerator(namedSpawnPacket, Core.getVersion() == 8 ? 1 : 0);
private static final Reflection.Field<UUID> namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0);
private Object getNamedSpawnPacket() {
@@ -25,7 +25,7 @@ import com.comphenix.tinyprotocol.TinyProtocol;
public class ServerDataHandler {
public ServerDataHandler() {
TinyProtocol.instance.addFilter(Reflection.getClass("{nms.network.protocol.game}.ClientboundServerDataPacket"), (p, o) -> null);
TinyProtocol.instance.addFilter(Reflection.getClass("{nms.network.protocol.game}.ServerboundChatSessionUpdatePacket"), (player, packet) -> null);
TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ClientboundServerDataPacket"), (p, o) -> null);
TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundChatSessionUpdatePacket"), (player, packet) -> null);
}
}
@@ -35,17 +35,17 @@ import java.util.stream.Collectors;
public class TechHider {
public static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
private static final Class<?> baseBlockPosition = Reflection.getClass("{nms.core}.BaseBlockPosition");
public static final Class<?> blockPosition = Reflection.getClass("net.minecraft.core.BlockPosition");
private static final Class<?> baseBlockPosition = Reflection.getClass("net.minecraft.core.BaseBlockPosition");
public static final Reflection.Field<Integer> blockPositionX = Reflection.getField(baseBlockPosition, int.class, 0);
public static final Reflection.Field<Integer> blockPositionY = Reflection.getField(baseBlockPosition, int.class, 1);
public static final Reflection.Field<Integer> blockPositionZ = Reflection.getField(baseBlockPosition, int.class, 2);
public static final Class<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
public static final Class<?> block = Reflection.getClass("{nms.world.level.block}.Block");
public static final Class<?> iBlockData = Reflection.getClass("net.minecraft.world.level.block.state.IBlockData");
public static final Class<?> block = Reflection.getClass("net.minecraft.world.level.block.Block");
private static final Reflection.Method getBlockDataByBlock = Reflection.getTypedMethod(block, null, iBlockData);
public static final Class<?> craftMagicNumbers = Reflection.getClass("{obc}.util.CraftMagicNumbers");
public static final Class<?> craftMagicNumbers = Reflection.getClass("org.bukkit.craftbukkit.util.CraftMagicNumbers");
private static final Reflection.Method getBlockByMaterial = Reflection.getTypedMethod(craftMagicNumbers, "getBlock", block, Material.class);
private static final Reflection.Method getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
@@ -86,14 +86,14 @@ public class TechHider {
techhiders.put(ChunkHider.impl.mapChunkPacket(), ChunkHider.impl.chunkHiderGenerator(this));
if(Core.getVersion() > 12 && Core.getVersion() < 19) {
Class<?> blockBreakClass = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutBlockBreak");
Class<?> blockBreakClass = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutBlockBreak");
techhiders.put(blockBreakClass, ProtocolWrapper.impl.blockBreakHiderGenerator(blockBreakClass, this));
}
if(Core.getVersion() > 8){
techhiders.put(Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem"), (p, packet) -> p.getGameMode() == GameMode.SPECTATOR ? null : packet);
techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayInUseItem"), (p, packet) -> p.getGameMode() == GameMode.SPECTATOR ? null : packet);
}
techhiders.put(Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity"), (p, packet) -> p.getGameMode() == GameMode.SPECTATOR ? null : packet);
techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayInUseEntity"), (p, packet) -> p.getGameMode() == GameMode.SPECTATOR ? null : packet);
}
@@ -105,10 +105,10 @@ public class TechHider {
techhiders.forEach(TinyProtocol.instance::removeFilter);
}
public static final Class<?> multiBlockChangePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutMultiBlockChange");
public static final Class<?> multiBlockChangePacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange");
public static final UnaryOperator<Object> multiBlockChangeCloner = ProtocolUtils.shallowCloneGenerator(TechHider.multiBlockChangePacket);
private static final Class<?> blockChangePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutBlockChange");
private static final Class<?> blockChangePacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutBlockChange");
private static final Function<Object, Object> blockChangeCloner = ProtocolUtils.shallowCloneGenerator(blockChangePacket);
private static final Reflection.Field<?> blockChangePosition = Reflection.getField(blockChangePacket, blockPosition, 0);
private static final Reflection.Field<?> blockChangeBlockData = Reflection.getField(blockChangePacket, iBlockData, 0);
@@ -131,7 +131,7 @@ public class TechHider {
}
}
private static final Class<?> blockActionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutBlockAction");
private static final Class<?> blockActionPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutBlockAction");
private static final Reflection.Field<?> blockActionPosition = Reflection.getField(blockActionPacket, blockPosition, 0);
private Object blockActionHider(Player p, Object packet) {
if (locationEvaluator.checkBlockPos(p, blockActionPosition.get(packet)) == State.SKIP)
@@ -139,7 +139,7 @@ public class TechHider {
return null;
}
public static final Class<?> tileEntityDataPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutTileEntityData");
public static final Class<?> tileEntityDataPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutTileEntityData");
private static final Reflection.Field<?> tileEntityDataPosition = Reflection.getField(tileEntityDataPacket, blockPosition, 0);
private Object tileEntityDataHider(Player p, Object packet) {
switch (locationEvaluator.checkBlockPos(p, tileEntityDataPosition.get(packet))) {