TinyProtocol #51
@ -54,22 +54,21 @@ public class NoClipCommand extends SWCommand implements Listener {
|
|||||||
private static final Object updateGamemode = playerInfoActionClass.getEnumConstants()[1];
|
private static final Object updateGamemode = playerInfoActionClass.getEnumConstants()[1];
|
||||||
private static final Reflection.FieldAccessor<List> playerInfoData = Reflection.getField(playerInfoPacket, List.class, 0);
|
private static final Reflection.FieldAccessor<List> playerInfoData = Reflection.getField(playerInfoPacket, List.class, 0);
|
||||||
private static final Class<?> playerInfoDataClass = Reflection.getClass("{nms}.PacketPlayOutPlayerInfo$PlayerInfoData");
|
private static final Class<?> playerInfoDataClass = Reflection.getClass("{nms}.PacketPlayOutPlayerInfo$PlayerInfoData");
|
||||||
private static final Class<?> enumGamemode = Reflection.getClass(Core.getVersion() > 9 ? "{nms}.EnumGamemode" : "{nms}.WorldSettings$EnumGamemode");
|
private static final Class<?> enumGamemode = Reflection.getClass("{nms}.EnumGamemode");
|
||||||
public static final Object creative = enumGamemode.getEnumConstants()[2];
|
|
||||||
private static final Object spectator = enumGamemode.getEnumConstants()[4];
|
private static final Object spectator = enumGamemode.getEnumConstants()[4];
|
||||||
private static final Class<?> iChatBaseComponent = Reflection.getClass("{nms}.IChatBaseComponent");
|
private static final Class<?> iChatBaseComponent = Reflection.getClass("{nms}.IChatBaseComponent");
|
||||||
|
|
||||||
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent);
|
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent);
|
||||||
|
|
||||||
public static final Class<?> gameStateChange = Reflection.getClass("{nms}.PacketPlayOutGameStateChange");
|
private static final Class<?> gameStateChange = Reflection.getClass("{nms}.PacketPlayOutGameStateChange");
|
||||||
private static final Reflection.FieldAccessor<Integer> integerFieldAccessor = Reflection.getField(gameStateChange, int.class, 0);
|
private static final Reflection.FieldAccessor<Integer> integerFieldAccessor = Reflection.getField(gameStateChange, int.class, 0);
|
||||||
private static final Reflection.FieldAccessor<Float> floatFieldAccessor = Reflection.getField(gameStateChange, float.class, 0);
|
private static final Reflection.FieldAccessor<Float> floatFieldAccessor = Reflection.getField(gameStateChange, float.class, 0);
|
||||||
|
|
||||||
public static final Class<?> position = Reflection.getClass("{nms}.PacketPlayInFlying$PacketPlayInPosition");
|
private static final Class<?> position = Reflection.getClass("{nms}.PacketPlayInFlying$PacketPlayInPosition");
|
||||||
public static final Class<?> positionLook = Reflection.getClass("{nms}.PacketPlayInFlying$PacketPlayInPositionLook");
|
private static final Class<?> positionLook = Reflection.getClass("{nms}.PacketPlayInFlying$PacketPlayInPositionLook");
|
||||||
public static final Class<?> useItem = Reflection.getClass("{nms}.PacketPlayInUseItem");
|
private static final Class<?> useItem = Reflection.getClass("{nms}.PacketPlayInUseItem");
|
||||||
public static final Class<?> blockDig = Reflection.getClass("{nms}.PacketPlayInBlockDig");
|
private static final Class<?> blockDig = Reflection.getClass("{nms}.PacketPlayInBlockDig");
|
||||||
public static final Class<?> windowClick = Reflection.getClass("{nms}.PacketPlayInWindowClick");
|
private static final Class<?> windowClick = Reflection.getClass("{nms}.PacketPlayInWindowClick");
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static final List<Player> NOCLIPS = new ArrayList<>();
|
private static final List<Player> NOCLIPS = new ArrayList<>();
|
||||||
@ -118,7 +117,7 @@ public class NoClipCommand extends SWCommand implements Listener {
|
|||||||
NOCLIPS.add(player);
|
NOCLIPS.add(player);
|
||||||
BauSystem.MESSAGE.send("OTHER_NOCLIP_SLOT_INFO", player);
|
BauSystem.MESSAGE.send("OTHER_NOCLIP_SLOT_INFO", player);
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, gameStateChangeObject);
|
ProtocolAPI.tinyProtocol.sendPacket(player, gameStateChangeObject);
|
||||||
pseudoSpectator(player, false);
|
pseudoSpectator(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,11 +154,11 @@ public class NoClipCommand extends SWCommand implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pseudoSpectator(Player player, boolean enable) {
|
private static void pseudoSpectator(Player player) {
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), enable ? creative : spectator));
|
ProtocolAPI.tinyProtocol.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), spectator));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object playerInfoPacket(Object action, GameProfile profile, Object mode) {
|
private static Object playerInfoPacket(Object action, GameProfile profile, Object mode) {
|
||||||
Object packet = playerInfoConstructor.invoke();
|
Object packet = playerInfoConstructor.invoke();
|
||||||
playerInfoAction.set(packet, action);
|
playerInfoAction.set(packet, action);
|
||||||
playerInfoData.set(packet, Collections.singletonList(playerInfoDataConstructor.invoke(packet, profile, 0, mode, null)));
|
playerInfoData.set(packet, Collections.singletonList(playerInfoDataConstructor.invoke(packet, profile, 0, mode, null)));
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren