77import com .earth2me .essentials .utils .AdventureUtil ;
88import com .earth2me .essentials .utils .EnumUtil ;
99import com .earth2me .essentials .utils .NumberUtil ;
10+ import com .earth2me .essentials .utils .VersionUtil ;
1011import com .google .common .collect .Lists ;
1112import net .essentialsx .api .v2 .services .BalanceTop ;
1213import org .bukkit .Bukkit ;
@@ -121,9 +122,14 @@ public void run() {
121122 final User user = ess .getUser (entry .getKey ());
122123
123124 final Statistic PLAY_ONE_TICK = EnumUtil .getStatistic ("PLAY_ONE_MINUTE" , "PLAY_ONE_TICK" );
125+ final boolean offlineStatisticSupported = VersionUtil .getServerBukkitVersion ().isHigherThanOrEqualTo (VersionUtil .v1_15_2_R01 );
124126 final long playtime ;
125127 if (user .getBase () == null || !user .getBase ().isOnline ()) {
126- playtime = Bukkit .getServer ().getOfflinePlayer (entry .getKey ()).getStatistic (PLAY_ONE_TICK );
128+ if (offlineStatisticSupported ) {
129+ playtime = Bukkit .getServer ().getOfflinePlayer (entry .getKey ()).getStatistic (PLAY_ONE_TICK );
130+ } else {
131+ playtime = -1 ;
132+ }
127133 } else {
128134 playtime = user .getBase ().getStatistic (PLAY_ONE_TICK );
129135 }
@@ -133,7 +139,8 @@ public void run() {
133139 // Checking if player meets the requirements of minimum balance and minimum playtime to be listed in baltop list
134140 if ((ess .getSettings ().showZeroBaltop () || balance .compareTo (BigDecimal .ZERO ) > 0 )
135141 && balance .compareTo (ess .getSettings ().getBaltopMinBalance ()) >= 0 &&
136- playTimeSecs >= ess .getSettings ().getBaltopMinPlaytime ()) {
142+ // Skip playtime check for offline players on versions below 1.15.2
143+ (playtime == -1 || playTimeSecs >= ess .getSettings ().getBaltopMinPlaytime ())) {
137144 newCache .getLines ().add (AdventureUtil .miniToLegacy (tlLiteral ("balanceTopLine" , pos , entry .getValue ().getDisplayName (), AdventureUtil .parsed (NumberUtil .displayCurrency (balance , ess )))));
138145 }
139146 pos ++;
0 commit comments