Work around potential issues with Mojang API ratelimites on startup (#560)

This commit is contained in:
Phoenix616 2023-08-13 19:46:08 +01:00
parent 0b8fe80443
commit 2b36b7314f
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 8 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import com.Acrobot.ChestShop.Events.AccountAccessEvent;
import com.Acrobot.ChestShop.Events.AccountQueryEvent;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.j256.ormlite.dao.Dao;
@ -344,7 +345,13 @@ public class NameManager implements Listener {
try {
accounts = DaoCreator.getDaoAndCreateTable(Account.class);
adminAccount = new Account(Properties.ADMIN_SHOP_NAME, Bukkit.getOfflinePlayer(Properties.ADMIN_SHOP_NAME).getUniqueId());
try {
adminAccount = new Account(Properties.ADMIN_SHOP_NAME, Bukkit.getOfflinePlayer(Properties.ADMIN_SHOP_NAME).getUniqueId());
} catch (NullPointerException ratelimitedException) {
// This happens when the server was ratelimited by Mojang. Unfortunately there is no nice way to check that.
// We fall back to the method used by CraftBukkit to generate an OfflinePlayer's UUID
adminAccount = new Account(Properties.ADMIN_SHOP_NAME, UUID.nameUUIDFromBytes(("OfflinePlayer:" + Properties.ADMIN_SHOP_NAME).getBytes(Charsets.UTF_8)));
}
accounts.createOrUpdate(adminAccount);
if (!Properties.SERVER_ECONOMY_ACCOUNT.isEmpty()) {