Fixed an issue with removing stargates during load
This commit is contained in:
parent
ec8c308651
commit
9473ca8f6f
2
README
2
README
@ -86,6 +86,8 @@ destroyexplosion - Whether to destroy a stargate with explosions, or stop an exp
|
|||||||
=============
|
=============
|
||||||
Changes
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.28]
|
||||||
|
- Fixed an issue with removing stargates during load
|
||||||
[Version 0.27]
|
[Version 0.27]
|
||||||
- Fixed portal count on load
|
- Fixed portal count on load
|
||||||
[Version 0.26]
|
[Version 0.26]
|
||||||
|
@ -5,6 +5,7 @@ import java.io.File;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -298,6 +299,14 @@ public class Portal {
|
|||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isChunkLoaded() {
|
||||||
|
return topLeft.getWorld().isChunkLoaded(topLeft.getBlock().getChunk());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadChunk() {
|
||||||
|
topLeft.getWorld().loadChunk(topLeft.getBlock().getChunk());
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isVerified() {
|
public boolean isVerified() {
|
||||||
for (RelativeBlockVector control : gate.getControls())
|
for (RelativeBlockVector control : gate.getControls())
|
||||||
verified = verified || getBlockAt(control).getBlock().getTypeId() == gate.getControlBlock();
|
verified = verified || getBlockAt(control).getBlock().getTypeId() == gate.getControlBlock();
|
||||||
@ -454,7 +463,7 @@ public class Portal {
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregister() {
|
public void unregister(boolean removeAll) {
|
||||||
Stargate.log.info("[Stargate] Unregistering gate " + getName());
|
Stargate.log.info("[Stargate] Unregistering gate " + getName());
|
||||||
close(true);
|
close(true);
|
||||||
lookupNamesNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
|
lookupNamesNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
|
||||||
@ -472,7 +481,9 @@ public class Portal {
|
|||||||
lookupEntrances.remove(entrance);
|
lookupEntrances.remove(entrance);
|
||||||
}
|
}
|
||||||
|
|
||||||
allPortals.remove(this);
|
if (removeAll)
|
||||||
|
allPortals.remove(this);
|
||||||
|
|
||||||
allPortalsNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
|
allPortalsNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());
|
||||||
|
|
||||||
if (id.getBlock().getType() == Material.WALL_SIGN) {
|
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.
|
// Open any always-on gates. Do this here as it should be more efficient than in the loop.
|
||||||
int OpenCount = 0;
|
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;
|
if (portal == null) continue;
|
||||||
|
|
||||||
// Verify portal integrity/register portal
|
// Verify portal integrity/register portal
|
||||||
if (!portal.wasVerified()) {
|
if (!portal.wasVerified()) {
|
||||||
if (!portal.isVerified() || !portal.checkIntegrity()) {
|
if (!portal.isVerified() || !portal.checkIntegrity()) {
|
||||||
portal.unregister();
|
portal.unregister(false);
|
||||||
|
iter.remove();
|
||||||
Stargate.log.info("[Stargate] Destroying stargate at " + portal.toString());
|
Stargate.log.info("[Stargate] Destroying stargate at " + portal.toString());
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -423,7 +423,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
|
|
||||||
if (hasPerm(player, "stargate.destroy", player.isOp()) || hasPerm(player, "stargate.destroy.all", player.isOp()) ||
|
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.getOwner().equalsIgnoreCase(player.getName()) && hasPerm(player, "stargate.destroy.owner", false) )) {
|
||||||
portal.unregister();
|
portal.unregister(true);
|
||||||
if (!dmgMsg.isEmpty()) {
|
if (!dmgMsg.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.RED + dmgMsg);
|
player.sendMessage(ChatColor.RED + dmgMsg);
|
||||||
}
|
}
|
||||||
@ -471,7 +471,7 @@ public class Stargate extends JavaPlugin {
|
|||||||
Portal portal = Portal.getByBlock(b);
|
Portal portal = Portal.getByBlock(b);
|
||||||
if (portal == null) continue;
|
if (portal == null) continue;
|
||||||
if (destroyExplosion) {
|
if (destroyExplosion) {
|
||||||
portal.unregister();
|
portal.unregister(true);
|
||||||
} else {
|
} else {
|
||||||
b.setType(b.getType());
|
b.setType(b.getType());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Stargate
|
name: Stargate
|
||||||
main: net.TheDgtl.Stargate.Stargate
|
main: net.TheDgtl.Stargate.Stargate
|
||||||
version: 0.27
|
version: 0.28
|
||||||
description: Stargate mod for Bukkit
|
description: Stargate mod for Bukkit
|
||||||
author: Drakia
|
author: Drakia
|
||||||
website: http://www.thedgtl.net
|
website: http://www.thedgtl.net
|
Loading…
Reference in New Issue
Block a user