package com.yaohun.wheatwar;

import com.yaohun.wheatwar.effect.SummonTheCow;
import com.yaohun.wheatwar.effect.SummonTheVillager;
import com.yaohun.wheatwar.effect.SummonTheZombie;
import com.yaohun.wheatwar.game.Game;
import com.yaohun.wheatwar.listener.GameEffectListener;
import com.yaohun.wheatwar.listener.GameListener;
import com.yaohun.wheatwar.listener.GamePotect;
import com.yaohun.wheatwar.listener.JoinListener;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import tools.GameUtil;

public class WheatWar extends JavaPlugin {

    private static WheatWar instance;
    private static Game game;

    @Override
    public void onEnable() {
        instance = this;
        game = new Game();
        getServer().getPluginManager().registerEvents(new GameEffectListener(),this);
        getServer().getPluginManager().registerEvents(new GameListener(),this);
        getServer().getPluginManager().registerEvents(new GamePotect(),this);
        getServer().getPluginManager().registerEvents(new JoinListener(),this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String Command, String[] args) {
        if (Command.equalsIgnoreCase("livegift")) {
            // RepairGiftGui.OpenGui((Player) sender);
            return true;
        }
        if (Command.equalsIgnoreCase("gameedit")) {
            // GameEditGui.OpenGui((Player) sender);
            return true;
        }
        if (Command.equalsIgnoreCase("game")) {
            if (args.length == 0) {
                sender.sendMessage("/game start - 开始游戏");
                return true;
            }
            if(args.length == 1 && args[0].equalsIgnoreCase("test1")){
                SummonTheVillager.apply(getGame(), (Player) sender, "村民", 50);
                sender.sendMessage("执行成功.");
            }
            if(args.length == 1 && args[0].equalsIgnoreCase("test2")){
                SummonTheCow.apply(getGame(), (Player) sender, "路人", 50);
                sender.sendMessage("执行成功.");
            }
            if(args.length == 1 && args[0].equalsIgnoreCase("test3")){
                SummonTheZombie.apply(getGame(), (Player) sender, "僵尸先生", 10);
                sender.sendMessage("执行成功.");
            }
        }
        return false;
    }

    public static WheatWar inst(){return instance;}

    public static Game getGame() {return game;}
}
