mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2025-01-02 18:38:10 +01:00
Merge branch 'main' into fix-187
Signed-off-by: Ryder Belserion <no-reply@ryderbelserion.com>
This commit is contained in:
commit
e7c5c7cccc
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
@ -1,58 +1,41 @@
|
||||
package com.badbones69.crazyauctions;
|
||||
|
||||
import com.badbones69.crazyauctions.api.CrazyManager;
|
||||
import com.badbones69.crazyauctions.api.enums.Files;
|
||||
import com.badbones69.crazyauctions.api.enums.Messages;
|
||||
import com.badbones69.crazyauctions.api.enums.other.Permissions;
|
||||
import com.badbones69.crazyauctions.api.guis.types.AuctionsMenu;
|
||||
import com.badbones69.crazyauctions.api.guis.types.CategoriesMenu;
|
||||
import com.badbones69.crazyauctions.api.guis.types.CurrentMenu;
|
||||
import com.badbones69.crazyauctions.api.guis.types.ExpiredMenu;
|
||||
import com.badbones69.crazyauctions.api.guis.types.other.BidMenu;
|
||||
import com.badbones69.crazyauctions.api.guis.types.other.BuyingMenu;
|
||||
import com.badbones69.crazyauctions.api.support.MetricsWrapper;
|
||||
import com.badbones69.crazyauctions.commands.AuctionCommand;
|
||||
import com.badbones69.crazyauctions.commands.AuctionTab;
|
||||
import com.badbones69.crazyauctions.controllers.GuiListener;
|
||||
import com.badbones69.crazyauctions.controllers.MarcoListener;
|
||||
import com.badbones69.crazyauctions.controllers.MiscListener;
|
||||
import com.badbones69.crazyauctions.currency.VaultSupport;
|
||||
import com.badbones69.crazyauctions.tasks.InventoryManager;
|
||||
import com.badbones69.crazyauctions.tasks.UserManager;
|
||||
import com.ryderbelserion.vital.paper.Vital;
|
||||
import com.ryderbelserion.vital.paper.api.enums.Support;
|
||||
import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Base64;
|
||||
|
||||
public class CrazyAuctions extends Vital {
|
||||
|
||||
public static CrazyAuctions getPlugin() {
|
||||
@NotNull
|
||||
public static CrazyAuctions get() {
|
||||
return JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
}
|
||||
|
||||
private UserManager userManager;
|
||||
private CrazyManager crazyManager;
|
||||
|
||||
private VaultSupport support;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (!Support.vault.isEnabled()) {
|
||||
getLogger().severe("Vault was not found, so the plugin will now disable.");
|
||||
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.support = new VaultSupport();
|
||||
|
||||
if (!this.support.setupEconomy()) {
|
||||
getLogger().severe("An economy provider was not found, so the plugin will disable.");
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
getLogger().severe("Vault was not found so the plugin will now disable.");
|
||||
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
|
||||
@ -62,59 +45,87 @@ public class CrazyAuctions extends Vital {
|
||||
getFileManager().addFile("config.yml")
|
||||
.addFile("data.yml")
|
||||
.addFile("messages.yml")
|
||||
//.addFile("test-file.yml")
|
||||
.init();
|
||||
|
||||
InventoryManager.loadButtons();
|
||||
this.crazyManager = new CrazyManager();
|
||||
|
||||
this.userManager = new UserManager();
|
||||
this.userManager.updateAuctionsCache();
|
||||
this.userManager.updateExpiredCache();
|
||||
FileConfiguration configuration = Files.data.getConfiguration();
|
||||
|
||||
// we want to update this cache, after the cache above... because we will also calculate if items are expired!
|
||||
new FoliaRunnable(getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
userManager.updateAuctionsCache();
|
||||
userManager.updateExpiredCache();
|
||||
if (configuration.contains("OutOfTime/Cancelled")) {
|
||||
for (String key : configuration.getConfigurationSection("OutOfTime/Cancelled").getKeys(false)) {
|
||||
final ItemStack itemStack = configuration.getItemStack("OutOfTime/Cancelled." + key + ".Item");
|
||||
|
||||
for (final Player player : getServer().getOnlinePlayers()) {
|
||||
final Inventory inventory = player.getInventory();
|
||||
if (itemStack != null) {
|
||||
configuration.set("OutOfTime/Cancelled." + key + ".Item", Base64.getEncoder().encodeToString(itemStack.serializeAsBytes()));
|
||||
|
||||
if (inventory instanceof AuctionsMenu menu) {
|
||||
menu.calculateItems();
|
||||
Files.data.save();
|
||||
}
|
||||
|
||||
continue;
|
||||
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());
|
||||
|
||||
Files.data.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (configuration.contains("Items")) {
|
||||
for (String key : configuration.getConfigurationSection("Items").getKeys(false)) {
|
||||
final ItemStack itemStack = configuration.getItemStack("Items." + key + ".Item");
|
||||
|
||||
if (itemStack != null) {
|
||||
configuration.set("Items." + key + ".Item", Base64.getEncoder().encodeToString(itemStack.serializeAsBytes()));
|
||||
|
||||
Files.data.save();
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
Files.data.save();
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory instanceof CurrentMenu menu) {
|
||||
menu.calculateItems();
|
||||
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());
|
||||
|
||||
Files.data.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runAtFixedRate(this, 20, 300 * 5);
|
||||
}
|
||||
|
||||
this.crazyManager = new CrazyManager();
|
||||
this.crazyManager.load();
|
||||
|
||||
final PluginManager manager = getServer().getPluginManager();
|
||||
|
||||
manager.registerEvents(new AuctionsMenu(), this); // register main menu
|
||||
manager.registerEvents(new CategoriesMenu(), this); // register categories menu
|
||||
manager.registerEvents(new CurrentMenu(), this); // register current listings menu
|
||||
manager.registerEvents(new ExpiredMenu(), this); // register expired menu
|
||||
manager.registerEvents(new BuyingMenu(), this); // register buying menu
|
||||
manager.registerEvents(new BidMenu(), this); // register bid menu
|
||||
|
||||
manager.registerEvents(new MiscListener(), this);
|
||||
manager.registerEvents(new MarcoListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new GuiListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new MarcoListener(), this);
|
||||
|
||||
registerCommand(getCommand("crazyauctions"), new AuctionTab(), new AuctionCommand());
|
||||
|
||||
for (final Permissions permission : Permissions.values()) {
|
||||
if (permission.shouldRegister()) {
|
||||
permission.registerPermission();
|
||||
this.support = new VaultSupport();
|
||||
this.support.loadVault();
|
||||
|
||||
new FoliaRunnable(getServer().getGlobalRegionScheduler()) {
|
||||
@Override
|
||||
public void run() {
|
||||
Methods.updateAuction();
|
||||
}
|
||||
}
|
||||
}.runAtFixedRate(this, 0L, 5000L);
|
||||
|
||||
Messages.addMissingMessages();
|
||||
|
||||
@ -141,8 +152,4 @@ public class CrazyAuctions extends Vital {
|
||||
public final CrazyManager getCrazyManager() {
|
||||
return this.crazyManager;
|
||||
}
|
||||
|
||||
public final UserManager getUserManager() {
|
||||
return this.userManager;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.badbones69.crazyauctions;
|
||||
|
||||
import com.badbones69.crazyauctions.api.enums.misc.Files;
|
||||
import com.badbones69.crazyauctions.api.enums.Files;
|
||||
import com.badbones69.crazyauctions.api.enums.Messages;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionExpireEvent;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionWinBidEvent;
|
||||
@ -9,16 +9,14 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Methods {
|
||||
|
||||
private final static CrazyAuctions plugin = CrazyAuctions.getPlugin();
|
||||
private final static CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
private final static Pattern HEX_PATTERN = Pattern.compile("#[a-fA-F0-9]{6}");
|
||||
|
||||
@ -81,23 +79,11 @@ public class Methods {
|
||||
return Base64.getEncoder().encodeToString(itemStack.serializeAsBytes());
|
||||
}
|
||||
|
||||
public static @Nullable ItemStack fromBase64(final String base64) {
|
||||
if (base64 == null || base64.isEmpty()) return null;
|
||||
|
||||
final byte[] decoded = Base64.getDecoder().decode(base64);
|
||||
|
||||
return ItemStack.deserializeBytes(decoded);
|
||||
public static @NotNull ItemStack fromBase64(final String base64) {
|
||||
return ItemStack.deserializeBytes(Base64.getDecoder().decode(base64));
|
||||
}
|
||||
|
||||
public static OfflinePlayer getOfflinePlayer(String name) {
|
||||
return getOfflinePlayer(name, true);
|
||||
}
|
||||
|
||||
public static OfflinePlayer getOfflinePlayer(String name, boolean fetchUUID) {
|
||||
if (!fetchUUID) {
|
||||
return CompletableFuture.supplyAsync(() -> plugin.getServer().getOfflinePlayer(name)).join();
|
||||
}
|
||||
|
||||
return plugin.getServer().getOfflinePlayer(UUID.fromString(name));
|
||||
}
|
||||
|
||||
@ -111,6 +97,17 @@ public class Methods {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isOnline(String name, CommandSender p) {
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
p.sendMessage(Messages.NOT_ONLINE.getMessage(p));
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasPermission(Player player, String perm) {
|
||||
if (!player.hasPermission("crazyauctions." + perm)) {
|
||||
player.sendMessage(Messages.NO_PERMISSION.getMessage(player));
|
||||
@ -123,13 +120,44 @@ public class Methods {
|
||||
|
||||
public static boolean hasPermission(CommandSender sender, String perm) {
|
||||
if (sender instanceof Player player) {
|
||||
return hasPermission(player, perm);
|
||||
if (!player.hasPermission("crazyauctions." + perm)) {
|
||||
player.sendMessage(Messages.NO_PERMISSION.getMessage(player));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<Integer> getPageItems(List<Integer> list, int page) {
|
||||
public static List<ItemStack> getPage(List<ItemStack> list, Integer page) {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
|
||||
if (page <= 0) page = 1;
|
||||
|
||||
int max = 45;
|
||||
int index = page * max - max;
|
||||
int endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
||||
|
||||
for (; index < endIndex; index++) {
|
||||
if (index < list.size()) items.add(list.get(index));
|
||||
}
|
||||
|
||||
for (; items.size() == 0; page--) {
|
||||
if (page <= 0) break;
|
||||
index = page * max - max;
|
||||
endIndex = index >= list.size() ? list.size() - 1 : index + max;
|
||||
for (; index < endIndex; index++) {
|
||||
if (index < list.size()) items.add(list.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public static List<Integer> getPageInts(List<Integer> list, Integer page) {
|
||||
List<Integer> items = new ArrayList<>();
|
||||
|
||||
if (page <= 0) page = 1;
|
||||
@ -156,6 +184,15 @@ public class Methods {
|
||||
return items;
|
||||
}
|
||||
|
||||
public static int getMaxPage(List<ItemStack> list) {
|
||||
int maxPage = 1;
|
||||
int amount = list.size();
|
||||
|
||||
for (; amount > 45; amount -= 45, maxPage++) ;
|
||||
|
||||
return maxPage;
|
||||
}
|
||||
|
||||
public static String convertToTime(long time) {
|
||||
Calendar C = Calendar.getInstance();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
@ -269,7 +306,6 @@ public class Methods {
|
||||
}
|
||||
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", winner);
|
||||
data.set("OutOfTime/Cancelled." + num + ".Name", data.getString("Items." + i + ".TopBidderName", "None"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", fullExpireTime.getTimeInMillis());
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Item", data.getString("Items." + i + ".Item"));
|
||||
@ -285,7 +321,6 @@ public class Methods {
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
data.set("OutOfTime/Cancelled." + num + ".Seller", data.getString("Items." + i + ".Seller"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Name", data.getString("Items." + i + ".Name", "None"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Full-Time", fullExpireTime.getTimeInMillis());
|
||||
data.set("OutOfTime/Cancelled." + num + ".StoreID", data.getInt("Items." + i + ".StoreID"));
|
||||
data.set("OutOfTime/Cancelled." + num + ".Item", data.getString("Items." + i + ".Item"));
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.badbones69.crazyauctions.api;
|
||||
|
||||
import com.badbones69.crazyauctions.Methods;
|
||||
import com.badbones69.crazyauctions.api.enums.misc.Files;
|
||||
import com.badbones69.crazyauctions.api.enums.Files;
|
||||
import com.badbones69.crazyauctions.api.enums.ShopType;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -26,8 +26,6 @@ import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.trim.ArmorTrim;
|
||||
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||
import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@ -47,7 +45,7 @@ import java.util.stream.Collectors;
|
||||
public class ItemBuilder {
|
||||
|
||||
@NotNull
|
||||
private static final CrazyAuctions plugin = CrazyAuctions.getPlugin();
|
||||
private static final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
// Items
|
||||
private Material material = Material.STONE;
|
||||
@ -717,38 +715,6 @@ public class ItemBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addString(String name, NamespacedKey key) {
|
||||
if (name.isEmpty()) return this;
|
||||
|
||||
this.itemStack.editMeta(itemMeta -> {
|
||||
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
|
||||
|
||||
container.set(key, PersistentDataType.STRING, name);
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addInteger(int value, NamespacedKey key) {
|
||||
this.itemStack.editMeta(itemMeta -> {
|
||||
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
|
||||
|
||||
container.set(key, PersistentDataType.INTEGER, value);
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addLong(long value, NamespacedKey key) {
|
||||
this.itemStack.editMeta(itemMeta -> {
|
||||
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
|
||||
|
||||
container.set(key, PersistentDataType.LONG, value);
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the lore of the item with papi support in the builder. This will auto force color in all the lores that contains color code. (&a, &c, &7, etc...)
|
||||
*
|
||||
@ -1119,11 +1085,9 @@ public class ItemBuilder {
|
||||
}
|
||||
|
||||
public static ItemBuilder convertItemStack(String item) {
|
||||
final ItemStack base64 = Methods.fromBase64(item);
|
||||
ItemStack itemStack = Methods.fromBase64(item);
|
||||
|
||||
if (base64 == null) return null;
|
||||
|
||||
return new ItemBuilder(base64);
|
||||
return new ItemBuilder(itemStack).setAmount(itemStack.getAmount()).setEnchantments(new HashMap<>(itemStack.getEnchantments()));
|
||||
}
|
||||
|
||||
public static ItemBuilder convertItemStack(ItemStack item, Player player) {
|
||||
|
@ -118,10 +118,6 @@ public enum Category {
|
||||
ma.add(Material.NETHERITE_SWORD);
|
||||
ma.add(Material.NETHERITE_AXE);
|
||||
|
||||
ma.add(Material.MACE);
|
||||
|
||||
ma.add(Material.SHIELD);
|
||||
|
||||
return ma;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.badbones69.crazyauctions.api.enums;
|
||||
|
||||
import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.ryderbelserion.vital.paper.api.files.FileManager;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public enum Files {
|
||||
|
||||
config("config.yml"),
|
||||
messages("messages.yml"),
|
||||
//test_file("test-file.yml"),
|
||||
data("data.yml");
|
||||
|
||||
private final String fileName;
|
||||
private final String strippedName;
|
||||
|
||||
private @NotNull final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
private @NotNull final FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
/**
|
||||
* A constructor to build a file
|
||||
*
|
||||
* @param fileName the name of the file
|
||||
*/
|
||||
Files(final String fileName) {
|
||||
this.fileName = fileName;
|
||||
this.strippedName = this.fileName.replace(".yml", "");
|
||||
}
|
||||
|
||||
public final YamlConfiguration getConfiguration() {
|
||||
return this.fileManager.getFile(this.fileName).getConfiguration();
|
||||
}
|
||||
|
||||
public final String getStrippedName() {
|
||||
return this.strippedName;
|
||||
}
|
||||
|
||||
public final String getFileName() {
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
this.fileManager.saveFile(this.fileName);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.fileManager.addFile(this.fileName);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.badbones69.crazyauctions.api.enums;
|
||||
|
||||
import com.badbones69.crazyauctions.Methods;
|
||||
import com.badbones69.crazyauctions.api.enums.misc.Files;
|
||||
import com.ryderbelserion.vital.paper.api.enums.Support;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -49,7 +48,6 @@ public enum Messages {
|
||||
CRAZYAUCTIONS_VIEW("CrazyAuctions-View", "&c/ah view <player>"),
|
||||
CRAZYAUCTIONS_SELL_BID("CrazyAuctions-Sell-Bid", "&c/ah sell/bid <price> [amount of items]"),
|
||||
BOOK_NOT_ALLOWED("Book-Not-Allowed", "&cThat book is not able to be sold in this auction house!"),
|
||||
HELP_MSG("Help-Msg", "&cPlease do /crazyauctions help for more information."),
|
||||
HELP("Help-Menu", Arrays.asList(
|
||||
"&e-- &6Crazy Auctions Help &e--",
|
||||
"&9/Ah - &eOpens the crazy auction.",
|
||||
|
@ -7,9 +7,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a player buys something from the selling auction house.
|
||||
*
|
||||
*/
|
||||
public class AuctionBuyEvent extends Event {
|
||||
|
||||
|
@ -9,9 +9,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a player's item is cancelled.
|
||||
*
|
||||
*/
|
||||
public class AuctionCancelledEvent extends Event {
|
||||
|
||||
|
@ -8,9 +8,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a player item expires.
|
||||
*
|
||||
*/
|
||||
public class AuctionExpireEvent extends Event {
|
||||
|
||||
|
@ -8,9 +8,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a new item is listed onto the auction house.
|
||||
*
|
||||
*/
|
||||
public class AuctionListEvent extends Event {
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event is fired when a player places a new bid onto an item in the auction house.
|
||||
*/
|
||||
public class AuctionNewBidEvent extends Event {
|
||||
|
@ -7,9 +7,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BadBones69
|
||||
*
|
||||
* This event is fired when a bidding item's time has run out and so a player wins the item.
|
||||
*
|
||||
*/
|
||||
public class AuctionWinBidEvent extends Event {
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@ -22,7 +23,7 @@ import java.util.UUID;
|
||||
*/
|
||||
public class SkullCreator {
|
||||
|
||||
private static @NotNull final CrazyAuctions plugin = CrazyAuctions.getPlugin();
|
||||
private static final @NotNull CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
|
||||
|
||||
/**
|
||||
* Creates a player skull with a UUID. 1.13 only.
|
||||
|
@ -4,13 +4,11 @@ import com.badbones69.crazyauctions.CrazyAuctions;
|
||||
import com.badbones69.crazyauctions.Methods;
|
||||
import com.badbones69.crazyauctions.api.CrazyManager;
|
||||
import com.badbones69.crazyauctions.api.enums.Category;
|
||||
import com.badbones69.crazyauctions.api.enums.misc.Files;
|
||||
import com.badbones69.crazyauctions.api.enums.Files;
|
||||
import com.badbones69.crazyauctions.api.enums.Messages;
|
||||
import com.badbones69.crazyauctions.api.enums.ShopType;
|
||||
import com.badbones69.crazyauctions.api.events.AuctionListEvent;
|
||||
import com.badbones69.crazyauctions.api.GuiManager;
|
||||
import com.badbones69.crazyauctions.tasks.InventoryManager;
|
||||
import com.badbones69.crazyauctions.tasks.UserManager;
|
||||
import com.badbones69.crazyauctions.controllers.GuiListener;
|
||||
import com.ryderbelserion.vital.paper.api.files.FileManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -25,20 +23,20 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class AuctionCommand implements CommandExecutor {
|
||||
|
||||
private final CrazyAuctions plugin = CrazyAuctions.getPlugin();
|
||||
private final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
private final CrazyManager crazyManager = this.plugin.getCrazyManager();
|
||||
|
||||
private final UserManager userManager = this.plugin.getUserManager();
|
||||
|
||||
private final FileManager fileManager = this.plugin.getFileManager();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String commandLabel, String[] args) {
|
||||
FileConfiguration config = Files.config.getConfiguration();
|
||||
FileConfiguration data = Files.data.getConfiguration();
|
||||
|
||||
if (args.length == 0) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
@ -53,16 +51,16 @@ public class AuctionCommand implements CommandExecutor {
|
||||
|
||||
if (config.contains("Settings.Category-Page-Opens-First")) {
|
||||
if (config.getBoolean("Settings.Category-Page-Opens-First")) {
|
||||
GuiManager.openCategories(player, ShopType.SELL);
|
||||
GuiListener.openCategories(player, ShopType.SELL);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.crazyManager.isSellingEnabled()) {
|
||||
GuiManager.openShop(player, ShopType.SELL, Category.NONE, 1);
|
||||
} else if (this.crazyManager.isBiddingEnabled()) {
|
||||
GuiManager.openShop(player, ShopType.BID, Category.NONE, 1);
|
||||
if (crazyManager.isSellingEnabled()) {
|
||||
GuiListener.openShop(player, ShopType.SELL, Category.NONE, 1);
|
||||
} else if (crazyManager.isBiddingEnabled()) {
|
||||
GuiListener.openShop(player, ShopType.BID, Category.NONE, 1);
|
||||
} else {
|
||||
player.sendMessage(Methods.getPrefix() + Methods.color("&cThe bidding and selling options are both disabled. Please contact the admin about this."));
|
||||
}
|
||||
@ -85,25 +83,10 @@ public class AuctionCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
Files.config.reload();
|
||||
Files.data.reload();
|
||||
Files.messages.reload();
|
||||
|
||||
this.fileManager.reloadFiles().init();
|
||||
|
||||
// update it again!
|
||||
this.userManager.updateAuctionsCache();
|
||||
|
||||
// we want to update this cache, after the cache above... because we will also calculate if items are expired!
|
||||
this.userManager.updateExpiredCache();
|
||||
|
||||
//todo() close inventories by tracking viewers, so the cache can be updated than re-open their inventories
|
||||
//todo() we need to track the specific inventory they opened, and if it's for them or another player
|
||||
|
||||
this.crazyManager.load();
|
||||
|
||||
InventoryManager.loadButtons();
|
||||
|
||||
sender.sendMessage(Messages.RELOAD.getMessage(sender));
|
||||
|
||||
return true;
|
||||
@ -121,7 +104,7 @@ public class AuctionCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
GuiManager.openViewer(player, args[1], 1);
|
||||
GuiListener.openViewer(player, args[1], 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -142,7 +125,7 @@ public class AuctionCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
GuiManager.openPlayersExpiredList(player, 1);
|
||||
GuiListener.openPlayersExpiredList(player, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -156,7 +139,7 @@ public class AuctionCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
GuiManager.openPlayersCurrentList(player, 1);
|
||||
GuiListener.openPlayersCurrentList(player, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -311,7 +294,7 @@ public class AuctionCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getStringList("Settings.BlackList").contains(item.getType().getKey().getKey().toUpperCase())) {
|
||||
if (config.getStringList("Settings.BlackList").contains(item.getType().getKey().getKey())) {
|
||||
player.sendMessage(Messages.ITEM_BLACKLISTED.getMessage(sender));
|
||||
|
||||
return true;
|
||||
@ -337,17 +320,53 @@ public class AuctionCommand implements CommandExecutor {
|
||||
return true;
|
||||
}*/
|
||||
|
||||
ShopType type = args[0].equalsIgnoreCase("bid") ? ShopType.BID : ShopType.SELL;
|
||||
String seller = player.getUniqueId().toString();
|
||||
|
||||
int num = 1;
|
||||
|
||||
for (; data.contains("Items." + num); num++) ;
|
||||
data.set("Items." + num + ".Price", price);
|
||||
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", "2m 30s")));
|
||||
} else {
|
||||
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", "10d")));
|
||||
int id = ThreadLocalRandom.current().nextInt(999999);
|
||||
|
||||
// Runs 3x to check for same ID.
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false))
|
||||
if (data.getInt("Items." + i + ".StoreID") == id) id = ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE);
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false))
|
||||
if (data.getInt("Items." + i + ".StoreID") == id) id = ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE);
|
||||
for (String i : data.getConfigurationSection("Items").getKeys(false))
|
||||
if (data.getInt("Items." + i + ".StoreID") == id) id = ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE);
|
||||
|
||||
data.set("Items." + num + ".StoreID", id);
|
||||
ShopType type = ShopType.SELL;
|
||||
|
||||
if (args[0].equalsIgnoreCase("bid")) {
|
||||
data.set("Items." + num + ".Biddable", true);
|
||||
type = ShopType.BID;
|
||||
} else {
|
||||
data.set("Items." + num + ".Biddable", false);
|
||||
}
|
||||
|
||||
data.set("Items." + num + ".TopBidder", "None");
|
||||
|
||||
ItemStack stack = item.clone();
|
||||
stack.setAmount(amount);
|
||||
|
||||
this.userManager.addAuctionItem(player, stack, price, args[0].equalsIgnoreCase("bid"));
|
||||
data.set("Items." + num + ".Item", Methods.toBase64(stack));
|
||||
|
||||
Files.data.save();
|
||||
|
||||
this.plugin.getServer().getPluginManager().callEvent(new AuctionListEvent(player, type, stack, price));
|
||||
|
||||
Map<String, String> placeholders = new HashMap<>();
|
||||
|
||||
placeholders.put("%Price%", String.valueOf(price));
|
||||
placeholders.put("%price%", String.valueOf(price));
|
||||
|
||||
@ -366,7 +385,7 @@ public class AuctionCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
default -> {
|
||||
sender.sendMessage(Messages.HELP_MSG.getMessage(sender));
|
||||
sender.sendMessage(Methods.getPrefix("&cPlease do /crazyauctions help for more information."));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||
|
||||
public class AuctionTab implements TabCompleter {
|
||||
|
||||
private final CrazyAuctions plugin = CrazyAuctions.getPlugin();
|
||||
private final CrazyAuctions plugin = CrazyAuctions.get();
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String commandLabel, String[] args) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
package com.badbones69.crazyauctions.controllers;
|
||||
|
||||
import com.badbones69.crazyauctions.api.enums.misc.Files;
|
||||
import com.badbones69.crazyauctions.api.enums.Files;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -1,8 +1,8 @@
|
||||
Settings:
|
||||
Prefix: '&7[&4Crazy &bAuctions&7]: ' #Prefix of when you get Crazy Auctions Messages.
|
||||
GUIName: '&4Crazy &bAuctions&8 #{page}' #Name of the Main GUI.
|
||||
GUIName: '&4Crazy &bAuctions&8' #Name of the Main GUI.
|
||||
Players-Current-Items: '&8Your Current Listings' #The Name of the Player Current Items GUI.
|
||||
Cancelled/Expired-Items: '&8Cancelled/Expired Listings #{page}' #Name of the Cancelled/Expired GUI.
|
||||
Cancelled/Expired-Items: '&8Canceled/Expired Listings' #Name of the Cancelled/Expired GUI.
|
||||
Buying-Item: '&8Purchase Item: Are You Sure?' #Name of the Buying GUI.
|
||||
Bidding-On-Item: '&8You Are Bidding On This Item.' #Name of the Bidding GUI.
|
||||
Categories: '&8Categories' #Name of the Category GUI.
|
||||
@ -134,7 +134,7 @@ Settings:
|
||||
Item: 'POISONOUS_POTATO'
|
||||
Toggle: true
|
||||
Slot: 47
|
||||
Name: '&6Collect Expired / Cancelled Items'
|
||||
Name: '&6Collect Expired / Canceled Items'
|
||||
Lore:
|
||||
- '&aClick here to view and collect all of the'
|
||||
- '&aitems you have canceled or has expired.'
|
||||
@ -144,7 +144,7 @@ Settings:
|
||||
Slot: 49
|
||||
Name: '&6Previous Page'
|
||||
Lore: { }
|
||||
Refresh: #The button for Refresh Page.
|
||||
Refesh: #The button for Refresh Page.
|
||||
Item: 'SUNFLOWER'
|
||||
Toggle: true
|
||||
Slot: 50
|
||||
|
@ -1,26 +1,2 @@
|
||||
active_auctions:
|
||||
45123240-248b-44e3-93c9-5c89093ffaad:
|
||||
'1':
|
||||
name: ryderbelserion
|
||||
item: H4sIAAAAAAAA/+NiYGBm4HZJLEkMSy0qzszPY2DgL+ZgYMpMYRDJzcxLTS5KTCuxyizKz4vPzEvPL2FmYE3OL80rYWBg4GIAABMgbks9AAAA
|
||||
store_id: 57ba09ce
|
||||
price: 100
|
||||
time:
|
||||
expire: 1730423765397
|
||||
full: 1731291215397
|
||||
status:
|
||||
top_bidder:
|
||||
uuid: None
|
||||
name: None
|
||||
price: 0
|
||||
biddable: true
|
||||
current_bids:
|
||||
- '42bf0b48-8574-44b5-8cce-5accf9363b05;100'
|
||||
42bf0b48-8574-44b5-8cce-5accf9363b05: {}
|
||||
|
||||
active_bids:
|
||||
57ba90ce:
|
||||
'42bf0b48-8574-44b5-8cce-5accf9363b05':
|
||||
bid: 100
|
||||
|
||||
expired_auctions: {}
|
||||
Items: {}
|
||||
OutOfTime/Cancelled: {}
|
@ -35,7 +35,6 @@ Messages:
|
||||
CrazyAuctions-View: '&c/ah view <player>'
|
||||
CrazyAuctions-Sell-Bid: '&c/ah sell/bid <price> [amount of items]'
|
||||
Book-Not-Allowed: '&cThat book is not able to be sold in this auction house!'
|
||||
Help-Msg: '&cPlease do /crazyauctions help for more information.'
|
||||
Help-Menu:
|
||||
- '&e-- &6Crazy Auctions Help &e--'
|
||||
- '&9/Ah - &eOpens the crazy auction.'
|
||||
|
@ -11,7 +11,46 @@ folia-supported: true
|
||||
|
||||
softdepend: [Vault]
|
||||
|
||||
folia-supported: true
|
||||
|
||||
commands:
|
||||
crazyauctions:
|
||||
description: Opens the Crazy Auctions GUI.
|
||||
aliases: [crazyauction, ah, ca]
|
||||
|
||||
permissions:
|
||||
crazyauctions.access:
|
||||
default: true
|
||||
|
||||
crazyauctions.test:
|
||||
default: op
|
||||
|
||||
crazyauctions.view:
|
||||
default: true
|
||||
|
||||
crazyauctions.reload:
|
||||
default: op
|
||||
|
||||
crazyauctions.bypass:
|
||||
default: false
|
||||
|
||||
crazyauctions.sell:
|
||||
default: true
|
||||
|
||||
crazyauctions.bid:
|
||||
default: true
|
||||
|
||||
crazyauctions.player.*:
|
||||
default: false
|
||||
children:
|
||||
crazyauctions.bid: true
|
||||
crazyauctions.sell: true
|
||||
crazyauctions.access: true
|
||||
crazyauctions.view: true
|
||||
|
||||
crazyauctions.admin:
|
||||
default: false
|
||||
children:
|
||||
crazyauctions.test: true
|
||||
crazyauctions.reload: true
|
||||
crazyauctions.bypass: true
|
@ -33,9 +33,9 @@ tasks {
|
||||
autoAddDependsOn.set(false)
|
||||
detectLoaders.set(false)
|
||||
|
||||
dependencies {
|
||||
/*dependencies {
|
||||
optional.version("fancyholograms", "2.3.2")
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
hangarPublish {
|
||||
@ -61,11 +61,11 @@ tasks {
|
||||
required = false
|
||||
}
|
||||
|
||||
hangar("FancyHolograms") {
|
||||
url("Oraxen", "https://www.spigotmc.org/resources/%E2%98%84%EF%B8%8F-oraxen-custom-items-blocks-emotes-furniture-resourcepack-and-gui-1-18-1-20-4.72448/") {
|
||||
required = false
|
||||
}
|
||||
|
||||
url("Oraxen", "https://www.spigotmc.org/resources/%E2%98%84%EF%B8%8F-oraxen-custom-items-blocks-emotes-furniture-resourcepack-and-gui-1-18-1-20-4.72448/") {
|
||||
/*hangar("FancyHolograms") {
|
||||
required = false
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ tasks {
|
||||
|
||||
url("DecentHolograms", "https://www.spigotmc.org/resources/decentholograms-1-8-1-20-4-papi-support-no-dependencies.96927/") {
|
||||
required = false
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user