Try to fix a few more errors

Fixes #7
This commit is contained in:
Dan Mulloy 2016-09-20 15:45:18 -04:00
parent 3fa939983b
commit e186635484
4 changed files with 18 additions and 9 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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());

View File

@ -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) {