diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java index ec18498..643be6c 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java @@ -1,16 +1,14 @@ package com.Acrobot.ChestShop.Listeners.Player; -import com.Acrobot.Breeze.Utils.NameUtil; -import com.Acrobot.ChestShop.ChestShop; -import com.Acrobot.ChestShop.UUIDs.NameManager; -import com.Acrobot.ChestShop.UUIDs.PlayerDTO; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; -import java.util.UUID; +import com.Acrobot.ChestShop.ChestShop; +import com.Acrobot.ChestShop.UUIDs.NameManager; +import com.Acrobot.ChestShop.UUIDs.PlayerDTO; /** * @author Acrobot @@ -24,8 +22,8 @@ public class PlayerConnect implements Listener { Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(), new Runnable() { @Override public void run() { - String playerName = NameUtil.stripUsername(playerDTO.getName()); - UUID uuid = NameManager.getUUID(playerName); + // String playerName = NameUtil.stripUsername(playerDTO.getName()); + // UUID uuid = NameManager.getUUID(playerName); NameManager.storeUsername(playerDTO); } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java index ce657c1..00c7c04 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java @@ -118,8 +118,11 @@ public class PlayerInteract implements Listener { String material = sign.getLine(ITEM_LINE); String ownerName = NameManager.getFullUsername(name); - UUID uuid = NameManager.getUUID(ownerName); + if (ownerName == null || ownerName.isEmpty()) { + return null; + } + UUID uuid = NameManager.getUUID(ownerName); if (uuid == null) { return null; } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRefundListener.java b/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRefundListener.java index cfd792d..f480fef 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRefundListener.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/ShopRemoval/ShopRefundListener.java @@ -32,6 +32,10 @@ public class ShopRefundListener implements Listener { } String ownerName = NameManager.getFullUsername(event.getSign().getLine(NAME_LINE)); + if (ownerName.isEmpty()) { + return; + } + UUID owner = NameManager.getUUID(ownerName); CurrencyAddEvent currencyEvent = new CurrencyAddEvent(BigDecimal.valueOf(refundPrice), owner, event.getSign().getWorld()); diff --git a/src/main/java/com/Acrobot/ChestShop/UUIDs/NameManager.java b/src/main/java/com/Acrobot/ChestShop/UUIDs/NameManager.java index bd0dedd..a2bf230 100644 --- a/src/main/java/com/Acrobot/ChestShop/UUIDs/NameManager.java +++ b/src/main/java/com/Acrobot/ChestShop/UUIDs/NameManager.java @@ -9,6 +9,8 @@ import com.Acrobot.ChestShop.Signs.ChestShopSign; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.j256.ormlite.dao.Dao; + +import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; @@ -72,6 +74,8 @@ public class NameManager { } public static UUID getUUID(String username) { + Validate.notEmpty(username, "user cannot be null or empty!"); + if (usernameToUUID.containsKey(username)) { return usernameToUUID.get(username); } @@ -241,7 +245,7 @@ public class NameManager { return false; } - return shortenedName.equals(name) || Permission.otherName(player, name) || player.getUniqueId().equals(getUUID(name)); + return shortenedName.equals(name) || Permission.otherName(player, name) || (!name.isEmpty() && player.getUniqueId().equals(getUUID(name))); } public static boolean isAdminShop(UUID uuid) {