use of org.dragonet.protocol.packets.PlayerListPacket in project DragonProxy by DragonetMC.
the class PCPlayerListItemPacketTranslator method translate.
public PEPacket[] translate(UpstreamSession session, ServerPlayerListEntryPacket packet) {
PlayerListPacket pk = new PlayerListPacket();
if (packet.getAction() == PlayerListEntryAction.ADD_PLAYER) {
PlayerListEntry[] entries = packet.getEntries();
Set<org.dragonet.protocol.type.PlayerListEntry> peEntries = new HashSet();
for (PlayerListEntry entry : entries) {
session.getPlayerInfoCache().put(entry.getProfile().getId(), entry);
org.dragonet.protocol.type.PlayerListEntry peEntry = new org.dragonet.protocol.type.PlayerListEntry();
peEntry.uuid = entry.getProfile().getId();
peEntry.eid = 1;
peEntry.username = entry.getProfile().getName();
peEntry.skin = Skin.DEFAULT_SKIN_STEVE;
peEntry.xboxUserId = entry.getProfile().getId().toString();
peEntries.add(peEntry);
}
pk.type = PlayerListPacket.TYPE_ADD;
pk.entries = (org.dragonet.protocol.type.PlayerListEntry[]) peEntries.toArray(new org.dragonet.protocol.type.PlayerListEntry[peEntries.size()]);
} else if (packet.getAction() == PlayerListEntryAction.REMOVE_PLAYER) {
PlayerListEntry[] entries = packet.getEntries();
Set<org.dragonet.protocol.type.PlayerListEntry> peEntries = new HashSet();
for (PlayerListEntry entry : entries) {
session.getPlayerInfoCache().remove(entry.getProfile().getId());
org.dragonet.protocol.type.PlayerListEntry peEntry = new org.dragonet.protocol.type.PlayerListEntry();
peEntry.uuid = entry.getProfile().getId();
peEntry.eid = 1;
peEntry.username = entry.getProfile().getName();
peEntry.skin = Skin.DEFAULT_SKIN_STEVE;
peEntry.xboxUserId = entry.getProfile().getId().toString();
peEntries.add(peEntry);
}
pk.type = PlayerListPacket.TYPE_REMOVE;
pk.entries = (org.dragonet.protocol.type.PlayerListEntry[]) peEntries.toArray(new org.dragonet.protocol.type.PlayerListEntry[peEntries.size()]);
}
return new PEPacket[] { pk };
}
Aggregations