Fixed an issue with removing stargates during load

This commit is contained in:
Drakia 2011-03-14 19:26:04 -07:00
parent ec8c308651
commit 9473ca8f6f
4 changed files with 23 additions and 7 deletions

2
README
View File

@ -86,6 +86,8 @@ destroyexplosion - Whether to destroy a stargate with explosions, or stop an exp
=============
Changes
=============
[Version 0.28]
- Fixed an issue with removing stargates during load
[Version 0.27]
- Fixed portal count on load
[Version 0.26]

View File

@ -5,6 +5,7 @@ import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;
import java.util.logging.Level;
@ -298,6 +299,14 @@ public class Portal {
return destination;
}
public boolean isChunkLoaded() {
return topLeft.getWorld().isChunkLoaded(topLeft.getBlock().getChunk());
}
public void loadChunk() {
topLeft.getWorld().loadChunk(topLeft.getBlock().getChunk());
}
public boolean isVerified() {
for (RelativeBlockVector control : gate.getControls())
verified = verified || getBlockAt(control).getBlock().getTypeId() == gate.getControlBlock();
@ -454,7 +463,7 @@ public class Portal {
return frame;
}
public void unregister() {
public void unregister(boolean removeAll) {
Stargate.log.info("[Stargate] Unregistering gate " + getName());
close(true);
lookupNamesNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
@ -472,7 +481,9 @@ public class Portal {
lookupEntrances.remove(entrance);
}
allPortals.remove(this);
if (removeAll)
allPortals.remove(this);
allPortalsNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
if (id.getBlock().getType() == Material.WALL_SIGN) {
@ -776,13 +787,16 @@ public class Portal {
// Open any always-on gates. Do this here as it should be more efficient than in the loop.
int OpenCount = 0;
for (Portal portal : allPortals) {
//for (Portal portal : allPortals) {
for (Iterator<Portal> iter = allPortals.iterator(); iter.hasNext(); ) {
Portal portal = iter.next();
if (portal == null) continue;
// Verify portal integrity/register portal
if (!portal.wasVerified()) {
if (!portal.isVerified() || !portal.checkIntegrity()) {
portal.unregister();
portal.unregister(false);
iter.remove();
Stargate.log.info("[Stargate] Destroying stargate at " + portal.toString());
continue;
} else {

View File

@ -423,7 +423,7 @@ public class Stargate extends JavaPlugin {
if (hasPerm(player, "stargate.destroy", player.isOp()) || hasPerm(player, "stargate.destroy.all", player.isOp()) ||
( portal.getOwner().equalsIgnoreCase(player.getName()) && hasPerm(player, "stargate.destroy.owner", false) )) {
portal.unregister();
portal.unregister(true);
if (!dmgMsg.isEmpty()) {
player.sendMessage(ChatColor.RED + dmgMsg);
}
@ -471,7 +471,7 @@ public class Stargate extends JavaPlugin {
Portal portal = Portal.getByBlock(b);
if (portal == null) continue;
if (destroyExplosion) {
portal.unregister();
portal.unregister(true);
} else {
b.setType(b.getType());
event.setCancelled(true);

View File

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