mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 04:35:50 +01:00
Inline eventlistenchunk
This commit is contained in:
parent
147a07f413
commit
deb9976a9b
@ -52,6 +52,8 @@ import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.world.ChunkEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.EntitiesLoadEvent;
|
||||
import org.bukkit.event.world.EntitiesUnloadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
@ -109,7 +111,7 @@ import net.citizensnpcs.util.PlayerAnimation;
|
||||
import net.citizensnpcs.util.Util;
|
||||
|
||||
public class EventListen implements Listener {
|
||||
private EventListenChunk chunkEventListener;
|
||||
private Listener chunkEventListener;
|
||||
private final Map<String, NPCRegistry> registries;
|
||||
private final SkinUpdateTracker skinUpdateTracker;
|
||||
private final ListMultimap<ChunkCoord, NPC> toRespawn = ArrayListMultimap.create(64, 4);
|
||||
@ -118,11 +120,21 @@ public class EventListen implements Listener {
|
||||
this.registries = registries;
|
||||
this.skinUpdateTracker = new SkinUpdateTracker(registries);
|
||||
try {
|
||||
this.chunkEventListener = new EventListenChunk(this);
|
||||
Bukkit.getPluginManager().registerEvents(chunkEventListener, CitizensAPI.getPlugin());
|
||||
} catch (Throwable ex) {
|
||||
this.chunkEventListener = null;
|
||||
Class.forName("org.bukkit.event.world.EntitiesLoadEvent");
|
||||
Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntitiesLoad(EntitiesLoadEvent event) {
|
||||
loadNPCs(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntitiesUnload(EntitiesUnloadEvent event) {
|
||||
unloadNPCs(event, event.getEntities());
|
||||
}
|
||||
}, CitizensAPI.getPlugin());
|
||||
} catch (Throwable ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
Class.forName("org.bukkit.event.entity.EntityTransformEvent");
|
||||
Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
|
@ -1,25 +0,0 @@
|
||||
package net.citizensnpcs;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.EntitiesLoadEvent;
|
||||
import org.bukkit.event.world.EntitiesUnloadEvent;
|
||||
|
||||
public class EventListenChunk implements Listener {
|
||||
EventListen listen;
|
||||
|
||||
EventListenChunk(EventListen listen) {
|
||||
this.listen = listen;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntitiesLoad(EntitiesLoadEvent event) {
|
||||
listen.loadNPCs(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntitiesUnload(EntitiesUnloadEvent event) {
|
||||
listen.unloadNPCs(event, event.getEntities());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user