Skip to content

Commit

Permalink
basic death listener to remove players from plugin battle players list
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Mills committed May 20, 2016
1 parent d970137 commit 1787577
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.github.gmills82.battleroyale.listeners;

import io.github.gmills82.battleroyale.BattleRoyalePlugin;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;

import java.util.List;

/**
* @author Grant Mills
* @since 5/20/16
*/
public class BRPlayerDeathListener implements Listener {

private final BattleRoyalePlugin plugin;

public BRPlayerDeathListener(BattleRoyalePlugin plugin) {
this.plugin = plugin;
}

@EventHandler
public void onDeath(PlayerDeathEvent event) {
Player playerLoggingOn = event.getEntity();

for(Player player : this.plugin.getCurrentBattlePlayers()) {
if(player.getName().equalsIgnoreCase(playerLoggingOn.getName())) {

//Remove player and reset list
List<Player> newPlayerList = this.plugin.getCurrentBattlePlayers();
newPlayerList.remove(player);
this.plugin.setCurrentBattlePlayers(newPlayerList);
}
}
}
}

0 comments on commit 1787577

Please sign in to comment.