Search in sources :

Example 1 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project HMCCosmetics by HibiscusMC.

the class PacketHelper_1_17_R1 method getPlayerInfoPacket.

@Override
public PacketContainer getPlayerInfoPacket(final Player player, final UUID uuid) {
    final GameProfile profile = this.getCopyProfile(player, uuid);
    final PacketContainer playerInfoPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
    final StructureModifier<EnumWrappers.PlayerInfoAction> action = playerInfoPacket.getPlayerInfoAction();
    final StructureModifier<List<PlayerInfoData>> infoData = playerInfoPacket.getPlayerInfoDataLists();
    final List<PlayerInfoData> playerInfoData = new ArrayList<>();
    playerInfoData.add(new PlayerInfoData(WrappedGameProfile.fromHandle(profile), 0, EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), WrappedChatComponent.fromText(profile.getName())));
    action.write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
    infoData.write(0, playerInfoData);
    return playerInfoPacket;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) GameProfile(com.mojang.authlib.GameProfile) WrappedGameProfile(com.comphenix.protocol.wrappers.WrappedGameProfile) PlayerInfoData(com.comphenix.protocol.wrappers.PlayerInfoData) IntArrayList(org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntArrayList) ArrayList(java.util.ArrayList) IntArrayList(org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project HMCCosmetics by HibiscusMC.

the class PacketHelper_1_17_R1 method getPlayerRemovePacket.

@Override
public PacketContainer getPlayerRemovePacket(final Player player, final UUID uuid, final int entityId) {
    final PacketContainer playerPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
    final StructureModifier<EnumWrappers.PlayerInfoAction> action = playerPacket.getPlayerInfoAction();
    final StructureModifier<List<PlayerInfoData>> infoData = playerPacket.getPlayerInfoDataLists();
    final List<PlayerInfoData> playerInfoData = new ArrayList<>();
    final GameProfile profile = this.getCopyProfile(player, uuid);
    playerInfoData.add(new PlayerInfoData(WrappedGameProfile.fromHandle(profile), 0, EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), WrappedChatComponent.fromText("")));
    action.write(0, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
    infoData.write(0, playerInfoData);
    return playerPacket;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) GameProfile(com.mojang.authlib.GameProfile) WrappedGameProfile(com.comphenix.protocol.wrappers.WrappedGameProfile) PlayerInfoData(com.comphenix.protocol.wrappers.PlayerInfoData) IntArrayList(org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntArrayList) ArrayList(java.util.ArrayList) IntArrayList(org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project HMCCosmetics by HibiscusMC.

the class PacketHelper_1_18_R1 method getPlayerInfoPacket.

@Override
public PacketContainer getPlayerInfoPacket(final Player player, final UUID uuid) {
    final GameProfile profile = this.getCopyProfile(player, uuid);
    final PacketContainer playerInfoPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
    final StructureModifier<EnumWrappers.PlayerInfoAction> action = playerInfoPacket.getPlayerInfoAction();
    final StructureModifier<List<PlayerInfoData>> infoData = playerInfoPacket.getPlayerInfoDataLists();
    final List<PlayerInfoData> playerInfoData = new ArrayList<>();
    playerInfoData.add(new PlayerInfoData(WrappedGameProfile.fromHandle(profile), 0, EnumWrappers.NativeGameMode.fromBukkit(GameMode.SURVIVAL), WrappedChatComponent.fromText(profile.getName())));
    action.write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
    infoData.write(0, playerInfoData);
    return playerInfoPacket;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) GameProfile(com.mojang.authlib.GameProfile) WrappedGameProfile(com.comphenix.protocol.wrappers.WrappedGameProfile) PlayerInfoData(com.comphenix.protocol.wrappers.PlayerInfoData) ArrayList(java.util.ArrayList) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList)

Example 4 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project HMCCosmetics by HibiscusMC.

the class PacketHelper_1_16_R3 method getPlayerRemovePacket.

@Override
public PacketContainer getPlayerRemovePacket(final Player player, final UUID uuid, final int entityId) {
    final PacketContainer playerPacket = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
    final StructureModifier<EnumWrappers.PlayerInfoAction> action = playerPacket.getPlayerInfoAction();
    final StructureModifier<List<PlayerInfoData>> infoData = playerPacket.getPlayerInfoDataLists();
    final List<PlayerInfoData> playerInfoData = new ArrayList<>();
    final GameProfile profile = this.getCopyProfile(player, uuid);
    playerInfoData.add(new PlayerInfoData(WrappedGameProfile.fromHandle(profile), 0, EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), WrappedChatComponent.fromText("")));
    action.write(0, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
    infoData.write(0, playerInfoData);
    return playerPacket;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) GameProfile(com.mojang.authlib.GameProfile) WrappedGameProfile(com.comphenix.protocol.wrappers.WrappedGameProfile) PlayerInfoData(com.comphenix.protocol.wrappers.PlayerInfoData) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project AntiCheatAddition by Photon-GitHub.

the class WrapperPlayServerPlayerInfo method updatePlayerInformation.

/**
 * This method updates the player information, and thus the tablist of a player.
 *
 * @param action         the {@link PlayerInfoAction} that will be executed.
 * @param gameProfile    the {@link WrappedGameProfile} of the player whose information will be updated.<br>
 *                       Use {@link WrappedGameProfile#fromPlayer(Player)} in order to get a {@link WrappedGameProfile} from a {@link Player}.
 * @param ping           the new ping of the updated {@link Player}.
 *                       Use {@link de.photon.anticheataddition.util.minecraft.ping.PingProvider#getPing(Player)} to get the ping of a {@link Player}.
 * @param gameMode       the {@link EnumWrappers.NativeGameMode} of the updated {@link Player}.
 * @param displayName    the new displayName of the updated {@link Player}
 * @param affectedPlayer the {@link Player} who will see the updated information as the packet is sent to him.
 */
public static void updatePlayerInformation(final PlayerInfoAction action, final WrappedGameProfile gameProfile, final int ping, final EnumWrappers.NativeGameMode gameMode, final WrappedChatComponent displayName, final Player affectedPlayer) {
    val playerInfoData = new PlayerInfoData(gameProfile, ping, gameMode, displayName);
    val playerInfoWrapper = new WrapperPlayServerPlayerInfo();
    playerInfoWrapper.setAction(action);
    playerInfoWrapper.setData(Collections.singletonList(playerInfoData));
    playerInfoWrapper.sendPacket(affectedPlayer);
}
Also used : lombok.val(lombok.val) PlayerInfoData(com.comphenix.protocol.wrappers.PlayerInfoData)

Aggregations

PlayerInfoData (com.comphenix.protocol.wrappers.PlayerInfoData)19 PacketContainer (com.comphenix.protocol.events.PacketContainer)13 WrappedGameProfile (com.comphenix.protocol.wrappers.WrappedGameProfile)10 ArrayList (java.util.ArrayList)10 GameProfile (com.mojang.authlib.GameProfile)6 List (java.util.List)6 Player (org.bukkit.entity.Player)5 WrapperPlayServerPlayerInfo (com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)2 IntArrayList (org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.IntArrayList)2 EnumWrappers (com.comphenix.protocol.wrappers.EnumWrappers)1 NativeGameMode (com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode)1 WrappedChatComponent (com.comphenix.protocol.wrappers.WrappedChatComponent)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 lombok.val (lombok.val)1 Disguise (me.libraryaddict.disguise.disguisetypes.Disguise)1 DisguiseEvent (me.libraryaddict.disguise.events.DisguiseEvent)1 UndisguiseEvent (me.libraryaddict.disguise.events.UndisguiseEvent)1