use of com.comphenix.protocol.wrappers.PlayerInfoData in project LibsDisguises by libraryaddict.
the class PacketListenerTabList method onPacketSending.
@Override
public void onPacketSending(final PacketEvent event) {
if (event.isCancelled()) {
return;
}
Player observer = event.getPlayer();
if (event.getPacket().getPlayerInfoAction().read(0) != PlayerInfoAction.ADD_PLAYER) {
return;
}
List<PlayerInfoData> list = event.getPacket().getPlayerInfoDataLists().read(0);
Iterator<PlayerInfoData> itel = list.iterator();
while (itel.hasNext()) {
PlayerInfoData data = itel.next();
Player player = Bukkit.getPlayer(data.getProfile().getUUID());
if (player == null) {
continue;
}
Disguise disguise = DisguiseAPI.getDisguise(observer, player);
if (disguise == null) {
continue;
}
if (!disguise.isHidePlayer()) {
continue;
}
itel.remove();
}
if (list.isEmpty()) {
event.setCancelled(true);
} else {
event.getPacket().getPlayerInfoDataLists().write(0, list);
}
}
use of com.comphenix.protocol.wrappers.PlayerInfoData in project HMCCosmetics by HibiscusMC.
the class PacketHelper_1_18_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;
}
use of com.comphenix.protocol.wrappers.PlayerInfoData in project HMCCosmetics by HibiscusMC.
the class PacketHelper_1_16_R3 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;
}
use of com.comphenix.protocol.wrappers.PlayerInfoData in project AdvancedReplay by Jumper251.
the class PacketNPCOld 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;
}
Aggregations