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();
}
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())));
}
}
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;
}
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;
}
Aggregations