File tree Expand file tree Collapse file tree
java/net/transferproxy/api/configuration
core/src/main/java/net/transferproxy/status Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -182,6 +182,20 @@ interface Status {
182182 @ Contract (pure = true )
183183 String getProtocol ();
184184
185+ /**
186+ * Gets the online displayed in client server lists.
187+ * @return the online
188+ */
189+ @ Contract (pure = true )
190+ int getOnline ();
191+
192+ /**
193+ * Gets the max online displayed in client server lists.
194+ * @return the max online
195+ */
196+ @ Contract (pure = true )
197+ int getMaxOnline ();
198+
185199 /**
186200 * Gets the filesystem path to the server's favicon image.
187201 * If the file is unavailable, no favicon is displayed in server lists.
Original file line number Diff line number Diff line change @@ -125,12 +125,16 @@ private static class YamlStatus implements ProxyConfiguration.Status {
125125 private final String name ;
126126 private final String description ;
127127 private final String protocol ;
128+ private final int online ;
129+ private final int maxOnline ;
128130 private final String faviconPath ;
129131
130132 private YamlStatus () {
131133 this .name = "TransferProxy" ;
132134 this .description = "<green>A TransferProxy server" ;
133135 this .protocol = "AUTO" ;
136+ this .online = -1 ;
137+ this .maxOnline = -1 ;
134138 this .faviconPath = "./favicon.png" ;
135139 }
136140
@@ -154,6 +158,16 @@ private YamlStatus() {
154158 return this .faviconPath ;
155159 }
156160
161+ @ Override
162+ public int getOnline () {
163+ return this .online ;
164+ }
165+
166+ @ Override
167+ public int getMaxOnline () {
168+ return this .maxOnline ;
169+ }
170+
157171 }
158172
159173 private static class YamlMiscellaneous implements ProxyConfiguration .Miscellaneous {
Original file line number Diff line number Diff line change @@ -25,6 +25,11 @@ status:
2525 # Sets server protocol version. 'AUTO' automatically matches client's version.
2626 # You can also directly specify the protocol number, such as 766.
2727 protocol : " AUTO"
28+ # Displayed number of online players.
29+ online : -1
30+ # Displayed maximum number of online players.
31+ # This value is only used for display and has no real effect.
32+ max-online : -1
2833 # The path of the file corresponding to the favicon to display.
2934 # If the file is not found, nothing will be displayed.
3035 favicon-path : " ./favicon.png"
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ public final class StatusManagerImpl implements StatusManager {
5555 private final Component description ;
5656 private final int protocol ;
5757 private final boolean autoProtocol ;
58+ private final int online ;
59+ private final int maxOnline ;
5860 private final String favicon ;
5961
6062 private ProtocolizedBuiltPacket builtResponse ;
@@ -71,6 +73,8 @@ public StatusManagerImpl() {
7173 this .autoProtocol = false ;
7274 this .protocol = this .parseProtocol (rawProtocol );
7375 }
76+ this .online = config .getOnline ();
77+ this .maxOnline = config .getMaxOnline ();
7478 this .favicon = this .readFavicon (Path .of (config .getFaviconPath ()));
7579
7680 if (!this .autoProtocol ) {
@@ -103,6 +107,8 @@ public void process(final @NotNull PlayerConnection connection) {
103107 .description (this .description )
104108 .protocol (this .autoProtocol ? protocol : this .protocol )
105109 .favicon (this .favicon )
110+ .online (this .online )
111+ .max (this .maxOnline )
106112 .build ();
107113 }
108114
You can’t perform that action at this time.
0 commit comments