Skip to content

Commit 53963a4

Browse files
committed
Fix #87 by always checking whether Essentials is null
1 parent e18edb5 commit 53963a4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

duels-plugin/src/main/java/me/realized/duels/spectate/SpectateManagerImpl.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public class SpectateManagerImpl implements Loadable, SpectateManager {
6565
private final Multimap<Arena, SpectatorImpl> arenas = HashMultimap.create();
6666

6767
private Teleport teleport;
68-
private MyPetHook myPet;
69-
private EssentialsHook essentials;
68+
@Nullable private MyPetHook myPet;
69+
@Nullable private EssentialsHook essentials;
7070

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

141141
// Hide from players in match
142-
if (match != null && !essentials.isVanished(player)) {
142+
if (match != null) {
143143
match.getAllPlayers()
144144
.stream()
145145
.filter(arenaPlayer -> arenaPlayer.isOnline() && arenaPlayer.canSee(player))
146146
.forEach(arenaPlayer -> {
147147
if (CompatUtil.hasHidePlayer()) {
148148
arenaPlayer.hidePlayer(plugin, player);
149149
} else {
150-
arenaPlayer.hidePlayer(player);
150+
if (essentials == null || !essentials.isVanished(player)) {
151+
arenaPlayer.hidePlayer(player);
152+
}
151153
}
152154
});
153155
}
@@ -224,15 +226,17 @@ public void stopSpectating(final Player player, final SpectatorImpl spectator) {
224226
final MatchImpl match = spectator.getArena().getMatch();
225227

226228
// Show to players in match
227-
if (match != null && !essentials.isVanished(player)) {
229+
if (match != null) {
228230
match.getAllPlayers()
229231
.stream()
230232
.filter(Player::isOnline)
231233
.forEach(arenaPlayer -> {
232234
if (CompatUtil.hasHidePlayer()) {
233235
arenaPlayer.showPlayer(plugin, player);
234236
} else {
235-
arenaPlayer.showPlayer(player);
237+
if (essentials == null || !essentials.isVanished(player)) {
238+
arenaPlayer.showPlayer(player);
239+
}
236240
}
237241
});
238242
}

0 commit comments

Comments
 (0)