Update OnPlayerDeath to delay respawning
Modified the OnPlayerDeath event to schedule game class application with a 10-second delay after player death instead of immediately applying it.
This commit is contained in:
parent
33578027d3
commit
7ed4c20d29
|
|
@ -87,7 +87,7 @@ public class Main extends JavaPlugin {
|
|||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
pluginManager.registerEvents(new SnowballEvent(gameManager), this);
|
||||
pluginManager.registerEvents(new FlagTryCaptureEvent(flag), this);
|
||||
pluginManager.registerEvents(new OnPlayerDeath(gameManager, worldBorderApi), this);
|
||||
pluginManager.registerEvents(new OnPlayerDeath(gameManager, worldBorderApi, this), this);
|
||||
pluginManager.registerEvents(new InventoryItemInteractionEvent(), this);
|
||||
pluginManager.registerEvents(new OnPlayerJoin(gameManager, flag), this);
|
||||
pluginManager.registerEvents(new GUIListener(), this);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package com.alttd.ctf.events;
|
||||
|
||||
import com.alttd.ctf.Main;
|
||||
import com.alttd.ctf.game.GameManager;
|
||||
import com.alttd.ctf.game.GamePhase;
|
||||
import com.alttd.ctf.team.TeamPlayer;
|
||||
import com.github.yannicklamprecht.worldborder.api.WorldBorderApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
|
@ -18,10 +20,12 @@ public class OnPlayerDeath implements Listener {
|
|||
|
||||
private final GameManager gameManager;
|
||||
private final WorldBorderApi worldBorderApi;
|
||||
private final Main main;
|
||||
|
||||
public OnPlayerDeath(GameManager gameManager, WorldBorderApi worldBorderApi) {
|
||||
public OnPlayerDeath(GameManager gameManager, WorldBorderApi worldBorderApi, Main main) {
|
||||
this.gameManager = gameManager;
|
||||
this.worldBorderApi = worldBorderApi;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
@ -49,8 +53,8 @@ public class OnPlayerDeath implements Listener {
|
|||
return;
|
||||
}
|
||||
TeamPlayer teamPlayer = optionalTeamPlayer.get();
|
||||
event.setRespawnLocation(teamPlayer.getTeam().getSpawnLocation());
|
||||
teamPlayer.getGameClass().apply(teamPlayer, worldBorderApi, gamePhase.get(), false);
|
||||
event.setRespawnLocation(player.getWorld().getSpawnLocation());
|
||||
Bukkit.getScheduler().runTaskLater(main, () -> teamPlayer.getGameClass().apply(teamPlayer, worldBorderApi, gamePhase.get(), true), 10 * 20);//10 x 20 ticks aka 10 seconds
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user