13
0
Dieser Commit ist enthalten in:
Lixfel 2020-11-06 10:26:57 +01:00
Ursprung 9d89c169d1
Commit 675ef2d274

Datei anzeigen

@ -19,11 +19,6 @@
package de.steamwar.spectatesystem.elements; 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.utility.Util;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import de.steamwar.spectatesystem.SpectateSystem; import de.steamwar.spectatesystem.SpectateSystem;
import net.minecraft.server.v1_15_R1.*; import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -31,10 +26,8 @@ import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
public abstract class REntity { public abstract class REntity {
@ -108,16 +101,11 @@ public abstract class REntity {
public void sneak(boolean sneaking) { public void sneak(boolean sneaking) {
entity.setSneaking(sneaking); entity.setSneaking(sneaking);
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA); entity.getDataWatcher().register(new DataWatcherObject<>(0, DataWatcherRegistry.a), (byte)0x02);
packet.getIntegers().write(0, entity.getId()); PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), false);
packet.getWatchableCollectionModifier().write(0, Util.asList(new WrappedWatchableObject(0, (byte)0x02)));
System.out.println(packet);
for(Player player : Bukkit.getOnlinePlayers()){ for(Player player : Bukkit.getOnlinePlayers()){
try { ((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
} catch (InvocationTargetException e) {
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
}
} }
} }