Finish migrating code to use uuids instead of player names

This commit is contained in:
Ryder Belserion 2024-06-16 21:38:06 -04:00
parent 39442f5663
commit 6292987f48
No known key found for this signature in database
10 changed files with 244 additions and 98 deletions

View File

@ -1,7 +1,7 @@
[versions] [versions]
# Minecraft # Minecraft
paper = "1.21-R0.1-SNAPSHOT" paper = "1.20.6-R0.1-SNAPSHOT"
minecraft = "1.21" minecraft = "1.20.6"
# Plugins # Plugins
itemsadder = "3.6.3-beta-14" itemsadder = "3.6.3-beta-14"
@ -22,7 +22,7 @@ kyori = "4.17.0"
vital = "1.5.9" vital = "1.5.9"
# Paper # Paper
paperweight="1.7.1" paperweight = "1.7.1"
runPaper = "2.3.0" runPaper = "2.3.0"
hangar = "0.1.2" hangar = "0.1.2"

View File

@ -65,7 +65,7 @@ tasks {
url("https://download.luckperms.net/1544/bukkit/loader/LuckPerms-Bukkit-5.4.131.jar") url("https://download.luckperms.net/1544/bukkit/loader/LuckPerms-Bukkit-5.4.131.jar")
} }
minecraftVersion("1.20.4") minecraftVersion("1.20.6")
} }
assemble { assemble {

View File

@ -118,7 +118,6 @@ timings:
url: https://timings.aikar.co/ url: https://timings.aikar.co/
verbose: false verbose: false
unsupported-settings: unsupported-settings:
allow-grindstone-overstacking: false
allow-headless-pistons: false allow-headless-pistons: false
allow-permanent-block-break-exploits: false allow-permanent-block-break-exploits: false
allow-piston-duplication: false allow-piston-duplication: false
@ -126,6 +125,7 @@ unsupported-settings:
allow-unsafe-end-portal-teleportation: false allow-unsafe-end-portal-teleportation: false
compression-format: ZLIB compression-format: ZLIB
perform-username-validation: true perform-username-validation: true
skip-vanilla-damage-tick-when-shield-blocked: false
watchdog: watchdog:
early-warning-delay: 10000 early-warning-delay: 10000
early-warning-every: 5000 early-warning-every: 5000

View File

@ -12,7 +12,7 @@
# Discord: https://discord.gg/papermc # Discord: https://discord.gg/papermc
# Website: https://papermc.io/ # Website: https://papermc.io/
_version: 30 _version: 31
anticheat: anticheat:
anti-xray: anti-xray:
enabled: false enabled: false
@ -131,7 +131,6 @@ entities:
wither: true wither: true
wither-skeleton: true wither-skeleton: true
spiders-immune-to-poison-effect: true spiders-immune-to-poison-effect: true
undead-immune-to-certain-effects: true
sniffer: sniffer:
boosted-hatch-time: default boosted-hatch-time: default
hatch-time: default hatch-time: default

View File

@ -5,6 +5,12 @@
"level": 4, "level": 4,
"bypassesPlayerLimit": false "bypassesPlayerLimit": false
}, },
{
"uuid": "42bf0b48-8574-44b5-8cce-5accf9363b05",
"name": "mitchy387",
"level": 4,
"bypassesPlayerLimit": false
},
{ {
"uuid": "64ccbf4e-87d2-490f-9370-8c4e53df9013", "uuid": "64ccbf4e-87d2-490f-9370-8c4e53df9013",
"name": "Rukkhadevata", "name": "Rukkhadevata",

View File

@ -1,61 +1,63 @@
#Minecraft server properties #Minecraft server properties
#Sun Mar 24 11:23:50 EDT 2024 #Sun Jun 16 21:34:17 EDT 2024
enable-jmx-monitoring=false accepts-transfers=false
rcon.port=25575
level-seed=
gamemode=survival
enable-command-block=false
enable-query=false
generator-settings={}
enforce-secure-profile=true
level-name=world
motd=A test server
query.port=25565
pvp=true
generate-structures=true
max-chained-neighbor-updates=1000000
difficulty=peaceful
network-compression-threshold=256
max-tick-time=60000
require-resource-pack=false
use-native-transport=true
max-players=5
online-mode=true
enable-status=true
allow-flight=false allow-flight=false
initial-disabled-packs=
broadcast-rcon-to-ops=false
view-distance=6
server-ip=
resource-pack-prompt=
allow-nether=false allow-nether=false
server-port=25565
enable-rcon=false
sync-chunk-writes=false
resource-pack-id=
op-permission-level=4
prevent-proxy-connections=false
hide-online-players=false
resource-pack=
entity-broadcast-range-percentage=100
simulation-distance=10
rcon.password=
player-idle-timeout=0
debug=false
force-gamemode=false
rate-limit=0
hardcore=false
white-list=false
broadcast-console-to-ops=false broadcast-console-to-ops=false
spawn-npcs=true broadcast-rcon-to-ops=false
spawn-animals=true debug=false
log-ips=false difficulty=peaceful
function-permission-level=2 enable-command-block=false
initial-enabled-packs=vanilla enable-jmx-monitoring=false
level-type=minecraft\:normal enable-query=false
text-filtering-config= enable-rcon=false
spawn-monsters=true enable-status=true
enforce-secure-profile=true
enforce-whitelist=false enforce-whitelist=false
spawn-protection=32 entity-broadcast-range-percentage=100
resource-pack-sha1= force-gamemode=false
function-permission-level=2
gamemode=survival
generate-structures=true
generator-settings={}
hardcore=false
hide-online-players=false
initial-disabled-packs=
initial-enabled-packs=vanilla
level-name=world
level-seed=
level-type=minecraft\:normal
log-ips=false
max-chained-neighbor-updates=1000000
max-players=5
max-tick-time=60000
max-world-size=29999984 max-world-size=29999984
motd=A test server
network-compression-threshold=256
online-mode=true
op-permission-level=4
player-idle-timeout=0
prevent-proxy-connections=false
pvp=true
query.port=25565
rate-limit=0
rcon.password=
rcon.port=25575
region-file-compression=deflate
require-resource-pack=false
resource-pack=
resource-pack-id=
resource-pack-prompt=
resource-pack-sha1=
server-ip=
server-port=25565
simulation-distance=10
spawn-animals=true
spawn-monsters=true
spawn-npcs=true
spawn-protection=32
sync-chunk-writes=false
text-filtering-config=
use-native-transport=true
view-distance=6
white-list=false

View File

@ -59,6 +59,7 @@ players:
disable-saving: false disable-saving: false
world-settings: world-settings:
default: default:
unload-frozen-chunks: false
seed-trialchambers: 94251327 seed-trialchambers: 94251327
below-zero-generation-in-existing-chunks: true below-zero-generation-in-existing-chunks: true
hanging-tick-frequency: 100 hanging-tick-frequency: 100

View File

@ -74,7 +74,7 @@ public class Methods {
public static Player getPlayer(String name) { public static Player getPlayer(String name) {
try { try {
return Bukkit.getServer().getPlayer(name); return Bukkit.getServer().getPlayer(UUID.fromString(name));
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }
@ -89,7 +89,7 @@ public class Methods {
} }
public static OfflinePlayer getOfflinePlayer(String name) { public static OfflinePlayer getOfflinePlayer(String name) {
return Bukkit.getServer().getOfflinePlayer(name); return Bukkit.getServer().getOfflinePlayer(UUID.fromString(name));
} }
public static boolean isOnline(String name) { public static boolean isOnline(String name) {

View File

@ -6,6 +6,7 @@ import org.bukkit.configuration.file.FileConfiguration;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public enum Messages { public enum Messages {
@ -75,7 +76,7 @@ public enum Messages {
return message; return message;
} }
public static String convertList(List<String> list, HashMap<String, String> placeholders) { public static String convertList(List<String> list, Map<String, String> placeholders) {
String message = convertList(list); String message = convertList(list);
for (String ph : placeholders.keySet()) { for (String ph : placeholders.keySet()) {
@ -120,7 +121,7 @@ public enum Messages {
} }
} }
public String getMessage(HashMap<String, String> placeholders) { public String getMessage(Map<String, String> placeholders) {
String message; String message;
if (isList()) { if (isList()) {

View File

@ -6,14 +6,15 @@ import com.badbones69.crazyauctions.api.*;
import com.badbones69.crazyauctions.api.FileManager.Files; import com.badbones69.crazyauctions.api.FileManager.Files;
import com.badbones69.crazyauctions.api.builders.ItemBuilder; import com.badbones69.crazyauctions.api.builders.ItemBuilder;
import com.badbones69.crazyauctions.api.enums.Category; import com.badbones69.crazyauctions.api.enums.Category;
import com.badbones69.crazyauctions.api.enums.Reaons;
import com.badbones69.crazyauctions.api.enums.Messages; import com.badbones69.crazyauctions.api.enums.Messages;
import com.badbones69.crazyauctions.api.enums.Reasons;
import com.badbones69.crazyauctions.api.enums.ShopType; import com.badbones69.crazyauctions.api.enums.ShopType;
import com.badbones69.crazyauctions.api.events.AuctionBuyEvent; import com.badbones69.crazyauctions.api.events.AuctionBuyEvent;
import com.badbones69.crazyauctions.api.events.AuctionCancelledEvent; import com.badbones69.crazyauctions.api.events.AuctionCancelledEvent;
import com.badbones69.crazyauctions.api.events.AuctionNewBidEvent; import com.badbones69.crazyauctions.api.events.AuctionNewBidEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.SoundCategory; import org.bukkit.SoundCategory;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -27,10 +28,10 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class GuiListener implements Listener { public class GuiListener implements Listener {
@ -73,9 +74,32 @@ public class GuiListener implements Listener {
if (data.getBoolean("Items." + i + ".Biddable")) { if (data.getBoolean("Items." + i + ".Biddable")) {
if (sell == ShopType.BID) { if (sell == ShopType.BID) {
String seller = data.getString("Items." + i + ".Seller"); String seller = data.getString("Items." + i + ".Seller");
OfflinePlayer target = null;
if (seller != null) {
target = Methods.getOfflinePlayer(seller);
}
String price = Methods.getPrice(i, false);
String time = Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"));
OfflinePlayer bidder = null;
String topbidder = data.getString("Items." + i + ".TopBidder"); String topbidder = data.getString("Items." + i + ".TopBidder");
for (String l : config.getStringList("Settings.GUISettings.Bidding")) {
lore.add(l.replace("%TopBid%", Methods.getPrice(i, false)).replace("%topbid%", Methods.getPrice(i, false)).replace("%Seller%", seller).replace("%seller%", seller).replace("%TopBidder%", topbidder).replace("%topbidder%", topbidder).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire")))); if (topbidder != null && !topbidder.equals("None")) {
bidder = Methods.getOfflinePlayer(topbidder);
}
for (String key : config.getStringList("Settings.GUISettings.Bidding")) {
String line = key.replace("%TopBid%", price).replace("%topbid%", price);
line = target != null ? line.replace("%Seller%", target.getName()).replace("%seller%", target.getName()) : line.replace("%Seller%", "N/A").replace("%seller%", "N/A");
line = bidder != null ? line.replace("%TopBidder%", bidder.getName()).replace("%topbidder%", bidder.getName()) : line.replace("%TopBidder%", "N/A").replace("%topbidder%", "N/A");
lore.add(line.replace("%Time%", time).replace("%time%", time));
} }
itemBuilder.setLore(lore); itemBuilder.setLore(lore);
@ -86,8 +110,23 @@ public class GuiListener implements Listener {
} }
} else { } else {
if (sell == ShopType.SELL) { if (sell == ShopType.SELL) {
String seller = data.getString("Items." + i + ".Seller");
OfflinePlayer target = null;
if (seller != null) {
target = Methods.getOfflinePlayer(seller);
}
String price = Methods.getPrice(i, false);
String time = Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"));
String format = String.format(Locale.ENGLISH, "%,d", Long.parseLong(price));
for (String l : config.getStringList("Settings.GUISettings.SellingItemLore")) { for (String l : config.getStringList("Settings.GUISettings.SellingItemLore")) {
lore.add(l.replace("%Price%", String.format(Locale.ENGLISH, "%,d", Long.parseLong(Methods.getPrice(i, false)))).replace("%price%", String.format(Locale.ENGLISH, "%,d", Long.parseLong(Methods.getPrice(i, false)))).replace("%Seller%", data.getString("Items." + i + ".Seller")).replace("%seller%", data.getString("Items." + i + ".Seller")).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire")))); lore.add(l.replace("%Price%", format).replace("%price%", format)
.replace("%Seller%", target != null ? target.getName() : "N/A").replace("%seller%", target != null ? target.getName() : "N/A")
.replace("%Time%", time).replace("%time%", time));
} }
itemBuilder.setLore(lore); itemBuilder.setLore(lore);
@ -248,10 +287,17 @@ public class GuiListener implements Listener {
if (data.contains("Items")) { if (data.contains("Items")) {
for (String i : data.getConfigurationSection("Items").getKeys(false)) { for (String i : data.getConfigurationSection("Items").getKeys(false)) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) { if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
String price = Methods.getPrice(i, false);
String time = Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"));
for (String l : config.getStringList("Settings.GUISettings.CurrentLore")) { 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")))); lore.add(l.replace("%Price%", price)
.replace("%price%", price)
.replace("%Time%", time)
.replace("%time%", time));
} }
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getString("Items." + i + ".Item")); ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getString("Items." + i + ".Item"));
@ -285,10 +331,17 @@ public class GuiListener implements Listener {
if (data.contains("OutOfTime/Cancelled")) { if (data.contains("OutOfTime/Cancelled")) {
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) { for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
if (data.getString("OutOfTime/Cancelled." + i + ".Seller") != null) { if (data.getString("OutOfTime/Cancelled." + i + ".Seller") != null) {
if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getName())) { if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
String price = Methods.getPrice(i, true);
String time = Methods.convertToTime(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"));
for (String l : config.getStringList("Settings.GUISettings.Cancelled/ExpiredLore")) { 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")))); lore.add(l.replace("%Price%", price)
.replace("%price%", price)
.replace("%Time%", time)
.replace("%time%", time));
} }
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getString("OutOfTime/Cancelled." + i + ".Item")); ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getString("OutOfTime/Cancelled." + i + ".Item"));
@ -392,8 +445,24 @@ public class GuiListener implements Listener {
} }
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
String price = Methods.getPrice(ID, false);
String time = Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire"));
OfflinePlayer target = null;
String id = data.getString("Items." + ID + ".Seller");
if (id != null) {
target = Methods.getOfflinePlayer(id);
}
for (String l : config.getStringList("Settings.GUISettings.SellingItemLore")) { for (String l : config.getStringList("Settings.GUISettings.SellingItemLore")) {
lore.add(l.replace("%Price%", Methods.getPrice(ID, false)).replace("%price%", Methods.getPrice(ID, false)).replace("%Seller%", data.getString("Items." + ID + ".Seller")).replace("%seller%", data.getString("Items." + ID + ".Seller")).replace("%Time%", Methods.convertToTime(data.getLong("Items." + l + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + l + ".Time-Till-Expire")))); lore.add(l.replace("%Price%", price).replace("%price%", price)
.replace("%Seller%", target != null ? target.getName() : "N/A")
.replace("%seller%", target != null ? target.getName() : "N/A")
.replace("%Time%", time)
.replace("%time%", time));
} }
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getString("Items." + ID + ".Item")); ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getString("Items." + ID + ".Item"));
@ -431,7 +500,7 @@ public class GuiListener implements Listener {
inv.setItem(13, getBiddingGlass(player, ID)); inv.setItem(13, getBiddingGlass(player, ID));
inv.setItem(22, new ItemBuilder().setMaterial(config.getString("Settings.GUISettings.OtherSettings.Bid.Item")).setAmount(1) inv.setItem(22, new ItemBuilder().setMaterial(config.getString("Settings.GUISettings.OtherSettings.Bid.Item")).setAmount(1)
.setName("Settings.GUISettings.OtherSettings.Bid.Name").setLore(config.getStringList("Settings.GUISettings.OtherSettings.Bid.Lore")).build()); .setName(config.getString("Settings.GUISettings.OtherSettings.Bid.Name")).setLore(config.getStringList("Settings.GUISettings.OtherSettings.Bid.Lore")).build());
inv.setItem(4, getBiddingItem(ID)); inv.setItem(4, getBiddingItem(ID));
@ -455,15 +524,45 @@ public class GuiListener implements Listener {
for (String i : data.getConfigurationSection("Items").getKeys(false)) { for (String i : data.getConfigurationSection("Items").getKeys(false)) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(other)) { if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(other)) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
String price = Methods.getPrice(i, false);
String time = Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"));
OfflinePlayer target = null;
String id = data.getString("Items." + i + ".Seller");
if (id != null) {
target = Methods.getOfflinePlayer(id);
}
OfflinePlayer bidder = null;
String bid = data.getString("Items." + i + ".TopBidder");
if (id != null) {
bidder = Methods.getOfflinePlayer(bid);
}
if (data.getBoolean("Items." + i + ".Biddable")) { if (data.getBoolean("Items." + i + ".Biddable")) {
String seller = data.getString("Items." + i + ".Seller");
String topbidder = data.getString("Items." + i + ".TopBidder");
for (String l : config.getStringList("Settings.GUISettings.Bidding")) { for (String l : config.getStringList("Settings.GUISettings.Bidding")) {
lore.add(l.replace("%TopBid%", Methods.getPrice(i, false)).replace("%topbid%", Methods.getPrice(i, false)).replace("%Seller%", seller).replace("%seller%", seller).replace("%TopBidder%", topbidder).replace("%topbidder%", topbidder).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire")))); lore.add(l.replace("%TopBid%", price)
.replace("%topbid%", price)
.replace("%Seller%", target != null ? target.getName() : "N/A")
.replace("%seller%", target != null ? target.getName() : "N/A")
.replace("%TopBidder%", bidder != null ? bidder.getName() : "N/A")
.replace("%topbidder%", bidder != null ? bidder.getName() : "N/A")
.replace("%Time%", time)
.replace("%time%", time));
} }
} else { } else {
for (String l : config.getStringList("Settings.GUISettings.SellingItemLore")) { for (String l : config.getStringList("Settings.GUISettings.SellingItemLore")) {
lore.add(l.replace("%Price%", Methods.getPrice(i, false)).replace("%price%", Methods.getPrice(i, false)).replace("%Seller%", data.getString("Items." + i + ".Seller")).replace("%seller%", data.getString("Items." + i + ".Seller")).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire")))); lore.add(l.replace("%Price%", price)
.replace("%price%", price)
.replace("%Seller%", target != null ? target.getName() : "N/A")
.replace("%seller%", target != null ? target.getName() : "N/A")
.replace("%Time%", time)
.replace("%time%", time));
} }
} }
@ -525,10 +624,15 @@ public class GuiListener implements Listener {
int bid = bidding.get(player.getUniqueId()); int bid = bidding.get(player.getUniqueId());
String price = Methods.getPrice(ID, false);
if (config.contains("Settings.GUISettings.OtherSettings.Bidding.Lore")) { if (config.contains("Settings.GUISettings.OtherSettings.Bidding.Lore")) {
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
for (String l : config.getStringList("Settings.GUISettings.OtherSettings.Bidding.Lore")) { for (String l : config.getStringList("Settings.GUISettings.OtherSettings.Bidding.Lore")) {
lore.add(l.replace("%Bid%", bid + "").replace("%bid%", bid + "").replace("%TopBid%", Methods.getPrice(ID, false)).replace("%topbid%", Methods.getPrice(ID, false))); lore.add(l.replace("%Bid%", String.valueOf(bid))
.replace("%bid%", String.valueOf(bid))
.replace("%TopBid%", price)
.replace("%topbid%", price));
} }
itemBuilder.setLore(lore); itemBuilder.setLore(lore);
@ -540,13 +644,35 @@ public class GuiListener implements Listener {
private static ItemStack getBiddingItem(String ID) { private static ItemStack getBiddingItem(String ID) {
FileConfiguration config = Files.CONFIG.getFile(); FileConfiguration config = Files.CONFIG.getFile();
FileConfiguration data = Files.DATA.getFile(); FileConfiguration data = Files.DATA.getFile();
String seller = data.getString("Items." + ID + ".Seller");
String topbidder = data.getString("Items." + ID + ".TopBidder");
ItemStack item = Methods.fromBase64(data.getString("Items." + ID + ".Item")); ItemStack item = Methods.fromBase64(data.getString("Items." + ID + ".Item"));
List<String> lore = new ArrayList<>(); List<String> lore = new ArrayList<>();
String price = Methods.getPrice(ID, false);
String time = Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire"));
OfflinePlayer target = null;
String id = data.getString("Items." + ID + ".Seller");
if (id != null) {
target = Methods.getOfflinePlayer(id);
}
OfflinePlayer bidder = null;
String bid = data.getString("Items." + ID + ".TopBidder");
if (bid != null && !bid.equals("None")) {
bidder = Methods.getOfflinePlayer(bid);
}
for (String l : config.getStringList("Settings.GUISettings.Bidding")) { for (String l : config.getStringList("Settings.GUISettings.Bidding")) {
lore.add(l.replace("%TopBid%", Methods.getPrice(ID, false)).replace("%topbid%", Methods.getPrice(ID, false)).replace("%Seller%", seller).replace("%seller%", seller).replace("%TopBidder%", topbidder).replace("%topbidder%", topbidder).replace("%Time%", Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire")))); lore.add(l.replace("%TopBid%", price)
.replace("%topbid%", price)
.replace("%Seller%", target != null ? target.getName() : "N/A").replace("%seller%", target != null ? target.getName() : "N/A")
.replace("%TopBidder%", bidder != null ? bidder.getName() : "N/A").replace("%topbidder%", bidder != null ? bidder.getName() : "N/A")
.replace("%Time%", time)
.replace("%time%", time));
} }
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(item); ItemBuilder itemBuilder = ItemBuilder.convertItemStack(item);
@ -658,21 +784,24 @@ public class GuiListener implements Listener {
return; return;
} }
Bukkit.getPluginManager().callEvent(new AuctionNewBidEvent(player, Methods.fromBase64(data.getString("Items." + ID + ".Item")), bid)); Bukkit.getPluginManager().callEvent(new AuctionNewBidEvent(player, Methods.fromBase64(data.getString("Items." + ID + ".Item")), bid));
data.set("Items." + ID + ".Price", 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<>();
Map<String, String> placeholders = new HashMap<>();
placeholders.put("%Bid%", bid + ""); placeholders.put("%Bid%", bid + "");
player.sendMessage(Messages.BID_MESSAGE.getMessage(placeholders)); player.sendMessage(Messages.BID_MESSAGE.getMessage(placeholders));
Files.DATA.saveFile(); Files.DATA.saveFile();
bidding.put(player.getUniqueId(), 0); bidding.put(player.getUniqueId(), 0);
player.closeInventory(); player.closeInventory();
playClick(player); playClick(player);
return; return;
} }
HashMap<String, Integer> priceEdits = new HashMap<>(); Map<String, Integer> priceEdits = new HashMap<>();
priceEdits.put("&a+1", 1); priceEdits.put("&a+1", 1);
priceEdits.put("&a+10", 10); priceEdits.put("&a+10", 10);
priceEdits.put("&a+100", 100); priceEdits.put("&a+100", 100);
@ -808,7 +937,7 @@ public class GuiListener implements Listener {
sellerPlayer.sendMessage(Messages.ADMIN_FORCE_CANCELLED_TO_PLAYER.getMessage()); sellerPlayer.sendMessage(Messages.ADMIN_FORCE_CANCELLED_TO_PLAYER.getMessage());
} }
AuctionCancelledEvent event = new AuctionCancelledEvent((sellerPlayer != null ? sellerPlayer : Bukkit.getOfflinePlayer(seller)), Methods.fromBase64(data.getString("Items." + ID + ".Item")), Reaons.ADMIN_FORCE_CANCEL); AuctionCancelledEvent event = new AuctionCancelledEvent((sellerPlayer != null ? sellerPlayer : Methods.getOfflinePlayer(seller)), Methods.fromBase64(data.getString("Items." + ID + ".Item")), Reasons.ADMIN_FORCE_CANCEL);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller")); data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
data.set("OutOfTime/Cancelled." + num + ".Full-Time", data.getLong("Items." + i + ".Full-Time")); data.set("OutOfTime/Cancelled." + num + ".Full-Time", data.getLong("Items." + i + ".Full-Time"));
@ -947,17 +1076,25 @@ public class GuiListener implements Listener {
plugin.getServer().getPluginManager().callEvent(new AuctionBuyEvent(player, i, cost)); plugin.getServer().getPluginManager().callEvent(new AuctionBuyEvent(player, i, cost));
plugin.getSupport().removeMoney(player, cost); plugin.getSupport().removeMoney(player, cost);
plugin.getSupport().addMoney(Methods.getOfflinePlayer(seller), cost); plugin.getSupport().addMoney(Methods.getOfflinePlayer(seller), cost);
HashMap<String, String> placeholders = new HashMap<>(); HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Price%", Methods.getPrice(ID, false));
placeholders.put("%price%", Methods.getPrice(ID, false)); String price = Methods.getPrice(ID, false);
placeholders.put("%Price%", price);
placeholders.put("%price%", price);
placeholders.put("%Player%", player.getName()); placeholders.put("%Player%", player.getName());
placeholders.put("%player%", player.getName()); placeholders.put("%player%", player.getName());
player.sendMessage(Messages.BOUGHT_ITEM.getMessage(placeholders)); player.sendMessage(Messages.BOUGHT_ITEM.getMessage(placeholders));
if (Methods.isOnline(seller) && Methods.getPlayer(seller) != null) {
if (seller != null && Methods.isOnline(seller) && Methods.getPlayer(seller) != null) {
Player sell = Methods.getPlayer(seller); Player sell = Methods.getPlayer(seller);
sell.sendMessage(Messages.PLAYER_BOUGHT_ITEM.getMessage(placeholders));
playSoldSound(sell); if (sell != null) {
sell.sendMessage(Messages.PLAYER_BOUGHT_ITEM.getMessage(placeholders));
playSoldSound(sell);
}
} }
player.getInventory().addItem(i); player.getInventory().addItem(i);
@ -1005,7 +1142,7 @@ public class GuiListener implements Listener {
int ID = data.getInt("Items." + i + ".StoreID"); int ID = data.getInt("Items." + i + ".StoreID");
if (id == ID) { if (id == ID) {
player.sendMessage(Messages.CANCELLED_ITEM.getMessage()); player.sendMessage(Messages.CANCELLED_ITEM.getMessage());
AuctionCancelledEvent event = new AuctionCancelledEvent(player, Methods.fromBase64(data.getString("Items." + i + ".Item")), Reaons.PLAYER_FORCE_CANCEL); AuctionCancelledEvent event = new AuctionCancelledEvent(player, Methods.fromBase64(data.getString("Items." + i + ".Item")), Reasons.PLAYER_FORCE_CANCEL);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
int num = 1; int num = 1;
for (; data.contains("OutOfTime/Cancelled." + num); num++) ; for (; data.contains("OutOfTime/Cancelled." + num); num++) ;
@ -1064,7 +1201,7 @@ public class GuiListener implements Listener {
int page = Integer.parseInt(e.getView().getTitle().split("#")[1]); int page = Integer.parseInt(e.getView().getTitle().split("#")[1]);
if (data.contains("OutOfTime/Cancelled")) { if (data.contains("OutOfTime/Cancelled")) {
for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) { for (String i : data.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getName())) { if (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
if (Methods.isInvFull(player)) { if (Methods.isInvFull(player)) {
player.sendMessage(Messages.INVENTORY_FULL.getMessage()); player.sendMessage(Messages.INVENTORY_FULL.getMessage());
break; break;