Initial tablist implementation
This commit is contained in:
@@ -6,6 +6,7 @@ import com.velocitypowered.api.proxy.messages.ChannelMessageSource;
|
||||
import com.velocitypowered.api.proxy.player.PlayerSettings;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import com.velocitypowered.api.proxy.player.TabList;
|
||||
import com.velocitypowered.api.util.MessagePosition;
|
||||
import com.velocitypowered.api.util.title.Title;
|
||||
import java.util.List;
|
||||
@@ -88,14 +89,20 @@ public interface Player extends CommandSource, InboundConnection, ChannelMessage
|
||||
* Sets the tab list header and footer for the player.
|
||||
* @param header the header component
|
||||
* @param footer the footer component
|
||||
* @deprecated Use {@link TabList#setHeaderAndFooter(Component, Component)}.
|
||||
*/
|
||||
@Deprecated
|
||||
void setHeaderAndFooter(Component header, Component footer);
|
||||
|
||||
/**
|
||||
* Clears the tab list header and footer for the player.
|
||||
* @deprecated Use {@link TabList#clearHeaderAndFooter()}.
|
||||
*/
|
||||
@Deprecated
|
||||
void clearHeaderAndFooter();
|
||||
|
||||
TabList getTabList();
|
||||
|
||||
/**
|
||||
* Disconnects the player with the specified reason. Once this method is called, further calls to other {@link Player}
|
||||
* methods will become undefined.
|
||||
|
@@ -0,0 +1,37 @@
|
||||
package com.velocitypowered.api.proxy.player;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import net.kyori.text.Component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents the tab list of a {@link Player}.
|
||||
* TODO: Desetude
|
||||
*/
|
||||
public interface TabList {
|
||||
/**
|
||||
* Sets the tab list header and footer for the player.
|
||||
* @param header the header component
|
||||
* @param footer the footer component
|
||||
*/
|
||||
void setHeaderAndFooter(Component header, Component footer);
|
||||
|
||||
/**
|
||||
* Clears the tab list header and footer for the player.
|
||||
*/
|
||||
void clearHeaderAndFooter();
|
||||
|
||||
void addEntry(TabListEntry entry);
|
||||
|
||||
Optional<TabListEntry> removeEntry(UUID uuid);
|
||||
|
||||
Collection<TabListEntry> getEntries();
|
||||
|
||||
//Necessary because the TabListEntry implementation isn't in the api
|
||||
@Deprecated
|
||||
TabListEntry buildEntry(GameProfile profile, Component displayName, int latency, int gameMode);
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
package com.velocitypowered.api.proxy.player;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import net.kyori.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* TODO: Desetude
|
||||
*/
|
||||
public interface TabListEntry {
|
||||
TabList getTabList();
|
||||
|
||||
GameProfile getProfile();
|
||||
|
||||
Optional<Component> getDisplayName();
|
||||
|
||||
TabListEntry setDisplayName(@Nullable Component displayName);
|
||||
|
||||
int getLatency();
|
||||
|
||||
TabListEntry setLatency(int latency);
|
||||
|
||||
int getGameMode();
|
||||
|
||||
TabListEntry setGameMode(int gameMode);
|
||||
|
||||
static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
class Builder {
|
||||
private TabList tabList;
|
||||
private GameProfile profile;
|
||||
private Component displayName;
|
||||
private int latency = 0;
|
||||
private int gameMode = 0;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
public Builder tabList(TabList tabList) {
|
||||
this.tabList = tabList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder profile(GameProfile profile) {
|
||||
this.profile = profile;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder displayName(@Nullable Component displayName) {
|
||||
this.displayName = displayName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder latency(int latency) {
|
||||
this.latency = latency;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder gameMode(int gameMode) {
|
||||
this.gameMode = gameMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TabListEntry build() {
|
||||
Preconditions.checkState(tabList != null, "The Tablist must be set when building a TabListEntry");
|
||||
Preconditions.checkState(profile != null, "The GameProfile must be set when building a TabListEntry");
|
||||
|
||||
return tabList.buildEntry(profile, displayName, latency, gameMode);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user