Search in sources :

Example 6 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project AdvancedReplay by Jumper251.

the class PacketNPC method getInfoAddPacket.

private WrapperPlayServerPlayerInfo getInfoAddPacket() {
    WrapperPlayServerPlayerInfo infoPacket = new WrapperPlayServerPlayerInfo();
    infoPacket.setAction(EnumWrappers.PlayerInfoAction.ADD_PLAYER);
    WrappedGameProfile profile = this.profile != null ? this.profile : new WrappedGameProfile(this.uuid, this.name);
    PlayerInfoData data = new PlayerInfoData(profile, 1, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(this.name));
    List<PlayerInfoData> dataList = new ArrayList<PlayerInfoData>();
    dataList.add(data);
    infoPacket.setData(dataList);
    return infoPacket;
}
Also used : PlayerInfoData(com.comphenix.protocol.wrappers.PlayerInfoData) ArrayList(java.util.ArrayList) WrapperPlayServerPlayerInfo(com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo) WrappedGameProfile(com.comphenix.protocol.wrappers.WrappedGameProfile)

Example 7 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project AdvancedReplay by Jumper251.

the class PacketNPC method getInfoRemovePacket.

private WrapperPlayServerPlayerInfo getInfoRemovePacket() {
    WrapperPlayServerPlayerInfo infoPacket = new WrapperPlayServerPlayerInfo();
    infoPacket.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
    WrappedGameProfile profile = this.profile != null ? this.profile : new WrappedGameProfile(this.uuid, this.name);
    PlayerInfoData data = new PlayerInfoData(profile, 1, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(this.name));
    List<PlayerInfoData> dataList = new ArrayList<PlayerInfoData>();
    dataList.add(data);
    infoPacket.setData(dataList);
    return infoPacket;
}
Also used : PlayerInfoData(com.comphenix.protocol.wrappers.PlayerInfoData) ArrayList(java.util.ArrayList) WrapperPlayServerPlayerInfo(com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo) WrappedGameProfile(com.comphenix.protocol.wrappers.WrappedGameProfile)

Example 8 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project AdvancedReplay by Jumper251.

the class PacketNPCOld method getInfoRemovePacket.

private WrapperPlayServerPlayerInfo getInfoRemovePacket() {
    WrapperPlayServerPlayerInfo infoPacket = new WrapperPlayServerPlayerInfo();
    infoPacket.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
    WrappedGameProfile profile = this.profile != null ? this.profile : new WrappedGameProfile(this.uuid, this.name);
    PlayerInfoData data = new PlayerInfoData(profile, 1, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(this.name));
    List<PlayerInfoData> dataList = new ArrayList<PlayerInfoData>();
    dataList.add(data);
    infoPacket.setData(dataList);
    return infoPacket;
}
Also used : PlayerInfoData(com.comphenix.protocol.wrappers.PlayerInfoData) ArrayList(java.util.ArrayList) WrapperPlayServerPlayerInfo(com.comphenix.packetwrapper.WrapperPlayServerPlayerInfo) WrappedGameProfile(com.comphenix.protocol.wrappers.WrappedGameProfile)

Example 9 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project ChangeSkin by games647.

the class SkinApplier method sendPacketsSelf.

private void sendPacketsSelf(WrappedGameProfile gameProfile) {
    PacketContainer removeInfo;
    PacketContainer addInfo;
    PacketContainer respawn;
    PacketContainer teleport;
    try {
        NativeGameMode gamemode = NativeGameMode.fromBukkit(receiver.getGameMode());
        WrappedChatComponent displayName = WrappedChatComponent.fromText(receiver.getPlayerListName());
        PlayerInfoData playerInfoData = new PlayerInfoData(gameProfile, 0, gamemode, displayName);
        // remove the old skin - client updates it only on a complete remove and add
        removeInfo = new PacketContainer(PLAYER_INFO);
        removeInfo.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
        removeInfo.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
        // add info containing the skin data
        addInfo = removeInfo.deepClone();
        addInfo.getPlayerInfoAction().write(0, PlayerInfoAction.ADD_PLAYER);
        // Respawn packet - notify the client that it should update the own skin
        respawn = createRespawnPacket(gamemode);
        // prevent the moved too quickly message
        teleport = createTeleportPacket(receiver.getLocation().clone());
    } catch (ReflectiveOperationException reflectiveEx) {
        plugin.getLog().error("Error occurred preparing packets. Cancelling self update", reflectiveEx);
        return;
    }
    sendPackets(removeInfo, addInfo, respawn, teleport);
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) WrappedChatComponent(com.comphenix.protocol.wrappers.WrappedChatComponent) PlayerInfoData(com.comphenix.protocol.wrappers.PlayerInfoData) NativeGameMode(com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode)

Example 10 with PlayerInfoData

use of com.comphenix.protocol.wrappers.PlayerInfoData in project LibsDisguises by libraryaddict.

the class DisguiseUtilities method getTabPacket.

public static PacketContainer getTabPacket(PlayerDisguise disguise, EnumWrappers.PlayerInfoAction action) {
    PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
    addTab.getPlayerInfoAction().write(0, action);
    addTab.getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(disguise.getGameProfile(), 0, EnumWrappers.NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(disguise.getName()))));
    return addTab;
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) 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