mirror of
https://github.com/chuushi/PhantomSMP.git
synced 2024-11-22 01:56:09 +01:00
Add Chunk Unload Event + Update bukkit api and bStats version
This commit is contained in:
parent
819b4f1e31
commit
b58b48bf04
2
.idea/PhantomSMP.iml
Normal file
2
.idea/PhantomSMP.iml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
13
.idea/compiler.xml
Normal file
13
.idea/compiler.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="PhantomSMP" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
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>
|
||||
|
@ -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
Block a user