Skip to content

Commit

Permalink
Fix #87 by always checking whether Essentials is null
Browse files Browse the repository at this point in the history
  • Loading branch information
skbeh committed Apr 9, 2023
1 parent e18edb5 commit 53963a4
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public class SpectateManagerImpl implements Loadable, SpectateManager {
private final Multimap<Arena, SpectatorImpl> arenas = HashMultimap.create();

private Teleport teleport;
private MyPetHook myPet;
private EssentialsHook essentials;
@Nullable private MyPetHook myPet;
@Nullable private EssentialsHook essentials;

public SpectateManagerImpl(final DuelsPlugin plugin) {
this.plugin = plugin;
Expand Down Expand Up @@ -139,15 +139,17 @@ public Result startSpectating(@NotNull final Player player, @NotNull final Playe
final MatchImpl match = arena.getMatch();

// Hide from players in match
if (match != null && !essentials.isVanished(player)) {
if (match != null) {
match.getAllPlayers()
.stream()
.filter(arenaPlayer -> arenaPlayer.isOnline() && arenaPlayer.canSee(player))
.forEach(arenaPlayer -> {
if (CompatUtil.hasHidePlayer()) {
arenaPlayer.hidePlayer(plugin, player);
} else {
arenaPlayer.hidePlayer(player);
if (essentials == null || !essentials.isVanished(player)) {
arenaPlayer.hidePlayer(player);
}
}
});
}
Expand Down Expand Up @@ -224,15 +226,17 @@ public void stopSpectating(final Player player, final SpectatorImpl spectator) {
final MatchImpl match = spectator.getArena().getMatch();

// Show to players in match
if (match != null && !essentials.isVanished(player)) {
if (match != null) {
match.getAllPlayers()
.stream()
.filter(Player::isOnline)
.forEach(arenaPlayer -> {
if (CompatUtil.hasHidePlayer()) {
arenaPlayer.showPlayer(plugin, player);
} else {
arenaPlayer.showPlayer(player);
if (essentials == null || !essentials.isVanished(player)) {
arenaPlayer.showPlayer(player);
}
}
});
}
Expand Down

0 comments on commit 53963a4

Please sign in to comment.