Merge remote-tracking branch 'origin/dev'
This commit is contained in:
commit
67e82e6d25
19 files changed
+167
-113
No files matched your search
+2
-2
@@ -56,7 +56,7 @@ dependencies {
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
|
||||
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
|
||||
compileOnly 'org.geysermc:connector:1.2.1-SNAPSHOT'
|
||||
compileOnly 'org.geysermc:connector:1.4.2-SNAPSHOT'
|
||||
compileOnly 'com.viaversion:viaversion-api:4.0.1'
|
||||
compileOnly 'com.github.ProtocolSupport:ProtocolSupport:3d24efeda6'
|
||||
|
||||
@@ -80,4 +80,4 @@ publishing {
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
public final class PacketEvents implements Listener, EventManager {
|
||||
private static PacketEvents instance;
|
||||
private static Plugin plugin;
|
||||
private final PEVersion version = new PEVersion(1, 7, 9, 17);
|
||||
private final PEVersion version = new PEVersion(1, 7, 9, 18);
|
||||
private final EventManager eventManager = new PEEventManager();
|
||||
private final PlayerUtils playerUtils = new PlayerUtils();
|
||||
private final ServerUtils serverUtils = new ServerUtils();
|
||||
|
||||
@@ -39,7 +39,6 @@ public abstract class NMSPacketEvent extends PacketEvent implements CallableEven
|
||||
private final InetSocketAddress socketAddress;
|
||||
private final byte packetID;
|
||||
protected NMSPacket packet;
|
||||
protected boolean cancelled;
|
||||
|
||||
public NMSPacketEvent(Object channel, NMSPacket packet) {
|
||||
this.channel = channel;
|
||||
|
||||
@@ -156,6 +156,30 @@ public interface EventManager {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a PacketListenerAbstract listener.
|
||||
*
|
||||
* @param listener {@link PacketListenerAbstract}
|
||||
* @return Same event manager instance.
|
||||
*/
|
||||
default EventManager unregisterListener(PacketListenerAbstract listener) {
|
||||
if (listener != null) {
|
||||
PEEventManager.EVENT_MANAGER_MODERN.unregisterListener(listener);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister multiple PacketListenerAbstract listeners.
|
||||
*
|
||||
* @param listeners {@link PacketListenerAbstract}
|
||||
* @return Same event manager instance.
|
||||
*/
|
||||
default EventManager unregisterListeners(PacketListenerAbstract... listeners) {
|
||||
PEEventManager.EVENT_MANAGER_MODERN.unregisterListeners(listeners);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister all registered event listeners.
|
||||
* All the deprecated and the dynamic listeners will be unregistered.
|
||||
|
||||
+24
-11
@@ -45,10 +45,6 @@ class EventManagerModern {
|
||||
* @see EventManagerLegacy#callEvent(PacketEvent, byte)
|
||||
*/
|
||||
public void callEvent(final PacketEvent event) {
|
||||
boolean cancel = false;
|
||||
if (event instanceof CancellableEvent) {
|
||||
cancel = ((CancellableEvent) event).isCancelled();
|
||||
}
|
||||
byte highestReachedPriority = (byte) (PacketListenerPriority.LOWEST.getId() - 1);
|
||||
for (byte priority = PacketListenerPriority.LOWEST.getId(); priority <= PacketListenerPriority.MONITOR.getId(); priority++) {
|
||||
HashSet<PacketListenerAbstract> listeners = listenersMap.get(priority);
|
||||
@@ -63,17 +59,10 @@ class EventManagerModern {
|
||||
//TODO Remove, because its redundant. We are only keeping it for compatibility with the legacy event manager.
|
||||
if (event instanceof CancellableEvent) {
|
||||
if (priority > highestReachedPriority) {
|
||||
CancellableEvent ce = (CancellableEvent) event;
|
||||
cancel = ce.isCancelled();
|
||||
highestReachedPriority = priority;
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO Remove. This is also redundant. The listeners are always called in order, the event is always being modified by each listener. The last listener therefore has the last decision on the cancellation.
|
||||
if (event instanceof CancellableEvent) {
|
||||
CancellableEvent ce = (CancellableEvent) event;
|
||||
ce.setCancelled(cancel);
|
||||
}
|
||||
}
|
||||
}
|
||||
PEEventManager.EVENT_MANAGER_LEGACY.callEvent(event, highestReachedPriority);
|
||||
@@ -105,6 +94,30 @@ class EventManagerModern {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister the dynamic packet event listener.
|
||||
*
|
||||
* @param listener {@link PacketListenerAbstract}
|
||||
*/
|
||||
public synchronized void unregisterListener(final PacketListenerAbstract listener) {
|
||||
byte priority = listener.getPriority().getId();
|
||||
HashSet<PacketListenerAbstract> listenerSet = listenersMap.get(priority);
|
||||
if (listenerSet != null) {
|
||||
listenerSet.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister multiple dynamic packet event listeners with one method.
|
||||
*
|
||||
* @param listeners {@link PacketListenerAbstract}
|
||||
*/
|
||||
public synchronized void unregisterListeners(PacketListenerAbstract... listeners) {
|
||||
for (PacketListenerAbstract listener : listeners) {
|
||||
unregisterListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister all dynamic packet event listeners.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ public class EarlyChannelInjectorLegacy implements EarlyInjector {
|
||||
List<Object> networkManagers = NMSUtils.getNetworkManagers();
|
||||
synchronized (networkManagers) {
|
||||
for (Object networkManager : networkManagers) {
|
||||
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager));
|
||||
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager), NMSUtils.networkManagerClass);
|
||||
Channel channel = (Channel) networkManagerWrapper.readObject(0, NMSUtils.nettyChannelClass);
|
||||
if (channel == null) {
|
||||
continue;
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ public class EarlyChannelInjectorModern implements EarlyInjector {
|
||||
List<Object> networkManagers = NMSUtils.getNetworkManagers();
|
||||
synchronized (networkManagers) {
|
||||
for (Object networkManager : networkManagers) {
|
||||
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager));
|
||||
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager), NMSUtils.networkManagerClass);
|
||||
Channel channel = (Channel) networkManagerWrapper.readObject(0, NMSUtils.nettyChannelClass);
|
||||
if (channel == null) {
|
||||
continue;
|
||||
|
||||
@@ -39,6 +39,7 @@ public class PacketType {
|
||||
*/
|
||||
public static final byte INVALID = -128;
|
||||
public static final Map<Class<?>, Byte> packetIDMap = new IdentityHashMap<>();
|
||||
private static final boolean isNine = ServerVersion.getVersion().isNewerThanOrEquals(ServerVersion.v_1_9);
|
||||
|
||||
private static void insertPacketID(Class<?> cls, byte packetID) {
|
||||
if (cls != null) {
|
||||
@@ -286,10 +287,7 @@ public class PacketType {
|
||||
* @return Has the client placed a block?
|
||||
*/
|
||||
public static boolean isBlockPlace(final byte packetID) {
|
||||
final ServerVersion version = PacketEvents.get().getServerUtils().getVersion();
|
||||
return version.isNewerThan(ServerVersion.v_1_8_8) ?
|
||||
packetID == PacketType.Play.Client.USE_ITEM
|
||||
: packetID == PacketType.Play.Client.BLOCK_PLACE;
|
||||
return isNine ? packetID == PacketType.Play.Client.USE_ITEM : packetID == PacketType.Play.Client.BLOCK_PLACE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -84,9 +84,9 @@ public final class WrappedPacketOutEntityVelocity extends WrappedPacketEntityAbs
|
||||
|
||||
public void setVelocity(Vector3d velocity) {
|
||||
if (packet != null) {
|
||||
writeInt(1, (int) (velocity.x));
|
||||
writeInt(2, (int) (velocity.y));
|
||||
writeInt(3, (int) (velocity.z));
|
||||
writeInt(1, (int) (velocity.x * 8000.0));
|
||||
writeInt(2, (int) (velocity.y * 8000.0));
|
||||
writeInt(3, (int) (velocity.z * 8000.0));
|
||||
}
|
||||
else {
|
||||
this.velocityX = velocity.x;
|
||||
|
||||
+38
-24
@@ -54,7 +54,6 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getChunkX() {
|
||||
return readInt(v_1_17 ? 1 : 0);
|
||||
}
|
||||
@@ -71,24 +70,11 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
||||
writeInt(v_1_17 ? 2: 1, chunkZ);
|
||||
}
|
||||
|
||||
public Optional<BitSet> getPrimaryBitMaskBitSet() {
|
||||
public BitSet getBitSet() {
|
||||
if (v_1_17) {
|
||||
return Optional.of(readObject(0, BitSet.class));
|
||||
return readObject(0, BitSet.class);
|
||||
}
|
||||
else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPrimaryBitMaskBitSet(BitSet bitMaskBitSet) {
|
||||
if (v_1_17) {
|
||||
writeObject(0, bitMaskBitSet);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Optional<Integer> getPrimaryBitMap() {
|
||||
return getPrimaryBitMask();
|
||||
return BitSet.valueOf(new long[]{getPrimaryBitMask()});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -96,22 +82,44 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
||||
setPrimaryBitMask(primaryBitMask);
|
||||
}
|
||||
|
||||
public Optional<Integer> getPrimaryBitMask() {
|
||||
if (v_1_17) {
|
||||
@Deprecated
|
||||
public Integer getPrimaryBitMask() {
|
||||
if (v_1_17) { // Possible lossy conversion
|
||||
long[] bitset = readObject(0, BitSet.class).toLongArray();
|
||||
return Optional.of(bitset.length == 0 ? 0 : (int) bitset[0]);
|
||||
return bitset.length == 0 ? 0 : (int) bitset[0];
|
||||
}
|
||||
if (v_1_8_x) {
|
||||
if (nmsChunkMap == null) {
|
||||
nmsChunkMap = readObject(0, chunkMapClass);
|
||||
}
|
||||
WrappedPacket nmsChunkMapWrapper = new WrappedPacket(new NMSPacket(nmsChunkMap));
|
||||
return Optional.of(nmsChunkMapWrapper.readInt(0));
|
||||
return nmsChunkMapWrapper.readInt(0);
|
||||
} else {
|
||||
return Optional.of(readInt(2));
|
||||
return readInt(2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bitSet Bitset that can hold multiple integer values to support the expanded world height on
|
||||
* 1.17 and newer servers. This is due to 1.17 needing to support up to 127 chunk sections
|
||||
* (2032 blocks) and an integer only being able to hold 32 bits to represent 32 chunk sections
|
||||
*/
|
||||
public void setPrimaryBitMask(BitSet bitSet) {
|
||||
if (v_1_17) {
|
||||
writeObject(0, bitSet);
|
||||
}
|
||||
setPrimaryBitMask((int) bitSet.toLongArray()[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param primaryBitMask Integer that determines which chunk sections the server is sending
|
||||
*
|
||||
* @deprecated Possible lossy conversion on 1.17 servers that could result in the client only reading 32
|
||||
* out of the total possible 127 chunk sections. Safe to use on 1.16 and below servers
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPrimaryBitMask(int primaryBitMask) {
|
||||
if (v_1_17) {
|
||||
writeObject(0, BitSet.valueOf(new long[] {primaryBitMask}));
|
||||
@@ -134,7 +142,10 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO Confirm if 1.17 support is possible
|
||||
/**
|
||||
*
|
||||
* @return Whether the packet overwrites the entire chunk column or just the sections being sent
|
||||
*/
|
||||
public Optional<Boolean> isGroundUpContinuous() {
|
||||
if (v_1_17) {
|
||||
return Optional.empty();
|
||||
@@ -142,7 +153,10 @@ public class WrappedPacketOutMapChunk extends WrappedPacket {
|
||||
return Optional.of(readBoolean(0));
|
||||
}
|
||||
|
||||
//TODO Confirm if 1.17 support is possible
|
||||
/**
|
||||
*
|
||||
* @param groundUpContinuous Whether the packet overwrites the entire chunk column or just the sections being sent
|
||||
*/
|
||||
public void setGroundUpContinuous(boolean groundUpContinuous) {
|
||||
if (v_1_17) {
|
||||
return;
|
||||
|
||||
+38
-34
@@ -19,33 +19,33 @@
|
||||
package io.github.retrooper.packetevents.packetwrappers.play.out.setcooldown;
|
||||
|
||||
import io.github.retrooper.packetevents.packettype.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.SendableWrapper;
|
||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
//TODO TEST
|
||||
public class WrappedPacketOutSetCooldown extends WrappedPacket implements SendableWrapper {
|
||||
private static final Map<Short, EntityType> ID_MAP = new IdentityHashMap<>();
|
||||
private static Constructor<?> packetConstructor;
|
||||
private EntityType type;
|
||||
private Object nmsItem;
|
||||
private int cooldownTicks;
|
||||
|
||||
public WrappedPacketOutSetCooldown(EntityType type, int cooldownTicks) {
|
||||
this.type = type;
|
||||
public WrappedPacketOutSetCooldown(NMSPacket packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutSetCooldown(Object nmsItem, int cooldownTicks) {
|
||||
this.nmsItem = nmsItem;
|
||||
this.cooldownTicks = cooldownTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void load() {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
ID_MAP.put(type.getTypeId(), type);
|
||||
}
|
||||
try {
|
||||
packetConstructor = PacketTypeClasses.Play.Server.SET_COOLDOWN.getConstructor(NMSUtils.nmsItemClass, int.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
@@ -53,23 +53,38 @@ public class WrappedPacketOutSetCooldown extends WrappedPacket implements Sendab
|
||||
}
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
if (packet != null) {
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return version.isNewerThan(ServerVersion.v_1_8_8);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
try {
|
||||
Object nmsItem = readObject(0, NMSUtils.nmsItemClass);
|
||||
short nmsItemID = (short) NMSUtils.getNMSItemId(nmsItem);
|
||||
return ID_MAP.get(nmsItemID);
|
||||
Object nmsItemStack = NMSUtils.itemStackConstructor.newInstance(nmsItem);
|
||||
return NMSUtils.toBukkitItemStack(nmsItemStack);
|
||||
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
public Object getNmsItem() {
|
||||
return nmsItem;
|
||||
}
|
||||
|
||||
public void setNMSItemStack(Object type) {
|
||||
if (packet != null) {
|
||||
write(NMSUtils.nmsItemClass, 0, type);
|
||||
} else {
|
||||
return type;
|
||||
this.nmsItem = type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setType(EntityType type) {
|
||||
if (packet != null) {
|
||||
Object nmsItem = NMSUtils.getNMSItemById(type.getTypeId());
|
||||
write(NMSUtils.nmsItemClass, 0, nmsItem);
|
||||
} else {
|
||||
this.type = type;
|
||||
}
|
||||
@Override
|
||||
public Object asNMSPacket() throws Exception {
|
||||
return packetConstructor.newInstance(nmsItem, getCooldownTicks());
|
||||
}
|
||||
|
||||
public int getCooldownTicks() {
|
||||
@@ -87,15 +102,4 @@ public class WrappedPacketOutSetCooldown extends WrappedPacket implements Sendab
|
||||
this.cooldownTicks = cooldownTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return version.isNewerThan(ServerVersion.v_1_8_8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object asNMSPacket() throws Exception {
|
||||
Object nmsItem = NMSUtils.getNMSItemById(getType().getTypeId());
|
||||
return packetConstructor.newInstance(nmsItem, getCooldownTicks());
|
||||
}
|
||||
}
|
||||
+12
-4
@@ -33,7 +33,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
//TODO Test wrapper
|
||||
public class WrappedPacketOutWindowItems extends WrappedPacket implements SendableWrapper {
|
||||
private static boolean v_1_17;
|
||||
private static boolean v_1_17, v_1_17_1;
|
||||
private static Object nonNullListInstance;
|
||||
private static Class<?> nonNullListClass;
|
||||
private static Constructor<?> packetConstructor;
|
||||
@@ -52,12 +52,20 @@ public class WrappedPacketOutWindowItems extends WrappedPacket implements Sendab
|
||||
@Override
|
||||
protected void load() {
|
||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||
v_1_17_1 = version.isNewerThanOrEquals(ServerVersion.v_1_17_1);
|
||||
try {
|
||||
if (v_1_17) {
|
||||
nonNullListClass = NMSUtils.getNMClassWithoutException("core.NonNullList");
|
||||
Constructor<?> nonNullListConstructor = nonNullListClass.getConstructor();
|
||||
nonNullListConstructor.setAccessible(true);
|
||||
nonNullListInstance = nonNullListConstructor.newInstance();
|
||||
if (v_1_17_1) {
|
||||
Constructor<?> nonNullListConstructor = nonNullListClass.getDeclaredConstructors()[0];
|
||||
nonNullListConstructor.setAccessible(true);
|
||||
nonNullListInstance = nonNullListConstructor.newInstance(new ArrayList<>(), null);
|
||||
}
|
||||
else {
|
||||
Constructor<?> nonNullListConstructor = nonNullListClass.getDeclaredConstructor();
|
||||
nonNullListConstructor.setAccessible(true);
|
||||
nonNullListInstance = nonNullListConstructor.newInstance();
|
||||
}
|
||||
packetConstructor = PacketTypeClasses.Play.Server.WINDOW_ITEMS.getConstructor(int.class, nonNullListClass);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -51,12 +51,12 @@ public final class NMSUtils {
|
||||
private static final ThreadLocal<Random> randomThreadLocal = ThreadLocal.withInitial(Random::new);
|
||||
public static boolean legacyNettyImportMode;
|
||||
public static ServerVersion version;
|
||||
public static Constructor<?> blockPosConstructor, minecraftKeyConstructor, vec3DConstructor, dataWatcherConstructor, packetDataSerializerConstructor;
|
||||
public static Constructor<?> blockPosConstructor, minecraftKeyConstructor, vec3DConstructor, dataWatcherConstructor, packetDataSerializerConstructor, itemStackConstructor;
|
||||
public static Class<?> mobEffectListClass, nmsEntityClass, minecraftServerClass, craftWorldClass, playerInteractManagerClass, entityPlayerClass, playerConnectionClass, craftServerClass,
|
||||
craftPlayerClass, serverConnectionClass, craftEntityClass, nmsItemStackClass, networkManagerClass, nettyChannelClass, gameProfileClass, iChatBaseComponentClass,
|
||||
blockPosClass, vec3DClass, channelFutureClass, blockClass, iBlockDataClass, nmsWorldClass, craftItemStackClass,
|
||||
soundEffectClass, minecraftKeyClass, chatSerializerClass, craftMagicNumbersClass, worldSettingsClass, worldServerClass, dataWatcherClass,
|
||||
dedicatedServerClass, entityHumanClass, packetDataSerializerClass, byteBufClass, dimensionManagerClass, nmsItemClass, movingObjectPositionBlockClass, boundingBoxClass,
|
||||
dedicatedServerClass, entityHumanClass, packetDataSerializerClass, byteBufClass, dimensionManagerClass, nmsItemClass, iMaterialClass, movingObjectPositionBlockClass, boundingBoxClass,
|
||||
tileEntityCommandClass;
|
||||
public static Class<? extends Enum<?>> enumDirectionClass, enumHandClass, enumGameModeClass, enumDifficultyClass, tileEntityCommandTypeClass;
|
||||
public static Method getBlockPosX, getBlockPosY, getBlockPosZ;
|
||||
@@ -190,6 +190,10 @@ public final class NMSUtils {
|
||||
if (nmsItemClass == null) {
|
||||
nmsItemClass = getNMClassWithoutException("world.item.Item");
|
||||
}
|
||||
iMaterialClass = getNMSClassWithoutException("IMaterial");
|
||||
if (iMaterialClass == null) {
|
||||
iMaterialClass = getNMClassWithoutException("world.level.IMaterial");
|
||||
}
|
||||
dedicatedServerClass = getNMSClassWithoutException("DedicatedServer");
|
||||
if (dedicatedServerClass == null) {
|
||||
dedicatedServerClass = getNMClassWithoutException("server.dedicated.DedicatedServer");
|
||||
@@ -262,6 +266,10 @@ public final class NMSUtils {
|
||||
if (dataWatcherClass != null) {
|
||||
dataWatcherConstructor = dataWatcherClass.getConstructor(nmsEntityClass);
|
||||
}
|
||||
|
||||
if (nmsItemStackClass != null && iMaterialClass != null) {
|
||||
itemStackConstructor = nmsItemStackClass.getDeclaredConstructor(iMaterialClass);
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -526,7 +534,7 @@ public final class NMSUtils {
|
||||
if (networkManager == null) {
|
||||
return null;
|
||||
}
|
||||
WrappedPacket wrapper = new WrappedPacket(new NMSPacket(networkManager));
|
||||
WrappedPacket wrapper = new WrappedPacket(new NMSPacket(networkManager), networkManagerClass);
|
||||
return wrapper.readObject(0, nettyChannelClass);
|
||||
}
|
||||
|
||||
@@ -719,9 +727,9 @@ public final class NMSUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Object generateDataWatcher(Entity entity) {
|
||||
public static Object generateDataWatcher(Object nmsEntity) {
|
||||
try {
|
||||
return dataWatcherConstructor.newInstance(entity);
|
||||
return dataWatcherConstructor.newInstance(nmsEntity);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ public enum ClientVersion {
|
||||
*
|
||||
* @return Is resolved
|
||||
*/
|
||||
public boolean isResoled() {
|
||||
public boolean isResolved() {
|
||||
return this != TEMP_UNRESOLVED && this != UNRESOLVED;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,8 @@ public final class PlayerUtils {
|
||||
return ClientVersion.UNKNOWN;
|
||||
}
|
||||
ClientVersion version = clientVersionsMap.get(player.getAddress());
|
||||
if (version == null) {
|
||||
// If a player's version didn't resolve, we should try and resolve it again
|
||||
if (version == null || !version.isResolved()) {
|
||||
//Prioritize asking ViaVersion and ProtocolSupport as they modify the protocol version in the packet we access it from.
|
||||
if (VersionLookupUtils.isDependencyAvailable()) {
|
||||
try {
|
||||
|
||||
@@ -89,7 +89,7 @@ public enum ServerVersion {
|
||||
* If PacketEvents has already attempted resolving, return the cached version.
|
||||
* If PacketEvents hasn't already attempted resolving, it will resolve it, cache it and return the version.
|
||||
*
|
||||
* @return Server Version. (possibly cached)
|
||||
* @return Server Version. (always cached)
|
||||
*/
|
||||
public static ServerVersion getVersion() {
|
||||
if (cachedVersion == null) {
|
||||
|
||||
@@ -160,12 +160,7 @@ public class Vector3d {
|
||||
*/
|
||||
@Override
|
||||
public Vector3d clone() {
|
||||
try {
|
||||
super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
return new Vector3d(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public Vector3d add(Vector3d target) {
|
||||
|
||||
@@ -151,13 +151,8 @@ public class Vector3f {
|
||||
* @return Clone.
|
||||
*/
|
||||
@Override
|
||||
public Vector3d clone() {
|
||||
try {
|
||||
super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
public Vector3f clone() {
|
||||
return new Vector3f(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -161,12 +161,7 @@ public class Vector3i {
|
||||
*/
|
||||
@Override
|
||||
public Vector3i clone() {
|
||||
try {
|
||||
super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
return new Vector3i(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user