I've a problem with the onWorldLoaded hook. It seems never to be called: Code: PluginManager pm = getServer().getPluginManager(); pm.registerEvent(Event.Type.WORLD_LOADED, new AnyRegWorldListener(), Event.Priority.Monitor, this); Code: private class AnyRegWorldListener extends WorldListener { public void onWorldLoaded(WorldEvent event) { log.info("[AnyReg] World listener heard something"); } } Other hooks work fine.
You are correct. It is never called anywhere in the code (at least in the version I have). It must not be implemented yet. (There are a fair few hooks that aren't implemented yet).
Hm, I don't see a todo note in the bukkit sourcode or the javadocs. Then getServer().getWorlds will have to work, until the hook is ready.
The hook works fine for me, I however implemented it as such: Code: private final wListener worldListener = new wListener(); pm.registerEvent(Event.Type.WORLD_LOADED, worldListener, Priority.Normal, this); Code: private class wListener extends WorldListener { @Override public void onWorldLoaded(WorldEvent event) { World w = event.getWorld(); // We have to make sure the world is actually loaded. This gets called twice for some reason. if (w.getBlockAt(w.getSpawnLocation()).getWorld() != null) { Portal.loadAllGates(w); } } } The event is called in https://github.com/Bukkit/CraftBukk.../java/org/bukkit/craftbukkit/CraftServer.java on line 335
Uh, tried the same and got nothing. Is the hook fired when loading a world (at server start, when the first player connects) or when creating a new one?
The main world is loaded before any plugins are loaded, so it doesn't fire the event. The event is only fired when a plugin such as MultiVerse creates a world. If you want to make sure to catch all past and future worlds, on plugin startup loop through getWorlds(), then have a hook for onWorldLoaded() that does stuff for any world loaded after that point (Via plugin)
Ah, thanks. That makes sense. But the "Loaded world: world" message when the first player joins is pretty useless then, or?
That is one of your plugins causing that, the core Bukkit server doesn't say anything about a world being loaded for me on first connect. This is the output on my server when I first start up and connect: http://pastebin.com/fQt8CmMj