Test sneaking
Dieser Commit ist enthalten in:
Ursprung
4cb3d0718e
Commit
974454b630
@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
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.wrappers.WrappedDataWatcher;
|
||||||
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;
|
||||||
@ -26,8 +30,10 @@ 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 {
|
||||||
|
|
||||||
@ -101,10 +107,17 @@ public abstract class REntity {
|
|||||||
|
|
||||||
public void sneak(boolean sneaking) {
|
public void sneak(boolean sneaking) {
|
||||||
entity.setSneaking(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()){
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
|
try {
|
||||||
connection.sendPacket(packet);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren