Merge branch 'main' into ver/1.21

Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
This commit is contained in:
Ryder Belserion 2024-06-19 21:02:22 -04:00 committed by GitHub
commit e20fbc6633
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 334 additions and 144 deletions

View File

@ -1,2 +1,2 @@
### Fixed:
- Caught a few stragglers in the code not yet updated to the using the methods for the new item format.
- Caught a few places still using the player name for reading or writing to the data.yml which breaks the uuid checks.

View File

@ -1,7 +1,7 @@
[versions]
# Minecraft
paper = "1.21-R0.1-SNAPSHOT"
minecraft = "1.21"
paper = "1.20.6-R0.1-SNAPSHOT"
minecraft = "1.20.6"
# Plugins
itemsadder = "3.6.3-beta-14"

View File

@ -44,7 +44,7 @@ tasks {
publications {
create<MavenPublication>("maven") {
groupId = rootProject.group.toString()
artifactId = "${rootProject.name.lowercase()}-${project.name.lowercase()}-api"
artifactId = "${rootProject.name.lowercase()}-paper-api"
version = rootProject.version.toString()
from(component)

View File

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

View File

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

View File

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

View File

@ -1,61 +1,63 @@
#Minecraft server properties
#Sun Mar 24 11:23:50 EDT 2024
enable-jmx-monitoring=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
#Sun Jun 16 21:34:17 EDT 2024
accepts-transfers=false
allow-flight=false
initial-disabled-packs=
broadcast-rcon-to-ops=false
view-distance=6
server-ip=
resource-pack-prompt=
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
spawn-npcs=true
spawn-animals=true
log-ips=false
function-permission-level=2
initial-enabled-packs=vanilla
level-type=minecraft\:normal
text-filtering-config=
spawn-monsters=true
broadcast-rcon-to-ops=false
debug=false
difficulty=peaceful
enable-command-block=false
enable-jmx-monitoring=false
enable-query=false
enable-rcon=false
enable-status=true
enforce-secure-profile=true
enforce-whitelist=false
spawn-protection=32
resource-pack-sha1=
entity-broadcast-range-percentage=100
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
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
world-settings:
default:
unload-frozen-chunks: false
seed-trialchambers: 94251327
below-zero-generation-in-existing-chunks: true
hanging-tick-frequency: 100

View File

@ -10,10 +10,12 @@ import com.badbones69.crazyauctions.commands.AuctionTab;
import com.badbones69.crazyauctions.controllers.GuiListener;
import com.badbones69.crazyauctions.controllers.MarcoListener;
import com.badbones69.crazyauctions.currency.VaultSupport;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
@ -66,6 +68,16 @@ public class CrazyAuctions extends JavaPlugin {
FileManager.Files.DATA.saveFile();
}
final String uuid = configuration.getString("OutOfTime/Cancelled." + key + ".Seller");
if (uuid != null) {
OfflinePlayer player = Methods.getOfflinePlayer(uuid);
configuration.set("OutOfTime/Cancelled." + key + ".Seller", player.getUniqueId().toString());
FileManager.Files.DATA.saveFile();
}
}
}
@ -78,6 +90,30 @@ public class CrazyAuctions extends JavaPlugin {
FileManager.Files.DATA.saveFile();
}
final String uuid = configuration.getString("Items." + key + ".Seller");
if (uuid != null) {
OfflinePlayer player = Methods.getOfflinePlayer(uuid);
if (!uuid.equals(player.getUniqueId().toString())) {
configuration.set("Items." + key + ".Seller", player.getUniqueId().toString());
FileManager.Files.DATA.saveFile();
}
}
final String bidder = configuration.getString("Items." + key + ".TopBidder");
if (bidder != null && !bidder.equals("None")) {
OfflinePlayer player = Methods.getOfflinePlayer(bidder);
if (!bidder.equals(player.getUniqueId().toString())) {
configuration.set("Items." + key + ".TopBidder", player.getUniqueId().toString());
FileManager.Files.DATA.saveFile();
}
}
}
}

View File

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

View File

@ -37,7 +37,7 @@ public class CrazyManager {
if (data.contains("Items")) {
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())) {
if (data.getBoolean("Items." + i + ".Biddable")) {
if (type == ShopType.BID) {
items.add(Methods.fromBase64(data.getString("Items." + i + ".Item")));

View File

@ -1400,6 +1400,7 @@ public class ItemBuilder {
private static Map<String, Color> createMap() {
Map<String, Color> map = new HashMap<>();
map.put("AQUA", Color.AQUA);
map.put("BLACK", Color.BLACK);
map.put("BLUE", Color.BLUE);
@ -1417,12 +1418,14 @@ public class ItemBuilder {
map.put("TEAL", Color.TEAL);
map.put("WHITE", Color.WHITE);
map.put("YELLOW", Color.YELLOW);
return map;
}
public static Color getColor(String color) {
if (color != null && !color.isBlank()) {
Color mappedColor = (Color)colors.get(color.toUpperCase());
Color mappedColor = colors.get(color.toUpperCase());
if (mappedColor != null) {
return mappedColor;
} else {

View File

@ -20,7 +20,7 @@ public enum Category {
/**
* @param name Name of the Shop Type.
*/
private Category(String name, ArrayList<Material> items) {
Category(String name, ArrayList<Material> items) {
this.name = name;
this.items = items;
}

View File

@ -6,6 +6,7 @@ import org.bukkit.configuration.file.FileConfiguration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum Messages {
@ -57,12 +58,12 @@ public enum Messages {
private String defaultMessage;
private List<String> defaultListMessage;
private Messages(String path, String defaultMessage) {
Messages(String path, String defaultMessage) {
this.path = path;
this.defaultMessage = defaultMessage;
}
private Messages(String path, List<String> defaultListMessage) {
Messages(String path, List<String> defaultListMessage) {
this.path = path;
this.defaultListMessage = defaultListMessage;
}
@ -75,14 +76,13 @@ public enum Messages {
return message;
}
public static String convertList(List<String> list, HashMap<String, String> placeholders) {
String message = "";
for (String m : list) {
message += Methods.color(m) + "\n";
}
public static String convertList(List<String> list, Map<String, String> placeholders) {
String message = convertList(list);
for (String ph : placeholders.keySet()) {
message = Methods.color(message.replace(ph, placeholders.get(ph))).replace(ph, placeholders.get(ph).toLowerCase());
}
return message;
}
@ -99,6 +99,7 @@ public enum Messages {
}
}
}
if (saveFile) {
Files.MESSAGES.saveFile();
}
@ -120,8 +121,9 @@ public enum Messages {
}
}
public String getMessage(HashMap<String, String> placeholders) {
public String getMessage(Map<String, String> placeholders) {
String message;
if (isList()) {
if (exists()) {
message = Methods.color(convertList(Files.MESSAGES.getFile().getStringList("Messages." + path), placeholders));
@ -134,12 +136,14 @@ public enum Messages {
} else {
message = Methods.getPrefix(getDefaultMessage());
}
for (String ph : placeholders.keySet()) {
if (message.contains(ph)) {
message = message.replace(ph, placeholders.get(ph)).replace(ph, placeholders.get(ph).toLowerCase());
}
}
}
return message;
}
@ -161,6 +165,7 @@ public enum Messages {
public String getMessageNoPrefix(HashMap<String, String> placeholders) {
String message;
if (isList()) {
if (exists()) {
message = Methods.color(convertList(Files.MESSAGES.getFile().getStringList("Messages." + path), placeholders));
@ -173,12 +178,14 @@ public enum Messages {
} else {
message = Methods.color(getDefaultMessage());
}
for (String ph : placeholders.keySet()) {
if (message.contains(ph)) {
message = message.replace(ph, placeholders.get(ph)).replace(ph, placeholders.get(ph).toLowerCase());
}
}
}
return message;
}
@ -205,5 +212,4 @@ public enum Messages {
private List<String> getDefaultListMessage() {
return defaultListMessage;
}
}

View File

@ -1,6 +1,6 @@
package com.badbones69.crazyauctions.api.enums;
public enum Reaons {
public enum Reasons {
/**
* Cancelled by an administrator.

View File

@ -33,5 +33,4 @@ public enum ShopType {
public String getName() {
return name;
}
}

View File

@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
*
@ -36,7 +37,7 @@ public class AuctionBuyEvent extends Event {
return handlers;
}
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return handlers;
}
@ -51,5 +52,4 @@ public class AuctionBuyEvent extends Event {
public long getPrice() {
return price;
}
}

View File

@ -1,11 +1,12 @@
package com.badbones69.crazyauctions.api.events;
import com.badbones69.crazyauctions.api.enums.Reaons;
import com.badbones69.crazyauctions.api.enums.Reasons;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
*
@ -20,7 +21,7 @@ public class AuctionCancelledEvent extends Event {
private final boolean isOnline;
private final ItemStack item;
private final Reaons reason;
private final Reasons reason;
private OfflinePlayer offlinePlayer;
private Player onlinePlayer;
@ -30,7 +31,7 @@ public class AuctionCancelledEvent extends Event {
* @param offlinePlayer The player whose item is cancelled.
* @param item The item that is cancelled.
*/
public AuctionCancelledEvent(OfflinePlayer offlinePlayer, ItemStack item, Reaons reason) {
public AuctionCancelledEvent(OfflinePlayer offlinePlayer, ItemStack item, Reasons reason) {
this.offlinePlayer = offlinePlayer;
this.item = item;
this.isOnline = false;
@ -42,7 +43,7 @@ public class AuctionCancelledEvent extends Event {
* @param onlinePlayer The player whose item is cancelled.
* @param item The item that is cancelled.
*/
public AuctionCancelledEvent(Player onlinePlayer, ItemStack item, Reaons reason) {
public AuctionCancelledEvent(Player onlinePlayer, ItemStack item, Reasons reason) {
this.onlinePlayer = onlinePlayer;
this.item = item;
this.isOnline = true;
@ -53,7 +54,7 @@ public class AuctionCancelledEvent extends Event {
return handlers;
}
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return handlers;
}
@ -73,8 +74,7 @@ public class AuctionCancelledEvent extends Event {
return item;
}
public Reaons getReason() {
public Reasons getReason() {
return reason;
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
*
@ -49,7 +50,7 @@ public class AuctionExpireEvent extends Event {
return handlers;
}
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return handlers;
}
@ -68,5 +69,4 @@ public class AuctionExpireEvent extends Event {
public ItemStack getItem() {
return item;
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
*
@ -39,7 +40,7 @@ public class AuctionListEvent extends Event {
return handlers;
}
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return handlers;
}
@ -58,5 +59,4 @@ public class AuctionListEvent extends Event {
public long getPrice() {
return price;
}
}

View File

@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
*
@ -32,7 +33,7 @@ public class AuctionNewBidEvent extends Event {
return handlers;
}
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return handlers;
}
@ -47,5 +48,4 @@ public class AuctionNewBidEvent extends Event {
public long getBid() {
return bid;
}
}

View File

@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
*
@ -35,7 +36,7 @@ public class AuctionWinBidEvent extends Event {
return handlers;
}
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return handlers;
}
@ -50,5 +51,4 @@ public class AuctionWinBidEvent extends Event {
public long getBid() {
return bid;
}
}

View File

@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.Random;
import java.util.UUID;
import java.util.logging.Level;
public class AuctionCommand implements CommandExecutor {
@ -100,7 +101,7 @@ public class AuctionCommand implements CommandExecutor {
if (item != null && item.getType() != Material.AIR) {
// For testing as another player
String seller = "Test-Account";
String seller = UUID.randomUUID().toString();
for (int it = 1; it <= times; it++) {
int num = 1;
@ -113,12 +114,12 @@ public class AuctionCommand implements CommandExecutor {
data.set("Items." + num + ".Seller", seller);
if (args[0].equalsIgnoreCase("bid")) {
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Bid-Time")));
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Bid-Time", "2m 30s")));
} else {
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Sell-Time")));
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Sell-Time", "2d")));
}
data.set("Items." + num + ".Full-Time", Methods.convertToMill(config.getString("Settings.Full-Expire-Time")));
data.set("Items." + num + ".Full-Time", Methods.convertToMill(config.getString("Settings.Full-Expire-Time", "10d")));
int id = random.nextInt(Integer.MAX_VALUE);
for (String i : data.getConfigurationSection("Items").getKeys(false))
@ -271,21 +272,21 @@ public class AuctionCommand implements CommandExecutor {
long price = Long.parseLong(args[1]);
if (args[0].equalsIgnoreCase("bid")) {
if (price < config.getLong("Settings.Minimum-Bid-Price")) {
if (price < config.getLong("Settings.Minimum-Bid-Price", 100)) {
player.sendMessage(Messages.BID_PRICE_TO_LOW.getMessage());
return true;
}
if (price > config.getLong("Settings.Max-Beginning-Bid-Price")) {
if (price > config.getLong("Settings.Max-Beginning-Bid-Price", 1000000)) {
player.sendMessage(Messages.BID_PRICE_TO_HIGH.getMessage());
return true;
}
} else {
if (price < config.getLong("Settings.Minimum-Sell-Price")) {
if (price < config.getLong("Settings.Minimum-Sell-Price", 10)) {
player.sendMessage(Messages.SELL_PRICE_TO_LOW.getMessage());
return true;
}
if (price > config.getLong("Settings.Max-Beginning-Sell-Price")) {
if (price > config.getLong("Settings.Max-Beginning-Sell-Price", 1000000)) {
player.sendMessage(Messages.SELL_PRICE_TO_HIGH.getMessage());
return true;
}
@ -352,7 +353,7 @@ public class AuctionCommand implements CommandExecutor {
return true;
}
if (!config.getBoolean("Settings.Allow-Damaged-Items")) {
if (!config.getBoolean("Settings.Allow-Damaged-Items", false)) {
for (Material i : getDamageableItems()) {
if (item.getType() == i) {
if (item.getDurability() > 0) {
@ -368,7 +369,7 @@ public class AuctionCommand implements CommandExecutor {
return true;
}
String seller = player.getName();
String seller = player.getUniqueId().toString();
int num = 1;
Random random = new Random();
@ -378,12 +379,12 @@ public class AuctionCommand implements CommandExecutor {
data.set("Items." + num + ".Seller", seller);
if (args[0].equalsIgnoreCase("bid")) {
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Bid-Time")));
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Bid-Time", "2m 30s")));
} else {
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Sell-Time")));
data.set("Items." + num + ".Time-Till-Expire", Methods.convertToMill(config.getString("Settings.Sell-Time", "2d")));
}
data.set("Items." + num + ".Full-Time", Methods.convertToMill(config.getString("Settings.Full-Expire-Time")));
data.set("Items." + num + ".Full-Time", Methods.convertToMill(config.getString("Settings.Full-Expire-Time", "10d")));
int id = random.nextInt(999999);
// Runs 3x to check for same ID.
for (String i : data.getConfigurationSection("Items").getKeys(false))

View File

@ -6,14 +6,15 @@ import com.badbones69.crazyauctions.api.*;
import com.badbones69.crazyauctions.api.FileManager.Files;
import com.badbones69.crazyauctions.api.builders.ItemBuilder;
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.Reasons;
import com.badbones69.crazyauctions.api.enums.ShopType;
import com.badbones69.crazyauctions.api.events.AuctionBuyEvent;
import com.badbones69.crazyauctions.api.events.AuctionCancelledEvent;
import com.badbones69.crazyauctions.api.events.AuctionNewBidEvent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.configuration.file.FileConfiguration;
@ -27,10 +28,10 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
public class GuiListener implements Listener {
@ -73,9 +74,32 @@ public class GuiListener implements Listener {
if (data.getBoolean("Items." + i + ".Biddable")) {
if (sell == ShopType.BID) {
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");
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);
@ -86,8 +110,23 @@ public class GuiListener implements Listener {
}
} else {
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")) {
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);
@ -248,10 +287,17 @@ public class GuiListener implements Listener {
if (data.contains("Items")) {
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<>();
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")) {
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"));
@ -285,10 +331,17 @@ public class GuiListener 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 (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
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")) {
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"));
@ -392,8 +445,24 @@ public class GuiListener implements Listener {
}
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")) {
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"));
@ -431,7 +500,7 @@ public class GuiListener implements Listener {
inv.setItem(13, getBiddingGlass(player, ID));
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));
@ -455,15 +524,45 @@ public class GuiListener implements Listener {
for (String i : data.getConfigurationSection("Items").getKeys(false)) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(other)) {
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")) {
String seller = data.getString("Items." + i + ".Seller");
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"))));
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 {
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());
String price = Methods.getPrice(ID, false);
if (config.contains("Settings.GUISettings.OtherSettings.Bidding.Lore")) {
List<String> lore = new ArrayList<>();
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);
@ -540,13 +644,35 @@ public class GuiListener implements Listener {
private static ItemStack getBiddingItem(String ID) {
FileConfiguration config = Files.CONFIG.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"));
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")) {
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);
@ -658,21 +784,24 @@ public class GuiListener implements Listener {
return;
}
Bukkit.getPluginManager().callEvent(new AuctionNewBidEvent(player, Methods.fromBase64(data.getString("Items." + ID + ".Item")), bid));
data.set("Items." + ID + ".Price", bid);
data.set("Items." + ID + ".TopBidder", player.getName());
HashMap<String, String> placeholders = new HashMap<>();
data.set("Items." + ID + ".TopBidder", player.getUniqueId().toString());
Map<String, String> placeholders = new HashMap<>();
placeholders.put("%Bid%", bid + "");
player.sendMessage(Messages.BID_MESSAGE.getMessage(placeholders));
Files.DATA.saveFile();
bidding.put(player.getUniqueId(), 0);
player.closeInventory();
playClick(player);
return;
}
HashMap<String, Integer> priceEdits = new HashMap<>();
Map<String, Integer> priceEdits = new HashMap<>();
priceEdits.put("&a+1", 1);
priceEdits.put("&a+10", 10);
priceEdits.put("&a+100", 100);
@ -808,7 +937,7 @@ public class GuiListener implements Listener {
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);
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
data.set("OutOfTime/Cancelled." + num + ".Full-Time", data.getLong("Items." + i + ".Full-Time"));
@ -826,7 +955,7 @@ public class GuiListener implements Listener {
final Runnable runnable = () -> inv.setItem(slot, item);
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
String itemName = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name");
@ -861,7 +990,7 @@ public class GuiListener implements Listener {
}
if (data.getBoolean("Items." + i + ".Biddable")) {
if (player.getName().equalsIgnoreCase(data.getString("Items." + i + ".TopBidder"))) {
if (player.getUniqueId().toString().equalsIgnoreCase(data.getString("Items." + i + ".TopBidder"))) {
String itemName = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Name");
@ -947,17 +1076,25 @@ public class GuiListener implements Listener {
plugin.getServer().getPluginManager().callEvent(new AuctionBuyEvent(player, i, cost));
plugin.getSupport().removeMoney(player, cost);
plugin.getSupport().addMoney(Methods.getOfflinePlayer(seller), cost);
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());
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);
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);
@ -1005,7 +1142,7 @@ public class GuiListener implements Listener {
int ID = data.getInt("Items." + i + ".StoreID");
if (id == ID) {
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);
int num = 1;
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]);
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 (data.getString("OutOfTime/Cancelled." + i + ".Seller").equalsIgnoreCase(player.getUniqueId().toString())) {
if (Methods.isInvFull(player)) {
player.sendMessage(Messages.INVENTORY_FULL.getMessage());
break;

View File

@ -23,8 +23,8 @@ Settings:
Macro-Dupe: true #Turn to false if you have an issue, but it should patch the bug.
Sounds:
Toggle: false #Disable the clicking sound.
Sound: 'CLICK' #Make sure if you use 1.8 or lower you use the 1.8 sound and 1.9 and up use 1.9 sounds. The default sound is 1.8.
Sold-Item-Sound: 'CLICK'
Sound: 'UI_BUTTON_CLICK' #Make sure if you use 1.8 or lower you use the 1.8 sound and 1.9 and up use 1.9 sounds. The default sound is 1.8.
Sold-Item-Sound: 'UI_BUTTON_CLICK'
#Sounds are found here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
GUISettings: #Settings for things in the gui.
SellingItemLore: #The lore on items that are being sold.