package com.yaohun.wheatwar.listener;

import com.yaohun.wheatwar.WheatWar;
import com.yaohun.wheatwar.game.Game;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.scheduler.BukkitRunnable;

public class JoinListener implements Listener {

    @EventHandler
    public void onJoin(PlayerJoinEvent e){
        Game game = WheatWar.getGame();
        new BukkitRunnable() {
            @Override
            public void run() {
                if(!game.isStarted()) {
                    game.start();
                }
                game.initPlayerData(e.getPlayer());
            }
        }.runTaskLater(WheatWar.inst(),10L);
    }
}
