Skip to content

Commit

Permalink
Trigger warning when player leave event fires without join event bein…
Browse files Browse the repository at this point in the history
…g called

Join event sets up the phantom list for specific player(s).
  • Loading branch information
chuushi committed May 29, 2019
1 parent 25759fa commit eeeac81
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/com/simonorj/mc/phantomsmp/PhantomListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ public void onPlayerJoin(PlayerJoinEvent e) {
public void onPlayerLeave(PlayerQuitEvent e) {
Player p = e.getPlayer();

for (Phantom phantom : playerPhantomMap.get(p)) {
Set<Phantom> phantoms = playerPhantomMap.get(p);

if (phantoms == null) {
plugin.getLogger().warning("Phantom list for '" + p.getName() + "' was not initiated! Was there an error during login?");
return;
}

for (Phantom phantom : phantoms) {
if (phantom.getTarget() == p) {
phantom.setTarget(null);
phantomPlayerMap.remove(phantom);
Expand Down Expand Up @@ -173,7 +180,6 @@ public void onPhantomTargeting(EntityTargetLivingEntityEvent e) {
targeting((Phantom) e.getEntity(), (Player) e.getTarget(), e);
}

// Check phantom in loaded chunks
@EventHandler
public void onPhantomInLoadedChunk(ChunkLoadEvent e) {
if (e.getWorld().getEnvironment() != World.Environment.NORMAL)
Expand All @@ -184,7 +190,6 @@ public void onPhantomInLoadedChunk(ChunkLoadEvent e) {
targeting((Phantom) ent, null, null);
}

// Untrack phantoms in unloaded chunks
@EventHandler
public void onPhantomInUnloadedChunk(ChunkUnloadEvent e) {
if (e.getWorld().getEnvironment() != World.Environment.NORMAL)
Expand Down

0 comments on commit eeeac81

Please sign in to comment.