mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-27 12:38:40 +01:00
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:
parent
da7e236c0e
commit
dd22c709e0
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user