This should cover the basics of UUID change

WARNING: Users with names longer than 15 characters will not be able to
receive money as long as they do not join the server
This commit is contained in:
Andrzej Pomirski 2014-04-10 22:52:21 +02:00
parent da7e236c0e
commit dd22c709e0
5 changed files with 25 additions and 3 deletions

View File

@ -34,6 +34,7 @@ import com.Acrobot.ChestShop.Listeners.ShopRemoval.ShopRemovalLogger;
import com.Acrobot.ChestShop.Logging.FileFormatter;
import com.Acrobot.ChestShop.Metadata.ItemDatabase;
import com.Acrobot.ChestShop.Signs.RestrictedSign;
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
import com.Acrobot.ChestShop.Utils.uName;
import com.avaje.ebean.EbeanServer;
import com.lennardf1989.bukkitex.Database;
@ -88,6 +89,8 @@ public class ChestShop extends JavaPlugin {
uName.file = loadFile("longName.storage");
uName.load();
UUIDSaver.load();
Methods.setPreferred(Properties.PREFERRED_ECONOMY_PLUGIN);
Dependencies.loadPlugins();

View File

@ -10,6 +10,7 @@ import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Plugins.ChestShop;
import com.Acrobot.ChestShop.Security;
import com.Acrobot.ChestShop.Signs.ChestShopSign;
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uName;
import org.bukkit.Bukkit;
@ -115,7 +116,7 @@ public class PlayerInteract implements Listener {
String prices = sign.getLine(PRICE_LINE);
String material = sign.getLine(ITEM_LINE);
String ownerName = uName.getName(name);
String ownerName = UUIDSaver.getFullUsername(name);
OfflinePlayer owner = Bukkit.getOfflinePlayer(ownerName);
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;

View File

@ -6,6 +6,7 @@ import com.Acrobot.ChestShop.Configuration.Messages;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Economy.Economy;
import com.Acrobot.ChestShop.Events.TransactionEvent;
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
import com.Acrobot.ChestShop.Utils.uName;
import com.google.common.base.Joiner;
import org.bukkit.Bukkit;
@ -15,6 +16,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
/**
* @author Acrobot
*/
@ -89,7 +92,7 @@ public class TransactionMessageSender implements Listener {
private static void sendMessageToOwner(String message, TransactionEvent event) {
String owner = event.getOwner().getName();
owner = uName.getName(owner);
owner = UUIDSaver.getFullUsername(owner);
Player player = Bukkit.getPlayerExact(owner);

View File

@ -7,6 +7,7 @@ import com.Acrobot.ChestShop.Economy.Economy;
import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent;
import com.Acrobot.ChestShop.Events.ShopDestroyedEvent;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
import com.Acrobot.ChestShop.Utils.uName;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -29,7 +30,7 @@ public class ShopRefundListener implements Listener {
return;
}
String owner = uName.getName(event.getSign().getLine(NAME_LINE));
String owner = UUIDSaver.getFullUsername(event.getSign().getLine(NAME_LINE));
CurrencyAddEvent currencyEvent = new CurrencyAddEvent(BigDecimal.valueOf(refundPrice), owner, event.getSign().getWorld());
ChestShop.callEvent(currencyEvent);

View File

@ -64,6 +64,20 @@ public class UUIDSaver {
return account.getName();
}
public static String getFullUsername(String username) {
String shortName = NameUtil.stripUsername(username);
Account account = null;
try {
account = accounts.queryBuilder().selectColumns("name").where().eq("shortName", shortName).queryForFirst();
} catch (SQLException e) {
e.printStackTrace();
return null;
}
return account.getName();
}
public static void storeUsername(Player player) {
UUID uuid = player.getUniqueId();