SteamWar/FightSystem
Archiviert
13
1

Fix 1.8/older versions
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-02-22 20:00:22 +01:00
Ursprung 735c2004f2
Commit 84f0ccee81
3 geänderte Dateien mit 13 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -27,7 +27,6 @@ import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.utils.ProtocolAPI;
import de.steamwar.fightsystem.utils.ProtocolWrapper;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -150,7 +149,7 @@ public class Fight {
}
public static Object playerInfoPacket(Object action, GameProfile profile, Object mode) {
Object packet = ProtocolAPI.construct(playerInfoPacket);
Object packet = Reflection.newInstance(playerInfoPacket);
playerInfoAction.set(packet, action);
playerInfoData.set(packet, Collections.singletonList(ProtocolWrapper.impl.playerInfoDataConstructor(packet, profile, mode)));
return packet;

Datei anzeigen

@ -177,7 +177,7 @@ public class REntity {
private static final Reflection.FieldAccessor<Integer> animationEntity = Reflection.getField(animationPacket, int.class, 0);
private static final Reflection.FieldAccessor<Integer> animationAnimation = Reflection.getField(animationPacket, int.class, 1);
public void animation(byte animation) {
Object packet = ProtocolAPI.construct(animationPacket);
Object packet = Reflection.newInstance(animationPacket);
animationEntity.set(packet, entityId);
animationAnimation.set(packet, (int) animation);
ProtocolAPI.broadcastPacket(packet);
@ -189,7 +189,7 @@ public class REntity {
private static final Reflection.FieldAccessor<Integer> velocityY = Reflection.getField(velocityPacket, int.class, 2);
private static final Reflection.FieldAccessor<Integer> velocityZ = Reflection.getField(velocityPacket, int.class, 3);
public void setVelocity(double dX, double dY, double dZ) {
Object packet = ProtocolAPI.construct(velocityPacket);
Object packet = Reflection.newInstance(velocityPacket);
velocityEntity.set(packet, entityId);
velocityX.set(packet, calcVelocity(dX));
velocityY.set(packet, calcVelocity(dY));
@ -201,7 +201,7 @@ public class REntity {
private static final Reflection.FieldAccessor<Integer> statusEntity = Reflection.getField(statusPacket, int.class, 0);
private static final Reflection.FieldAccessor<Byte> statusStatus = Reflection.getField(statusPacket, byte.class, 0);
public void damage() {
Object packet = ProtocolAPI.construct(statusPacket);
Object packet = Reflection.newInstance(statusPacket);
statusEntity.set(packet, entityId);
statusStatus.set(packet, (byte) 2);
ProtocolAPI.broadcastPacket(packet);
@ -259,7 +259,7 @@ public class REntity {
team.removeEntry(name);
}
Object packet = ProtocolAPI.construct(destroyPacket);
Object packet = Reflection.newInstance(destroyPacket);
destroyEntities.set(packet, Core.getVersion() > 15 ? new IntArrayList(new int[]{entityId}) : new int[]{entityId});
ProtocolAPI.broadcastPacket(packet);
}
@ -272,7 +272,7 @@ public class REntity {
private static final Reflection.FieldAccessor<Integer> metadataEntity = Reflection.getField(metadataPacket, int.class, 0);
private static final Reflection.FieldAccessor<List> metadataMetadata = Reflection.getField(metadataPacket, List.class, 0);
private Object getDataWatcherPacket(Object dataWatcherObject, Object value) {
Object packet = ProtocolAPI.construct(metadataPacket);
Object packet = Reflection.newInstance(metadataPacket);
metadataEntity.set(packet, entityId);
metadataMetadata.set(packet, Collections.singletonList(BountifulWrapper.impl.getDataWatcherItem(dataWatcherObject, value)));
return packet;
@ -283,7 +283,7 @@ public class REntity {
private static final Reflection.FieldAccessor<Byte> teleportYaw = Reflection.getField(teleportPacket, byte.class, 0);
private static final Reflection.FieldAccessor<Byte> teleportPitch = Reflection.getField(teleportPacket, byte.class, 1);
private Object getTeleportPacket(){
Object packet = ProtocolAPI.construct(teleportPacket);
Object packet = Reflection.newInstance(teleportPacket);
teleportEntity.set(packet, entityId);
BountifulWrapper.impl.setTeleportPacketPosition(packet, locX, locY, locZ);
teleportYaw.set(packet, yaw);
@ -295,7 +295,7 @@ public class REntity {
private static final Reflection.FieldAccessor<Integer> headRotationEntity = Reflection.getField(headRotationPacket, int.class, 0);
private static final Reflection.FieldAccessor<Byte> headRotationYaw = Reflection.getField(headRotationPacket, byte.class, 0);
private Object getHeadRotationPacket(){
Object packet = ProtocolAPI.construct(headRotationPacket);
Object packet = Reflection.newInstance(headRotationPacket);
headRotationEntity.set(packet, entityId);
headRotationYaw.set(packet, headYaw);
return packet;
@ -304,7 +304,7 @@ public class REntity {
public static final Class<?> spawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutSpawnEntity");
private static final Reflection.FieldAccessor<Integer> spawnEntity = Reflection.getField(spawnPacket, int.class, 0);
private Object getSpawnEntityPacket(){
Object packet = ProtocolAPI.construct(spawnPacket);
Object packet = Reflection.newInstance(spawnPacket);
spawnEntity.set(packet, entityId);
BountifulWrapper.impl.setSpawnPacketUUID(packet, uuid);
ProtocolWrapper.impl.setSpawnPacketType(packet, entityType);
@ -318,7 +318,7 @@ public class REntity {
private static final Class<?> craftItemStack = Reflection.getClass("{obc}.inventory.CraftItemStack");
private static final Reflection.MethodInvoker asNMSCopy = Reflection.getTypedMethod(REntity.craftItemStack, "asNMSCopy", REntity.itemStack, ItemStack.class);
private Object getEquipmentPacket(String slot, ItemStack stack){
Object packet = ProtocolAPI.construct(equipmentPacket);
Object packet = Reflection.newInstance(equipmentPacket);
equipmentEntity.set(packet, entityId);
ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, asNMSCopy.invoke(null, stack));
return packet;
@ -332,7 +332,7 @@ public class REntity {
private static final Reflection.FieldAccessor<Integer> namedSpawnEntity = Reflection.getField(namedSpawnPacket, int.class, 0);
private static final Reflection.FieldAccessor<UUID> namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0);
private Object getNamedSpawnPacket(){
Object packet = ProtocolAPI.construct(namedSpawnPacket);
Object packet = Reflection.newInstance(namedSpawnPacket);
namedSpawnEntity.set(packet, entityId);
namedSpawnUUID.set(packet, uuid);
FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet);

Datei anzeigen

@ -19,8 +19,8 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import jdk.internal.misc.Unsafe;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -88,19 +88,11 @@ public class ProtocolAPI {
};
}
public static <T> T construct(Class<T> clazz) {
try {
return (T) Unsafe.getUnsafe().allocateInstance(clazz);
} catch (InstantiationException e) {
throw new IllegalStateException(e);
}
}
public static UnaryOperator<Object> shallowCloneGenerator(Class<?> clazz) {
BiConsumer<Object, Object> filler = shallowFill(clazz);
return source -> {
Object clone = construct(clazz);
Object clone = Reflection.newInstance(clazz);
filler.accept(source, clone);
return clone;
};