diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java b/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java index 5839185..4d255ce 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java @@ -1,10 +1,10 @@ package com.Acrobot.ChestShop.Listeners.PreShopCreation; +import com.Acrobot.ChestShop.ChestShop; import com.Acrobot.ChestShop.Database.Account; import com.Acrobot.ChestShop.Events.AccountQueryEvent; import com.Acrobot.ChestShop.Events.PreShopCreationEvent; import com.Acrobot.ChestShop.UUIDs.NameManager; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -41,8 +41,20 @@ public class NameChecker implements Listener { account = NameManager.getOrCreateAccount(player); } else { AccountQueryEvent accountQueryEvent = new AccountQueryEvent(name); - Bukkit.getPluginManager().callEvent(accountQueryEvent); + ChestShop.callEvent(accountQueryEvent); account = accountQueryEvent.getAccount(); + if (account == null) { + Player otherPlayer = ChestShop.getBukkitServer().getPlayer(name); + try { + if (otherPlayer != null) { + account = NameManager.getOrCreateAccount(otherPlayer); + } else { + account = NameManager.getOrCreateAccount(ChestShop.getBukkitServer().getOfflinePlayer(name)); + } + } catch (IllegalArgumentException e) { + event.getPlayer().sendMessage(e.getMessage()); + } + } } } catch (Exception e) { e.printStackTrace();