Added debug option

Fixed gates will now show in the list of gates they link to.
Line endings in SignPost
This commit is contained in:
Drakia 2011-05-06 17:00:21 -07:00
parent 4c6c829348
commit 858a40e0cf
5 changed files with 172 additions and 134 deletions

4
README
View File

@ -122,10 +122,14 @@ not-enough-money-message - The message displayed if a player lacks money to do s
networkfilter - Whether or not to disallow users access to a network if they don't have the 'stargate.network.{networkname}' permission.
worldfilter - Whether or not to disallow users access to a network if they don't have the 'stargate.world.{worldname}' permission.
toowner - Whether the money from gate-use goes to the owner or nobody
debug - Whether to show massive debug output for gate creation
=============
Changes
=============
[Version 0.4.7]
- Added debug option
- Fixed gates will now show in the list of gates they link to.
[Version 0.4.6]
- Fixed a bug in iConomy handling.
[Version 0.4.5]

View File

@ -355,8 +355,8 @@ public class Portal {
if (Stargate.worldFilter && !Stargate.hasPerm(player, "stargate.world." + portal.getWorld().getName(), player.isOp())) continue;
// Check if dest is this portal
if (dest.equalsIgnoreCase(getName())) continue;
// Check if dest is a fixed gate
if (portal.isFixed()) continue;
// Check if dest is a fixed gate not pointing to this gate
if (portal.isFixed() && !portal.getDestinationName().equalsIgnoreCase(getName())) continue;
// Visible to this player.
if (!portal.isHidden() || Stargate.hasPerm(player, "stargate.hidden", player.isOp()) || portal.getOwner().equals(player.getName())) {
destinations.add(portal.getName());
@ -556,9 +556,15 @@ public class Portal {
public static Portal createPortal(SignPost id, Player player) {
Block idParent = id.getParent();
if (idParent == null) return null;
if (idParent == null) {
Stargate.debug("createPortal", "idParent == null");
return null;
}
if (Gate.getGatesByControlBlock(idParent).length == 0) return null;
if (Portal.getByBlock(idParent) != null) return null;
if (Portal.getByBlock(idParent) != null) {
Stargate.debug("createPortal", "idParent belongs to existing gate");
return null;
}
Blox parent = new Blox(player.getWorld(), idParent.getX(), idParent.getY(), idParent.getZ());
Blox topleft = null;
@ -582,11 +588,15 @@ public class Portal {
alwaysOn = false;
}
// Debug
Stargate.debug("createPortal", "h = " + hidden + " a = " + alwaysOn + " p = " + priv + " f = " + free);
if ((network.length() < 1) || (network.length() > 11)) {
network = Stargate.getDefaultNetwork();
}
if ((name.length() < 1) || (name.length() > 11) || (getByName(name, network) != null)) {
Stargate.debug("createPortal", "Name Error");
return null;
}
@ -668,13 +678,17 @@ public class Portal {
}
if ((gate == null) || (buttonVector == null)) {
Stargate.debug("createPortal", "Could not find matching gate layout");
return null;
}
// Bleh, gotta check to make sure none of this gate belongs to another gate. Boo slow.
for (RelativeBlockVector v : gate.getBorder()) {
Blox b = topleft.modRelative(v.getRight(), v.getDepth(), v.getDistance(), modX, 1, modZ);
if (Portal.getByBlock(b.getBlock()) != null) return null;
if (Portal.getByBlock(b.getBlock()) != null) {
Stargate.debug("createPortal", "Gate conflicts with existing gate");
return null;
}
}
if (iConomyHandler.useiConomy() && !Stargate.hasPerm(player, "stargate.free.create", player.isOp())) {

View File

@ -94,11 +94,11 @@ public class SignPost {
offsetY = -1;
}
if (sign == null) {
Stargate.log.info("Sign is null");
Stargate.debug("findParent", "sign == null");
return;
}
if (world == null) {
Stargate.log.info("World is null");
Stargate.debug("findParent", "world == null");
return;
}
parent = new Blox(world, sign.getX() + offsetX, sign.getY() + offsetY, sign.getZ() + offsetZ);

View File

@ -3,6 +3,7 @@ package net.TheDgtl.Stargate;
import java.io.File;
import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
@ -85,6 +86,9 @@ public class Stargate extends JavaPlugin {
private static int activeLimit = 10;
private static int openLimit = 10;
// Used for debug
private static boolean debug = false;
public static ConcurrentLinkedQueue<Portal> openList = new ConcurrentLinkedQueue<Portal>();
public static ConcurrentLinkedQueue<Portal> activeList = new ConcurrentLinkedQueue<Portal>();
@ -116,6 +120,7 @@ public class Stargate extends JavaPlugin {
// Check to see if iConomy/Permissions is loaded yet.
permissions = (Permissions)checkPlugin("Permissions");
if (iConomyHandler.useiConomy)
iConomyHandler.iconomy = (iConomy)checkPlugin("iConomy");
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
@ -150,6 +155,8 @@ public class Stargate extends JavaPlugin {
destroyExplosion = config.getBoolean("destroyexplosion", destroyExplosion);
networkFilter = config.getBoolean("networkfilter", networkFilter);
worldFilter = config.getBoolean("worldfilter", worldFilter);
// Debug
debug = config.getBoolean("debug", debug);
// iConomy
iConomyHandler.useiConomy = config.getBoolean("useiconomy", iConomyHandler.useiConomy);
iConomyHandler.createCost = config.getInt("createcost", iConomyHandler.createCost);
@ -226,6 +233,14 @@ public class Stargate extends JavaPlugin {
}
}
public static void debug(String rout, String msg) {
if (Stargate.debug) {
log.info("[Stargate::" + rout + "] " + msg);
} else {
log.log(Level.FINEST, "[Stargate::" + rout + "] " + msg);
}
}
public static String getSaveLocation() {
return portalFolder;
}
@ -470,7 +485,10 @@ public class Stargate extends JavaPlugin {
sign.setText(2, event.getLine(2));
sign.setText(3, event.getLine(3));
Portal portal = Portal.createPortal(sign, player);
if (portal == null) return;
if (portal == null) {
Stargate.debug("SignChange", "createPortal returned null");
return;
}
if (!regMsg.isEmpty()) {
player.sendMessage(ChatColor.GREEN + regMsg);
@ -482,6 +500,8 @@ public class Stargate extends JavaPlugin {
event.setLine(1, sign.getText(1));
event.setLine(2, sign.getText(2));
event.setLine(3, sign.getText(3));
} else {
Stargate.debug("SignChange", player.getName() + " tried to create gate without permissions");
}
}
@ -576,7 +596,7 @@ public class Stargate extends JavaPlugin {
private class sListener extends ServerListener {
@Override
public void onPluginEnable(PluginEnableEvent event) {
if (iConomyHandler.iconomy == null) {
if (iConomyHandler.useiConomy && iConomyHandler.iconomy == null) {
if (event.getPlugin().getDescription().getName().equalsIgnoreCase("iConomy")) {
iConomyHandler.iconomy = (iConomy)checkPlugin(event.getPlugin());
}
@ -590,7 +610,7 @@ public class Stargate extends JavaPlugin {
@Override
public void onPluginDisable(PluginDisableEvent event) {
if (event.getPlugin() == iConomyHandler.iconomy) {
if (iConomyHandler.useiConomy && event.getPlugin() == iConomyHandler.iconomy) {
log.info("[Stargate] iConomy plugin lost.");
iConomyHandler.iconomy = null;
}

View File

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