From df75afef085aa19141c88b7c8e9acc708d6a0bc2 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Fri, 4 Mar 2011 10:42:41 -0600 Subject: [PATCH] handle a few random errors that popped up in my server log --- src/com/bukkit/mcteam/factions/Commands.java | 7 ++++++- .../mcteam/factions/listeners/FactionsBlockListener.java | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/bukkit/mcteam/factions/Commands.java b/src/com/bukkit/mcteam/factions/Commands.java index 227ecb53..3df5a75d 100644 --- a/src/com/bukkit/mcteam/factions/Commands.java +++ b/src/com/bukkit/mcteam/factions/Commands.java @@ -170,7 +170,12 @@ public class Commands { if (Conf.aliasHelp.contains(command)) { int page = 1; if (tokens.size() > 0) { - page = Integer.parseInt(tokens.get(0)); + try { + page = Integer.parseInt(tokens.get(0)); + } + catch (NumberFormatException e) { + // wasn't an integer + } } help(me, page); } else if (Conf.aliasLeave.contains(command)) { diff --git a/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java b/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java index f0175df9..1396f803 100644 --- a/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java +++ b/src/com/bukkit/mcteam/factions/listeners/FactionsBlockListener.java @@ -43,7 +43,7 @@ public class FactionsBlockListener extends BlockListener { Coord coord = Coord.parseCoord(block); Faction otherFaction = Board.get(player.getWorld()).getFactionAt(coord); - if (otherFaction.id == 0) { + if (otherFaction == null || otherFaction.id == 0) { return true; // This is no faction territory. You may build or break stuff here. } @@ -92,7 +92,7 @@ public class FactionsBlockListener extends BlockListener { Coord blockCoord = Coord.from(block.getLocation()); Faction otherFaction = Board.get(player.getWorld()).getFactionAt(blockCoord); - if (otherFaction.id != 0 && myFaction != otherFaction) { + if (otherFaction != null && otherFaction.id != 0 && myFaction != otherFaction) { me.sendMessage(Conf.colorSystem+"You can't use "+TextUtil.getMaterialName(material)+" in the territory of "+otherFaction.getTag(myFaction)); //otherFaction.sendMessage(me.getNameAndRelevant(otherFaction)+Conf.colorSystem+" tried to use "+TextUtil.getMaterialName(material)+" in your territory"); return false;