Newer
Older
ChallengeSystem / src / main / java / de / fanta / challenges / commands / reset / ResetConfirmCommand.java
@fanta fanta on 6 Aug 2023 1 KB AHHHHH
package de.fanta.challenges.commands.reset;

import de.fanta.challenges.Challenges;
import de.fanta.challenges.utils.ChatUtil;
import de.fanta.challenges.utils.SaveWorldUtils;
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 ResetConfirmCommand extends SubCommand {

    private final Challenges plugin;

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

    @Override
    public boolean onCommand(CommandSender sender, Command command, String alias, String commandString, ArgsParser args) {
        if ((sender instanceof Player && plugin.isEditor((Player) sender)) || sender.hasPermission("Challenges.editor.override")) {
            SaveWorldUtils.restartServer(args.getNext(null));
        } else if (plugin.getCurrentEditor() != null) {
            ChatUtil.sendErrorMessage(sender, "Du bist kein Editor! Nur " + plugin.getCurrentEditor().getName() + " kann die Map zurücksetzen!");
            return true;
        } else {
            ChatUtil.sendErrorMessage(sender, "Aktuell gibt es keinen Editor!");
            ChatUtil.sendErrorMessage(sender, "Um selbst Editor zu werden musst du dir im Freebuild VIP kaufen!");
            return true;
        }
        return true;
    }
}