mirror of
https://github.com/chuushi/PhantomSMP.git
synced 2025-02-16 11:21:20 +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>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.13.1-R0.1-SNAPSHOT</version>
|
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerBedEnterEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
|
||||||
import java.util.*;
|
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)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
playerPhantomMap.put(e.getPlayer(), new LinkedHashSet<>());
|
playerPhantomMap.put(e.getPlayer(), new LinkedHashSet<>());
|
||||||
@ -176,17 +184,22 @@ public class PhantomListener implements Listener {
|
|||||||
targeting((Phantom) ent, null, null);
|
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
|
@EventHandler
|
||||||
public void onPhantomDeath(EntityDeathEvent e) {
|
public void onPhantomDeath(EntityDeathEvent e) {
|
||||||
if (!(e.getEntity() instanceof Phantom))
|
if (!(e.getEntity() instanceof Phantom))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Phantom phantom = (Phantom) e.getEntity();
|
removePhantom((Phantom) e.getEntity());
|
||||||
|
|
||||||
Player p = phantomPlayerMap.remove(phantom);
|
|
||||||
if (p == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
playerPhantomMap.get(p).remove(phantom);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user