mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-24 18:18:58 +01:00
testing new Bukkit events
This commit is contained in:
parent
367dba47fb
commit
21e985dc5d
Binary file not shown.
@ -1,12 +1,17 @@
|
|||||||
package net.citizensnpcs;
|
package net.citizensnpcs;
|
||||||
|
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
|
import net.citizensnpcs.api.npc.trait.trait.LocationTrait;
|
||||||
|
import net.citizensnpcs.listener.WorldListen;
|
||||||
import net.citizensnpcs.npc.CitizensNPCManager;
|
import net.citizensnpcs.npc.CitizensNPCManager;
|
||||||
import net.citizensnpcs.util.Messaging;
|
import net.citizensnpcs.util.Messaging;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class Citizens extends JavaPlugin {
|
public class Citizens extends JavaPlugin {
|
||||||
|
private CitizensNPCManager npcManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
@ -15,10 +20,33 @@ public class Citizens extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
CitizensAPI.setNPCManager(new CitizensNPCManager());
|
npcManager = new CitizensNPCManager();
|
||||||
|
CitizensAPI.setNPCManager(npcManager);
|
||||||
|
|
||||||
|
registerEvents();
|
||||||
|
|
||||||
// TODO wait to load until after all plugins using CitizensAPI are
|
|
||||||
// loaded
|
|
||||||
Messaging.log("v" + getDescription().getVersion() + " enabled.");
|
Messaging.log("v" + getDescription().getVersion() + " enabled.");
|
||||||
|
|
||||||
|
// Setup NPCs after all plugins have been enabled (allows for multiworld
|
||||||
|
// support and for NPCs to properly register external settings)
|
||||||
|
if (Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
setupNPCs();
|
||||||
|
}
|
||||||
|
}, 100) == -1)
|
||||||
|
Messaging.log("Issue enabling plugin. Disabling.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupNPCs() {
|
||||||
|
// TODO set up saving
|
||||||
|
for (NPC npc : npcManager.getNPCs()) {
|
||||||
|
npc.spawn(((LocationTrait) npc.getTrait("location")).getLocation());
|
||||||
|
}
|
||||||
|
Messaging.log("Loaded " + npcManager.getNPCs().size() + " NPCs.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerEvents() {
|
||||||
|
getServer().getPluginManager().registerEvents(new WorldListen(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
20
src/net/citizensnpcs/listener/WorldListen.java
Normal file
20
src/net/citizensnpcs/listener/WorldListen.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package net.citizensnpcs.listener;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
|
||||||
|
public class WorldListen implements Listener {
|
||||||
|
|
||||||
|
@EventHandler(event = ChunkLoadEvent.class, priority = EventPriority.NORMAL)
|
||||||
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(event = ChunkLoadEvent.class, priority = EventPriority.NORMAL)
|
||||||
|
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user