forked from SteamWar/SteamWar
Move and rename Reflection fields
This commit is contained in:
@@ -19,11 +19,10 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.Reflection;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayOutEntity;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -47,14 +46,14 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
private static final Class<?> dataWatcherObject = Reflection.getClass("{nms.network.syncher}.DataWatcherObject");
|
||||
private static final Class<?> dataWatcherRegistry = Reflection.getClass("{nms.network.syncher}.DataWatcherRegistry");
|
||||
private static final Class<?> dataWatcherSerializer = Reflection.getClass("{nms.network.syncher}.DataWatcherSerializer");
|
||||
private static final Reflection.ConstructorInvoker dataWatcherObjectConstructor = Reflection.getConstructor(dataWatcherObject, int.class, dataWatcherSerializer);
|
||||
private static final Reflection.Constructor dataWatcherObjectConstructor = Reflection.getConstructor(dataWatcherObject, int.class, dataWatcherSerializer);
|
||||
@Override
|
||||
public Object getDataWatcherObject(int index, Class<?> type) {
|
||||
return dataWatcherObjectConstructor.invoke(index, Reflection.getField(dataWatcherRegistry, dataWatcherSerializer, 0, type).get(null));
|
||||
}
|
||||
|
||||
private static final Class<?> item = Reflection.getClass("{nms.network.syncher}.DataWatcher$Item");
|
||||
private static final Reflection.ConstructorInvoker itemConstructor = Reflection.getConstructor(item, dataWatcherObject, Object.class);
|
||||
private static final Reflection.Constructor itemConstructor = Reflection.getConstructor(item, dataWatcherObject, Object.class);
|
||||
@Override
|
||||
public Object getDataWatcherItem(Object dwo, Object value) {
|
||||
return itemConstructor.invoke(dwo, value);
|
||||
@@ -62,13 +61,13 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
|
||||
@Override
|
||||
public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset) {
|
||||
Reflection.FieldAccessor<Double> posX = Reflection.getField(packetClass, double.class, fieldOffset);
|
||||
Reflection.FieldAccessor<Double> posY = Reflection.getField(packetClass, double.class, fieldOffset+1);
|
||||
Reflection.FieldAccessor<Double> posZ = Reflection.getField(packetClass, double.class, fieldOffset+2);
|
||||
Reflection.Field<Double> posX = Reflection.getField(packetClass, double.class, fieldOffset);
|
||||
Reflection.Field<Double> posY = Reflection.getField(packetClass, double.class, fieldOffset+1);
|
||||
Reflection.Field<Double> posZ = Reflection.getField(packetClass, double.class, fieldOffset+2);
|
||||
boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport") || packetClass.getSimpleName().contains("PacketPlayOutNamedEntitySpawn");
|
||||
Class<?> pitchYawType = isByteClass ? byte.class : int.class;
|
||||
Reflection.FieldAccessor<?> lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1);
|
||||
Reflection.FieldAccessor<?> lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2);
|
||||
Reflection.Field<?> lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1);
|
||||
Reflection.Field<?> lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2);
|
||||
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
posX.set(packet, x);
|
||||
@@ -87,11 +86,11 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
@Override
|
||||
public BountifulWrapper.PositionSetter getRelMoveSetter(Class<?> packetClass) {
|
||||
Class<?> type = Core.getVersion() > 12 ? short.class : int.class;
|
||||
Reflection.FieldAccessor<?> moveX = Reflection.getField(packetClass, "b", type);
|
||||
Reflection.FieldAccessor<?> moveY = Reflection.getField(packetClass, "c", type);
|
||||
Reflection.FieldAccessor<?> moveZ = Reflection.getField(packetClass, "d", type);
|
||||
Reflection.FieldAccessor<Byte> movePitch = Reflection.getField(packetClass, "e", byte.class);
|
||||
Reflection.FieldAccessor<Byte> moveYaw = Reflection.getField(packetClass, "f", byte.class);
|
||||
Reflection.Field<?> moveX = Reflection.getField(packetClass, "b", type);
|
||||
Reflection.Field<?> moveY = Reflection.getField(packetClass, "c", type);
|
||||
Reflection.Field<?> moveZ = Reflection.getField(packetClass, "d", type);
|
||||
Reflection.Field<Byte> movePitch = Reflection.getField(packetClass, "e", byte.class);
|
||||
Reflection.Field<Byte> moveYaw = Reflection.getField(packetClass, "f", byte.class);
|
||||
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
moveX.set(packet, (short)(x*4096));
|
||||
@@ -104,7 +103,7 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
|
||||
@Override
|
||||
public BountifulWrapper.UUIDSetter getUUIDSetter(Class<?> packetClass) {
|
||||
Reflection.FieldAccessor<UUID> uuidField = Reflection.getField(packetClass, UUID.class, 0);
|
||||
Reflection.Field<UUID> uuidField = Reflection.getField(packetClass, UUID.class, 0);
|
||||
|
||||
return uuidField::set;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -27,8 +27,8 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapp
|
||||
|
||||
private static final Class<?> chunk = Reflection.getClass("{nms.world.level.chunk}.Chunk");
|
||||
private static final Class<?> packetPlayOutMapChunk = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutMapChunk");
|
||||
private static final Reflection.ConstructorInvoker newPacketPlayOutMapChunk = Reflection.getConstructor(packetPlayOutMapChunk, chunk, int.class);
|
||||
private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle");
|
||||
private static final Reflection.Constructor newPacketPlayOutMapChunk = Reflection.getConstructor(packetPlayOutMapChunk, chunk, int.class);
|
||||
private static final Reflection.Method getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle");
|
||||
|
||||
@Override
|
||||
public void sendChunk(Player p, int chunkX, int chunkZ) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.techhider;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.Reflection;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -34,14 +34,14 @@ public class ChunkHider9 extends ChunkHider8 {
|
||||
|
||||
private static final UnaryOperator<Object> mapChunkCloner = ProtocolUtils.shallowCloneGenerator(mapChunkPacket);
|
||||
|
||||
private static final Reflection.FieldAccessor<Integer> mapChunkX = Reflection.getField(mapChunkPacket, int.class, 0);
|
||||
private static final Reflection.FieldAccessor<Integer> mapChunkZ = Reflection.getField(mapChunkPacket, int.class, 1);
|
||||
private static final Reflection.FieldAccessor<Integer> mapChunkBitMask = Reflection.getField(mapChunkPacket, int.class, 2);
|
||||
private static final Reflection.FieldAccessor<List> mapChunkBlockEntities = Reflection.getField(mapChunkPacket, List.class, 0);
|
||||
private static final Reflection.FieldAccessor<byte[]> mapChunkData = Reflection.getField(mapChunkPacket, byte[].class, 0);
|
||||
private static final Reflection.Field<Integer> mapChunkX = Reflection.getField(mapChunkPacket, int.class, 0);
|
||||
private static final Reflection.Field<Integer> mapChunkZ = Reflection.getField(mapChunkPacket, int.class, 1);
|
||||
private static final Reflection.Field<Integer> mapChunkBitMask = Reflection.getField(mapChunkPacket, int.class, 2);
|
||||
private static final Reflection.Field<List> mapChunkBlockEntities = Reflection.getField(mapChunkPacket, List.class, 0);
|
||||
private static final Reflection.Field<byte[]> mapChunkData = Reflection.getField(mapChunkPacket, byte[].class, 0);
|
||||
|
||||
private static final Class<?> nbtTagCompound = Reflection.getClass("{nms.nbt}.NBTTagCompound");
|
||||
private static final Reflection.MethodInvoker nbtTagGetString = Reflection.getTypedMethod(nbtTagCompound, null, String.class, String.class);
|
||||
private static final Reflection.Method nbtTagGetString = Reflection.getTypedMethod(nbtTagCompound, null, String.class, String.class);
|
||||
|
||||
@Override
|
||||
public BiFunction<Player, Object, Object> chunkHiderGenerator(TechHider techHider) {
|
||||
|
||||
Reference in New Issue
Block a user