Search in sources :

Example 1 with ClientboundNucleusNameMappingsPacket

use of com.almuradev.almura.feature.nick.network.ClientboundNucleusNameMappingsPacket in project Almura by AlmuraDev.

the class ServerNickManager method getMappingMessage.

private ClientboundNucleusNameMappingsPacket getMappingMessage(final NucleusNicknameService service) {
    final Map<UUID, Text> nicknames = new HashMap<>();
    this.game.getServer().getOnlinePlayers().forEach((player) -> {
        Text nickname = service.getNickname(player).orElse(null);
        if (nickname == null) {
            nickname = Text.of(player.getName());
        } else {
            nickname = Text.of("~" + nickname.toPlain());
        }
        nicknames.put(player.getUniqueId(), nickname);
    });
    return new ClientboundNucleusNameMappingsPacket(nicknames);
}
Also used : ClientboundNucleusNameMappingsPacket(com.almuradev.almura.feature.nick.network.ClientboundNucleusNameMappingsPacket) HashMap(java.util.HashMap) Text(org.spongepowered.api.text.Text) UUID(java.util.UUID)

Aggregations

ClientboundNucleusNameMappingsPacket (com.almuradev.almura.feature.nick.network.ClientboundNucleusNameMappingsPacket)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 Text (org.spongepowered.api.text.Text)1