forked from SteamWar/SteamWar
Replace {nms} and {obc} tags
This commit is contained in:
@@ -39,7 +39,7 @@ import org.bukkit.entity.Player;
|
||||
@UtilityClass
|
||||
public class Commands {
|
||||
|
||||
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);
|
||||
public static void injectCommand(Command cmd) {
|
||||
commandMap.get(Bukkit.getServer()).register("FightSystem", cmd);
|
||||
}
|
||||
|
||||
@@ -215,9 +215,9 @@ public class Kit {
|
||||
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
|
||||
}
|
||||
|
||||
private static final Class<?> itemStack = Reflection.getClass("{nms.world.item}.ItemStack");
|
||||
private static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(Reflection.getClass("{obc}.inventory.CraftItemStack"), "asNMSCopy", itemStack, ItemStack.class);
|
||||
private static final Class<?> nbtTagCompound = Reflection.getClass("{nms.nbt}.NBTTagCompound");
|
||||
private static final Class<?> itemStack = Reflection.getClass("net.minecraft.world.item.ItemStack");
|
||||
private static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack"), "asNMSCopy", itemStack, ItemStack.class);
|
||||
private static final Class<?> nbtTagCompound = Reflection.getClass("net.minecraft.nbt.NBTTagCompound");
|
||||
private static final Reflection.Method getTag = Reflection.getTypedMethod(itemStack, null, nbtTagCompound);
|
||||
private static final Reflection.Method getKeys = Reflection.getTypedMethod(nbtTagCompound, null, Set.class);
|
||||
public static boolean hasItems(ItemStack stack) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ArrowStopper {
|
||||
new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1);
|
||||
}
|
||||
|
||||
private static final Class<?> entityArrow = Reflection.getClass("{nms.world.entity.projectile}.EntityArrow");
|
||||
private static final Class<?> entityArrow = Reflection.getClass("net.minecraft.world.entity.projectile.EntityArrow");
|
||||
private void run() {
|
||||
Recording.iterateOverEntities(entityArrow::isInstance, entity -> {
|
||||
Projectile arrow = (Projectile) entity;
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class ClickAnalyzer {
|
||||
public ClickAnalyzer() {
|
||||
TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace);
|
||||
if(Core.getVersion() > 8)
|
||||
TinyProtocol.instance.addFilter(Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseItem"), this::onBlockPlace);
|
||||
TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayInUseItem"), this::onBlockPlace);
|
||||
}
|
||||
|
||||
public Object onBlockPlace(Player player, Object packet) {
|
||||
|
||||
@@ -77,8 +77,8 @@ public class Recording implements Listener {
|
||||
return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE;
|
||||
}
|
||||
|
||||
public static final Class<?> primedTnt = Reflection.getClass("{nms.world.entity.item}.EntityTNTPrimed");
|
||||
private static final Reflection.Method getBukkitEntity = Reflection.getTypedMethod(Reflection.getClass("{nms.world.entity}.Entity"), "getBukkitEntity", null);
|
||||
public static final Class<?> primedTnt = Reflection.getClass("net.minecraft.world.entity.item.EntityTNTPrimed");
|
||||
private static final Reflection.Method getBukkitEntity = Reflection.getTypedMethod(Reflection.getClass("net.minecraft.world.entity.Entity"), "getBukkitEntity", null);
|
||||
public static void iterateOverEntities(Predicate<Object> filter, Consumer<Entity> consumer) {
|
||||
CraftbukkitWrapper.impl.entityIterator().filter(filter).map(entity -> (Entity) getBukkitEntity.invoke(entity)).forEach(consumer);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public class Recording implements Listener {
|
||||
GlobalRecorder.getInstance().entitySpeed(entity);
|
||||
}
|
||||
|
||||
private static final Class<?> blockDigPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInBlockDig");
|
||||
private static final Class<?> blockDigPacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayInBlockDig");
|
||||
private static final Class<?> playerDigType = blockDigPacket.getDeclaredClasses()[0];
|
||||
private static final Reflection.Field<?> blockDigType = Reflection.getField(blockDigPacket, playerDigType, 0);
|
||||
private static final Object releaseUseItem = playerDigType.getEnumConstants()[5];
|
||||
@@ -139,7 +139,7 @@ public class Recording implements Listener {
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static final Class<?> blockPlacePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInBlockPlace");
|
||||
public static final Class<?> blockPlacePacket = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayInBlockPlace");
|
||||
private Object blockPlace(Player p, Object packet) {
|
||||
boolean mainHand = BountifulWrapper.impl.mainHand(packet);
|
||||
if(!isNotSent(p) && BountifulWrapper.impl.bowInHand(mainHand, p))
|
||||
|
||||
@@ -29,11 +29,11 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface BlockIdWrapper {
|
||||
Class<?> worldServer = Reflection.getClass("{nms.server.level}.WorldServer");
|
||||
Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", worldServer);
|
||||
Class<?> worldServer = Reflection.getClass("net.minecraft.server.level.WorldServer");
|
||||
Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", worldServer);
|
||||
|
||||
Class<?> craftPlayer = Reflection.getClass("{obc}.entity.CraftPlayer");
|
||||
Class<?> entityPlayer = Reflection.getClass("{nms.server.level}.EntityPlayer");
|
||||
Class<?> craftPlayer = Reflection.getClass("org.bukkit.craftbukkit.entity.CraftPlayer");
|
||||
Class<?> entityPlayer = Reflection.getClass("net.minecraft.server.level.EntityPlayer");
|
||||
Reflection.Method getPlayer = Reflection.getTypedMethod(craftPlayer, "getHandle", entityPlayer);
|
||||
|
||||
BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
|
||||
|
||||
@@ -71,10 +71,10 @@ public class HullHider implements Listener {
|
||||
|
||||
packetHiders.put(packetPlayOutWorldEvent, this::worldEventHider);
|
||||
packetHiders.put(packetPlayOutExplosion, this::explosionHider);
|
||||
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutWorldParticles", Core.getVersion() >= 18 ? double.class : float.class, 1.0);
|
||||
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutNamedSoundEffect", int.class, 8.0);
|
||||
posHiderGenerator("net.minecraft.network.protocol.game.PacketPlayOutWorldParticles", Core.getVersion() >= 18 ? double.class : float.class, 1.0);
|
||||
posHiderGenerator("net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect", int.class, 8.0);
|
||||
if(Core.getVersion() >= 9 && Core.getVersion() < 18)
|
||||
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutCustomSoundEffect", int.class, 8.0);
|
||||
posHiderGenerator("net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect", int.class, 8.0);
|
||||
|
||||
new StateDependentListener(TechHiderWrapper.ENABLED, FightState.Schem, this);
|
||||
new StateDependent(TechHiderWrapper.ENABLED, FightState.Schem) {
|
||||
@@ -198,15 +198,15 @@ public class HullHider implements Listener {
|
||||
}
|
||||
|
||||
|
||||
private static final Class<?> packetPlayOutWorldEvent = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutWorldEvent");
|
||||
private static final Class<?> packetPlayOutWorldEvent = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutWorldEvent");
|
||||
private static final Reflection.Field<?> worldEventPosition = Reflection.getField(packetPlayOutWorldEvent, TechHider.blockPosition, 0);
|
||||
public static final Reflection.Field<Integer> blockPositionY = Reflection.getField("{nms.core}.BaseBlockPosition", int.class, 1);
|
||||
public static final Reflection.Field<Integer> blockPositionY = Reflection.getField("net.minecraft.core.BaseBlockPosition", int.class, 1);
|
||||
private Object worldEventHider(Player player, Object packet) {
|
||||
Object baseBlock = worldEventPosition.get(packet);
|
||||
return packetHider(player, packet, new Location(Config.world, TechHider.blockPositionX.get(baseBlock), blockPositionY.get(baseBlock), TechHider.blockPositionZ.get(baseBlock)));
|
||||
}
|
||||
|
||||
private static final Class<?> packetPlayOutExplosion = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||
private static final Class<?> packetPlayOutExplosion = Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutExplosion");
|
||||
private static final Reflection.Field<List> explosionBlocks = Reflection.getField(packetPlayOutExplosion, List.class, 0);
|
||||
private static final Function<Object, Location> explosionLocation = posPacketToLocation(packetPlayOutExplosion, double.class, 1.0);
|
||||
private Object explosionHider(Player player, Object packet) {
|
||||
|
||||
Reference in New Issue
Block a user