Search in sources :

Example 1 with WeatherTimeModule

use of au.com.mineauz.minigames.minigame.modules.WeatherTimeModule in project Minigames by AddstarMC.

the class Events method playerSpawn.

@EventHandler(priority = EventPriority.HIGHEST)
private void playerSpawn(PlayerRespawnEvent event) {
    final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame()) {
        final WeatherTimeModule mod = WeatherTimeModule.getMinigameModule(ply.getMinigame());
        if (mod.isUsingCustomWeather()) {
            Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

                @Override
                public void run() {
                    ply.getPlayer().setPlayerWeather(mod.getCustomWeather());
                }
            });
        }
        if (ply.getMinigame().getState() == MinigameState.ENDED) {
            plugin.pdata.quitMinigame(ply, true);
        }
    }
    if (ply.isRequiredQuit()) {
        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

            @Override
            public void run() {
                ply.restorePlayerData();
            }
        });
        event.setRespawnLocation(ply.getQuitPos());
        ply.setRequiredQuit(false);
        ply.setQuitPos(null);
    }
}
Also used : WeatherTimeModule(au.com.mineauz.minigames.minigame.modules.WeatherTimeModule) EventHandler(org.bukkit.event.EventHandler)

Aggregations

WeatherTimeModule (au.com.mineauz.minigames.minigame.modules.WeatherTimeModule)1 EventHandler (org.bukkit.event.EventHandler)1