Reduce Spam from the TabList by not sending every package multiple times (#902)
* Reduce Spam from the TabList by not sending every package multiple times VelocityTabList#processUpsert called entry.setX which will create a package and send it to the client. BackendPlaySessionHandler doesn't return true for those packages, therefore the package for tab list updates will be send two times. * Cleanup TabList#buildEntry, added listed status to Entry builder
This commit is contained in:
@@ -84,8 +84,10 @@ public interface TabList {
|
||||
* @deprecated Internal usage. Use {@link TabListEntry.Builder} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
|
||||
int gameMode);
|
||||
default TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
|
||||
int gameMode) {
|
||||
return buildEntry(profile, displayName, latency, gameMode, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a tab list entry.
|
||||
@@ -99,8 +101,10 @@ public interface TabList {
|
||||
* @deprecated Internal usage. Use {@link TabListEntry.Builder} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
|
||||
int gameMode, @Nullable IdentifiedKey key);
|
||||
default TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
|
||||
int gameMode, @Nullable IdentifiedKey key) {
|
||||
return buildEntry(profile, displayName, latency, gameMode, null, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -115,6 +119,24 @@ public interface TabList {
|
||||
* @deprecated Internal usage. Use {@link TabListEntry.Builder} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
default TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
|
||||
int gameMode, @Nullable ChatSession chatSession) {
|
||||
return buildEntry(profile, displayName, latency, gameMode, chatSession, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an entry in a {@link Player}'s tab list.
|
||||
*
|
||||
* @param profile the profile
|
||||
* @param displayName the display name
|
||||
* @param latency the latency
|
||||
* @param gameMode the game mode
|
||||
* @param chatSession the chat session
|
||||
* @param listed the visible status of entry
|
||||
* @return the entry
|
||||
* @deprecated Internal usage. Use {@link TabListEntry.Builder} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
|
||||
int gameMode, @Nullable ChatSession chatSession);
|
||||
int gameMode, @Nullable ChatSession chatSession, boolean listed);
|
||||
}
|
||||
|
@@ -160,6 +160,7 @@ public interface TabListEntry extends KeyIdentifiable {
|
||||
private @Nullable Component displayName;
|
||||
private int latency = 0;
|
||||
private int gameMode = 0;
|
||||
private boolean listed = true;
|
||||
|
||||
private @Nullable ChatSession chatSession;
|
||||
|
||||
@@ -241,6 +242,18 @@ public interface TabListEntry extends KeyIdentifiable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets wether this entry should be visible.
|
||||
*
|
||||
* @param listed to set
|
||||
* @return ${code this}, for chaining
|
||||
* @see TabListEntry#isListed()
|
||||
*/
|
||||
public Builder listed(boolean listed) {
|
||||
this.listed = listed;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the {@link TabListEntry} specified by {@code this} {@link Builder}.
|
||||
*
|
||||
@@ -253,7 +266,7 @@ public interface TabListEntry extends KeyIdentifiable {
|
||||
if (profile == null) {
|
||||
throw new IllegalStateException("The GameProfile must be set when building a TabListEntry");
|
||||
}
|
||||
return tabList.buildEntry(profile, displayName, latency, gameMode, chatSession);
|
||||
return tabList.buildEntry(profile, displayName, latency, gameMode, chatSession, listed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user