package de.fanta.challenges.commands;
import de.fanta.challenges.Challenges;
import de.fanta.challenges.guis.eventgui.BingoItemsGui;
import de.fanta.challenges.utils.ChatUtil;
import de.fanta.challenges.utils.Config;
import de.iani.cubesideutils.bukkit.commands.SubCommand;
import de.iani.cubesideutils.commands.ArgsParser;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Objects;
public class BingoCommand extends SubCommand {
private final Challenges plugin;
public BingoCommand(Challenges plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String commandString, ArgsParser args) {
if (!(sender instanceof Player)) {
ChatUtil.sendErrorMessage(sender, "You are not a Player :>");
return true;
}
if (Config.getBoolean("event.enabled") && Objects.equals(Config.getString("event.type"), "bingo") && plugin.getTimer().isRunning()) {
if (args.hasNext()) {
String playerName = args.getNext();
Player player = Bukkit.getPlayer(playerName);
if (player == null) {
ChatUtil.sendErrorMessage(sender, "Dieser Spieler ist nicht online!");
return true;
}
BingoItemsGui.openPlayerInv(player, (Player) sender);
} else {
BingoItemsGui.openPlayerInv((Player) sender, (Player) sender);
}
return true;
} else {
ChatUtil.sendErrorMessage(sender, "Aktuell läuft kein Bingo Event");
}
return true;
}
}