Skip to content

Commit

Permalink
[Fix] NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
iceBear67 committed Nov 21, 2020
1 parent c5641a5 commit e8325ef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/io/ib67/manhunt/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public void stop(GameResult result) {
ManHunt.getInstance().getLanguage().GAMING.HUNTER.WON :
ManHunt.getInstance().getLanguage().GAMING.RUNNER.WON;
inGamePlayers.stream().map(GamePlayer::getPlayer).forEach(p -> {
if (p == null) return;
p.setGameMode(GameMode.SPECTATOR);
p.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
p.sendTitle(title, "", 20, 2 * 20, 20);
Expand Down Expand Up @@ -187,7 +188,11 @@ public void kickPlayer(String player) {


public Optional<GamePlayer> isInGame(Player player) {
return inGamePlayers.stream().filter(s -> s.getPlayer().getName().equals(player.getName())).findFirst();
return inGamePlayers.stream().filter(s -> {
Player playe = s.getPlayer();
if (playe == null) return false;
return playe.getName().equals(player.getName());
}).findFirst();
}

public List<GamePlayer> getInGamePlayers() {
Expand Down

0 comments on commit e8325ef

Please sign in to comment.