@@ -274,24 +274,22 @@ public String onRequest(OfflinePlayer p, @NotNull String identifier) {
274274
275275 public String getTps (String arg ) {
276276 if (arg == null || arg .isEmpty ()) {
277- StringBuilder sb = new StringBuilder ();
278- for (double t : serverUtils .getTps ()) {
279- sb .append (getColoredTps (t ))
280- .append (ChatColor .GRAY )
281- .append (", " );
277+ StringJoiner joiner = new StringJoiner (ChatColor .GRAY + ", " );
278+ for (double tps : serverUtils .getTps ()) {
279+ joiner .add (getColoredTps (tps ));
282280 }
283- return sb .toString ();
281+ return joiner .toString ();
284282 }
285- switch (arg ) {
283+ switch (arg ) {
286284 case "1" :
287- case "one" :
288- return String . valueOf ( fix (serverUtils .getTps ()[0 ]) );
285+ case "one" :
286+ return fix (serverUtils .getTps ()[0 ]);
289287 case "5" :
290288 case "five" :
291- return String . valueOf ( fix (serverUtils .getTps ()[1 ]) );
289+ return fix (serverUtils .getTps ()[1 ]);
292290 case "15" :
293291 case "fifteen" :
294- return String . valueOf (serverUtils .getTps ()[2 ]);
292+ return fix (serverUtils .getTps ()[2 ]);
295293 case "1_colored" :
296294 case "one_colored" :
297295 return getColoredTps (serverUtils .getTps ()[0 ]);
@@ -388,13 +386,14 @@ public static String formatTime(final Duration duration) {
388386 return builder .toString ();
389387 }
390388
391- private double fix (double tps ) {
392- return Math .min (Math .round (tps * 100.0 ) / 100.0 , 20.0 );
389+ private String fix (double tps ) {
390+ double finalTps = Math .min (Math .round (tps ), 20.0 );
391+
392+ return (tps > 20.0 ? "*" : "" ) + finalTps ;
393393 }
394394
395395 private String color (double tps ) {
396- return ChatColor .translateAlternateColorCodes ('&' , (tps > 18.0 ) ? high : (tps > 16.0 ) ? medium : low )
397- + ((tps > 20.0 ) ? "*" : "" );
396+ return ChatColor .translateAlternateColorCodes ('&' , (tps > 18.0 ) ? high : (tps > 16.0 ) ? medium : low );
398397 }
399398
400399 private String getColoredTps (double tps ) {
@@ -405,6 +404,12 @@ private String getColoredTpsPercent(double tps){
405404 return color (tps ) + getPercent (tps );
406405 }
407406
407+ private String getPercent (double tps ){
408+ double finalPercent = Math .min (Math .round (100 / 20.0 * tps ), 100.0 );
409+
410+ return (tps > 20.0 ? "*" : "" ) + finalPercent + "%" ;
411+ }
412+
408413 private Integer getChunks (){
409414 int loadedChunks = 0 ;
410415 for (final World world : Bukkit .getWorlds ()) {
@@ -431,9 +436,4 @@ private Integer getTotalEntities(){
431436
432437 return allEntities ;
433438 }
434-
435- private String getPercent (double tps ){
436- return Math .min (Math .round (100 / 20.0 * tps ), 100.0 ) + "%" ;
437- }
438-
439439}
0 commit comments