From a8c57bc0ab7cc59d8785c5e5fef3a1d72b312038 Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Tue, 7 May 2019 23:57:56 +0100 Subject: [PATCH] Set name line empty if name isn't usable and always use account name --- .../Listeners/PreShopCreation/NameChecker.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 2eee766..234aa3d 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java @@ -12,6 +12,7 @@ import org.bukkit.event.Listener; import static com.Acrobot.ChestShop.Permission.OTHER_NAME_CREATE; import static com.Acrobot.ChestShop.Signs.ChestShopSign.NAME_LINE; +import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.SHOP_CREATED_SUCCESSFULLY; import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.UNKNOWN_PLAYER; /** @@ -23,20 +24,22 @@ public class NameChecker implements Listener { public static void onPreShopCreation(PreShopCreationEvent event) { String name = event.getSignLine(NAME_LINE); Player player = event.getPlayer(); + event.setSignLine(NAME_LINE, ""); + event.setOutcome(UNKNOWN_PLAYER); if (name.isEmpty() || !NameManager.canUseName(player, OTHER_NAME_CREATE, name)) { Account account = NameManager.getOrCreateAccount(player); if (account != null) { event.setSignLine(NAME_LINE, account.getShortName()); - } else { - event.setOutcome(UNKNOWN_PLAYER); + event.setOutcome(SHOP_CREATED_SUCCESSFULLY); } } else { AccountQueryEvent accountQueryEvent = new AccountQueryEvent(name); Bukkit.getPluginManager().callEvent(accountQueryEvent); Account account = accountQueryEvent.getAccount(); - if (account == null) { - event.setOutcome(UNKNOWN_PLAYER); + if (account != null) { + event.setSignLine(NAME_LINE, account.getShortName()); + event.setOutcome(SHOP_CREATED_SUCCESSFULLY); } } }