diff --git a/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java b/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java index debddf8..2862ecc 100644 --- a/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java +++ b/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java @@ -6,12 +6,18 @@ import com.badbones69.crazyauctions.api.enums.Messages; import com.badbones69.crazyauctions.api.support.MetricsWrapper; import com.badbones69.crazyauctions.commands.AuctionCommand; import com.badbones69.crazyauctions.commands.AuctionTab; +import com.badbones69.crazyauctions.commands.v2.BaseCommand; +import com.badbones69.crazyauctions.commands.v2.player.CommandHelp; +import com.badbones69.crazyauctions.commands.v2.staff.CommandReload; import com.badbones69.crazyauctions.configs.ConfigManager; import com.badbones69.crazyauctions.controllers.GuiListener; import com.badbones69.crazyauctions.controllers.MarcoListener; import com.badbones69.crazyauctions.currency.VaultSupport; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.ryderbelserion.vital.paper.Vital; import com.ryderbelserion.vital.paper.util.scheduler.FoliaRunnable; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandExecutor; import org.bukkit.command.PluginCommand; @@ -22,6 +28,7 @@ import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.Base64; +import java.util.List; public class CrazyAuctions extends Vital { @@ -117,7 +124,19 @@ public class CrazyAuctions extends Vital { getServer().getPluginManager().registerEvents(new GuiListener(), this); getServer().getPluginManager().registerEvents(new MarcoListener(), this); - registerCommand(getCommand("crazyauctions"), new AuctionTab(), new AuctionCommand()); + registerCommand(getCommand("ca"), new AuctionTab(), new AuctionCommand()); + + // Register commands. + getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> { + LiteralArgumentBuilder root = new BaseCommand().registerPermission().literal().createBuilder(); + + List.of( + new CommandReload(), + new CommandHelp() + ).forEach(command -> root.then(command.registerPermission().literal())); + + event.registrar().register(root.build(), "the base command for CrazyAuctions"); + }); this.support = new VaultSupport(); this.support.loadVault();