diff --git a/lib/CitizensAPI.jar b/lib/CitizensAPI.jar index 154cf5606..23b214b01 100644 Binary files a/lib/CitizensAPI.jar and b/lib/CitizensAPI.jar differ diff --git a/src/net/citizensnpcs/Citizens.java b/src/net/citizensnpcs/Citizens.java index 9cc725565..4b479fe17 100644 --- a/src/net/citizensnpcs/Citizens.java +++ b/src/net/citizensnpcs/Citizens.java @@ -12,6 +12,7 @@ import java.util.logging.Level; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.DataKey; +import net.citizensnpcs.api.exception.NPCException; import net.citizensnpcs.api.exception.NPCLoadException; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.trait.Character; @@ -205,13 +206,15 @@ public class Citizens extends JavaPlugin { if (!key.keyExists("name")) throw new NPCLoadException("Could not find a name for the NPC with ID '" + id + "'."); - // TODO better trait exception handling String type = key.getString("traits.type"); NPC npc = npcManager.createNPC( type.equalsIgnoreCase("DEFAULT") ? CreatureType.MONSTER : CreatureType.valueOf(key.getString( "traits.type").toUpperCase()), id, key.getString("name"), null); - - npc.load(key); + try { + npc.load(key); + } catch (NPCException ex) { + Messaging.log(ex.getMessage()); + } ++created; if (npc.isSpawned()) ++spawned; diff --git a/src/net/citizensnpcs/trait/LookClose.java b/src/net/citizensnpcs/trait/LookClose.java index 2e4158c2c..b935ba79f 100644 --- a/src/net/citizensnpcs/trait/LookClose.java +++ b/src/net/citizensnpcs/trait/LookClose.java @@ -1,8 +1,11 @@ package net.citizensnpcs.trait; import net.citizensnpcs.api.DataKey; +import net.citizensnpcs.api.exception.NPCLoadException; +import net.citizensnpcs.api.npc.trait.SaveId; import net.citizensnpcs.api.npc.trait.Trait; +@SaveId("look-close") public class LookClose implements Trait { private boolean shouldLookClose; @@ -14,13 +17,12 @@ public class LookClose implements Trait { } @Override - public String getName() { - return "look-close"; - } - - @Override - public void load(DataKey key) { - shouldLookClose = key.getBoolean(""); + public void load(DataKey key) throws NPCLoadException { + try { + shouldLookClose = key.getBoolean(""); + } catch (Exception ex) { + throw new NPCLoadException("Invalid value. Valid values: true or false"); + } } @Override