From fd186f7034a8b94fb1355b5a2781fb19e2e993a6 Mon Sep 17 00:00:00 2001 From: Ryder Belserion Date: Sun, 19 Feb 2023 03:26:19 -0500 Subject: [PATCH] Push my shit --- .../crazyauctions/CrazyAuctions.java | 11 +++++--- .../commands/AuctionCommand.java | 27 +++++++++++++++++++ .../crazyauctions/configs/Config.java | 2 +- .../configs/data/AuctionData.java | 26 ++++++++++++++++++ .../spigot/src/main/resources/plugin.yml | 2 +- 5 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 platforms/spigot/src/main/java/com/badbones69/crazyauctions/commands/AuctionCommand.java create mode 100644 platforms/spigot/src/main/java/com/badbones69/crazyauctions/configs/data/AuctionData.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 8990612..576fc11 100644 --- a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java @@ -2,9 +2,10 @@ package com.badbones69.crazyauctions; import com.badbones69.crazyauctions.api.economy.vault.VaultSupport; import com.badbones69.crazyauctions.api.enums.PluginSupport; +import com.badbones69.crazyauctions.commands.AuctionCommand; import com.badbones69.crazyauctions.configs.Config; import com.badbones69.crazyauctions.configs.Locale; -import net.dehya.ruby.PaperRuby; +import com.badbones69.crazyauctions.configs.data.AuctionData; import net.dehya.ruby.RubyCore; import net.dehya.ruby.SpigotRuby; import net.dehya.ruby.command.cloud.RubyCommand; @@ -13,7 +14,6 @@ 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; @@ -55,11 +55,15 @@ public class CrazyAuctions extends JavaPlugin implements RubyCore { public void onEnable() { Config.reload(this); Locale.reload(this); + + AuctionData.load(this); + + getCommand("ah").setExecutor(new AuctionCommand()); } @Override public void onDisable() { - + AuctionData.save(this); } @Override @@ -135,5 +139,4 @@ 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/commands/AuctionCommand.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/commands/AuctionCommand.java new file mode 100644 index 0000000..3c539f2 --- /dev/null +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/commands/AuctionCommand.java @@ -0,0 +1,27 @@ +package com.badbones69.crazyauctions.commands; + +import com.badbones69.crazyauctions.CrazyAuctions; +import com.badbones69.crazyauctions.configs.data.AuctionData; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import java.util.UUID; + +public class AuctionCommand implements CommandExecutor { + + private final CrazyAuctions plugin = CrazyAuctions.getPlugin(); + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + + Player player = (Player) sender; + + AuctionData.auctionData.putIfAbsent(player.getUniqueId(), UUID.randomUUID().toString()); + + AuctionData.save(this.plugin); + + return false; + } +} \ 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 a362a87..f31779a 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 @@ -11,7 +11,7 @@ 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) +@FileBuilder(isLogging = true, isAsync = false, isData = false, fileType = FileType.YAML) public class Config extends FileExtension { @Key("settings.prefix") diff --git a/platforms/spigot/src/main/java/com/badbones69/crazyauctions/configs/data/AuctionData.java b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/configs/data/AuctionData.java new file mode 100644 index 0000000..e62dae8 --- /dev/null +++ b/platforms/spigot/src/main/java/com/badbones69/crazyauctions/configs/data/AuctionData.java @@ -0,0 +1,26 @@ +package com.badbones69.crazyauctions.configs.data; + +import com.badbones69.crazyauctions.CrazyAuctions; +import net.dehya.ruby.common.annotations.FileBuilder; +import net.dehya.ruby.common.enums.FileType; +import net.dehya.ruby.files.FileExtension; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +@FileBuilder(isLogging = true, isAsync = false, isData = false, fileType = FileType.JSON) +public class AuctionData extends FileExtension { + + public static ConcurrentHashMap auctionData = new ConcurrentHashMap<>(); + + public AuctionData() { + super("auction-data.json"); + } + + public static void load(CrazyAuctions plugin) { + plugin.getSpigotFileManager().addFile(new AuctionData()); + } + + public static void save(CrazyAuctions plugin) { + plugin.getSpigotFileManager().saveFile(new AuctionData()); + } +} \ No newline at end of file diff --git a/platforms/spigot/src/main/resources/plugin.yml b/platforms/spigot/src/main/resources/plugin.yml index 41925c8..9929bc0 100644 --- a/platforms/spigot/src/main/resources/plugin.yml +++ b/platforms/spigot/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -name: "CrazyCrates" +name: "CrazyAuctions" main: "${group}.CrazyAuctions" authors: [BadBones69, RyderBelserion]