mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-22 11:55:12 +01:00
Merge pull request #105 from RefusingsPaPa/master
Made the plugin use UUIDs rather than names
This commit is contained in:
commit
8c4867971f
@ -6,18 +6,19 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CrazyAuctions {
|
||||
|
||||
|
||||
private static CrazyAuctions instance = new CrazyAuctions();
|
||||
private FileManager fileManager = FileManager.getInstance();
|
||||
private Boolean sellingEnabled;
|
||||
private Boolean biddingEnabled;
|
||||
|
||||
|
||||
public static CrazyAuctions getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
public void loadCrazyAuctions() {
|
||||
if (Files.CONFIG.getFile().contains("Settings.Feature-Toggle.Selling")) {
|
||||
this.sellingEnabled = Files.CONFIG.getFile().getBoolean("Settings.Feature-Toggle.Selling");
|
||||
@ -30,34 +31,34 @@ public class CrazyAuctions {
|
||||
this.biddingEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Boolean isSellingEnabled() {
|
||||
return sellingEnabled;
|
||||
}
|
||||
|
||||
|
||||
public Boolean isBiddingEnabled() {
|
||||
return biddingEnabled;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<ItemStack> getItems(Player player) {
|
||||
FileConfiguration data = Files.DATA.getFile();
|
||||
ArrayList<ItemStack> items = new ArrayList<>();
|
||||
if (data.contains("Items")) {
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
|
||||
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
|
||||
if (UUID.fromString(data.getString("Items." + i + ".Seller")).equals(player.getUniqueId())) {
|
||||
items.add(data.getItemStack("Items." + i + ".Item").clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<ItemStack> getItems(Player player, ShopType type) {
|
||||
FileConfiguration data = Files.DATA.getFile();
|
||||
ArrayList<ItemStack> items = new ArrayList<>();
|
||||
if (data.contains("Items")) {
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
|
||||
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
|
||||
if (UUID.fromString(data.getString("Items." + i + ".Seller")).equals(player.getUniqueId())) {
|
||||
if (data.getBoolean("Items." + i + ".Biddable")) {
|
||||
if (type == ShopType.BID) {
|
||||
items.add(data.getItemStack("Items." + i + ".Item").clone());
|
||||
@ -72,5 +73,5 @@ public class CrazyAuctions {
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -21,10 +21,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class GUI implements Listener {
|
||||
@ -194,7 +191,7 @@ public class GUI implements Listener {
|
||||
}
|
||||
if (data.contains("Items")) {
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
|
||||
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
|
||||
if (UUID.fromString(data.getString("Items." + i + ".Seller")).equals(player.getUniqueId())) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String l : config.getStringList("Settings.GUISettings.CurrentLore")) {
|
||||
lore.add(l.replace("%Price%", Methods.getPrice(i, false)).replace("%price%", Methods.getPrice(i, false)).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))));
|
||||
@ -222,7 +219,7 @@ public class GUI implements Listener {
|
||||
if (data.contains("OutOfTime/Cancelled")) {
|
||||
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
||||
if (data.getString("OutOfTime/Cancelled." + i + ".Seller") != null) {
|
||||
if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getName())) {
|
||||
if (UUID.fromString(data.getString("OutOfTime/Cancelled." + i + ".Seller")).equals(player.getUniqueId())) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String l : config.getStringList("Settings.GUISettings.Cancelled/ExpiredLore")) {
|
||||
lore.add(l.replace("%Price%", Methods.getPrice(i, true)).replace("%price%", Methods.getPrice(i, true)).replace("%Time%", Methods.convertToTime(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"))).replace("%time%", Methods.convertToTime(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"))));
|
||||
@ -534,7 +531,7 @@ public class GUI implements Listener {
|
||||
}
|
||||
Bukkit.getPluginManager().callEvent(new AuctionNewBidEvent(player, data.getItemStack("Items." + ID + ".Item"), bid));
|
||||
data.set("Items." + ID + ".Price", bid);
|
||||
data.set("Items." + ID + ".TopBidder", player.getName());
|
||||
data.set("Items." + ID + ".TopBidder", player.getUniqueId().toString());
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("%Bid%", bid + "");
|
||||
player.sendMessage(Messages.BID_MESSAGE.getMessage(placeholders));
|
||||
@ -676,7 +673,7 @@ public class GUI implements Listener {
|
||||
}
|
||||
}
|
||||
final Runnable runnable = () -> inv.setItem(slot, item);
|
||||
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
|
||||
if (UUID.fromString(data.getString("Items." + i + ".Seller")).equals(player.getUniqueId())) {
|
||||
String it = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
|
||||
String name = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name");
|
||||
ItemStack I;
|
||||
@ -706,7 +703,7 @@ public class GUI implements Listener {
|
||||
return;
|
||||
}
|
||||
if (data.getBoolean("Items." + i + ".Biddable")) {
|
||||
if (player.getName().equalsIgnoreCase(data.getString("Items." + i + ".TopBidder"))) {
|
||||
if (player.getUniqueId().equals(UUID.fromString(data.getString("Items." + i + ".TopBidder")))) {
|
||||
String it = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Item");
|
||||
String name = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Name");
|
||||
ItemStack I;
|
||||
@ -885,7 +882,7 @@ public class GUI implements Listener {
|
||||
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
|
||||
if (data.contains("OutOfTime/Cancelled")) {
|
||||
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
||||
if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getName())) {
|
||||
if (UUID.fromString(data.getString("OutOfTime/Cancelled." + i + ".Seller")).equals(player.getUniqueId())) {
|
||||
if (Methods.isInvFull(player)) {
|
||||
player.sendMessage(Messages.INVENTORY_FULL.getMessage());
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user