mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-23 18:45:31 +01:00
More UUID changes
This commit is contained in:
parent
7321e6dc07
commit
4107b10f4b
@ -1,12 +1,13 @@
|
|||||||
package com.Acrobot.Breeze.Utils;
|
package com.Acrobot.Breeze.Utils;
|
||||||
|
|
||||||
import org.bukkit.block.*;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
|
import org.bukkit.block.DoubleChest;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.material.*;
|
import org.bukkit.material.Attachable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -19,7 +19,10 @@ import com.Acrobot.ChestShop.Listeners.Item.ItemMoveListener;
|
|||||||
import com.Acrobot.ChestShop.Listeners.ItemInfoListener;
|
import com.Acrobot.ChestShop.Listeners.ItemInfoListener;
|
||||||
import com.Acrobot.ChestShop.Listeners.Modules.DiscountModule;
|
import com.Acrobot.ChestShop.Listeners.Modules.DiscountModule;
|
||||||
import com.Acrobot.ChestShop.Listeners.Modules.PriceRestrictionModule;
|
import com.Acrobot.ChestShop.Listeners.Modules.PriceRestrictionModule;
|
||||||
import com.Acrobot.ChestShop.Listeners.Player.*;
|
import com.Acrobot.ChestShop.Listeners.Player.PlayerConnect;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Player.PlayerInteract;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Player.PlayerInventory;
|
||||||
|
import com.Acrobot.ChestShop.Listeners.Player.PlayerTeleport;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.CreationFeeGetter;
|
import com.Acrobot.ChestShop.Listeners.PostShopCreation.CreationFeeGetter;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.MessageSender;
|
import com.Acrobot.ChestShop.Listeners.PostShopCreation.MessageSender;
|
||||||
import com.Acrobot.ChestShop.Listeners.PostShopCreation.ShopCreationLogger;
|
import com.Acrobot.ChestShop.Listeners.PostShopCreation.ShopCreationLogger;
|
||||||
@ -34,8 +37,7 @@ import com.Acrobot.ChestShop.Listeners.ShopRemoval.ShopRemovalLogger;
|
|||||||
import com.Acrobot.ChestShop.Logging.FileFormatter;
|
import com.Acrobot.ChestShop.Logging.FileFormatter;
|
||||||
import com.Acrobot.ChestShop.Metadata.ItemDatabase;
|
import com.Acrobot.ChestShop.Metadata.ItemDatabase;
|
||||||
import com.Acrobot.ChestShop.Signs.RestrictedSign;
|
import com.Acrobot.ChestShop.Signs.RestrictedSign;
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import com.Acrobot.ChestShop.Utils.uName;
|
|
||||||
import com.avaje.ebean.EbeanServer;
|
import com.avaje.ebean.EbeanServer;
|
||||||
import com.lennardf1989.bukkitex.Database;
|
import com.lennardf1989.bukkitex.Database;
|
||||||
import com.nijikokun.register.payment.forChestShop.Methods;
|
import com.nijikokun.register.payment.forChestShop.Methods;
|
||||||
@ -86,10 +88,7 @@ public class ChestShop extends JavaPlugin {
|
|||||||
|
|
||||||
itemDatabase = new ItemDatabase();
|
itemDatabase = new ItemDatabase();
|
||||||
|
|
||||||
uName.file = loadFile("longName.storage");
|
NameManager.load();
|
||||||
uName.load();
|
|
||||||
|
|
||||||
UUIDSaver.load();
|
|
||||||
|
|
||||||
Methods.setPreferred(Properties.PREFERRED_ECONOMY_PLUGIN);
|
Methods.setPreferred(Properties.PREFERRED_ECONOMY_PLUGIN);
|
||||||
|
|
||||||
@ -196,7 +195,6 @@ public class ChestShop extends JavaPlugin {
|
|||||||
registerEvent(new ItemInfoListener());
|
registerEvent(new ItemInfoListener());
|
||||||
|
|
||||||
registerEvent(new RestrictedSign());
|
registerEvent(new RestrictedSign());
|
||||||
registerEvent(new ShortNameSaver());
|
|
||||||
|
|
||||||
if (!Properties.TURN_OFF_HOPPER_PROTECTION) {
|
if (!Properties.TURN_OFF_HOPPER_PROTECTION) {
|
||||||
registerEvent(new ItemMoveListener());
|
registerEvent(new ItemMoveListener());
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.Acrobot.ChestShop.Events.Economy;
|
package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -29,7 +29,7 @@ public class CurrencyAddEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CurrencyAddEvent(BigDecimal amount, Player target) {
|
public CurrencyAddEvent(BigDecimal amount, Player target) {
|
||||||
this(amount, UUIDSaver.getUsername(target.getUniqueId()), target.getWorld());
|
this(amount, NameManager.getUsername(target.getUniqueId()), target.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.Acrobot.ChestShop.Events.Economy;
|
package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -26,7 +26,7 @@ public class CurrencyAmountEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CurrencyAmountEvent(Player player) {
|
public CurrencyAmountEvent(Player player) {
|
||||||
this(UUIDSaver.getUsername(player.getUniqueId()), player.getWorld());
|
this(NameManager.getUsername(player.getUniqueId()), player.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.Acrobot.ChestShop.Events.Economy;
|
package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -29,7 +29,7 @@ public class CurrencyCheckEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CurrencyCheckEvent(BigDecimal amount, Player player) {
|
public CurrencyCheckEvent(BigDecimal amount, Player player) {
|
||||||
this(amount, UUIDSaver.getUsername(player.getUniqueId()), player.getWorld());
|
this(amount, NameManager.getUsername(player.getUniqueId()), player.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.Acrobot.ChestShop.Events.Economy;
|
package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -29,7 +29,7 @@ public class CurrencyHoldEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CurrencyHoldEvent(BigDecimal amount, Player target) {
|
public CurrencyHoldEvent(BigDecimal amount, Player target) {
|
||||||
this(amount, UUIDSaver.getUsername(target.getUniqueId()), target.getWorld());
|
this(amount, NameManager.getUsername(target.getUniqueId()), target.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.Acrobot.ChestShop.Events.Economy;
|
package com.Acrobot.ChestShop.Events.Economy;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -29,7 +29,7 @@ public class CurrencySubtractEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CurrencySubtractEvent(BigDecimal amount, Player target) {
|
public CurrencySubtractEvent(BigDecimal amount, Player target) {
|
||||||
this(amount, UUIDSaver.getUsername(target.getUniqueId()), target.getWorld());
|
this(amount, NameManager.getUsername(target.getUniqueId()), target.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +38,7 @@ import static com.Acrobot.Breeze.Utils.BlockUtil.isSign;
|
|||||||
import static com.Acrobot.ChestShop.Permission.ADMIN;
|
import static com.Acrobot.ChestShop.Permission.ADMIN;
|
||||||
import static com.Acrobot.ChestShop.Permission.MOD;
|
import static com.Acrobot.ChestShop.Permission.MOD;
|
||||||
import static com.Acrobot.ChestShop.Signs.ChestShopSign.NAME_LINE;
|
import static com.Acrobot.ChestShop.Signs.ChestShopSign.NAME_LINE;
|
||||||
import static com.Acrobot.ChestShop.Utils.uName.canUseName;
|
import static com.Acrobot.ChestShop.UUIDs.NameManager.canUseName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Acrobot
|
* @author Acrobot
|
||||||
|
@ -3,7 +3,7 @@ package com.Acrobot.ChestShop.Listeners.Player;
|
|||||||
import com.Acrobot.ChestShop.ChestShop;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
import com.Acrobot.ChestShop.Permission;
|
import com.Acrobot.ChestShop.Permission;
|
||||||
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
@ -30,6 +30,6 @@ public class PlayerConnect implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public static void onPlayerConnect(PlayerJoinEvent event) {
|
public static void onPlayerConnect(PlayerJoinEvent event) {
|
||||||
UUIDSaver.storeUsername(event.getPlayer());
|
NameManager.storeUsername(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import com.Acrobot.ChestShop.Permission;
|
|||||||
import com.Acrobot.ChestShop.Plugins.ChestShop;
|
import com.Acrobot.ChestShop.Plugins.ChestShop;
|
||||||
import com.Acrobot.ChestShop.Security;
|
import com.Acrobot.ChestShop.Security;
|
||||||
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import com.Acrobot.ChestShop.Utils.uBlock;
|
import com.Acrobot.ChestShop.Utils.uBlock;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -115,8 +115,8 @@ public class PlayerInteract implements Listener {
|
|||||||
String prices = sign.getLine(PRICE_LINE);
|
String prices = sign.getLine(PRICE_LINE);
|
||||||
String material = sign.getLine(ITEM_LINE);
|
String material = sign.getLine(ITEM_LINE);
|
||||||
|
|
||||||
String ownerName = UUIDSaver.getFullUsername(name);
|
String ownerName = NameManager.getFullUsername(name);
|
||||||
OfflinePlayer owner = Bukkit.getOfflinePlayer(UUIDSaver.getUUID(ownerName));
|
OfflinePlayer owner = Bukkit.getOfflinePlayer(NameManager.getUUID(ownerName));
|
||||||
|
|
||||||
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
|
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
|
||||||
double price = (action == buy ? PriceUtil.getBuyPrice(prices) : PriceUtil.getSellPrice(prices));
|
double price = (action == buy ? PriceUtil.getBuyPrice(prices) : PriceUtil.getSellPrice(prices));
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package com.Acrobot.ChestShop.Listeners.Player;
|
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.Events.ShopCreatedEvent;
|
|
||||||
import com.Acrobot.ChestShop.Utils.uName;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Acrobot
|
|
||||||
*/
|
|
||||||
public class ShortNameSaver implements Listener {
|
|
||||||
@EventHandler
|
|
||||||
public static void onShopCreated(ShopCreatedEvent event) {
|
|
||||||
uName.saveName(event.getPlayer().getName());
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,7 @@ import com.Acrobot.ChestShop.ChestShop;
|
|||||||
import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent;
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent;
|
||||||
import com.Acrobot.ChestShop.Events.Economy.CurrencySubtractEvent;
|
import com.Acrobot.ChestShop.Events.Economy.CurrencySubtractEvent;
|
||||||
import com.Acrobot.ChestShop.Events.TransactionEvent;
|
import com.Acrobot.ChestShop.Events.TransactionEvent;
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public class EconomicModule implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(BigDecimal.valueOf(event.getPrice()),
|
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(BigDecimal.valueOf(event.getPrice()),
|
||||||
UUIDSaver.getUsername(event.getOwner().getUniqueId()),
|
NameManager.getUsername(event.getOwner().getUniqueId()),
|
||||||
event.getSign().getWorld());
|
event.getSign().getWorld());
|
||||||
ChestShop.callEvent(currencyAddEvent);
|
ChestShop.callEvent(currencyAddEvent);
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class EconomicModule implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(BigDecimal.valueOf(event.getPrice()),
|
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(BigDecimal.valueOf(event.getPrice()),
|
||||||
UUIDSaver.getUsername(event.getOwner().getUniqueId()),
|
NameManager.getUsername(event.getOwner().getUniqueId()),
|
||||||
event.getSign().getWorld());
|
event.getSign().getWorld());
|
||||||
ChestShop.callEvent(currencySubtractEvent);
|
ChestShop.callEvent(currencySubtractEvent);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import com.Acrobot.ChestShop.Configuration.Messages;
|
|||||||
import com.Acrobot.ChestShop.Configuration.Properties;
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||||
import com.Acrobot.ChestShop.Economy.Economy;
|
import com.Acrobot.ChestShop.Economy.Economy;
|
||||||
import com.Acrobot.ChestShop.Events.TransactionEvent;
|
import com.Acrobot.ChestShop.Events.TransactionEvent;
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -89,7 +89,7 @@ public class TransactionMessageSender implements Listener {
|
|||||||
|
|
||||||
private static void sendMessageToOwner(String message, TransactionEvent event) {
|
private static void sendMessageToOwner(String message, TransactionEvent event) {
|
||||||
String owner = event.getOwner().getName();
|
String owner = event.getOwner().getName();
|
||||||
owner = UUIDSaver.getFullUsername(owner);
|
owner = NameManager.getFullUsername(owner);
|
||||||
|
|
||||||
Player player = Bukkit.getPlayerExact(owner);
|
Player player = Bukkit.getPlayerExact(owner);
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package com.Acrobot.ChestShop.Listeners.PreShopCreation;
|
package com.Acrobot.ChestShop.Listeners.PreShopCreation;
|
||||||
|
|
||||||
|
import com.Acrobot.Breeze.Utils.NameUtil;
|
||||||
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
|
import com.Acrobot.ChestShop.Events.PreShopCreationEvent;
|
||||||
import com.Acrobot.ChestShop.Permission;
|
import com.Acrobot.ChestShop.Permission;
|
||||||
import com.Acrobot.ChestShop.Utils.uName;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -20,8 +21,12 @@ public class NameChecker implements Listener {
|
|||||||
String name = event.getSignLine(NAME_LINE);
|
String name = event.getSignLine(NAME_LINE);
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (name.isEmpty() || (!uName.canUseName(player, name) && !Permission.has(player, Permission.ADMIN))) {
|
if (name.isEmpty()) {
|
||||||
String shortName = uName.stripName(player);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NameManager.canUseName(player, name) && !Permission.has(player, Permission.ADMIN)) {
|
||||||
|
String shortName = NameUtil.stripUsername(NameManager.getUsername(player.getUniqueId()));
|
||||||
event.setSignLine(NAME_LINE, shortName);
|
event.setSignLine(NAME_LINE, shortName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.Acrobot.Breeze.Utils.InventoryUtil;
|
|||||||
import com.Acrobot.ChestShop.ChestShop;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
import com.Acrobot.ChestShop.Events.Economy.CurrencyCheckEvent;
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyCheckEvent;
|
||||||
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
|
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@ -53,7 +53,7 @@ public class AmountAndPriceChecker implements Listener {
|
|||||||
Inventory clientInventory = event.getClientInventory();
|
Inventory clientInventory = event.getClientInventory();
|
||||||
|
|
||||||
CurrencyCheckEvent currencyCheckEvent = new CurrencyCheckEvent(BigDecimal.valueOf(event.getPrice()),
|
CurrencyCheckEvent currencyCheckEvent = new CurrencyCheckEvent(BigDecimal.valueOf(event.getPrice()),
|
||||||
UUIDSaver.getUsername(event.getOwner().getUniqueId()),
|
NameManager.getUsername(event.getOwner().getUniqueId()),
|
||||||
event.getSign().getWorld());
|
event.getSign().getWorld());
|
||||||
ChestShop.callEvent(currencyCheckEvent);
|
ChestShop.callEvent(currencyCheckEvent);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import com.Acrobot.ChestShop.Events.Economy.CurrencyAmountEvent;
|
|||||||
import com.Acrobot.ChestShop.Events.Economy.CurrencyCheckEvent;
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyCheckEvent;
|
||||||
import com.Acrobot.ChestShop.Events.Economy.CurrencyHoldEvent;
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyHoldEvent;
|
||||||
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
|
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -61,7 +61,7 @@ public class PartialTransactionModule implements Listener {
|
|||||||
event.setStock(getCountedItemStack(stock, amountAffordable));
|
event.setStock(getCountedItemStack(stock, amountAffordable));
|
||||||
}
|
}
|
||||||
|
|
||||||
String seller = UUIDSaver.getUsername(event.getOwner().getUniqueId());
|
String seller = NameManager.getUsername(event.getOwner().getUniqueId());
|
||||||
|
|
||||||
CurrencyHoldEvent currencyHoldEvent = new CurrencyHoldEvent(BigDecimal.valueOf(price), seller, client.getWorld());
|
CurrencyHoldEvent currencyHoldEvent = new CurrencyHoldEvent(BigDecimal.valueOf(price), seller, client.getWorld());
|
||||||
ChestShop.callEvent(currencyHoldEvent);
|
ChestShop.callEvent(currencyHoldEvent);
|
||||||
@ -94,7 +94,7 @@ public class PartialTransactionModule implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player client = event.getClient();
|
Player client = event.getClient();
|
||||||
String ownerName = UUIDSaver.getUsername(event.getOwner().getUniqueId());
|
String ownerName = NameManager.getUsername(event.getOwner().getUniqueId());
|
||||||
ItemStack[] stock = event.getStock();
|
ItemStack[] stock = event.getStock();
|
||||||
|
|
||||||
double price = event.getPrice();
|
double price = event.getPrice();
|
||||||
|
@ -7,7 +7,7 @@ import com.Acrobot.ChestShop.Economy.Economy;
|
|||||||
import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent;
|
import com.Acrobot.ChestShop.Events.Economy.CurrencyAddEvent;
|
||||||
import com.Acrobot.ChestShop.Events.ShopDestroyedEvent;
|
import com.Acrobot.ChestShop.Events.ShopDestroyedEvent;
|
||||||
import com.Acrobot.ChestShop.Permission;
|
import com.Acrobot.ChestShop.Permission;
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -29,7 +29,7 @@ public class ShopRefundListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String owner = UUIDSaver.getFullUsername(event.getSign().getLine(NAME_LINE));
|
String owner = NameManager.getFullUsername(event.getSign().getLine(NAME_LINE));
|
||||||
|
|
||||||
CurrencyAddEvent currencyEvent = new CurrencyAddEvent(BigDecimal.valueOf(refundPrice), owner, event.getSign().getWorld());
|
CurrencyAddEvent currencyEvent = new CurrencyAddEvent(BigDecimal.valueOf(refundPrice), owner, event.getSign().getWorld());
|
||||||
ChestShop.callEvent(currencyEvent);
|
ChestShop.callEvent(currencyEvent);
|
||||||
|
@ -3,8 +3,8 @@ package com.Acrobot.ChestShop.Plugins;
|
|||||||
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
||||||
import com.Acrobot.ChestShop.Permission;
|
import com.Acrobot.ChestShop.Permission;
|
||||||
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
||||||
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import com.Acrobot.ChestShop.Utils.uBlock;
|
import com.Acrobot.ChestShop.Utils.uBlock;
|
||||||
import com.Acrobot.ChestShop.Utils.uName;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -67,6 +67,6 @@ public class ChestShop implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isShopMember(Player player, Sign sign) {
|
private static boolean isShopMember(Player player, Sign sign) {
|
||||||
return uName.canUseName(player, sign.getLine(0));
|
return NameManager.canUseName(player, sign.getLine(ChestShopSign.NAME_LINE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.Acrobot.ChestShop.Plugins;
|
package com.Acrobot.ChestShop.Plugins;
|
||||||
|
|
||||||
|
import com.Acrobot.Breeze.Utils.NameUtil;
|
||||||
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
||||||
import com.Acrobot.ChestShop.Utils.uName;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -25,7 +26,7 @@ public class Lockette implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String shortPlayerName = uName.stripName(player);
|
String shortPlayerName = NameUtil.stripUsername(NameManager.getUsername(player.getUniqueId()));
|
||||||
|
|
||||||
if (!org.yi.acru.bukkit.Lockette.Lockette.isUser(block, shortPlayerName, true)) {
|
if (!org.yi.acru.bukkit.Lockette.Lockette.isUser(block, shortPlayerName, true)) {
|
||||||
event.setResult(Event.Result.DENY);
|
event.setResult(Event.Result.DENY);
|
||||||
|
@ -6,7 +6,7 @@ import com.Acrobot.ChestShop.Configuration.Properties;
|
|||||||
import com.Acrobot.ChestShop.Events.Protection.ProtectBlockEvent;
|
import com.Acrobot.ChestShop.Events.Protection.ProtectBlockEvent;
|
||||||
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
||||||
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
||||||
import com.Acrobot.ChestShop.UUIDs.UUIDSaver;
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -64,7 +64,7 @@ public class Security {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean anotherShopFound(Block baseBlock, Block signBlock, Player player) {
|
private static boolean anotherShopFound(Block baseBlock, Block signBlock, Player player) {
|
||||||
String playerName = UUIDSaver.getUsername(player.getUniqueId());
|
String playerName = NameManager.getUsername(player.getUniqueId());
|
||||||
String shortName = NameUtil.stripUsername(playerName);
|
String shortName = NameUtil.stripUsername(playerName);
|
||||||
|
|
||||||
for (BlockFace face : SIGN_CONNECTION_FACES) {
|
for (BlockFace face : SIGN_CONNECTION_FACES) {
|
||||||
|
@ -3,8 +3,8 @@ package com.Acrobot.ChestShop.Signs;
|
|||||||
import com.Acrobot.Breeze.Utils.BlockUtil;
|
import com.Acrobot.Breeze.Utils.BlockUtil;
|
||||||
import com.Acrobot.ChestShop.Configuration.Properties;
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
||||||
import com.Acrobot.ChestShop.Containers.AdminInventory;
|
import com.Acrobot.ChestShop.Containers.AdminInventory;
|
||||||
|
import com.Acrobot.ChestShop.UUIDs.NameManager;
|
||||||
import com.Acrobot.ChestShop.Utils.uBlock;
|
import com.Acrobot.ChestShop.Utils.uBlock;
|
||||||
import com.Acrobot.ChestShop.Utils.uName;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.DoubleChest;
|
import org.bukkit.block.DoubleChest;
|
||||||
@ -81,7 +81,7 @@ public class ChestShopSign {
|
|||||||
if (player == null) return false;
|
if (player == null) return false;
|
||||||
if (sign == null) return true;
|
if (sign == null) return true;
|
||||||
|
|
||||||
return uName.canUseName(player, sign.getLine(0));
|
return NameManager.canUseName(player, sign.getLine(NAME_LINE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValidPreparedSign(String[] lines) {
|
public static boolean isValidPreparedSign(String[] lines) {
|
||||||
|
@ -4,6 +4,7 @@ import com.Acrobot.Breeze.Utils.NameUtil;
|
|||||||
import com.Acrobot.ChestShop.ChestShop;
|
import com.Acrobot.ChestShop.ChestShop;
|
||||||
import com.Acrobot.ChestShop.Database.Account;
|
import com.Acrobot.ChestShop.Database.Account;
|
||||||
import com.Acrobot.ChestShop.Database.ConnectionManager;
|
import com.Acrobot.ChestShop.Database.ConnectionManager;
|
||||||
|
import com.Acrobot.ChestShop.Permission;
|
||||||
import com.j256.ormlite.dao.Dao;
|
import com.j256.ormlite.dao.Dao;
|
||||||
import com.j256.ormlite.dao.DaoManager;
|
import com.j256.ormlite.dao.DaoManager;
|
||||||
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
||||||
@ -20,7 +21,7 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @author Andrzej Pomirski (Acrobot)
|
* @author Andrzej Pomirski (Acrobot)
|
||||||
*/
|
*/
|
||||||
public class UUIDSaver {
|
public class NameManager {
|
||||||
private static Dao<Account, String> accounts;
|
private static Dao<Account, String> accounts;
|
||||||
|
|
||||||
public static UUID getUUID(String username) {
|
public static UUID getUUID(String username) {
|
||||||
@ -102,6 +103,12 @@ public class UUIDSaver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean canUseName(Player player, String name) {
|
||||||
|
String shortenedName = NameUtil.stripUsername(getUsername(player.getUniqueId()));
|
||||||
|
|
||||||
|
return shortenedName.equals(name) || Permission.otherName(player, name);
|
||||||
|
}
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
File databaseFile = ChestShop.loadFile("users.db");
|
File databaseFile = ChestShop.loadFile("users.db");
|
||||||
String uri = ConnectionManager.getURI(databaseFile);
|
String uri = ConnectionManager.getURI(databaseFile);
|
@ -1,58 +0,0 @@
|
|||||||
package com.Acrobot.ChestShop.Utils;
|
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.Permission;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Acrobot
|
|
||||||
*/
|
|
||||||
public class uName {
|
|
||||||
public static YamlConfiguration config;
|
|
||||||
public static File file;
|
|
||||||
|
|
||||||
public static String getName(String shortName) {
|
|
||||||
return config.getString(shortName, shortName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void saveName(String name) {
|
|
||||||
if (name.length() <= 15) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
config.set(stripName(name), name);
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String stripName(String name) {
|
|
||||||
if (name.length() > 15) {
|
|
||||||
return name.substring(0, 15);
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String stripName(Player player) {
|
|
||||||
return stripName(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canUseName(Player player, String name) {
|
|
||||||
return stripName(player).equals(name) || Permission.otherName(player, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void load() {
|
|
||||||
config = YamlConfiguration.loadConfiguration(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void reload() {
|
|
||||||
try {
|
|
||||||
config.save(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
load();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user