Skip to content

Commit

Permalink
Work around potential issues with Mojang API ratelimites on startup (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Phoenix616 committed Aug 13, 2023
1 parent 0b8fe80 commit 2b36b73
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/com/Acrobot/ChestShop/UUIDs/NameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;

Expand Down Expand Up @@ -344,7 +345,13 @@ public static void load() {
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()) {
Expand Down

0 comments on commit 2b36b73

Please sign in to comment.