Added 1.13.2 support, made backwards premium

This commit is contained in:
libraryaddict
2020-02-13 19:47:02 +13:00
parent 7fdbea1185
commit 1fcefbcdcc
49 changed files with 1114 additions and 539 deletions

View File

@@ -29,7 +29,6 @@ public class PacketsHandler {
packetHandlers.add(new PacketHandlerAnimation());
packetHandlers.add(new PacketHandlerAttributes());
packetHandlers.add(new PacketHandlerBed());
packetHandlers.add(new PacketHandlerCollect());
packetHandlers.add(new PacketHandlerEntityStatus());
packetHandlers.add(new PacketHandlerEquipment(this));

View File

@@ -1,28 +0,0 @@
package me.libraryaddict.disguise.utilities.packets.packethandlers;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
/**
* Created by libraryaddict on 3/01/2019.
*/
public class PacketHandlerBed implements IPacketHandler {
@Override
public PacketType[] getHandledPackets() {
return new PacketType[]{};
}
@Override
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
Entity entity) {
// If the entity is going into a bed, stop everything but players from doing this
if (!disguise.getType().isPlayer()) {
packets.clear();
}
}
}

View File

@@ -225,7 +225,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
packets.addPacket(spawnPlayer);
if (ReflectionManager.isSupported(NmsVersion.v1_15)) {
if (NmsVersion.v1_15.isSupported()) {
PacketContainer metaPacket = ProtocolLibrary.getProtocolManager()
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entityId, newWatcher, true)
.createPacket(entityId, newWatcher, true);
@@ -314,7 +314,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
.createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity),
disguise.getWatcher());
if (ReflectionManager.isSupported(NmsVersion.v1_15)) {
if (NmsVersion.v1_15.isSupported()) {
PacketContainer metaPacket = ProtocolLibrary.getProtocolManager()
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, disguisedEntity.getEntityId(),
newWatcher, true).createPacket(disguisedEntity.getEntityId(), newWatcher, true);
@@ -348,14 +348,26 @@ public class PacketHandlerSpawn implements IPacketHandler {
data = ((((int) loc.getYaw() % 360) + 720 + 45) / 90) % 4;
}
Object entityType = ReflectionManager.getEntityType(disguise.getType().getEntityType());
PacketContainer spawnEntity;
Object[] params = new Object[]{disguisedEntity.getEntityId(), disguisedEntity.getUniqueId(), x, y, z,
loc.getPitch(), loc.getYaw(), entityType, data,
ReflectionManager.getVec3D(disguisedEntity.getVelocity())};
if (NmsVersion.v1_14.isSupported()) {
Object entityType = ReflectionManager.getEntityType(disguise.getType().getEntityType());
Object[] params = new Object[]{disguisedEntity.getEntityId(), disguisedEntity.getUniqueId(), x, y, z,
loc.getPitch(), loc.getYaw(), entityType, data,
ReflectionManager.getVec3D(disguisedEntity.getVelocity())};
spawnEntity = ProtocolLibrary.getProtocolManager()
.createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, params).createPacket(params);
} else {
int objectId = disguise.getType().getObjectId();
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
spawnEntity = ProtocolLibrary.getProtocolManager()
.createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, objectId, data)
.createPacket(nmsEntity, objectId, data);
}
PacketContainer spawnEntity = ProtocolLibrary.getProtocolManager()
.createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, params).createPacket(params);
packets.addPacket(spawnEntity);
// If it's not the same type, then highly likely they have different velocity settings which we'd want to