Fixed multi-world stargates causing an NPE

Code cleanup
Added a few more errors when a gate can't be loaded
Hopefully fixed path issue on some Linux installs
This commit is contained in:
Drakia 2011-03-10 13:26:14 -08:00
parent e851b395d2
commit 896dc04e7a
4 changed files with 15 additions and 3 deletions

6
README
View File

@ -82,6 +82,12 @@ gate-folder - The folder containing your .gate files
============= =============
Changes Changes
============= =============
[Version 0.22]
- Fixed multi-world stargates causing an NPE
[Version 0.21]
- Code cleanup
- Added a few more errors when a gate can't be loaded
- Hopefully fixed path issue on some Linux installs
[Version 0.20] [Version 0.20]
- Fixed the bug SIGN_CHANGE exception when using plugins such as Lockette - Fixed the bug SIGN_CHANGE exception when using plugins such as Lockette
[Version 0.19] [Version 0.19]

View File

@ -791,7 +791,7 @@ public class Portal {
} }
Stargate.log.info("[Stargate] {" + world.getName() + "} Loaded " + portalCount + " stargates with " + OpenCount + " set as always-on"); Stargate.log.info("[Stargate] {" + world.getName() + "} Loaded " + portalCount + " stargates with " + OpenCount + " set as always-on");
} catch (Exception e) { } catch (Exception e) {
Stargate.log.log(Level.SEVERE, "Exception while reading stargates from " + location + ": " + l); Stargate.log.log(Level.SEVERE, "Exception while reading stargates from " + db.getName() + ": " + l);
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {

View File

@ -449,13 +449,18 @@ public class Stargate extends JavaPlugin {
private class wListener extends WorldListener { private class wListener extends WorldListener {
@Override @Override
public void onWorldLoaded(WorldEvent event) { public void onWorldLoaded(WorldEvent event) {
Portal.loadAllGates(event.getWorld()); 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);
}
} }
} }
private class SGThread implements Runnable { private class SGThread implements Runnable {
public void run() { public void run() {
long time = System.currentTimeMillis() / 1000; long time = System.currentTimeMillis() / 1000;
// Close open portals
for (Iterator<Portal> iter = Stargate.openList.iterator(); iter.hasNext();) { for (Iterator<Portal> iter = Stargate.openList.iterator(); iter.hasNext();) {
Portal p = iter.next(); Portal p = iter.next();
if (time > p.getOpenTime() + Stargate.openLimit) { if (time > p.getOpenTime() + Stargate.openLimit) {
@ -463,6 +468,7 @@ public class Stargate extends JavaPlugin {
iter.remove(); iter.remove();
} }
} }
// Deactivate active portals
for (Iterator<Portal> iter = Stargate.activeList.iterator(); iter.hasNext();) { for (Iterator<Portal> iter = Stargate.activeList.iterator(); iter.hasNext();) {
Portal p = iter.next(); Portal p = iter.next();
if (time > p.getOpenTime() + Stargate.activeLimit) { if (time > p.getOpenTime() + Stargate.activeLimit) {

View File

@ -1,6 +1,6 @@
name: Stargate name: Stargate
main: net.TheDgtl.Stargate.Stargate main: net.TheDgtl.Stargate.Stargate
version: 0.20 version: 0.22
description: Stargate mod for Bukkit description: Stargate mod for Bukkit
author: Drakia author: Drakia
website: http://www.thedgtl.net website: http://www.thedgtl.net