-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic death listener to remove players from plugin battle players list
- Loading branch information
Grant Mills
committed
May 20, 2016
1 parent
d970137
commit 1787577
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/java/io/github/gmills82/battleroyale/listeners/BRPlayerDeathListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |