13
0
Dieser Commit ist enthalten in:
Lixfel 2020-11-03 18:03:43 +01:00
Ursprung 4cb3d0718e
Commit 974454b630

Datei anzeigen

@ -19,6 +19,10 @@
package de.steamwar.spectatesystem.elements;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import de.steamwar.spectatesystem.SpectateSystem;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit;
@ -26,8 +30,10 @@ import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
public abstract class REntity {
@ -101,10 +107,17 @@ public abstract class REntity {
public void sneak(boolean sneaking) {
entity.setSneaking(sneaking);
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), false);
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, entity.getId());
packet.getDataWatcherModifier().write(0, WrappedDataWatcher.getEntityWatcher(entity.getBukkitEntity()));
for(Player player : Bukkit.getOnlinePlayers()){
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(packet);
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
} catch (InvocationTargetException e) {
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
}
}
}