Convert all the packet ids to use the new packettype

This commit is contained in:
libraryaddict 2013-12-08 03:30:30 +13:00
parent af51c6def0
commit a8b5c44a72
5 changed files with 111 additions and 133 deletions

@ -41,6 +41,11 @@
<name>Comphenix Repository</name> <name>Comphenix Repository</name>
<url>http://repo.comphenix.net/content/groups/public</url> <url>http://repo.comphenix.net/content/groups/public</url>
</repository> </repository>
<repository>
<id>comphenix-rep</id>
<name>Comphenix Snapshot Repository</name>
<url>http://repo.comphenix.net/content/repositories/snapshots/</url>
</repository>
<repository> <repository>
<id>bukkit-repo</id> <id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url> <url>http://repo.bukkit.org/content/groups/public</url>

@ -22,6 +22,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.Packets; import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
@ -210,7 +211,7 @@ public abstract class Disguise {
if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) { if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) {
PacketContainer lookPacket = null; PacketContainer lookPacket = null;
if (getType() == DisguiseType.WITHER_SKULL) { if (getType() == DisguiseType.WITHER_SKULL) {
lookPacket = new PacketContainer(Packets.Server.ENTITY_LOOK); lookPacket = new PacketContainer(PacketType.Play.Server.ENTITY_LOOK);
StructureModifier<Object> mods = lookPacket.getModifier(); StructureModifier<Object> mods = lookPacket.getModifier();
mods.write(0, getEntity().getEntityId()); mods.write(0, getEntity().getEntityId());
Location loc = getEntity().getLocation(); Location loc = getEntity().getLocation();
@ -233,7 +234,7 @@ public abstract class Disguise {
try { try {
Field ping = ReflectionManager.getNmsClass("EntityPlayer").getField("ping"); Field ping = ReflectionManager.getNmsClass("EntityPlayer").getField("ping");
for (Player player : getPerverts()) { for (Player player : getPerverts()) {
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_VELOCITY); PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_VELOCITY);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
if (getEntity() == player) { if (getEntity() == player) {
if (!isSelfDisguiseVisible()) { if (!isSelfDisguiseVisible()) {
@ -260,7 +261,7 @@ public abstract class Disguise {
} }
// If we need to send more packets because else it still 'sinks' // If we need to send more packets because else it still 'sinks'
if (sendMovementPacket) { if (sendMovementPacket) {
PacketContainer packet = new PacketContainer(Packets.Server.REL_ENTITY_MOVE); PacketContainer packet = new PacketContainer(PacketType.Play.Server.REL_ENTITY_MOVE);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, getEntity().getEntityId()); mods.write(0, getEntity().getEntityId());
for (Player player : getPerverts()) { for (Player player : getPerverts()) {

@ -12,6 +12,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.EntityEquipment;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.Packets; import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
@ -232,7 +233,7 @@ public class FlagWatcher {
Object value = entityValues.get(data); Object value = entityValues.get(data);
List<WrappedWatchableObject> list = new ArrayList<WrappedWatchableObject>(); List<WrappedWatchableObject> list = new ArrayList<WrappedWatchableObject>();
list.add(new WrappedWatchableObject(data, value)); list.add(new WrappedWatchableObject(data, value));
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_METADATA); PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, entity.getEntityId()); mods.write(0, entity.getEntityId());
packet.getWatchableCollectionModifier().write(0, list); packet.getWatchableCollectionModifier().write(0, list);
@ -316,7 +317,7 @@ public class FlagWatcher {
slot++; slot++;
if (slot > 4) if (slot > 4)
slot = 0; slot = 0;
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_EQUIPMENT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, getDisguise().getEntity().getEntityId()); mods.write(0, getDisguise().getEntity().getEntityId());
mods.write(1, slot); mods.write(1, slot);

@ -23,6 +23,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.Packets; import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.ProtocolManager;
@ -282,7 +283,7 @@ public class DisguiseUtilities {
public static void removeSelfDisguise(Player player) { public static void removeSelfDisguise(Player player) {
if (selfDisguisesIds.containsKey(player.getEntityId())) { if (selfDisguisesIds.containsKey(player.getEntityId())) {
// Send a packet to destroy the fake entity // Send a packet to destroy the fake entity
PacketContainer packet = new PacketContainer(Packets.Server.DESTROY_ENTITY); PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
packet.getModifier().write(0, new int[] { selfDisguisesIds.get(player.getEntityId()) }); packet.getModifier().write(0, new int[] { selfDisguisesIds.get(player.getEntityId()) });
try { try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
@ -313,7 +314,7 @@ public class DisguiseUtilities {
player, player,
ProtocolLibrary ProtocolLibrary
.getProtocolManager() .getProtocolManager()
.createPacketConstructor(Packets.Server.ENTITY_METADATA, player.getEntityId(), .createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),
WrappedDataWatcher.getEntityWatcher(player), true) WrappedDataWatcher.getEntityWatcher(player), true)
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true)); .createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
} catch (Exception ex) { } catch (Exception ex) {
@ -352,11 +353,11 @@ public class DisguiseUtilities {
.getNmsEntity(player)); .getNmsEntity(player));
ProtocolManager manager = ProtocolLibrary.getProtocolManager(); ProtocolManager manager = ProtocolLibrary.getProtocolManager();
// Send the player a packet with himself being spawned // Send the player a packet with himself being spawned
manager.sendServerPacket(player, manager.createPacketConstructor(Packets.Server.NAMED_ENTITY_SPAWN, player) manager.sendServerPacket(player, manager.createPacketConstructor(PacketType.Play.Server.NAMED_ENTITY_SPAWN, player)
.createPacket(player)); .createPacket(player));
manager.sendServerPacket( manager.sendServerPacket(
player, player,
manager.createPacketConstructor(Packets.Server.ENTITY_METADATA, player.getEntityId(), manager.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),
WrappedDataWatcher.getEntityWatcher(player), true).createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true).createPacket(player.getEntityId(),
WrappedDataWatcher.getEntityWatcher(player), true)); WrappedDataWatcher.getEntityWatcher(player), true));
@ -373,7 +374,7 @@ public class DisguiseUtilities {
Vector velocity = player.getVelocity(); Vector velocity = player.getVelocity();
manager.sendServerPacket( manager.sendServerPacket(
player, player,
manager.createPacketConstructor(Packets.Server.ENTITY_VELOCITY, player.getEntityId(), velocity.getX(), manager.createPacketConstructor(PacketType.Play.Server.ENTITY_VELOCITY, player.getEntityId(), velocity.getX(),
velocity.getY(), velocity.getZ()).createPacket(player.getEntityId(), velocity.getX(), velocity.getY(), velocity.getZ()).createPacket(player.getEntityId(), velocity.getX(),
velocity.getY(), velocity.getZ())); velocity.getY(), velocity.getZ()));
} }
@ -381,11 +382,11 @@ public class DisguiseUtilities {
// Why the hell would he even need this. Meh. // Why the hell would he even need this. Meh.
if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) { if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
manager.sendServerPacket(player, manager.sendServerPacket(player,
manager.createPacketConstructor(Packets.Server.ATTACH_ENTITY, 0, player, player.getVehicle()) manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player, player.getVehicle())
.createPacket(0, player, player.getVehicle())); .createPacket(0, player, player.getVehicle()));
} else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) { } else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) {
manager.sendServerPacket(player, manager.sendServerPacket(player,
manager.createPacketConstructor(Packets.Server.ATTACH_ENTITY, 0, player.getPassenger(), player) manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player.getPassenger(), player)
.createPacket(0, player.getPassenger(), player)); .createPacket(0, player.getPassenger(), player));
} }
@ -400,7 +401,7 @@ public class DisguiseUtilities {
if (item != null && item.getType() != Material.AIR) { if (item != null && item.getType() != Material.AIR) {
manager.sendServerPacket(player, manager.sendServerPacket(player,
manager.createPacketConstructor(Packets.Server.ENTITY_EQUIPMENT, player.getEntityId(), i, item) manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EQUIPMENT, player.getEntityId(), i, item)
.createPacket(player.getEntityId(), i, item)); .createPacket(player.getEntityId(), i, item));
} }
} }
@ -409,7 +410,7 @@ public class DisguiseUtilities {
if (player.isSleeping()) { if (player.isSleeping()) {
manager.sendServerPacket( manager.sendServerPacket(
player, player,
manager.createPacketConstructor(Packets.Server.ENTITY_LOCATION_ACTION, player, 0, loc.getBlockX(), manager.createPacketConstructor(PacketType.Play.Server.BED, player, 0, loc.getBlockX(),
loc.getBlockY(), loc.getBlockZ()).createPacket(player, 0, loc.getBlockX(), loc.getBlockY(), loc.getBlockY(), loc.getBlockZ()).createPacket(player, 0, loc.getBlockX(), loc.getBlockY(),
loc.getBlockZ())); loc.getBlockZ()));
} }
@ -419,7 +420,7 @@ public class DisguiseUtilities {
while (iterator.hasNext()) { while (iterator.hasNext()) {
PotionEffect potionEffect = (PotionEffect) iterator.next(); PotionEffect potionEffect = (PotionEffect) iterator.next();
manager.sendServerPacket(player, manager.sendServerPacket(player,
manager.createPacketConstructor(Packets.Server.MOB_EFFECT, player.getEntityId(), potionEffect) manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), potionEffect)
.createPacket(player.getEntityId(), potionEffect)); .createPacket(player.getEntityId(), potionEffect));
} }
} catch (Exception ex) { } catch (Exception ex) {

@ -33,7 +33,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.comphenix.protocol.Packets; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ConnectionSide; import com.comphenix.protocol.events.ConnectionSide;
@ -59,18 +59,21 @@ public class PacketsManager {
public static void addPacketListeners(JavaPlugin libsDisguises) { public static void addPacketListeners(JavaPlugin libsDisguises) {
ProtocolManager manager = ProtocolLibrary.getProtocolManager(); ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(libsDisguises, ConnectionSide.SERVER_SIDE, ListenerPriority.HIGH, manager.addPacketListener(new PacketAdapter(libsDisguises, ListenerPriority.HIGH,
Packets.Server.NAMED_ENTITY_SPAWN, Packets.Server.ENTITY_METADATA, Packets.Server.ARM_ANIMATION, PacketType.Play.Server.NAMED_ENTITY_SPAWN, PacketType.Play.Server.ENTITY_METADATA,
Packets.Server.REL_ENTITY_MOVE_LOOK, Packets.Server.ENTITY_LOOK, Packets.Server.ENTITY_TELEPORT, PacketType.Play.Server.ANIMATION, PacketType.Play.Server.ENTITY_MOVE_LOOK, PacketType.Play.Server.ENTITY_LOOK,
Packets.Server.ADD_EXP_ORB, Packets.Server.VEHICLE_SPAWN, Packets.Server.MOB_SPAWN, PacketType.Play.Server.ENTITY_TELEPORT, PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB,
Packets.Server.ENTITY_PAINTING, Packets.Server.COLLECT, Packets.Server.UPDATE_ATTRIBUTES, PacketType.Play.Server.SPAWN_ENTITY, PacketType.Play.Server.SPAWN_ENTITY_LIVING,
Packets.Server.ENTITY_EQUIPMENT, Packets.Server.BED, Packets.Server.ENTITY_STATUS) { PacketType.Play.Server.SPAWN_ENTITY_PAINTING, PacketType.Play.Server.COLLECT,
PacketType.Play.Server.UPDATE_ATTRIBUTES, PacketType.Play.Server.ENTITY_EQUIPMENT, PacketType.Play.Server.BED,
PacketType.Play.Server.ENTITY_STATUS) {
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
final Player observer = event.getPlayer(); final Player observer = event.getPlayer();
// First get the entity, the one sending this packet // First get the entity, the one sending this packet
StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld()); StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld());
org.bukkit.entity.Entity entity = entityModifer.read((Packets.Server.COLLECT == event.getPacketID() ? 1 : 0)); org.bukkit.entity.Entity entity = entityModifer.read((PacketType.Play.Server.COLLECT == event.getPacketType() ? 1
: 0));
// If the entity is the same as the sender. Don't disguise! // If the entity is the same as the sender. Don't disguise!
// Prevents problems and there is no advantage to be gained. // Prevents problems and there is no advantage to be gained.
if (entity == observer) if (entity == observer)
@ -103,8 +106,7 @@ public class PacketsManager {
// Now add a client listener to cancel them interacting with uninteractable disguised entitys. // Now add a client listener to cancel them interacting with uninteractable disguised entitys.
// You ain't supposed to be allowed to 'interact' with a item that cannot be clicked. // You ain't supposed to be allowed to 'interact' with a item that cannot be clicked.
// Because it kicks you for hacking. // Because it kicks you for hacking.
manager.addPacketListener(new PacketAdapter(libsDisguises, ConnectionSide.CLIENT_SIDE, ListenerPriority.NORMAL, manager.addPacketListener(new PacketAdapter(libsDisguises, ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
Packets.Client.USE_ENTITY) {
@Override @Override
public void onPacketReceiving(PacketEvent event) { public void onPacketReceiving(PacketEvent event) {
try { try {
@ -145,7 +147,7 @@ public class PacketsManager {
} }
} }
if (item == null || item.getType() == Material.AIR) { if (item == null || item.getType() == Material.AIR) {
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_EQUIPMENT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, disguisedEntity.getEntityId()); mods.write(0, disguisedEntity.getEntityId());
mods.write(1, nmsSlot); mods.write(1, nmsSlot);
@ -163,7 +165,7 @@ public class PacketsManager {
if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) { if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) {
spawnPackets[0] = new PacketContainer(Packets.Server.ADD_EXP_ORB); spawnPackets[0] = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB);
StructureModifier<Object> mods = spawnPackets[0].getModifier(); StructureModifier<Object> mods = spawnPackets[0].getModifier();
mods.write(0, disguisedEntity.getEntityId()); mods.write(0, disguisedEntity.getEntityId());
mods.write(1, (int) Math.floor(loc.getX() * 32)); mods.write(1, (int) Math.floor(loc.getX() * 32));
@ -172,7 +174,7 @@ public class PacketsManager {
mods.write(4, 1); mods.write(4, 1);
} else if (disguise.getType() == DisguiseType.PAINTING) { } else if (disguise.getType() == DisguiseType.PAINTING) {
spawnPackets[0] = new PacketContainer(Packets.Server.ENTITY_PAINTING); spawnPackets[0] = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_PAINTING);
StructureModifier<Object> mods = spawnPackets[0].getModifier(); StructureModifier<Object> mods = spawnPackets[0].getModifier();
mods.write(0, disguisedEntity.getEntityId()); mods.write(0, disguisedEntity.getEntityId());
mods.write(1, loc.getBlockX()); mods.write(1, loc.getBlockX());
@ -183,7 +185,7 @@ public class PacketsManager {
mods.write(5, ReflectionManager.getEnumArt(Art.values()[id])); mods.write(5, ReflectionManager.getEnumArt(Art.values()[id]));
// Make the teleport packet to make it visible.. // Make the teleport packet to make it visible..
spawnPackets[1] = new PacketContainer(Packets.Server.ENTITY_TELEPORT); spawnPackets[1] = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
mods = spawnPackets[1].getModifier(); mods = spawnPackets[1].getModifier();
mods.write(0, disguisedEntity.getEntityId()); mods.write(0, disguisedEntity.getEntityId());
mods.write(1, (int) Math.floor(loc.getX() * 32D)); mods.write(1, (int) Math.floor(loc.getX() * 32D));
@ -194,7 +196,7 @@ public class PacketsManager {
} else if (disguise.getType().isPlayer()) { } else if (disguise.getType().isPlayer()) {
spawnPackets[0] = new PacketContainer(Packets.Server.NAMED_ENTITY_SPAWN); spawnPackets[0] = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
StructureModifier<String> stringMods = spawnPackets[0].getStrings(); StructureModifier<String> stringMods = spawnPackets[0].getStrings();
if (stringMods.size() > 0) { if (stringMods.size() > 0) {
for (int i = 0; i < stringMods.size(); i++) { for (int i = 0; i < stringMods.size(); i++) {
@ -225,7 +227,7 @@ public class PacketsManager {
DisguiseValues values = DisguiseValues.getDisguiseValues(disguise.getType()); DisguiseValues values = DisguiseValues.getDisguiseValues(disguise.getType());
Vector vec = disguisedEntity.getVelocity(); Vector vec = disguisedEntity.getVelocity();
spawnPackets[0] = new PacketContainer(Packets.Server.MOB_SPAWN); spawnPackets[0] = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
StructureModifier<Object> mods = spawnPackets[0].getModifier(); StructureModifier<Object> mods = spawnPackets[0].getModifier();
mods.write(0, disguisedEntity.getEntityId()); mods.write(0, disguisedEntity.getEntityId());
mods.write(1, (int) disguise.getType().getEntityType().getTypeId()); mods.write(1, (int) disguise.getType().getEntityType().getTypeId());
@ -277,12 +279,13 @@ public class PacketsManager {
data = -data; data = -data;
}*/ }*/
spawnPackets[0] = ProtocolLibrary.getProtocolManager() spawnPackets[0] = ProtocolLibrary.getProtocolManager()
.createPacketConstructor(Packets.Server.VEHICLE_SPAWN, nmsEntity, id, data).createPacket(nmsEntity, id, data); .createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, id, data)
.createPacket(nmsEntity, id, data);
spawnPackets[0].getModifier().write(2, (int) Math.floor(loc.getY() * 32D)); spawnPackets[0].getModifier().write(2, (int) Math.floor(loc.getY() * 32D));
spawnPackets[0].getModifier().write(8, yaw); spawnPackets[0].getModifier().write(8, yaw);
// Make the teleport packet to make it visible.. // Make the teleport packet to make it visible..
spawnPackets[1] = new PacketContainer(Packets.Server.ENTITY_TELEPORT); spawnPackets[1] = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
StructureModifier<Object> mods = spawnPackets[1].getModifier(); StructureModifier<Object> mods = spawnPackets[1].getModifier();
mods.write(0, disguisedEntity.getEntityId()); mods.write(0, disguisedEntity.getEntityId());
mods.write(1, (int) Math.floor(loc.getX() * 32D)); mods.write(1, (int) Math.floor(loc.getX() * 32D));
@ -294,7 +297,7 @@ public class PacketsManager {
} }
if (spawnPackets[1] == null) { if (spawnPackets[1] == null) {
// Make a packet to turn his head! // Make a packet to turn his head!
spawnPackets[1] = new PacketContainer(Packets.Server.ENTITY_HEAD_ROTATION); spawnPackets[1] = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
StructureModifier<Object> mods = spawnPackets[1].getModifier(); StructureModifier<Object> mods = spawnPackets[1].getModifier();
mods.write(0, disguisedEntity.getEntityId()); mods.write(0, disguisedEntity.getEntityId());
mods.write(1, yaw); mods.write(1, yaw);
@ -456,15 +459,15 @@ public class PacketsManager {
*/ */
public static void init(LibsDisguises plugin) { public static void init(LibsDisguises plugin) {
libsDisguises = plugin; libsDisguises = plugin;
soundsListener = new PacketAdapter(libsDisguises, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, soundsListener = new PacketAdapter(libsDisguises, ListenerPriority.NORMAL, PacketType.Play.Server.NAMED_SOUND_EFFECT,
Packets.Server.NAMED_SOUND_EFFECT, Packets.Server.ENTITY_STATUS) { PacketType.Play.Server.ENTITY_STATUS) {
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
if (event.isCancelled()) if (event.isCancelled())
return; return;
StructureModifier<Object> mods = event.getPacket().getModifier(); StructureModifier<Object> mods = event.getPacket().getModifier();
Player observer = event.getPlayer(); Player observer = event.getPlayer();
if (event.getPacketID() == Packets.Server.NAMED_SOUND_EFFECT) { if (event.getPacketType() == PacketType.Play.Server.NAMED_SOUND_EFFECT) {
String soundName = (String) mods.read(0); String soundName = (String) mods.read(0);
SoundType soundType = null; SoundType soundType = null;
Location soundLoc = new Location(observer.getWorld(), ((Integer) mods.read(1)) / 8D, Location soundLoc = new Location(observer.getWorld(), ((Integer) mods.read(1)) / 8D,
@ -606,7 +609,7 @@ public class PacketsManager {
} }
} }
} }
} else if (event.getPacketID() == Packets.Server.ENTITY_STATUS) { } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) {
if ((Byte) mods.read(1) == 1) { if ((Byte) mods.read(1) == 1) {
// It made a damage animation // It made a damage animation
Entity entity = event.getPacket().getEntityModifier(observer.getWorld()).read(0); Entity entity = event.getPacket().getEntityModifier(observer.getWorld()).read(0);
@ -644,7 +647,7 @@ public class PacketsManager {
String sound = disSound.getSound(soundType); String sound = disSound.getSound(soundType);
if (sound != null) { if (sound != null) {
Location loc = entity.getLocation(); Location loc = entity.getLocation();
PacketContainer packet = new PacketContainer(Packets.Server.NAMED_SOUND_EFFECT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.NAMED_SOUND_EFFECT);
mods = packet.getModifier(); mods = packet.getModifier();
mods.write(0, sound); mods.write(0, sound);
mods.write(1, (int) (loc.getX() * 8D)); mods.write(1, (int) (loc.getX() * 8D));
@ -677,12 +680,14 @@ public class PacketsManager {
} }
} }
}; };
viewDisguisesListener = new PacketAdapter(libsDisguises, ConnectionSide.SERVER_SIDE, ListenerPriority.HIGH, viewDisguisesListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGH,
Packets.Server.NAMED_ENTITY_SPAWN, Packets.Server.ATTACH_ENTITY, Packets.Server.REL_ENTITY_MOVE, PacketType.Play.Server.NAMED_ENTITY_SPAWN, PacketType.Play.Server.ATTACH_ENTITY,
Packets.Server.REL_ENTITY_MOVE_LOOK, Packets.Server.ENTITY_LOOK, Packets.Server.ENTITY_TELEPORT, PacketType.Play.Server.REL_ENTITY_MOVE, PacketType.Play.Server.ENTITY_MOVE_LOOK,
Packets.Server.ENTITY_HEAD_ROTATION, Packets.Server.ENTITY_METADATA, Packets.Server.ENTITY_EQUIPMENT, PacketType.Play.Server.ENTITY_LOOK, PacketType.Play.Server.ENTITY_TELEPORT,
Packets.Server.ARM_ANIMATION, Packets.Server.ENTITY_LOCATION_ACTION, Packets.Server.MOB_EFFECT, PacketType.Play.Server.ENTITY_HEAD_ROTATION, PacketType.Play.Server.ENTITY_METADATA,
Packets.Server.ENTITY_VELOCITY, Packets.Server.UPDATE_ATTRIBUTES) { PacketType.Play.Server.ENTITY_EQUIPMENT, PacketType.Play.Server.ANIMATION, PacketType.Play.Server.BED,
PacketType.Play.Server.ENTITY_EFFECT, PacketType.Play.Server.ENTITY_VELOCITY,
PacketType.Play.Server.UPDATE_ATTRIBUTES) {
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
final Player observer = event.getPlayer(); final Player observer = event.getPlayer();
@ -721,8 +726,7 @@ public class PacketsManager {
}); });
} }
switch (event.getPacketID()) { if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) {
case Packets.Server.ENTITY_METADATA:
event.setPacket(event.getPacket().deepClone()); event.setPacket(event.getPacket().deepClone());
Iterator<WrappedWatchableObject> itel = event.getPacket().getWatchableCollectionModifier().read(0) Iterator<WrappedWatchableObject> itel = event.getPacket().getWatchableCollectionModifier().read(0)
.iterator(); .iterator();
@ -736,9 +740,9 @@ public class PacketsManager {
watch.setValue(a); watch.setValue(a);
} }
} }
break; }
case Packets.Server.NAMED_ENTITY_SPAWN: if (event.getPacketType() == PacketType.Play.Server.NAMED_ENTITY_SPAWN) {
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_METADATA); PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, observer.getEntityId()); mods.write(0, observer.getEntityId());
List<WrappedWatchableObject> watchableList = new ArrayList<WrappedWatchableObject>(); List<WrappedWatchableObject> watchableList = new ArrayList<WrappedWatchableObject>();
@ -748,34 +752,31 @@ public class PacketsManager {
watchableList.add(new WrappedWatchableObject(0, b)); watchableList.add(new WrappedWatchableObject(0, b));
packet.getWatchableCollectionModifier().write(0, watchableList); packet.getWatchableCollectionModifier().write(0, watchableList);
event.setPacket(packet); event.setPacket(packet);
break; }
case Packets.Server.ATTACH_ENTITY: if (event.getPacketType() == PacketType.Play.Server.ATTACH_ENTITY
case Packets.Server.REL_ENTITY_MOVE: || event.getPacketType() == PacketType.Play.Server.REL_ENTITY_MOVE
case Packets.Server.REL_ENTITY_MOVE_LOOK: || event.getPacketType() == PacketType.Play.Server.ENTITY_MOVE_LOOK
case Packets.Server.ENTITY_LOOK: || event.getPacketType() == PacketType.Play.Server.ENTITY_LOOK
case Packets.Server.ENTITY_TELEPORT: || event.getPacketType() == PacketType.Play.Server.ENTITY_TELEPORT
case Packets.Server.ENTITY_HEAD_ROTATION: || event.getPacketType() == PacketType.Play.Server.ENTITY_HEAD_ROTATION
case Packets.Server.MOB_EFFECT: || event.getPacketType() == PacketType.Play.Server.ENTITY_EFFECT
case Packets.Server.ENTITY_EQUIPMENT: || event.getPacketType() == PacketType.Play.Server.ENTITY_EQUIPMENT) {
event.setCancelled(true); event.setCancelled(true);
break; }
/* case Packets.Server.ENTITY_STATUS: /* case PacketType.Play.Server.ENTITY_STATUS:
if (DisguiseAPI.getDisguise(entity).canHearSelfDisguise() if (DisguiseAPI.getDisguise(entity).canHearSelfDisguise()
&& (Byte) event.getPacket().getModifier().read(1) == 1) { && (Byte) event.getPacket().getModifier().read(1) == 1) {
event.setCancelled(true); event.setCancelled(true);
} }
break;*/ break;*/
default:
break;
}
} }
} }
} }
}; };
// TODO Potentionally combine both listeners. // TODO Potentionally combine both listeners.
inventoryListenerServer = new PacketAdapter(libsDisguises, ConnectionSide.SERVER_SIDE, ListenerPriority.HIGHEST, inventoryListenerServer = new PacketAdapter(libsDisguises, ListenerPriority.HIGHEST, PacketType.Play.Server.SET_SLOT,
Packets.Server.SET_SLOT, Packets.Server.WINDOW_ITEMS) { PacketType.Play.Server.WINDOW_ITEMS) {
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
// If the inventory is the players inventory // If the inventory is the players inventory
@ -785,14 +786,13 @@ public class PacketsManager {
// If the player is disguised, views self disguises and is hiding a item. // If the player is disguised, views self disguises and is hiding a item.
if (disguise != null && disguise.isSelfDisguiseVisible() if (disguise != null && disguise.isSelfDisguiseVisible()
&& (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
switch (event.getPacketID()) {
// If the server is setting the slot // If the server is setting the slot
// Need to set it to air if its in a place it shouldn't be. // Need to set it to air if its in a place it shouldn't be.
// Things such as picking up a item, spawned in item. Plugin sets the item. etc. Will fire this // Things such as picking up a item, spawned in item. Plugin sets the item. etc. Will fire this
/** /**
* Done * Done
*/ */
case Packets.Server.SET_SLOT: { if (event.getPacketType() == PacketType.Play.Server.SET_SLOT) {
// The raw slot // The raw slot
// nms code has the start of the hotbar being 36. // nms code has the start of the hotbar being 36.
int slot = event.getPacket().getIntegers().read(1); int slot = event.getPacket().getIntegers().read(1);
@ -824,12 +824,8 @@ public class PacketsManager {
} }
} }
} }
break;
} }
/** if (event.getPacketType() == PacketType.Play.Server.WINDOW_ITEMS) {
* Done
*/
case Packets.Server.WINDOW_ITEMS: {
event.setPacket(event.getPacket().deepClone()); event.setPacket(event.getPacket().deepClone());
StructureModifier<ItemStack[]> mods = event.getPacket().getItemArrayModifier(); StructureModifier<ItemStack[]> mods = event.getPacket().getItemArrayModifier();
ItemStack[] items = mods.read(0); ItemStack[] items = mods.read(0);
@ -858,17 +854,14 @@ public class PacketsManager {
} }
} }
mods.write(0, items); mods.write(0, items);
break;
}
default:
break;
} }
} }
} }
} }
}; };
inventoryListenerClient = new PacketAdapter(libsDisguises, ConnectionSide.CLIENT_SIDE, ListenerPriority.HIGHEST, inventoryListenerClient = new PacketAdapter(libsDisguises, ListenerPriority.HIGHEST,
Packets.Client.BLOCK_ITEM_SWITCH, Packets.Client.SET_CREATIVE_SLOT, Packets.Client.WINDOW_CLICK) { PacketType.Play.Client.HELD_ITEM_SLOT, PacketType.Play.Client.SET_CREATIVE_SLOT,
PacketType.Play.Client.WINDOW_CLICK) {
@Override @Override
public void onPacketReceiving(final PacketEvent event) { public void onPacketReceiving(final PacketEvent event) {
if (event.getPlayer().getVehicle() == null) { if (event.getPlayer().getVehicle() == null) {
@ -876,16 +869,15 @@ public class PacketsManager {
// If player is disguised, views self disguises and has a inventory modifier // If player is disguised, views self disguises and has a inventory modifier
if (disguise != null && disguise.isSelfDisguiseVisible() if (disguise != null && disguise.isSelfDisguiseVisible()
&& (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
switch (event.getPacketID()) {
// If they are in creative and clicked on a slot // If they are in creative and clicked on a slot
case Packets.Client.SET_CREATIVE_SLOT: { if (event.getPacketType() == PacketType.Play.Client.SET_CREATIVE_SLOT) {
int slot = event.getPacket().getIntegers().read(0); int slot = event.getPacket().getIntegers().read(0);
if (slot >= 5 && slot <= 8) { if (slot >= 5 && slot <= 8) {
if (disguise.isHidingArmorFromSelf()) { if (disguise.isHidingArmorFromSelf()) {
int armorSlot = Math.abs((slot - 5) - 3); int armorSlot = Math.abs((slot - 5) - 3);
org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot]; org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot];
if (item != null && item.getType() != Material.AIR) { if (item != null && item.getType() != Material.AIR) {
PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.SET_SLOT);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, 0); mods.write(0, 0);
mods.write(1, slot); mods.write(1, slot);
@ -904,7 +896,7 @@ public class PacketsManager {
if (slot + 36 == currentSlot) { if (slot + 36 == currentSlot) {
org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand(); org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand();
if (item != null && item.getType() != Material.AIR) { if (item != null && item.getType() != Material.AIR) {
PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.SET_SLOT);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, 0); mods.write(0, 0);
mods.write(1, slot); mods.write(1, slot);
@ -919,10 +911,9 @@ public class PacketsManager {
} }
} }
} }
break;
} }
// If the player switched item, aka he moved from slot 1 to slot 2 // If the player switched item, aka he moved from slot 1 to slot 2
case Packets.Client.BLOCK_ITEM_SWITCH: { else if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_SLOT) {
if (disguise.isHidingHeldItemFromSelf()) { if (disguise.isHidingHeldItemFromSelf()) {
// From logging, it seems that both bukkit and nms uses the same thing for the slot switching. // From logging, it seems that both bukkit and nms uses the same thing for the slot switching.
// 0 1 2 3 - 8 // 0 1 2 3 - 8
@ -931,7 +922,7 @@ public class PacketsManager {
org.bukkit.inventory.ItemStack currentlyHeld = event.getPlayer().getItemInHand(); org.bukkit.inventory.ItemStack currentlyHeld = event.getPlayer().getItemInHand();
// If his old weapon isn't air // If his old weapon isn't air
if (currentlyHeld != null && currentlyHeld.getType() != Material.AIR) { if (currentlyHeld != null && currentlyHeld.getType() != Material.AIR) {
PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.SET_SLOT);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, 0); mods.write(0, 0);
mods.write(1, event.getPlayer().getInventory().getHeldItemSlot() + 36); mods.write(1, event.getPlayer().getInventory().getHeldItemSlot() + 36);
@ -946,7 +937,7 @@ public class PacketsManager {
.getItem(event.getPacket().getIntegers().read(0)); .getItem(event.getPacket().getIntegers().read(0));
// If his new weapon isn't air either! // If his new weapon isn't air either!
if (newHeld != null && newHeld.getType() != Material.AIR) { if (newHeld != null && newHeld.getType() != Material.AIR) {
PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.SET_SLOT);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, 0); mods.write(0, 0);
mods.write(1, event.getPacket().getIntegers().read(0) + 36); mods.write(1, event.getPacket().getIntegers().read(0) + 36);
@ -958,10 +949,9 @@ public class PacketsManager {
} }
} }
} }
break;
} }
case Packets.Client.WINDOW_CLICK: { else if (event.getPacketType() == PacketType.Play.Client.WINDOW_CLICK) {
int slot = event.getPacket().getIntegers().read(1); int slot = event.getPacket().getIntegers().read(1);
org.bukkit.inventory.ItemStack clickedItem; org.bukkit.inventory.ItemStack clickedItem;
if (event.getPacket().getIntegers().read(3) == 1) { if (event.getPacket().getIntegers().read(3) == 1) {
@ -989,7 +979,7 @@ public class PacketsManager {
// If the slot is a armor slot // If the slot is a armor slot
if (slot >= 5 && slot <= 8) { if (slot >= 5 && slot <= 8) {
if (disguise.isHidingArmorFromSelf()) { if (disguise.isHidingArmorFromSelf()) {
PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.SET_SLOT);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, 0); mods.write(0, 0);
mods.write(1, slot); mods.write(1, slot);
@ -1007,7 +997,7 @@ public class PacketsManager {
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot(); int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
// Check if the player is on the same slot as the slot that its setting // Check if the player is on the same slot as the slot that its setting
if (slot == currentSlot + 36) { if (slot == currentSlot + 36) {
PacketContainer packet = new PacketContainer(Packets.Server.SET_SLOT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.SET_SLOT);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, 0); mods.write(0, 0);
mods.write(1, slot); mods.write(1, slot);
@ -1022,11 +1012,6 @@ public class PacketsManager {
} }
} }
} }
break;
}
default:
break;
} }
} }
} }
@ -1113,75 +1098,67 @@ public class PacketsManager {
try { try {
// First get the entity, the one sending this packet // First get the entity, the one sending this packet
StructureModifier<Entity> entityModifer = sentPacket.getEntityModifier(observer.getWorld()); StructureModifier<Entity> entityModifer = sentPacket.getEntityModifier(observer.getWorld());
org.bukkit.entity.Entity entity = entityModifer.read((Packets.Server.COLLECT == sentPacket.getID() ? 1 : 0)); org.bukkit.entity.Entity entity = entityModifer
.read((PacketType.Play.Server.COLLECT == sentPacket.getType() ? 1 : 0));
Disguise disguise = DisguiseAPI.getDisguise(observer, entity); Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
// If disguised. // If disguised.
if (disguise != null) { if (disguise != null) {
// If packet is Packets.Server.UPDATE_ATTRIBUTES // If packet is PacketType.Play.Server.UPDATE_ATTRIBUTES
// This packet sends attributes // This packet sends attributes
switch (sentPacket.getID()) { if (sentPacket.getType() == PacketType.Play.Server.UPDATE_ATTRIBUTES)
case Packets.Server.UPDATE_ATTRIBUTES:
{ {
packets = new PacketContainer[0]; packets = new PacketContainer[0];
break;
} }
// Else if the packet is sending entity metadata // Else if the packet is sending entity metadata
case Packets.Server.ENTITY_METADATA: if (sentPacket.getType() == PacketType.Play.Server.ENTITY_METADATA)
{ {
List<WrappedWatchableObject> watchableObjects = disguise.getWatcher().convert( List<WrappedWatchableObject> watchableObjects = disguise.getWatcher().convert(
packets[0].getWatchableCollectionModifier().read(0)); packets[0].getWatchableCollectionModifier().read(0));
packets[0] = new PacketContainer(sentPacket.getID()); packets[0] = new PacketContainer(sentPacket.getType());
StructureModifier<Object> newMods = packets[0].getModifier(); StructureModifier<Object> newMods = packets[0].getModifier();
newMods.write(0, entity.getEntityId()); newMods.write(0, entity.getEntityId());
packets[0].getWatchableCollectionModifier().write(0, watchableObjects); packets[0].getWatchableCollectionModifier().write(0, watchableObjects);
break;
} }
// Else if the packet is spawning.. // Else if the packet is spawning..
case Packets.Server.NAMED_ENTITY_SPAWN: if (sentPacket.getType() == PacketType.Play.Server.NAMED_ENTITY_SPAWN
case Packets.Server.MOB_SPAWN: || sentPacket.getType() == PacketType.Play.Server.SPAWN_ENTITY_LIVING
case Packets.Server.ADD_EXP_ORB: || sentPacket.getType() == PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB
case Packets.Server.VEHICLE_SPAWN: || sentPacket.getType() == PacketType.Play.Server.SPAWN_ENTITY
case Packets.Server.ENTITY_PAINTING: || sentPacket.getType() == PacketType.Play.Server.SPAWN_ENTITY_PAINTING)
{
packets = constructSpawnPackets(disguise, entity); packets = constructSpawnPackets(disguise, entity);
break;
}
// Else if the disguise is attempting to send players a forbidden packet // Else if the disguise is attempting to send players a forbidden packet
case Packets.Server.ARM_ANIMATION: if (sentPacket.getType() == PacketType.Play.Server.ANIMATION)
{ {
if (disguise.getType().isMisc() || (packets[0].getIntegers().read(1) == 3 && !disguise.getType().isPlayer())) { if (disguise.getType().isMisc() || (packets[0].getIntegers().read(1) == 3 && !disguise.getType().isPlayer())) {
packets = new PacketContainer[0]; packets = new PacketContainer[0];
} }
break;
} }
case Packets.Server.COLLECT: if (sentPacket.getType() == PacketType.Play.Server.COLLECT)
{ {
if (disguise.getType().isMisc()) { if (disguise.getType().isMisc()) {
packets = new PacketContainer[0]; packets = new PacketContainer[0];
} }
break;
} }
// Else if the disguise is moving. // Else if the disguise is moving.
case Packets.Server.REL_ENTITY_MOVE_LOOK: if (sentPacket.getType() == PacketType.Play.Server.ENTITY_MOVE_LOOK
case Packets.Server.ENTITY_LOOK: || sentPacket.getType() == PacketType.Play.Server.ENTITY_LOOK
case Packets.Server.ENTITY_TELEPORT: || sentPacket.getType() == PacketType.Play.Server.ENTITY_TELEPORT)
{ {
if (sentPacket.getID() == Packets.Server.ENTITY_LOOK && disguise.getType() == DisguiseType.WITHER_SKULL) { if (sentPacket.getType() == PacketType.Play.Server.ENTITY_LOOK
&& disguise.getType() == DisguiseType.WITHER_SKULL) {
packets = new PacketContainer[0]; packets = new PacketContainer[0];
} else { } else {
packets[0] = sentPacket.shallowClone(); packets[0] = sentPacket.shallowClone();
@ -1190,7 +1167,7 @@ public class PacketsManager {
mods.write(4, getYaw(disguise.getType(), entity.getType(), yawValue)); mods.write(4, getYaw(disguise.getType(), entity.getType(), yawValue));
byte pitchValue = (Byte) mods.read(5); byte pitchValue = (Byte) mods.read(5);
mods.write(5, getPitch(disguise.getType(), DisguiseType.getType(entity.getType()), pitchValue)); mods.write(5, getPitch(disguise.getType(), DisguiseType.getType(entity.getType()), pitchValue));
if (sentPacket.getID() == Packets.Server.ENTITY_TELEPORT) { if (sentPacket.getType() == PacketType.Play.Server.ENTITY_TELEPORT) {
double y = getYModifier(entity, disguise.getType()); double y = getYModifier(entity, disguise.getType());
if (y != 0) { if (y != 0) {
y *= 32; y *= 32;
@ -1198,10 +1175,9 @@ public class PacketsManager {
} }
} }
} }
break;
} }
case Packets.Server.ENTITY_EQUIPMENT: if (sentPacket.getType() == PacketType.Play.Server.ENTITY_EQUIPMENT)
{ {
int slot = (Integer) packets[0].getModifier().read(1) - 1; int slot = (Integer) packets[0].getModifier().read(1) - 1;
@ -1213,29 +1189,23 @@ public class PacketsManager {
packets[0].getModifier().write(2, packets[0].getModifier().write(2,
(itemstack.getTypeId() == 0 ? null : ReflectionManager.getNmsItem(itemstack))); (itemstack.getTypeId() == 0 ? null : ReflectionManager.getNmsItem(itemstack)));
} }
break;
} }
case Packets.Server.ENTITY_LOCATION_ACTION: if (sentPacket.getType() == PacketType.Play.Server.BED)
{ {
if (!disguise.getType().isPlayer()) { if (!disguise.getType().isPlayer()) {
packets = new PacketContainer[0]; packets = new PacketContainer[0];
} }
break;
} }
case Packets.Server.ENTITY_STATUS: if (sentPacket.getType() == PacketType.Play.Server.ENTITY_STATUS)
{ {
if (packets[0].getBytes().read(0) == (byte) 3) { if (packets[0].getBytes().read(0) == (byte) 3) {
packets = new PacketContainer[0]; packets = new PacketContainer[0];
} }
} }
default:
break;
}
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();