Search in sources :

Example 1 with TabListEntry

use of org.spongepowered.api.entity.living.player.tab.TabListEntry in project SpongeCommon by SpongePowered.

the class SpongeTabList method removeEntry.

@Override
public Optional<TabListEntry> removeEntry(UUID uniqueId) {
    checkNotNull(uniqueId, "unique id");
    if (this.entries.containsKey(uniqueId)) {
        TabListEntry entry = this.entries.remove(uniqueId);
        this.sendUpdate(entry, SPacketPlayerListItem.Action.REMOVE_PLAYER);
        return Optional.of(entry);
    }
    return Optional.empty();
}
Also used : TabListEntry(org.spongepowered.api.entity.living.player.tab.TabListEntry)

Example 2 with TabListEntry

use of org.spongepowered.api.entity.living.player.tab.TabListEntry in project modules-extra by CubeEngine.

the class Tablist method onJoin.

@Listener
public void onJoin(ClientConnectionEvent.Join event) {
    Player player = event.getTargetEntity();
    String prefix = player.getOption("tablist-prefix").orElse("");
    if (this.config.header != null && !this.config.header.isEmpty()) {
        player.getTabList().setHeader(FORMATTING_CODE.deserialize(this.config.header));
    }
    for (Player p : Sponge.getServer().getOnlinePlayers()) {
        Optional<TabListEntry> entry = p.getTabList().getEntry(player.getUniqueId());
        entry.ifPresent(tle -> tle.setDisplayName(FORMATTING_CODE.deserialize(prefix + player.getName())));
        String pPrefix = p.getOption("tablist-prefix").orElse("");
        Optional<TabListEntry> pEntry = player.getTabList().getEntry(p.getUniqueId());
        pEntry.ifPresent(tle -> tle.setDisplayName(FORMATTING_CODE.deserialize(pPrefix + p.getName())));
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) TabListEntry(org.spongepowered.api.entity.living.player.tab.TabListEntry) Listener(org.spongepowered.api.event.Listener)

Example 3 with TabListEntry

use of org.spongepowered.api.entity.living.player.tab.TabListEntry in project LanternServer by LanternPowered.

the class LanternTabList method removeEntry.

@Override
public Optional<TabListEntry> removeEntry(UUID uniqueId) {
    final Optional<TabListEntry> entry = this.removeRawEntry(uniqueId);
    entry.ifPresent(entry0 -> {
        this.player.getConnection().send(new MessagePlayOutTabListEntries(Collections.singletonList(new MessagePlayOutTabListEntries.Entry.Remove(entry0.getProfile()))));
        ((LanternTabListEntry) entry0).getGlobalEntry().removeEntry((LanternTabListEntry) entry0);
    });
    return entry;
}
Also used : TabListEntry(org.spongepowered.api.entity.living.player.tab.TabListEntry) TabListEntry(org.spongepowered.api.entity.living.player.tab.TabListEntry) MessagePlayOutTabListEntries(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutTabListEntries)

Example 4 with TabListEntry

use of org.spongepowered.api.entity.living.player.tab.TabListEntry in project LanternServer by LanternPowered.

the class LanternTabList method addEntry.

@Override
public TabList addEntry(TabListEntry entry) throws IllegalArgumentException {
    checkNotNull(entry, "entry");
    UUID uniqueId = entry.getProfile().getUniqueId();
    checkArgument(entry.getList() == this, "The tab list entries #getList() list does not match to this list.");
    checkArgument(!this.tabListEntries.containsKey(uniqueId), "There is already a tab list entry assigned with the unique id: " + uniqueId.toString());
    this.tabListEntries.put(uniqueId, (LanternTabListEntry) entry);
    this.player.getConnection().send(new MessagePlayOutTabListEntries(Collections.singletonList(new MessagePlayOutTabListEntries.Entry.Add(entry.getProfile(), entry.getGameMode(), entry.getDisplayName().orElse(null), entry.getLatency()))));
    LanternTabListEntry entry0 = (LanternTabListEntry) entry;
    entry0.attached = true;
    entry0.getGlobalEntry().addEntry(entry0);
    return this;
}
Also used : TabListEntry(org.spongepowered.api.entity.living.player.tab.TabListEntry) MessagePlayOutTabListEntries(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutTabListEntries) UUID(java.util.UUID)

Aggregations

TabListEntry (org.spongepowered.api.entity.living.player.tab.TabListEntry)4 MessagePlayOutTabListEntries (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutTabListEntries)2 UUID (java.util.UUID)1 Player (org.spongepowered.api.entity.living.player.Player)1 Listener (org.spongepowered.api.event.Listener)1