Newer
Older
TreasureChest / src / main / java / de / iani / treasurechest / commands / HelpCommand.java
@Brokkonaut Brokkonaut on 15 Jul 2024 3 KB components
package de.iani.treasurechest.commands;

import de.iani.cubesideutils.bukkit.commands.SubCommand;
import de.iani.cubesideutils.bukkit.commands.exceptions.DisallowsCommandBlockException;
import de.iani.cubesideutils.bukkit.commands.exceptions.IllegalSyntaxException;
import de.iani.cubesideutils.bukkit.commands.exceptions.InternalCommandException;
import de.iani.cubesideutils.bukkit.commands.exceptions.NoPermissionException;
import de.iani.cubesideutils.bukkit.commands.exceptions.RequiresPlayerException;
import de.iani.cubesideutils.commands.ArgsParser;
import de.iani.treasurechest.Permissions;
import de.iani.treasurechest.TreasureChest;
import java.util.Collection;
import java.util.List;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class HelpCommand extends SubCommand {
    private TreasureChest plugin;

    public HelpCommand(TreasureChest plugin) {
        this.plugin = plugin;
    }

    @Override
    public String getRequiredPermission() {
        return null;
    }

    @Override
    public boolean requiresPlayer() {
        return false;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String alias, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
        plugin.sendMessage(sender, Component.text("Commands", NamedTextColor.GREEN));
        if (sender instanceof Player && sender.hasPermission(Permissions.SET_CHEST)) {
            plugin.sendMessage(sender, "/" + alias + " setchest");
            plugin.sendMessage(sender, Component.text("  Set the treasure chest location to the location you are looking at.", NamedTextColor.GREEN));
        }
        if (sender instanceof Player && sender.hasPermission(Permissions.CREATE)) {
            plugin.sendMessage(sender, "/" + alias + " create");
            plugin.sendMessage(sender, Component.text("  Creates a price with the item in hand as display item.", NamedTextColor.GREEN));
            plugin.sendMessage(sender, "/" + alias + " additem");
            plugin.sendMessage(sender, Component.text("  Adds the item in hand to the price.", NamedTextColor.GREEN));
            plugin.sendMessage(sender, "/" + alias + " addmoney <amount>");
            plugin.sendMessage(sender, Component.text("  Adds money to a price.", NamedTextColor.GREEN));
        }
        if (sender instanceof Player && sender.hasPermission(Permissions.GIVE)) {
            plugin.sendMessage(sender, "/" + alias + " give <player>");
            plugin.sendMessage(sender, Component.text("  Gives a price to a player.", NamedTextColor.GREEN));
        }
        if (sender.hasPermission(Permissions.LIST)) {
            plugin.sendMessage(sender, "/" + alias + " list <player>");
            plugin.sendMessage(sender, Component.text("  Gives price for a player.", NamedTextColor.GREEN));
        }
        if (sender.hasPermission(Permissions.REMOVE)) {
            plugin.sendMessage(sender, "/" + alias + " remove <player> <id>");
            plugin.sendMessage(sender, Component.text("  Removes a price from a players chest.", NamedTextColor.GREEN));
        }
        if (sender.hasPermission(Permissions.TRANSFER)) {
            plugin.sendMessage(sender, "/" + alias + " transfer <fromplayer> <toplayer> CONFIRM");
            plugin.sendMessage(sender, Component.text("  Transfers all prices from one player to another.", NamedTextColor.GREEN));
        }
        return true;
    }

    @Override
    public Collection<String> onTabComplete(CommandSender sender, Command command, String alias, ArgsParser args) {
        return List.of();
    }
}