Merge branch 'master' into v1.1.1-snapshot
This commit is contained in:
commit
25759faa3f
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
4
pom.xml
4
pom.xml
|
@ -28,13 +28,13 @@
|
|||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.13.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# ![Logo](https://www.spigotmc.org/data/resource_icons/59/59721.jpg) PhantomSMP
|
||||
[![Build Status](https://travis-ci.org/SimonOrJ/PhantomSMP.svg?branch=master)](https://travis-ci.org/SimonOrJ/PhantomSMP) [![Maintainability](https://api.codeclimate.com/v1/badges/ec57a5bdcfdb28f9d5cb/maintainability)](https://codeclimate.com/github/SimonOrJ/PhantomSMP/maintainability)
|
||||
|
||||
*Better Phantom handling for SMP*
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerBedEnterEvent;
|
|||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -115,6 +116,13 @@ public class PhantomListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
private void removePhantom(Phantom phantom) {
|
||||
Player p = phantomPlayerMap.remove(phantom);
|
||||
if (p == null)
|
||||
return;
|
||||
playerPhantomMap.get(p).remove(phantom);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
playerPhantomMap.put(e.getPlayer(), new LinkedHashSet<>());
|
||||
|
@ -176,17 +184,22 @@ public class PhantomListener implements Listener {
|
|||
targeting((Phantom) ent, null, null);
|
||||
}
|
||||
|
||||
// Untrack phantoms in unloaded chunks
|
||||
@EventHandler
|
||||
public void onPhantomInUnloadedChunk(ChunkUnloadEvent e) {
|
||||
if (e.getWorld().getEnvironment() != World.Environment.NORMAL)
|
||||
return;
|
||||
|
||||
for (Entity ent : e.getChunk().getEntities())
|
||||
if (ent instanceof Phantom)
|
||||
removePhantom((Phantom) ent);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPhantomDeath(EntityDeathEvent e) {
|
||||
if (!(e.getEntity() instanceof Phantom))
|
||||
return;
|
||||
|
||||
Phantom phantom = (Phantom) e.getEntity();
|
||||
|
||||
Player p = phantomPlayerMap.remove(phantom);
|
||||
if (p == null)
|
||||
return;
|
||||
|
||||
playerPhantomMap.get(p).remove(phantom);
|
||||
removePhantom((Phantom) e.getEntity());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue