package de.fanta.challengesjoinentities.commands.AdventureCommand;
import de.fanta.challengesjoinentities.ChallengesJoinEntities;
import de.fanta.challengesjoinentities.ChatUtil;
import de.fanta.challengesjoinentities.Server;
import de.fanta.challengesjoinentities.adventure.AdventureMap;
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 AdventureTestMapCommand extends SubCommand {
private final ChallengesJoinEntities plugin;
public AdventureTestMapCommand(ChallengesJoinEntities plugin) {
this.plugin = plugin;
}
public boolean onCommand(CommandSender sender, Command command, String alias, String commandString, ArgsParser args) {
if (!(sender instanceof Player p)) {
ChatUtil.sendErrorMessage(sender, "Du musst ein Spieler sein!");
return true;
}
if (sender.hasPermission("challenges.starttestmap")) {
if (args.hasNext()) {
String category = args.getNext();
if (args.hasNext()) {
String map = args.getNext();
if (!Server.serverPlayers.containsValue(p.getUniqueId())) {
this.plugin.getPluginConfig().getOnlineAdventureServer().ifPresentOrElse(server -> server.loadNewAdventure(p, category, map, plugin.getAdventureMapsConfig().getMap(map).getVersion()), () -> ChatUtil.sendErrorMessage(p, "Aktuell ist kein Server Frei!"));
} else {
ChatUtil.sendErrorMessage(p, "Du kannst nur einen Server starten!");
}
} else {
ChatUtil.sendWarningMessage(p, "/ladventure testmap <Kategorie> <Map Name>");
}
} else {
ChatUtil.sendWarningMessage(p, "/ladventure testmap <Kategorie> <Map Name>");
}
} else {
ChatUtil.sendErrorMessage(p, "Keine Rechte!");
}
return true;
}
}