Sfoglia il codice sorgente

Updated to FluxAPI v.1.2.6

Jan 4 settimane fa
parent
commit
65f126527f
27 ha cambiato i file con 218 aggiunte e 247 eliminazioni
  1. 1 1
      pom.xml
  2. 3 6
      src/main/java/me/lethunderhawk/clans/ClanModule.java
  3. 14 14
      src/main/java/me/lethunderhawk/clans/command/ClanCommand.java
  4. 11 1
      src/main/java/me/lethunderhawk/clans/gui/AdminMenuGUI.java
  5. 1 1
      src/main/java/me/lethunderhawk/clans/gui/ClaimSettingsGUI.java
  6. 4 18
      src/main/java/me/lethunderhawk/custom/item/CustomItemModule.java
  7. 7 3
      src/main/java/me/lethunderhawk/custom/item/command/CustomItemCommand.java
  8. 4 5
      src/main/java/me/lethunderhawk/custom/recipes/CustomRecipeModule.java
  9. 5 5
      src/main/java/me/lethunderhawk/custom/recipes/command/RecipeEditorCommand.java
  10. 1 5
      src/main/java/me/lethunderhawk/dungeon/DungeonModule.java
  11. 5 5
      src/main/java/me/lethunderhawk/dungeon/command/DungeonCommand.java
  12. 5 7
      src/main/java/me/lethunderhawk/economy/EconomyModule.java
  13. 14 7
      src/main/java/me/lethunderhawk/economy/command/EcoCommand.java
  14. 5 17
      src/main/java/me/lethunderhawk/minion/MinionModule.java
  15. 6 6
      src/main/java/me/lethunderhawk/minion/command/MinionCommand.java
  16. 1 2
      src/main/java/me/lethunderhawk/profile/ProfileModule.java
  17. 4 4
      src/main/java/me/lethunderhawk/profile/command/ProfileCommand.java
  18. 9 11
      src/main/java/me/lethunderhawk/tradeplugin/TradeModule.java
  19. 5 2
      src/main/java/me/lethunderhawk/tradeplugin/api/TradePlaceholder.java
  20. 25 19
      src/main/java/me/lethunderhawk/tradeplugin/command/TradeAcceptCommand.java
  21. 38 20
      src/main/java/me/lethunderhawk/tradeplugin/command/TradeCommand.java
  22. 5 4
      src/main/java/me/lethunderhawk/tradeplugin/listener/PlayerInteractListener.java
  23. 3 3
      src/main/java/me/lethunderhawk/tradeplugin/listener/TradeInventoryListener.java
  24. 31 22
      src/main/java/me/lethunderhawk/tradeplugin/trade/TradeRequestManager.java
  25. 3 8
      src/main/java/me/lethunderhawk/world/WorldModule.java
  26. 8 8
      src/main/java/me/lethunderhawk/world/command/WorldCommand.java
  27. 0 43
      src/main/resources/plugin.yml

+ 1 - 1
pom.xml

@@ -98,7 +98,7 @@
         <dependency>
             <groupId>me.lethunderhawk</groupId>
             <artifactId>FluxAPI</artifactId>
-            <version>1.2.5</version>
+            <version>1.2.6</version>
             <scope>provided</scope>
         </dependency>
     </dependencies>

+ 3 - 6
src/main/java/me/lethunderhawk/clans/ClanModule.java

@@ -6,7 +6,6 @@ import me.lethunderhawk.clans.command.ClanCommand;
 import me.lethunderhawk.clans.placeholder.ClanPlaceHolder;
 import me.lethunderhawk.fluxapi.FluxService;
 import me.lethunderhawk.fluxapi.util.interfaces.FluxAPIModule;
-import org.bukkit.event.HandlerList;
 import org.bukkit.plugin.java.JavaPlugin;
 
 public class ClanModule extends FluxAPIModule {
@@ -30,10 +29,8 @@ public class ClanModule extends FluxAPIModule {
 
         FluxService.register(ClaimListener.class, claimListener);
 
-        plugin.getCommand("clan").setExecutor(new ClanCommand(clanManager));
-        plugin.getCommand("clan").setTabCompleter(new ClanCommand(clanManager));
-
-        plugin.getServer().getPluginManager().registerEvents(claimListener, plugin);
+        registerCommand("clan", new ClanCommand(clanManager));
+        registerListener(claimListener);
 
         if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
             new ClanPlaceHolder().register();
@@ -42,7 +39,7 @@ public class ClanModule extends FluxAPIModule {
     }
 
     public void onDisable(){
-        HandlerList.unregisterAll(FluxService.get(ClaimListener.class));
+        unregisterAllListeners();
         FluxService.get(ClanManager.class).saveClans();
     }
 }

+ 14 - 14
src/main/java/me/lethunderhawk/clans/command/ClanCommand.java

@@ -32,37 +32,37 @@ public class ClanCommand extends CustomCommand {
     }
 
     @Override
-    public void setRootCommand() {
-        rootCommand = new CommandNode("clan", "Main clan command", null);
+    public CommandNode getRootCommand(){
+        return new CommandNode("clan", "Main clan command", null);
     }
 
     @Override
     public void createCommands() {
-        registerCommand("list", "List all clans", this::handleList);
-        registerCommand("leave", "Leave your current clan", this::handleLeaveClan);
-        registerCommand("reload", "Reload the clan Plugin", this::handleReload);
-        registerCommand("members", "Show the members of your clan", this::handleShowMembers);
-        registerCommand("save", "Save all clans and Claims", this::handleSave);
-        registerCommand("menu", "Shows a GUI to handle your clan if you are the owner", this::handleGUI);
-        CommandNode claimNode = registerCommand("claim", "Claim land for your clan", this::handleClaim);
+        registerSubCommand("list", "List all clans", this::handleList);
+        registerSubCommand("leave", "Leave your current clan", this::handleLeaveClan);
+        registerSubCommand("reload", "Reload the clan Plugin", this::handleReload);
+        registerSubCommand("members", "Show the members of your clan", this::handleShowMembers);
+        registerSubCommand("save", "Save all clans and Claims", this::handleSave);
+        registerSubCommand("menu", "Shows a GUI to handle your clan if you are the owner", this::handleGUI);
+        CommandNode claimNode = registerSubCommand("claim", "Claim land for your clan", this::handleClaim);
         claimNode.registerSubCommand("info", "Get information about your claims", this::infoClaims);
         claimNode.registerSubCommand("removeAll", "Remove all current claims", this::removeAllClaims);
         claimNode.registerSubCommand("tool", "Get the claimTool", this::getClaimTool);
 
 
-        CommandNode acceptNode = registerCommand("acceptRequest", "Accept a pending request of a player", this::handleAcceptRequest);
+        CommandNode acceptNode = registerSubCommand("acceptRequest", "Accept a pending request of a player", this::handleAcceptRequest);
         acceptNode.setTabCompleter(this::completeRequests);
 
-        CommandNode declineNode = registerCommand("declineRequest", "Decline a pending request of a player", this::handleDeclineRequest);
+        CommandNode declineNode = registerSubCommand("declineRequest", "Decline a pending request of a player", this::handleDeclineRequest);
         declineNode.setTabCompleter(this::completeRequests);
 
-        CommandNode removeNode = registerCommand("remove", "Remove a Clan", this::removeClan);
+        CommandNode removeNode = registerSubCommand("remove", "Remove a Clan", this::removeClan);
         removeNode.setTabCompleter(this::completeClans);
 
-        CommandNode joinNode = registerCommand("join", "Join a clan", this::handleJoin);
+        CommandNode joinNode = registerSubCommand("join", "Join a clan", this::handleJoin);
         joinNode.setTabCompleter(this::completeClans);
 
-        registerCommand("create", "Create a new clan", this::handleCreate);
+        registerSubCommand("create", "Create a new clan", this::handleCreate);
     }
 
     private void getClaimTool(CommandSender sender, String[] strings) {

+ 11 - 1
src/main/java/me/lethunderhawk/clans/gui/AdminMenuGUI.java

@@ -19,7 +19,7 @@ import java.util.List;
 
 public class AdminMenuGUI extends InventoryGUI {
     private final Player player;
-
+    // Fix Bug with not being able to see other clans?
     public AdminMenuGUI(Player player) {
         super("Admin Panel - Edit all clans", 36);
         this.player = player;
@@ -57,6 +57,16 @@ public class AdminMenuGUI extends InventoryGUI {
     }
 
     private ItemStack buildItemStackFromClan(Clan clan) {
+        if(clan.getOwner() == null){
+            return CustomHeadCreator.createCustomHead("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjcwNWZkOTRhMGM0MzE5MjdmYjRlNjM5YjBmY2ZiNDk3MTdlNDEyMjg1YTAyYjQzOWUwMTEyZGEyMmIyZTJlYyJ9fX0=",
+                    Component.text(clan.getName()),
+                    List.of(
+                            Component.text("Owner: Unknown" , NamedTextColor.GOLD),
+                            Component.text(""),
+                            Component.text("Right click to remove", NamedTextColor.YELLOW),
+                            Component.text("Left click to open a GUI for this clan", NamedTextColor.YELLOW)
+                    ));
+        }
         return CustomHeadCreator.createCustomHead(clan.getOwner(),
                 Component.text(clan.getName()),
                 List.of(

+ 1 - 1
src/main/java/me/lethunderhawk/clans/gui/ClaimSettingsGUI.java

@@ -123,7 +123,7 @@ public class ClaimSettingsGUI extends InventoryGUI {
     }
 
     private void showRename(Player player, ClickType type) {
-        SignMenuFactory.Menu menu = new SignMenuFactory(FluxService.get(BazaarFlux.class)).newMenu(List.of("", "^^^^^^^^^^^^", "Enter the new", "name of the claim"))
+        SignMenuFactory.SignMenu menu = new SignMenuFactory(FluxService.get(BazaarFlux.class)).newMenu(List.of("", "^^^^^^^^^^^^", "Enter the new", "name of the claim"))
                 .reopenIfFail(true)
                 .response((p, strings) -> {
                     rename(strings[0]);

+ 4 - 18
src/main/java/me/lethunderhawk/custom/item/CustomItemModule.java

@@ -17,14 +17,12 @@ import me.lethunderhawk.fluxapi.util.interfaces.FluxAPIModule;
 import me.lethunderhawk.fluxapi.util.itemdesign.ItemData;
 import me.lethunderhawk.main.BazaarFlux;
 import org.bukkit.command.CommandSender;
-import org.bukkit.event.HandlerList;
 import org.bukkit.plugin.java.JavaPlugin;
 
 import java.io.File;
 import java.util.Map;
 
 public class CustomItemModule extends FluxAPIModule {
-    private CustomItemListener listener;
 
     public CustomItemModule(JavaPlugin plugin) {
         super(plugin);
@@ -63,13 +61,9 @@ public class CustomItemModule extends FluxAPIModule {
         Map<String, ItemDefinition> definitions = loader.loadAll(itemsDir);
         CustomItemRegistry itemRegistry = new CustomItemRegistry().fromRegistry(definitions);
 
-        // --- Reload listener ---
-
-        listener = new CustomItemListener(
+        registerListener(new CustomItemListener(
                 new AbilityDispatchService(itemRegistry, abilityRegistry)
-        );
-
-        bazaarFlux.getServer().getPluginManager().registerEvents(listener, bazaarFlux);
+        ));
 
         // --- FluxService ---
         FluxService.register(CustomItemRegistry.class, itemRegistry);
@@ -79,20 +73,12 @@ public class CustomItemModule extends FluxAPIModule {
         BlockRegistry blockRegistry = new BlockRegistry();
         bazaarFlux.getServer().getPluginManager().registerEvents(blockRegistry, bazaarFlux);
         FluxService.register(BlockRegistry.class, blockRegistry);
-        registerCommands();
-    }
-
-    private void registerCommands() {
-        CustomItemCommand customItemCommand = new CustomItemCommand(this);
-        FluxService.get(BazaarFlux.class).getCommand("customItems").setExecutor(customItemCommand);
-        FluxService.get(BazaarFlux.class).getCommand("customItems").setTabCompleter(customItemCommand);
+        registerCommand("customItems", new CustomItemCommand(this));
     }
 
     @Override
     public void onDisable() {
-        if (listener != null) {
-            HandlerList.unregisterAll(listener);
-        }
+        unregisterAllListeners();
     }
 
     public void reload(CommandSender sender, String[] strings) {

+ 7 - 3
src/main/java/me/lethunderhawk/custom/item/command/CustomItemCommand.java

@@ -24,17 +24,21 @@ public class CustomItemCommand extends CustomCommand {
     }
 
     @Override
-    public void setRootCommand() {
-        rootCommand = new CommandNode("customItems", "Main Custom Item Command", null);
+    public CommandNode getRootCommand(){
+       return new CommandNode("customItems", "Main Custom Item Command", null);
     }
 
     @Override
     public void createCommands() {
         rootCommand.registerSubCommand("getAll", "Get all custom items", this::getAllItems);
-        rootCommand.registerSubCommand("reload", "Reload", module::reload);
+        rootCommand.registerSubCommand("reload", "Reload", this::reload);
         rootCommand.registerSubCommand("migrateMe", "Migrate your inventory to the newest version", this::migrateInventory);
     }
 
+    private void reload(CommandSender sender, String[] strings) {
+        module.reload(sender);
+    }
+
     private void migrateInventory(CommandSender sender, String[] strings) {
         if(!(sender instanceof Player player)) return;
         if(!sender.hasPermission("custom.items.migrate")) return;

+ 4 - 5
src/main/java/me/lethunderhawk/custom/recipes/CustomRecipeModule.java

@@ -32,20 +32,19 @@ public class CustomRecipeModule extends FluxAPIModule {
 
         recipeManager.loadRecipes(FluxService.get(ConfigLoader.class));
 
-        plugin.getServer().getPluginManager().registerEvents(recipeManager, plugin);
+        registerListener(recipeManager);
 
         RecipeEditorCommand command = new RecipeEditorCommand(this);
-        plugin.getCommand("customrecipe").setExecutor(command);
-        plugin.getCommand("customrecipe").setExecutor(command);
+
+        registerCommand("customrecipe", command);
     }
 
     @Override
     public void onDisable() {
-
         if(recipeManager != null) {
 
             recipeManager.saveRecipes(FluxService.get(ConfigLoader.class));
-
+            listeners.remove(recipeManager);
             HandlerList.unregisterAll(recipeManager);
         }
     }

+ 5 - 5
src/main/java/me/lethunderhawk/custom/recipes/command/RecipeEditorCommand.java

@@ -14,18 +14,18 @@ public class RecipeEditorCommand extends CustomCommand {
     }
 
     @Override
-    public void setRootCommand() {
-        rootCommand = new CommandNode("customrecipe", "base cmd", null);
+    public CommandNode getRootCommand(){
+       return new CommandNode("customrecipe", "base cmd", null);
     }
 
     @Override
     public void createCommands() {
-        registerCommand("gui", "displays a neat UI", this::showGUI);
-        registerCommand("restart", "Restart the module", this::reload);
+        registerSubCommand("gui", "displays a neat UI", this::showGUI);
+        registerSubCommand("restart", "Restart the module", this::reload);
     }
 
     private void reload(CommandSender sender, String[] strings) {
-        module.reload(sender, strings);
+        module.reload(sender);
     }
 
     private void showGUI(CommandSender sender, String[] strings) {

+ 1 - 5
src/main/java/me/lethunderhawk/dungeon/DungeonModule.java

@@ -4,7 +4,6 @@ import me.lethunderhawk.dungeon.command.DungeonCommand;
 import me.lethunderhawk.dungeon.manager.DungeonManager;
 import me.lethunderhawk.fluxapi.FluxService;
 import me.lethunderhawk.fluxapi.util.interfaces.FluxAPIModule;
-import me.lethunderhawk.main.BazaarFlux;
 import org.bukkit.plugin.java.JavaPlugin;
 
 public class DungeonModule extends FluxAPIModule {
@@ -20,12 +19,9 @@ public class DungeonModule extends FluxAPIModule {
 
     @Override
     public void onEnable() {
-
-        BazaarFlux bazaarFlux = FluxService.get(BazaarFlux.class);
         FluxService.register(DungeonManager.class, new DungeonManager());
 
-        bazaarFlux.getCommand("dungeon").setExecutor(new DungeonCommand());
-        bazaarFlux.getCommand("dungeon").setTabCompleter(new DungeonCommand());
+        registerCommand("dungeon", new DungeonCommand());
     }
 
     @Override

+ 5 - 5
src/main/java/me/lethunderhawk/dungeon/command/DungeonCommand.java

@@ -18,24 +18,24 @@ public class DungeonCommand extends CustomCommand {
     }
 
     @Override
-    public void setRootCommand() {
-        rootCommand = new CommandNode("dungeon", "Main Dungeon command", null);
+    public CommandNode getRootCommand() {
+        return new CommandNode("dungeon", "Main Dungeon command", null);
     }
 
     @Override
     public void createCommands() {
-        registerCommand(
+        registerSubCommand(
                 "test",
                 "creates a test instance of a dungeon and teleports you there",
                 this::testDungeon
         );
-        registerCommand(
+        registerSubCommand(
                 "cleanup",
                 "Clears all dungeon worlds",
                 this::clearDungeons
         );
 
-        registerCommand(
+        registerSubCommand(
                 "back",
                 "go back to the world you were previously in",
                 this::backFromDungeon

+ 5 - 7
src/main/java/me/lethunderhawk/economy/EconomyModule.java

@@ -10,6 +10,7 @@ import me.lethunderhawk.fluxapi.FluxService;
 import me.lethunderhawk.fluxapi.util.config.ConfigLoader;
 import me.lethunderhawk.fluxapi.util.interfaces.FluxAPIModule;
 import me.lethunderhawk.scoreboard.ScoreboardManager;
+import me.lethunderhawk.tradeplugin.TradeModule;
 import me.lethunderhawk.tradeplugin.api.TradePlaceholder;
 import org.bukkit.configuration.serialization.ConfigurationSerialization;
 import org.bukkit.plugin.java.JavaPlugin;
@@ -41,7 +42,6 @@ public class EconomyModule extends FluxAPIModule {
         FluxService.register(EconomyAPI.class, economyAPI);
         loader.getFile("economy/itemValues");
 
-
         ItemValues values = loader.loadObject("economy/itemValues", "Item_values", ItemValues.class);
         if(values == null) {
             values = new ItemValues();
@@ -50,20 +50,18 @@ public class EconomyModule extends FluxAPIModule {
         economyManager.setItemValues(values);
 
         scoreboardManager = new ScoreboardManager(this);
-
-        plugin.getCommand("eco").setExecutor(new EcoCommand(this));
-        plugin.getCommand("eco").setTabCompleter(new EcoCommand(this));
+        registerCommand("eco", new EcoCommand(this));
 
         if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
             new EconomyPlaceholder(economyAPI).register();
-            new TradePlaceholder().register();
+            new TradePlaceholder(FluxService.get(TradeModule.class)).register();
         }
-
-        plugin.getServer().getPluginManager().registerEvents(new PlayerJoinListener(scoreboardManager), plugin);
+        registerListener(new PlayerJoinListener(scoreboardManager));
     }
 
     @Override
     public void onDisable() {
+        unregisterAllListeners();
         loader.saveObject("economy/itemValues", "Item_values", economyManager.getItemValues());
     }
 

+ 14 - 7
src/main/java/me/lethunderhawk/economy/command/EcoCommand.java

@@ -26,25 +26,25 @@ public class EcoCommand extends CustomCommand {
     }
 
     @Override
-    public void setRootCommand() {
-        rootCommand = new CommandNode("eco", "Main economy command", null);
+    public CommandNode getRootCommand(){
+       return new CommandNode("eco", "Main economy command", null);
     }
 
     @Override
     public void createCommands() {
-        CommandNode set = registerCommand("set", "Set the balance of a player", this::setEco);
+        CommandNode set = registerSubCommand("set", "Set the balance of a player", this::setEco);
         set.setTabCompleter(this::completeAllEcoCommands);
 
-        CommandNode add = registerCommand("add", "Add any amount to the balance of a player", this::addEco);
+        CommandNode add = registerSubCommand("add", "Add any amount to the balance of a player", this::addEco);
         add.setTabCompleter(this::completeAllEcoCommands);
 
-        CommandNode remove = registerCommand("remove", "Remove any amount of the balance of a player", this::removeEco);
+        CommandNode remove = registerSubCommand("remove", "Remove any amount of the balance of a player", this::removeEco);
         remove.setTabCompleter(this::completeAllEcoCommands);
 
-        CommandNode get = registerCommand("get", "Get the balance of a player", this::getBalance);
+        CommandNode get = registerSubCommand("get", "Get the balance of a player", this::getBalance);
         get.setTabCompleter(this::completePlayers);
 
-        //CommandNode shop = registerCommand("shop", "Open the main Shop", this::openShop);
+        //CommandNode shop = registerSubCommand("shop", "Open the main Shop", this::openShop);
     }
 
     private void openShop(CommandSender sender, String[] strings) {
@@ -90,6 +90,13 @@ public class EcoCommand extends CustomCommand {
     }
 
     private void removeEco(CommandSender commandSender, String[] strings) {
+        if(!commandSender.isOp()) return;
+        Player target = Bukkit.getPlayer(strings[0]);
+        if (target == null) {
+            module.sendText(commandSender, Component.text("Spieler nicht gefunden.",  NamedTextColor.RED));
+        }else{
+            getAPI().removeMoney(target.getUniqueId(), Double.parseDouble(strings[1]));
+        }
     }
 
     private void addEco(CommandSender commandSender, String[] strings) {

+ 5 - 17
src/main/java/me/lethunderhawk/minion/MinionModule.java

@@ -4,8 +4,8 @@ import me.lethunderhawk.custom.recipes.enchantedVariant.EnchantedVariantRecipeMa
 import me.lethunderhawk.custom.recipes.enchantedVariant.item.EnchantedCobblestone;
 import me.lethunderhawk.custom.recipes.enchantedVariant.item.EnchantedRedstone;
 import me.lethunderhawk.custom.recipes.enchantedVariant.item.abstraction.DisableEnchantedItemPlacingListener;
-import me.lethunderhawk.custom.recipes.enchantedVariant.item.abstraction.EnchantedVariant;
 import me.lethunderhawk.custom.recipes.enchantedVariant.item.abstraction.EnchantedItemRegistry;
+import me.lethunderhawk.custom.recipes.enchantedVariant.item.abstraction.EnchantedVariant;
 import me.lethunderhawk.fluxapi.FluxService;
 import me.lethunderhawk.fluxapi.util.interfaces.FluxAPIModule;
 import me.lethunderhawk.minion.command.MinionCommand;
@@ -18,7 +18,6 @@ import me.lethunderhawk.minion.persistence.MinionStorage;
 import me.lethunderhawk.minion.registry.MinionRegistry;
 import me.lethunderhawk.minion.runtime.PlacedMinion;
 import org.bukkit.Material;
-import org.bukkit.event.HandlerList;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.plugin.java.JavaPlugin;
 
@@ -28,7 +27,6 @@ import java.util.List;
 public class MinionModule extends FluxAPIModule {
 
     private List<ItemStack> allMinions;
-    private MinionListener minionListener;
     private MinionFactory factory;
     private MinionStorage storage;
     private EnchantedVariantRecipeManager enchantedVariantRecipeManager;
@@ -48,23 +46,18 @@ public class MinionModule extends FluxAPIModule {
         allMinions = new ArrayList<>();
         customRecipes();
 
-        MinionCommand cmd = new MinionCommand(this);
-        plugin.getServer().getPluginCommand("minion").setExecutor(cmd);
-        plugin.getServer().getPluginCommand("minion").setTabCompleter(cmd);
+        registerCommand("minion", new MinionCommand(this));
         this.factory = new MinionFactory();
         registerMinions();
 
         loadAllMinions();
-
-        minionListener = new MinionListener(plugin, factory.getMinionItem());
-        plugin.getServer().getPluginManager().registerEvents(minionListener, plugin);
+        registerListener(new MinionListener(plugin, factory.getMinionItem()));
     }
 
     private void customRecipes() {
 
         this.enchantedVariantRecipeManager = FluxService.get(EnchantedVariantRecipeManager.class);
-
-        plugin.getServer().getPluginManager().registerEvents(new DisableEnchantedItemPlacingListener(), plugin);
+        registerListener(new DisableEnchantedItemPlacingListener());
 
         registerRecipes();
         clearRecipes();
@@ -123,17 +116,12 @@ public class MinionModule extends FluxAPIModule {
     @Override
     public void onDisable() {
         clearRecipes();
-        unregisterListeners();
+        unregisterAllListeners();
         saveAllMinions();
-
     }
 
     private void saveAllMinions() {
         storage.saveAllMinionsToStorage();
     }
 
-    public void unregisterListeners() {
-        HandlerList.unregisterAll(minionListener);
-        minionListener = null;
-    }
 }

+ 6 - 6
src/main/java/me/lethunderhawk/minion/command/MinionCommand.java

@@ -21,17 +21,17 @@ public class MinionCommand extends CustomCommand {
     }
 
     @Override
-    public void setRootCommand() {
-        rootCommand = new CommandNode("minion", "Main minion command", null);
+    public CommandNode getRootCommand(){
+       return new CommandNode("minion", "Main minion command", null);
     }
 
     @Override
     public void createCommands() {
-        registerCommand("all", "get all minions", this::getAll);
-        registerCommand("reload", "reload", this::reload);
-        registerCommand("removeAll", "remove all minions", this::removeAll);
+        registerSubCommand("all", "get all minions", this::getAll);
+        registerSubCommand("reload", "reload", this::reload);
+        registerSubCommand("removeAll", "remove all minions", this::removeAll);
 
-        CommandNode menu = registerCommand("menu", "See all minion types in a GUI", this::showMenu);
+        CommandNode menu = registerSubCommand("menu", "See all minion types in a GUI", this::showMenu);
             CommandNode cobble = new CommandNode("cobblestone", "See all cobblestone minions", this::showCobbleMenu);
 
         menu.addSubCommands(cobble);

+ 1 - 2
src/main/java/me/lethunderhawk/profile/ProfileModule.java

@@ -53,8 +53,7 @@ public class ProfileModule extends FluxAPIModule {
         );
 
         ProfileCommand command = new ProfileCommand(this);
-        plugin.getCommand("profile").setExecutor(command);
-        plugin.getCommand("profile").setTabCompleter(command);
+        registerCommand("profile", command);
     }
 
     private void loadConfig() {

+ 4 - 4
src/main/java/me/lethunderhawk/profile/command/ProfileCommand.java

@@ -14,17 +14,17 @@ public class ProfileCommand extends CustomCommand {
     }
 
     @Override
-    public void setRootCommand() {
-        this.rootCommand = new CommandNode("profile", "base command", this::showProfile);
+    public CommandNode getRootCommand(){
+       return new CommandNode("profile", "base command", this::showProfile);
     }
 
     @Override
     public void createCommands() {
-        registerCommand("reload", "Reloads the profile module", this::reload);
+        registerSubCommand("reload", "Reloads the profile module", this::reload);
     }
 
     private void reload(CommandSender sender, String[] strings) {
-        module.reload(sender, strings);
+        module.reload(sender);
     }
 
     private void showProfile(CommandSender sender, String[] strings) {

+ 9 - 11
src/main/java/me/lethunderhawk/tradeplugin/TradeModule.java

@@ -1,7 +1,6 @@
 package me.lethunderhawk.tradeplugin;
 
 import me.lethunderhawk.fluxapi.util.interfaces.FluxAPIModule;
-import me.lethunderhawk.tradeplugin.command.TradeAcceptCommand;
 import me.lethunderhawk.tradeplugin.command.TradeCommand;
 import me.lethunderhawk.tradeplugin.listener.PlayerInteractListener;
 import me.lethunderhawk.tradeplugin.listener.TradeInventoryListener;
@@ -11,8 +10,8 @@ import org.bukkit.plugin.java.JavaPlugin;
 
 public class TradeModule extends FluxAPIModule {
 
-    private static TradeManager tradeManager;
-    private static TradeRequestManager requestManager;
+    private TradeManager tradeManager;
+    private TradeRequestManager requestManager;
 
     public TradeModule(JavaPlugin plugin) {
         super(plugin);
@@ -25,13 +24,12 @@ public class TradeModule extends FluxAPIModule {
 
     public void onEnable() {
         tradeManager = new TradeManager(plugin);
-        requestManager = new TradeRequestManager();
+        requestManager = new TradeRequestManager(this);
+        registerListener(new PlayerInteractListener(this));
+        registerListener(new TradeInventoryListener(this));
 
-        plugin.getServer().getPluginManager().registerEvents(new PlayerInteractListener(this), plugin);
-        plugin.getServer().getPluginManager().registerEvents(new TradeInventoryListener(this), plugin);
-
-        plugin.getCommand("trade").setExecutor(new TradeCommand());
-        plugin.getCommand("tradeaccept").setExecutor(new TradeAcceptCommand());
+        registerCommand("trade", new TradeCommand(this));
+        //registerCommand("acceptTrade", new TradeAcceptCommand(this));
     }
 
     @Override
@@ -39,11 +37,11 @@ public class TradeModule extends FluxAPIModule {
 
     }
 
-    public static TradeManager getTradeManager() {
+    public TradeManager getTradeManager() {
         return tradeManager;
     }
 
-    public static TradeRequestManager getRequestManager() {
+    public TradeRequestManager getRequestManager() {
         return requestManager;
     }
 }

+ 5 - 2
src/main/java/me/lethunderhawk/tradeplugin/api/TradePlaceholder.java

@@ -2,13 +2,16 @@ package me.lethunderhawk.tradeplugin.api;
 
 import me.clip.placeholderapi.expansion.PlaceholderExpansion;
 import me.lethunderhawk.tradeplugin.TradeModule;
+import me.lethunderhawk.tradeplugin.trade.TradeManager;
 import me.lethunderhawk.tradeplugin.trade.TradeSession;
 import org.bukkit.entity.Player;
 import org.jetbrains.annotations.NotNull;
 
 public class TradePlaceholder extends PlaceholderExpansion {
+    private final TradeManager tradeManager;
 
-    public TradePlaceholder() {
+    public TradePlaceholder(TradeModule module) {
+        this.tradeManager = module.getTradeManager();
     }
 
     @Override
@@ -28,7 +31,7 @@ public class TradePlaceholder extends PlaceholderExpansion {
     @Override
     public String onPlaceholderRequest(Player p, String identifier) {
         if (identifier.equalsIgnoreCase("flux_total") && p != null) {
-            TradeSession session = TradeModule.getTradeManager().getSession(p);
+            TradeSession session = tradeManager.getSession(p);
             if (session != null) return String.valueOf(session.getMoneyFor(p));
             return "0";
         }

+ 25 - 19
src/main/java/me/lethunderhawk/tradeplugin/command/TradeAcceptCommand.java

@@ -1,49 +1,55 @@
 package me.lethunderhawk.tradeplugin.command;
 
-import me.lethunderhawk.fluxapi.FluxService;
+import me.lethunderhawk.fluxapi.util.command.CommandNode;
+import me.lethunderhawk.fluxapi.util.command.CustomCommand;
 import me.lethunderhawk.tradeplugin.TradeModule;
 import me.lethunderhawk.tradeplugin.trade.TradeManager;
 import me.lethunderhawk.tradeplugin.trade.TradeRequestManager;
 import net.kyori.adventure.text.Component;
 import net.kyori.adventure.text.format.NamedTextColor;
 import org.bukkit.Bukkit;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
 import org.bukkit.command.CommandSender;
 import org.bukkit.entity.Player;
 
-public class TradeAcceptCommand implements CommandExecutor {
+public class TradeAcceptCommand extends CustomCommand {
 
     private final TradeRequestManager requestManager;
     private final TradeManager tradeManager;
-    private final TradeModule tradeModule;
 
-    public TradeAcceptCommand() {
-        this.requestManager = TradeModule.getRequestManager();
-        this.tradeManager = TradeModule.getTradeManager();
-        this.tradeModule = FluxService.get(TradeModule.class);
+    public TradeAcceptCommand(TradeModule module) {
+        super(module);
+        this.requestManager = module.getRequestManager();
+        this.tradeManager = module.getTradeManager();
     }
 
     @Override
-    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
-        if (!(sender instanceof Player target)) return true;
+    public CommandNode getRootCommand() {
+        return new CommandNode("acceptTrade", "Accept a trade", this::acceptTrade);
+    }
+
+    private void acceptTrade(CommandSender sender, String[] args) {
+        if (!(sender instanceof Player target)) return;
 
-        if (args.length != 1) return true;
+        if (args.length != 1) return;
 
         Player requester = Bukkit.getPlayerExact(args[0]);
         if (requester == null) {
-            tradeModule.sendText(target, Component.text("Spieler ist nicht online.",  NamedTextColor.RED));
-            return true;
+            module.sendText(target, Component.text("Spieler ist nicht online.",  NamedTextColor.RED));
+            return;
         }
 
-        if (!requestManager.isPending(target, requester)) {
-            tradeModule.sendText(target, Component.text("Keine Anfrage von diesem Spieler offen.",  NamedTextColor.RED));
-            return true;
+        if (!requestManager.isPending(target.getUniqueId(), requester.getUniqueId())) {
+            module.sendText(target, Component.text("Keine Anfrage von diesem Spieler offen.",  NamedTextColor.RED));
+            return;
         }
 
-        requestManager.accept(target, requester);
+        requestManager.accept(target.getUniqueId(), requester.getUniqueId());
 
         tradeManager.startTrade(requester, target);
-        return true;
+    }
+
+    @Override
+    public void createCommands() {
+
     }
 }

+ 38 - 20
src/main/java/me/lethunderhawk/tradeplugin/command/TradeCommand.java

@@ -1,55 +1,73 @@
 package me.lethunderhawk.tradeplugin.command;
 
-import me.lethunderhawk.fluxapi.FluxService;
+import me.lethunderhawk.fluxapi.util.command.CommandNode;
+import me.lethunderhawk.fluxapi.util.command.CustomCommand;
 import me.lethunderhawk.tradeplugin.TradeModule;
 import me.lethunderhawk.tradeplugin.trade.TradeManager;
 import me.lethunderhawk.tradeplugin.trade.TradeRequestManager;
 import net.kyori.adventure.text.Component;
 import net.kyori.adventure.text.format.NamedTextColor;
 import org.bukkit.Bukkit;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
 import org.bukkit.command.CommandSender;
 import org.bukkit.entity.Player;
 
-public class TradeCommand implements CommandExecutor {
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class TradeCommand extends CustomCommand {
 
     private final TradeManager tradeManager;
     private final TradeRequestManager requestManager;
-    private final TradeModule tradeModule;
 
-    public TradeCommand() {
-        this.tradeManager = TradeModule.getTradeManager();
-        this.requestManager = TradeModule.getRequestManager();
-        this.tradeModule = FluxService.get(TradeModule.class);
+    public TradeCommand(TradeModule module) {
+        super(module);
+        this.tradeManager = module.getTradeManager();
+        this.requestManager = module.getRequestManager();
     }
 
     @Override
-    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
-        if (!(sender instanceof Player p)) return true;
+    public CommandNode getRootCommand() {
+        return new CommandNode("trade", "Allows you to trade players", this::trade);
+    }
+
+    private void trade(CommandSender sender, String[] args) {
+        if (!(sender instanceof Player p)) return;
 
         if (args.length != 1) {
-            tradeModule.sendText(p, Component.text("Verwendung: /trade <Spieler>", NamedTextColor.RED));
-            return true;
+            module.sendText(p, Component.text("Verwendung: /trade <Spieler>", NamedTextColor.RED));
+            return;
         }
 
         Player target = Bukkit.getPlayerExact(args[0]);
         if (target == null) {
-            tradeModule.sendText(p, Component.text("Spieler nicht gefunden.", NamedTextColor.RED));
-            return true;
+            module.sendText(p, Component.text("Spieler nicht gefunden.", NamedTextColor.RED));
+            return;
         }
 
         if (p.equals(target)) {
-            tradeModule.sendText(p, Component.text("Du kannst nicht mit dir selbst handeln.", NamedTextColor.RED));
-            return true;
+            module.sendText(p, Component.text("Du kannst nicht mit dir selbst handeln.", NamedTextColor.RED));
+            return;
         }
 
         if (tradeManager.isInTrade(p) || tradeManager.isInTrade(target)) {
-            tradeModule.sendText(p, Component.text("Einer von euch handelt bereits.", NamedTextColor.RED));
-            return true;
+            module.sendText(p, Component.text("Einer von euch handelt bereits.", NamedTextColor.RED));
+            return;
         }
 
         requestManager.sendRequest(p, target);
-        return true;
+    }
+
+    @Override
+    public void createCommands() {
+        rootCommand.setTabCompleter(this::completePlayers);
+    }
+
+    private List<String> completePlayers(CommandSender sender, String[] args){
+        if(args.length == 0) return Bukkit.getOnlinePlayers().stream().map(Player::getName).toList();
+        String partial = args[0].toLowerCase();
+        return Bukkit.getOnlinePlayers().stream()
+                .map(Player::getName)
+                .filter(name -> name.toLowerCase().startsWith(partial))
+                .collect(Collectors.toList());
     }
 }

+ 5 - 4
src/main/java/me/lethunderhawk/tradeplugin/listener/PlayerInteractListener.java

@@ -9,10 +9,11 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
 
 public class PlayerInteractListener implements Listener {
 
+    private final TradeModule module;
     private final TradeManager manager;
-
-    public PlayerInteractListener(TradeModule plugin) {
-        this.manager = TradeModule.getTradeManager();
+    public PlayerInteractListener(TradeModule module) {
+        this.module = module;
+        this.manager = module.getTradeManager();
     }
 
     @EventHandler
@@ -26,6 +27,6 @@ public class PlayerInteractListener implements Listener {
             return;
         }
 
-        TradeModule.getRequestManager().sendRequest(p, target);
+        module.getRequestManager().sendRequest(p, target);
     }
 }

+ 3 - 3
src/main/java/me/lethunderhawk/tradeplugin/listener/TradeInventoryListener.java

@@ -31,8 +31,8 @@ public class TradeInventoryListener implements Listener {
 
     private final TradeManager manager;
 
-    public TradeInventoryListener(TradeModule plugin) {
-        this.manager = TradeModule.getTradeManager();
+    public TradeInventoryListener(TradeModule module) {
+        this.manager = module.getTradeManager();
     }
 
     @EventHandler
@@ -107,7 +107,7 @@ public class TradeInventoryListener implements Listener {
     }
 
     private void openSignMenu(Player p) {
-        SignMenuFactory.Menu signInput = new SignMenuFactory(FluxService.get(BazaarFlux.class)).newMenu(List.of("", "^^^^^^^^^^^^", "Input the amount", "to trade"))
+        SignMenuFactory.SignMenu signInput = new SignMenuFactory(FluxService.get(BazaarFlux.class)).newMenu(List.of("", "^^^^^^^^^^^^", "Input the amount", "to trade"))
                 .reopenIfFail(true)
                 .response((player, input) -> {
                     long value = EconomyUtil.longFromString(input[0]);

+ 31 - 22
src/main/java/me/lethunderhawk/tradeplugin/trade/TradeRequestManager.java

@@ -11,17 +11,24 @@ import net.kyori.adventure.text.format.NamedTextColor;
 import org.bukkit.Bukkit;
 import org.bukkit.entity.Player;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
+import java.util.*;
 
 public class TradeRequestManager {
 
-    private final Map<UUID, UUID> requests = new HashMap<>(); // Sender ; Target
+    private final Map<UUID, List<UUID>> requests = new HashMap<>(); // Sender ; Target
     private final Map<UUID, Integer> timeoutTasks = new HashMap<>();
+    private final TradeManager tradeManager;
+
+    public TradeRequestManager(TradeModule tradeModule) {
+        this.tradeManager = tradeModule.getTradeManager();
+    }
 
     public void sendRequest(Player sender, Player target) {
-        if(isPending(sender, target)){
+        UUID targetUUID = target.getUniqueId();
+        UUID senderUUID = sender.getUniqueId();
+        requests.putIfAbsent(senderUUID, new ArrayList<>());
+        // If target already proposed a trade
+        if(isPending(targetUUID, senderUUID)){
 
             Component targetmsg = Component.text(sender.getName())
                     .color(NamedTextColor.GREEN)
@@ -38,21 +45,18 @@ public class TradeRequestManager {
             FluxService.get(TradeModule.class).sendText(sender, sendermsg);
             FluxService.get(TradeModule.class).sendText(target, targetmsg);
 
-            TradeModule.getTradeManager().startTrade(sender, target);
-
-            accept(sender, target);
-            accept(target, sender);
-        }else{
-            if(requests.get(target.getUniqueId()) != null) return;
+            tradeManager.startTrade(sender, target);
 
-            requests.put(target.getUniqueId(), sender.getUniqueId());
+            accept(senderUUID, targetUUID);
+        }else if(!requests.get(senderUUID).contains(targetUUID)){
+            requests.get(senderUUID).add(targetUUID);
 
             Component targetmsg = Component.text(sender.getName() + " möchte mit dir handeln. ")
                     .color(NamedTextColor.YELLOW)
                     .append(
                             Component.text("[Annehmen]")
                                     .color(NamedTextColor.GREEN)
-                                    .clickEvent(ClickEvent.runCommand("/tradeaccept " + sender.getName()))
+                                    .clickEvent(ClickEvent.runCommand("/trade " + sender.getName()))
                     );
 
             Component sendermsg = Component.text("Handelsanfrage an ")
@@ -79,8 +83,8 @@ public class TradeRequestManager {
             int task = Bukkit.getScheduler().scheduleSyncDelayedTask(
                     FluxService.get(BazaarFlux.class),
                     () -> {
-                        if (isPending(target, sender)) {
-                            requests.remove(target.getUniqueId());
+                        if (isPending(senderUUID, targetUUID)) {
+                            requests.get(senderUUID).remove(targetUUID);
                             FluxService.get(TradeModule.class).sendText(sender, Component.text("Deine Handelsanfrage an " + target.getName() + " ist abgelaufen.", NamedTextColor.RED));
                             FluxService.get(TradeModule.class).sendText(target, Component.text("Die Handelsanfrage von " + sender.getName() + " ist abgelaufen.", NamedTextColor.RED));
                         }
@@ -88,19 +92,24 @@ public class TradeRequestManager {
                     20L * 60 // 1 Minute
             );
 
-            timeoutTasks.put(target.getUniqueId(), task);
+
+            timeoutTasks.put(senderUUID, task);
         }
     }
 
-    public boolean isPending(Player target, Player sender) {
-        return requests.getOrDefault(target.getUniqueId(), null) != null
-                && requests.get(target.getUniqueId()).equals(sender.getUniqueId());
+    public boolean isPending(UUID target, UUID sender) {
+
+        return requests.getOrDefault(target, null) != null
+                && requests.get(target).contains(sender);
     }
 
-    public void accept(Player target, Player sender) {
-        requests.remove(target.getUniqueId());
+    public void accept(UUID sender, UUID target) {
+        requests.get(sender).remove(target);
+        requests.get(target).remove(sender);
 
-        Integer task = timeoutTasks.remove(target.getUniqueId());
+        Integer task = timeoutTasks.remove(target);
+        Integer task2 = timeoutTasks.remove(sender);
         if (task != null) Bukkit.getScheduler().cancelTask(task);
+        if (task2 != null) Bukkit.getScheduler().cancelTask(task2);
     }
 }

+ 3 - 8
src/main/java/me/lethunderhawk/world/WorldModule.java

@@ -10,7 +10,6 @@ import org.bukkit.event.HandlerList;
 import org.bukkit.plugin.java.JavaPlugin;
 
 import java.io.File;
-import java.util.Objects;
 
 public class WorldModule extends FluxAPIModule {
 
@@ -32,7 +31,7 @@ public class WorldModule extends FluxAPIModule {
         initWorldStorage();
 
         bazaarFlux.getLogger().info("World folders initialized!");
-        registerCommands(bazaarFlux);
+        registerCommand("warp", new WorldCommand(this));
 
         registerBootsTrapper(bazaarFlux);
     }
@@ -41,8 +40,8 @@ public class WorldModule extends FluxAPIModule {
         NestedWorldStorageManager manager = new NestedWorldStorageManager();
         FluxService.register(NestedWorldStorageManager.class, manager);
 
-        manager.registerCategory("islands");
-        manager.registerCategory("dungeons");
+        //manager.registerCategory("islands");
+        //manager.registerCategory("dungeons");
     }
 
     private void registerBootsTrapper(BazaarFlux bazaarFlux) {
@@ -51,10 +50,6 @@ public class WorldModule extends FluxAPIModule {
         bazaarFlux.getServer().getPluginManager().registerEvents(bootstrapListener, bazaarFlux);
     }
 
-    private void registerCommands(BazaarFlux bazaarFlux) {
-        WorldCommand worldCommand = new WorldCommand(this);
-        Objects.requireNonNull(bazaarFlux.getCommand("warp")).setExecutor(worldCommand);
-    }
 
     @Override
     public void onDisable() {

+ 8 - 8
src/main/java/me/lethunderhawk/world/command/WorldCommand.java

@@ -27,8 +27,8 @@ public class WorldCommand extends CustomCommand {
     }
 
     @Override
-    public void setRootCommand() {
-        rootCommand = new CommandNode("warp", "Hop between worlds!", null);
+    public CommandNode getRootCommand(){
+       return new CommandNode("warp", "Hop between worlds!", null);
     }
 
     private void populateLocationMap() {
@@ -55,10 +55,10 @@ public class WorldCommand extends CustomCommand {
 
     @Override
     public void createCommands() {
-        registerCommand("island", "Warp to your island", this::warpToIsland);
-        registerCommand("overworld", "Warp to the overworld", this::warpOverworld);
-        registerCommand("reload", "Reload this module", this::reload);
-        registerCommand("deleteIslands", "delete all worlds in island folder", this::deleteAllIslands);
+        registerSubCommand("island", "Warp to your island", this::warpToIsland);
+        registerSubCommand("overworld", "Warp to the overworld", this::warpOverworld);
+        registerSubCommand("reload", "Reload this module", this::reload);
+        registerSubCommand("deleteIslands", "delete all worlds in island folder", this::deleteAllIslands);
         registerAllDefaultWorldCommands();
     }
 
@@ -71,14 +71,14 @@ public class WorldCommand extends CustomCommand {
 
 
     private void reload(CommandSender sender, String[] strings) {
-        module.reload(sender, strings);
+        module.reload(sender);
     }
 
     private void registerAllDefaultWorldCommands() {
         if(locations == null || locations.isEmpty()) return;
         for(Map.Entry<String, Location> entry : locations.entrySet()){
             String locationName = entry.getKey();
-            registerCommand(locationName, "Warp to " + locationName, warpToLocation(entry.getValue()));
+            registerSubCommand(locationName, "Warp to " + locationName, warpToLocation(entry.getValue()));
         }
     }
 

+ 0 - 43
src/main/resources/plugin.yml

@@ -5,49 +5,6 @@ api-version: 1.21.10
 prefix: BazaarFlux
 depend:
   - FluxAPI
-commands:
-  eco:
-    description: Economy administration command
-    usage: /eco <set|add|remove|get> <player> <amount>
-    permission: currency.eco
-
-  trade:
-    description: Send a trade request
-
-  tradeaccept:
-    description: Accept a trade request
-
-  clan:
-    description: Clan management command
-    usage: /clan <join|rule>
-
-  customItems:
-    description: Custom Item management command
-    usage: /customItem
-    permission: customItem.commands
-
-  minion:
-    description: Minion management command
-    usage: /minion
-    permission: minion.commands
-
-  dungeon:
-    description: Dungeons command
-    usage: /dungeon
-    permission: dungeons.commands
-
-  warp:
-    description: Warping between worlds
-    usage: /warp
-    permission: warp.commands
-
-  profile:
-    description: Shows your profile
-    usage: /profile
-
-  customrecipe:
-    description: Shows recipes
-    usage: /customrecipe
 
 permissions:
   minion.commands: