From 023be7ea5ea34beef91acf4386f07bd56b4b8454 Mon Sep 17 00:00:00 2001 From: BadBones Date: Sun, 19 Feb 2023 01:35:17 -0500 Subject: [PATCH] Commited --- .../crazyauctions/CrazyAuctions.java | 5 ++ .../com/badbones69/crazyauctions/Starter.java | 8 +++ .../crazyauctions/api/CrazyManager.java | 13 ++++ .../enums}/AuctionType.java | 7 +- .../auctionhouse/interfaces/AuctionItem.java | 26 +++++++ .../auctionhouse/objects/AuctionHouse.java | 37 ++++++++++ .../auctionhouse/objects/BuyingAuction.java | 49 +++++++++++++ .../objects/InventorySettings.java | 15 ++++ .../auctionhouse/objects/SellingAuction.java | 69 +++++++++++++++++++ .../api/enums/eco/AuctionCategory.java | 5 -- .../crazyauctions/configs/Config.java | 19 +++++ .../spigot/src/main/resources/config.yml | 3 +- 12 files changed, 247 insertions(+), 9 deletions(-) create mode 100644 platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java rename platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/{enums/eco => auctionhouse/enums}/AuctionType.java (81%) create mode 100644 platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/interfaces/AuctionItem.java create mode 100644 platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/AuctionHouse.java create mode 100644 platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/BuyingAuction.java create mode 100644 platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/InventorySettings.java create mode 100644 platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/SellingAuction.java delete mode 100644 platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/enums/eco/AuctionCategory.java diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java index 0f2f94f..8990612 100644 --- a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java @@ -3,6 +3,8 @@ package com.badbones69.crazyauctions; import com.badbones69.crazyauctions.api.economy.vault.VaultSupport; import com.badbones69.crazyauctions.api.enums.PluginSupport; import com.badbones69.crazyauctions.configs.Config; +import com.badbones69.crazyauctions.configs.Locale; +import net.dehya.ruby.PaperRuby; import net.dehya.ruby.RubyCore; import net.dehya.ruby.SpigotRuby; import net.dehya.ruby.command.cloud.RubyCommand; @@ -11,6 +13,7 @@ import net.dehya.ruby.player.RubyPlayerRegistry; import net.dehya.ruby.registry.senders.types.Console; import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; + import java.lang.reflect.Field; import java.nio.file.Path; import java.util.Collections; @@ -51,6 +54,7 @@ public class CrazyAuctions extends JavaPlugin implements RubyCore { @Override public void onEnable() { Config.reload(this); + Locale.reload(this); } @Override @@ -131,4 +135,5 @@ public class CrazyAuctions extends JavaPlugin implements RubyCore { public VaultSupport getVaultSupport() { return this.starter.getVaultSupport(); } + } \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/Starter.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/Starter.java index d601bf7..4e74ef6 100644 --- a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/Starter.java +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/Starter.java @@ -1,16 +1,23 @@ package com.badbones69.crazyauctions; +import com.badbones69.crazyauctions.api.CrazyManager; import com.badbones69.crazyauctions.api.economy.vault.VaultSupport; import com.badbones69.crazyauctions.api.enums.PluginSupport; public class Starter { private final CrazyAuctions plugin = CrazyAuctions.getPlugin(); + private CrazyManager crazyManager = new CrazyManager(); private VaultSupport vaultSupport; public void init() { if (getVaultSupport() != null && PluginSupport.SupportedPlugins.VAULT.isPluginLoaded()) plugin.getLogger().warning("Vault support is now enabled."); + crazyManager = new CrazyManager(); + } + + public CrazyManager getCrazyManager() { + return crazyManager; } public Starter setVaultSupport(VaultSupport vaultSupport) { @@ -24,4 +31,5 @@ public class Starter { public VaultSupport getVaultSupport() { return this.vaultSupport; } + } \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java new file mode 100644 index 0000000..dab0238 --- /dev/null +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java @@ -0,0 +1,13 @@ +package com.badbones69.crazyauctions.api; + +import com.badbones69.crazyauctions.CrazyAuctions; + +public class CrazyManager { + + private final CrazyAuctions plugin = CrazyAuctions.getPlugin(); + + public void load() { + + } + +} \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/enums/eco/AuctionType.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/enums/AuctionType.java similarity index 81% rename from platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/enums/eco/AuctionType.java rename to platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/enums/AuctionType.java index dcd5886..7f34263 100644 --- a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/enums/eco/AuctionType.java +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/enums/AuctionType.java @@ -1,9 +1,9 @@ -package com.badbones69.crazyauctions.api.enums.eco; +package com.badbones69.crazyauctions.api.auctionhouse.enums; public enum AuctionType { - SELL_TYPE(""), - BID_TYPE(""); + BID("Bid"), + SELL("Sell"); private final String name; @@ -22,4 +22,5 @@ public enum AuctionType { public String getName() { return this.name; } + } \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/interfaces/AuctionItem.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/interfaces/AuctionItem.java new file mode 100644 index 0000000..a382e10 --- /dev/null +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/interfaces/AuctionItem.java @@ -0,0 +1,26 @@ +package com.badbones69.crazyauctions.api.auctionhouse.interfaces; + +import com.badbones69.crazyauctions.api.auctionhouse.enums.AuctionType; +import org.bukkit.inventory.ItemStack; + +import java.util.UUID; + +public interface AuctionItem { + + UUID auctionID = UUID.randomUUID(); + + default UUID getAuctionID() { + return auctionID; + } + + AuctionType getAuctionType(); + + UUID getSeller(); + + long getPrice(); + + long getExpireTime(); + + ItemStack getSellingItem(); + +} \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/AuctionHouse.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/AuctionHouse.java new file mode 100644 index 0000000..b38d593 --- /dev/null +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/AuctionHouse.java @@ -0,0 +1,37 @@ +package com.badbones69.crazyauctions.api.auctionhouse.objects; + +import com.badbones69.crazyauctions.api.auctionhouse.enums.AuctionType; +import com.badbones69.crazyauctions.api.auctionhouse.interfaces.AuctionItem; +import org.simpleyaml.configuration.file.YamlFile; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class AuctionHouse { + + private String name; + private InventorySettings inventorySettings; + private List auctionItems = new ArrayList<>(); + + public AuctionHouse(String name, YamlFile file) { + this.name = name; + this.inventorySettings = new InventorySettings(); + inventorySettings.setTitle("Set Title Here with Color"); + for (String auctionID : file.getConfigurationSection("auction-house.item-on-auction").getKeys(false)) { + String path = "auction-house.item-on-auction" + auctionID + "."; + AuctionType auctionType = AuctionType.getTypeFromName(file.getString(path + "auction-type")); + if (auctionType == AuctionType.SELL) { + auctionItems.add(new BuyingAuction( + UUID.fromString(file.getString(path + "UUID")), + file.getLong(path + "price"), + file.getLong(path + "expire-time"), + file.getI(path + "") + )); + } else { + + } + } + } + +} \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/BuyingAuction.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/BuyingAuction.java new file mode 100644 index 0000000..6766ee6 --- /dev/null +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/BuyingAuction.java @@ -0,0 +1,49 @@ +package com.badbones69.crazyauctions.api.auctionhouse.objects; + +import com.badbones69.crazyauctions.api.auctionhouse.enums.AuctionType; +import com.badbones69.crazyauctions.api.auctionhouse.interfaces.AuctionItem; +import org.bukkit.inventory.ItemStack; + +import java.util.UUID; + +public class BuyingAuction implements AuctionItem { + + AuctionType auctionType = AuctionType.SELL; + UUID seller; + long price; + long expireTime; + ItemStack sellingItem; + + public BuyingAuction(UUID seller, long price, long expireTime, ItemStack sellingItem) { + this.seller = seller; + this.price = price; + this.expireTime = expireTime; + this.sellingItem = sellingItem; + } + + @Override + public AuctionType getAuctionType() { + return auctionType; + } + + @Override + public UUID getSeller() { + return seller; + } + + @Override + public long getPrice() { + return price; + } + + @Override + public long getExpireTime() { + return expireTime; + } + + @Override + public ItemStack getSellingItem() { + return sellingItem; + } + +} \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/InventorySettings.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/InventorySettings.java new file mode 100644 index 0000000..0d8597f --- /dev/null +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/InventorySettings.java @@ -0,0 +1,15 @@ +package com.badbones69.crazyauctions.api.auctionhouse.objects; + +public class InventorySettings { + + private String title; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + +} \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/SellingAuction.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/SellingAuction.java new file mode 100644 index 0000000..f039fc7 --- /dev/null +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/auctionhouse/objects/SellingAuction.java @@ -0,0 +1,69 @@ +package com.badbones69.crazyauctions.api.auctionhouse.objects; + +import com.badbones69.crazyauctions.api.auctionhouse.enums.AuctionType; +import com.badbones69.crazyauctions.api.auctionhouse.interfaces.AuctionItem; +import org.bukkit.inventory.ItemStack; + +import java.util.UUID; + +public class SellingAuction implements AuctionItem { + + AuctionType auctionType = AuctionType.BID; + UUID seller; + UUID highestBidder; + long price; + long currentBid; + long expireTime; + ItemStack sellingItem; + + public SellingAuction(UUID seller, long price, long expireTime, ItemStack sellingItem) { + this.seller = seller; + this.highestBidder = null; + this.price = price; + this.currentBid = 0; + this.expireTime = expireTime; + this.sellingItem = sellingItem; + } + + @Override + public AuctionType getAuctionType() { + return auctionType; + } + + @Override + public UUID getSeller() { + return seller; + } + + public UUID getHighestBidder() { + return highestBidder; + } + + public void setHighestBidder(UUID highestBidder) { + this.highestBidder = highestBidder; + } + + @Override + public long getPrice() { + return price; + } + + public long getCurrentBid() { + return currentBid; + } + + public void setCurrentBid(long currentBid) { + this.currentBid = currentBid; + } + + @Override + public long getExpireTime() { + return expireTime; + } + + @Override + public ItemStack getSellingItem() { + return sellingItem; + } + +} \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/enums/eco/AuctionCategory.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/enums/eco/AuctionCategory.java deleted file mode 100644 index c4a2ea0..0000000 --- a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/api/enums/eco/AuctionCategory.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.badbones69.crazyauctions.api.enums.eco; - -public enum AuctionCategory { - -} \ No newline at end of file diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/configs/Config.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/configs/Config.java index f05a8ce..fcb71c7 100644 --- a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/configs/Config.java +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/configs/Config.java @@ -7,6 +7,10 @@ import net.dehya.ruby.common.annotations.yaml.Comment; import net.dehya.ruby.common.annotations.yaml.Key; import net.dehya.ruby.common.enums.FileType; import net.dehya.ruby.files.FileExtension; +import net.dehya.ruby.files.FileManager; +import org.simpleyaml.configuration.file.YamlFile; + +import java.io.IOException; @FileBuilder(isLogging = true, isAsync = true, isData = false, fileType = FileType.YAML) /*@Header(""" @@ -39,6 +43,10 @@ public class Config extends FileExtension { @Comment("DO NOT TOUCH THIS: We use this to identify if your configs are outdated.") public static double CONFIG_VERSION = 1.0; + @Key("settings.storage-type") + @Comment("Choose what type of storage option for the data to use. FLAT/MYSQL/") + public static String STORAGE_TYPE = "FLAT"; + public Config() { super("config.yml"); } @@ -46,4 +54,15 @@ public class Config extends FileExtension { public static void reload(CrazyAuctions plugin) { plugin.getSpigotFileManager().addFile(new Config()); } + + public static YamlFile getConfiguration(FileManager fileManager) { + try { + return fileManager.getFileConfiguration(new Config()); + } catch (IOException e) { + //Error Message goes here + } + + return null; + } + } \ No newline at end of file diff --git a/platforms/spigot/src/main/resources/config.yml b/platforms/spigot/src/main/resources/config.yml index c1adee1..b8a0e4f 100644 --- a/platforms/spigot/src/main/resources/config.yml +++ b/platforms/spigot/src/main/resources/config.yml @@ -5,4 +5,5 @@ settings: update-checker: true # Whether you want to be notified when an update is published to Modrinth. toggle-metrics: true # Whether you want your server statistics to be sent to https://bstats.org/ ( Requires a restart! ) - config-version: 1.0 # DO NOT TOUCH THIS: We use this to identify if configs are outdated. \ No newline at end of file + config-version: 1.0 # DO NOT TOUCH THIS: We use this to identify if configs are outdated. + storage-type: 'FLAT' #Choose what type of storage option for the data to use. FLAT/MYSQL/ \ No newline at end of file