Newer
Older
ChallengeSystem / src / main / java / de / fanta / challenges / commands / BackpackCommand.java
@Github Actions Github Actions on 16 Jun 2021 1 KB Jave 16 Minecraft 1.17 Add Cubeside nmsUtils
package de.fanta.challenges.commands;

import de.fanta.challenges.Challenges;
import de.fanta.challenges.utils.ChatUtil;
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 BackpackCommand extends SubCommand {
    private final Challenges plugin;

    public BackpackCommand(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.getBingo().isRunning()) {
            plugin.getBackpack().open(p);
        } else {
            ChatUtil.sendWarningMessage(p, "Bei einem Bingo Event kannst du den Backpack nicht Nutzen!");
        }
        return true;
    }
}