Fixed database errors if players were online during server reload

This commit is contained in:
cervinakuy committed 2022-10-14 19:11:20 -07:00
1 parent ed66227f95
commit 4479c259ac
1 file changed
+12
@@ -87,10 +87,22 @@ public class Game extends JavaPlugin implements Listener {
hasWorldGuard = true;
}
populateUUIDCacheForOnlinePlayers();
Toolkit.printToConsole("&7[&b&lKIT-PVP&7] &aDone!");
}
private void populateUUIDCacheForOnlinePlayers() {
// populates UUID cache if there are players online when doing /reload to avoid a lot of errors related
// to database and UUIDs
if (Bukkit.getOnlinePlayers().size() > 0) {
for (Player player : Bukkit.getOnlinePlayers()) {
CacheManager.getUUIDCache().put(player.getName(), player.getUniqueId().toString());
}
}
}
private void checkUpdate() {
Updater.of(this).resourceId(27107).handleResponse((versionResponse, version) -> {
switch (versionResponse) {