use of pl.themolka.arcade.game.PlayerApplicable in project Arcade2 by ShootGame.
the class TeamApplyListeners method playerRespawn.
// This is a special listener where we manually set player's
// respawn location by looping all apply contents.
@Handler(priority = Priority.LOWEST)
public void playerRespawn(PlayerRespawnEvent event) {
GamePlayer player = event.getGamePlayer();
Team team = this.game.getTeam(player);
if (this.shouldApplyTo(team)) {
player.getPlayer().clearInventory(true);
Location spawn = this.fetchSpawn(team, MatchApplyContext.EventType.PLAYER_RESPAWN, player);
if (spawn != null) {
event.setRespawnPosition(spawn);
}
// The player must be spawned to be able to be meta attachable.
this.game.getServer().getScheduler().runTaskLater(this.game.getPlugin(), new Runnable() {
@Override
public void run() {
if (!player.isOnline()) {
return;
}
for (PlayerApplicable content : team.getApplyContext().getAllContent(MatchApplyContext.EventType.PLAYER_RESPAWN)) {
if (!(content instanceof SpawnApply)) {
content.apply(player);
}
}
}
}, Time.ZERO.toTicks());
}
}
Aggregations