From c5490270dea69ee3e6e6acb94b63873f820ceae1 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Wed, 16 May 2012 22:58:34 +0200 Subject: [PATCH] changed setId method of gate class --- src/org/mcteam/ancientgates/Gate.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/org/mcteam/ancientgates/Gate.java b/src/org/mcteam/ancientgates/Gate.java index 7906457..d3904b6 100644 --- a/src/org/mcteam/ancientgates/Gate.java +++ b/src/org/mcteam/ancientgates/Gate.java @@ -46,13 +46,17 @@ public class Gate extends BaseGate implements ConfigurationSerializable } - public void setId(String id) throws Exception + /** + * @return true if the id has been changed; false otherwise + */ + public boolean setId(String id) { - if (instances.get(id) != null) { - throw new Exception("Cannot set new ID: this ID is already in use"); + if (!exists(id)) { + this.id = id; + return true; } - this.id = id; + return false; } @@ -112,7 +116,7 @@ public class Gate extends BaseGate implements ConfigurationSerializable /* - * PERSISTANCE and ENTITY MANAGEMENT + * ENTITY MANAGEMENT */ public static Gate get(String id)