7
7
import com .earth2me .essentials .utils .AdventureUtil ;
8
8
import com .earth2me .essentials .utils .EnumUtil ;
9
9
import com .earth2me .essentials .utils .NumberUtil ;
10
+ import com .earth2me .essentials .utils .VersionUtil ;
10
11
import com .google .common .collect .Lists ;
11
12
import net .essentialsx .api .v2 .services .BalanceTop ;
12
13
import org .bukkit .Bukkit ;
@@ -121,9 +122,14 @@ public void run() {
121
122
final User user = ess .getUser (entry .getKey ());
122
123
123
124
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 );
124
126
final long playtime ;
125
127
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
+ }
127
133
} else {
128
134
playtime = user .getBase ().getStatistic (PLAY_ONE_TICK );
129
135
}
@@ -133,7 +139,8 @@ public void run() {
133
139
// Checking if player meets the requirements of minimum balance and minimum playtime to be listed in baltop list
134
140
if ((ess .getSettings ().showZeroBaltop () || balance .compareTo (BigDecimal .ZERO ) > 0 )
135
141
&& 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 ())) {
137
144
newCache .getLines ().add (AdventureUtil .miniToLegacy (tlLiteral ("balanceTopLine" , pos , entry .getValue ().getDisplayName (), AdventureUtil .parsed (NumberUtil .displayCurrency (balance , ess )))));
138
145
}
139
146
pos ++;
0 commit comments