Fixes #488 equip packet
This commit is contained in:
parent
6fbdcc9855
commit
5f2ac293bf
@ -9,6 +9,7 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
@ -756,8 +757,16 @@ public class FlagWatcher {
|
|||||||
StructureModifier<Object> mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
|
|
||||||
mods.write(0, getDisguise().getEntity().getEntityId());
|
mods.write(0, getDisguise().getEntity().getEntityId());
|
||||||
|
|
||||||
|
if (NmsVersion.v1_16.isSupported()) {
|
||||||
|
List<Pair<Object, Object>> list = new ArrayList<>();
|
||||||
|
list.add(Pair.of(ReflectionManager.createEnumItemSlot(slot), itemToSend));
|
||||||
|
|
||||||
|
mods.write(1, list);
|
||||||
|
} else {
|
||||||
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
||||||
mods.write(2, itemToSend);
|
mods.write(2, itemToSend);
|
||||||
|
}
|
||||||
|
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
try {
|
try {
|
||||||
|
@ -4,8 +4,10 @@ import com.comphenix.protocol.PacketType;
|
|||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -14,10 +16,7 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 3/01/2019.
|
* Created by libraryaddict on 3/01/2019.
|
||||||
@ -117,8 +116,16 @@ public class LibsPackets {
|
|||||||
StructureModifier<Object> mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
|
|
||||||
mods.write(0, disguise.getEntity().getEntityId());
|
mods.write(0, disguise.getEntity().getEntityId());
|
||||||
|
|
||||||
|
if (NmsVersion.v1_16.isSupported()) {
|
||||||
|
List<Pair<Object, Object>> list = new ArrayList<>();
|
||||||
|
list.add(Pair.of(ReflectionManager.createEnumItemSlot(slot), ReflectionManager.getNmsItem(itemToSend)));
|
||||||
|
|
||||||
|
mods.write(1, list);
|
||||||
|
} else {
|
||||||
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
||||||
mods.write(2, ReflectionManager.getNmsItem(itemToSend));
|
mods.write(2, ReflectionManager.getNmsItem(itemToSend));
|
||||||
|
}
|
||||||
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.comphenix.protocol.reflect.StructureModifier;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.*;
|
import me.libraryaddict.disguise.disguisetypes.*;
|
||||||
@ -436,8 +437,17 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||||||
StructureModifier<Object> mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
|
|
||||||
mods.write(0, disguisedEntity.getEntityId());
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
|
|
||||||
|
if (NmsVersion.v1_16.isSupported()) {
|
||||||
|
List<Pair<Object, Object>> list = new ArrayList<>();
|
||||||
|
list.add(Pair.of(ReflectionManager.createEnumItemSlot(slot),
|
||||||
|
ReflectionManager.getNmsItem(itemToSend)));
|
||||||
|
|
||||||
|
mods.write(1, list);
|
||||||
|
} else {
|
||||||
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
||||||
mods.write(2, ReflectionManager.getNmsItem(itemToSend));
|
mods.write(2, ReflectionManager.getNmsItem(itemToSend));
|
||||||
|
}
|
||||||
|
|
||||||
packets.addDelayedPacket(packet);
|
packets.addDelayedPacket(packet);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user