Add some Sneaking Methods
Dieser Commit ist enthalten in:
Ursprung
ca8801563d
Commit
17c0995f24
@ -19,13 +19,21 @@
|
|||||||
|
|
||||||
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 com.mojang.authlib.GameProfile;
|
||||||
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;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
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.craftbukkit.v1_15_R1.metadata.EntityMetadataStore;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -48,6 +56,7 @@ public abstract class REntity {
|
|||||||
for(Player player : Bukkit.getOnlinePlayers()){
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
sendToPlayer(player);
|
sendToPlayer(player);
|
||||||
}
|
}
|
||||||
|
sneak(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playerJoins(Player player){
|
public static void playerJoins(Player player){
|
||||||
@ -103,17 +112,33 @@ public abstract class REntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sneak(boolean sneaking) {
|
private static Method setPoseMethod = null;
|
||||||
entity.setSneaking(sneaking);
|
|
||||||
|
|
||||||
/*DataWatcher dataWatcher = new DataWatcher(entity);
|
public void sneak(boolean sneaking) {
|
||||||
System.out.println("Let " + entity.getName() + " sneak " + sneaking);
|
try {
|
||||||
dataWatcher.register(new DataWatcherObject<>(0, DataWatcherRegistry.a), sneaking ? (byte)0x02 : (byte)0x40);
|
if(setPoseMethod == null) {
|
||||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false);
|
setPoseMethod = Entity.class.getDeclaredMethod("setPose", EntityPose.class);
|
||||||
|
setPoseMethod.setAccessible(true);
|
||||||
|
}
|
||||||
|
setPoseMethod.invoke(entity, sneaking?EntityPose.CROUCHING:EntityPose.STANDING);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
/*System.out.println("Let " + entity.getName() + " sneak " + sneaking+ " | " + entity.getClass());
|
||||||
|
DataWatcher dataWatcher = entity.getDataWatcher();
|
||||||
|
|
||||||
|
dataWatcher.set(new DataWatcherObject<>(6, DataWatcherRegistry.s), sneaking?EntityPose.CROUCHING:EntityPose.STANDING);
|
||||||
|
//dataWatcher.set(new DataWatcherObject<>(0, DataWatcherRegistry.a), Byte.valueOf((byte) (sneaking?2:0)));*/
|
||||||
|
|
||||||
|
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), false);
|
||||||
|
|
||||||
for(Player player : Bukkit.getOnlinePlayers()){
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void animation(byte animation) {
|
public void animation(byte animation) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren