Change the packet sent for data to a packet container instead of CB packet
This commit is contained in:
parent
8ca7f25b4a
commit
d4c657eee6
@ -1,18 +1,21 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes;
|
package me.libraryaddict.disguise.DisguiseTypes;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.Packets;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
|
||||||
import net.minecraft.server.v1_6_R2.ChunkCoordinates;
|
import net.minecraft.server.v1_6_R2.ChunkCoordinates;
|
||||||
import net.minecraft.server.v1_6_R2.ItemStack;
|
import net.minecraft.server.v1_6_R2.ItemStack;
|
||||||
import net.minecraft.server.v1_6_R2.Packet40EntityMetadata;
|
|
||||||
import net.minecraft.server.v1_6_R2.WatchableObject;
|
import net.minecraft.server.v1_6_R2.WatchableObject;
|
||||||
|
|
||||||
public class FlagWatcher {
|
public class FlagWatcher {
|
||||||
@ -110,20 +113,21 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void sendData(int data) {
|
protected void sendData(int data) {
|
||||||
Packet40EntityMetadata packet = new Packet40EntityMetadata();
|
Object value = entityValues.get(data);
|
||||||
try {
|
List<WatchableObject> list = new ArrayList<WatchableObject>();
|
||||||
packet.a = entityId;
|
list.add(new WatchableObject(classTypes.get(value.getClass()), data, value));
|
||||||
Field field = Packet40EntityMetadata.class.getDeclaredField("b");
|
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_METADATA);
|
||||||
field.setAccessible(true);
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
Object value = entityValues.get(data);
|
mods.write(0, entityId);
|
||||||
List<WatchableObject> list = new ArrayList<WatchableObject>();
|
mods.write(1, list);
|
||||||
list.add(new WatchableObject(classTypes.get(value.getClass()), data, value));
|
|
||||||
field.set(packet, list);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
|
if (p.getEntityId() != entityId) {
|
||||||
|
try {
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(p, packet);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user