Newer
Older
ChallengeSystem / Challenge / src / main / java / de / fanta / challenge / commands / SkipItemCommand.java
@fanta fanta on 7 Jun 2024 1 KB start module system
package de.fanta.challenge.commands;

import de.fanta.challenge.Challenges;
import de.fanta.challenge.challenges.AllItemsChallenge;
import de.fanta.challenge.utils.ChatUtil;
import de.fanta.challenge.utils.Config;
import de.iani.cubesideutils.bukkit.commands.SubCommand;
import de.iani.cubesideutils.commands.ArgsParser;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class SkipItemCommand extends SubCommand {

    private final Challenges plugin;

    public SkipItemCommand(Challenges plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String alias, String commandString, ArgsParser args) {
        if (!(sender instanceof Player p)) {
            ChatUtil.sendErrorMessage(sender, "You are not a Player :>");
            return true;
        }
        if (plugin.getCurrentEditor() != null) {
            if (!plugin.isEditor(p) || !p.hasPermission("Challenges.editor.override")) {
                ChatUtil.sendErrorMessage(p, "Das kann nur der Editor!");
                return true;
            }
        } else {
            ChatUtil.sendErrorMessage(p, "Aktuell gibt es keinen Editor!");
        }

        if (Config.getBoolean("allitems")) {
            AllItemsChallenge.next(p, true);
        } else {
            ChatUtil.sendErrorMessage(p, "Dies geht nur wenn All Items Aktiv ist!");
        }

        return true;
    }
}