summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIaccidentally <coryhuckaby@gmail.com>2013-04-30 08:30:41 -0700
committerIaccidentally <coryhuckaby@gmail.com>2013-04-30 08:30:41 -0700
commit42dc6a2e0756d34a4e4812662cf084a3259cbc56 (patch)
treefb6f3ece299fb260d26c20865de4892241bbe901
parent9ba922363239e3a2580a0f68decd57d0f790fdd9 (diff)
parent538a2425c53e08d884bfbc74513b98048c25bcab (diff)
downloadEssentials-42dc6a2e0756d34a4e4812662cf084a3259cbc56.tar
Essentials-42dc6a2e0756d34a4e4812662cf084a3259cbc56.tar.gz
Essentials-42dc6a2e0756d34a4e4812662cf084a3259cbc56.tar.lz
Essentials-42dc6a2e0756d34a4e4812662cf084a3259cbc56.tar.xz
Essentials-42dc6a2e0756d34a4e4812662cf084a3259cbc56.zip
Merge pull request #460 from main--/2.9
Made the "throws" declaration of getWarps() more specific
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsConf.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/Warps.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/api/IWarps.java7
-rw-r--r--Essentials/src/com/earth2me/essentials/api/InvalidWorldException.java16
4 files changed, 27 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java
index 26f9d1c9d..e454db75a 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java
@@ -1,6 +1,8 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
+
+import com.earth2me.essentials.api.InvalidWorldException;
import com.google.common.io.Files;
import java.io.*;
import java.nio.ByteBuffer;
@@ -379,7 +381,7 @@ public class EssentialsConf extends YamlConfiguration
return isSet(path);
}
- public Location getLocation(final String path, final Server server) throws Exception
+ public Location getLocation(final String path, final Server server) throws InvalidWorldException
{
final String worldName = getString((path == null ? "" : path + ".") + "world");
if (worldName == null || worldName.isEmpty())
@@ -389,7 +391,7 @@ public class EssentialsConf extends YamlConfiguration
final World world = server.getWorld(worldName);
if (world == null)
{
- throw new Exception(_("invalidWorld"));
+ throw new InvalidWorldException(worldName);
}
return new Location(world,
getDouble((path == null ? "" : path + ".") + "x", 0),
diff --git a/Essentials/src/com/earth2me/essentials/Warps.java b/Essentials/src/com/earth2me/essentials/Warps.java
index 39f31369c..c5cfb12df 100644
--- a/Essentials/src/com/earth2me/essentials/Warps.java
+++ b/Essentials/src/com/earth2me/essentials/Warps.java
@@ -3,6 +3,7 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IWarps;
import com.earth2me.essentials.api.InvalidNameException;
+import com.earth2me.essentials.api.InvalidWorldException;
import com.earth2me.essentials.commands.WarpNotFoundException;
import java.io.File;
import java.io.IOException;
@@ -49,7 +50,7 @@ public class Warps implements IConf, IWarps
}
@Override
- public Location getWarp(String warp) throws Exception
+ public Location getWarp(String warp) throws WarpNotFoundException, InvalidWorldException
{
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
if (conf == null)
diff --git a/Essentials/src/com/earth2me/essentials/api/IWarps.java b/Essentials/src/com/earth2me/essentials/api/IWarps.java
index 8bab07397..1866083a5 100644
--- a/Essentials/src/com/earth2me/essentials/api/IWarps.java
+++ b/Essentials/src/com/earth2me/essentials/api/IWarps.java
@@ -2,6 +2,8 @@ package com.earth2me.essentials.api;
import java.io.File;
import java.util.Collection;
+
+import com.earth2me.essentials.commands.WarpNotFoundException;
import org.bukkit.Location;
@@ -12,9 +14,10 @@ public interface IWarps
*
* @param warp - Warp name
* @return - Location the warp is set to
- * @throws Exception
+ * @throws WarpNotFoundException When the warp is not found
+ * @throws InvalidWorldException When the world the warp is in is not found
*/
- Location getWarp(String warp) throws Exception;
+ Location getWarp(String warp) throws WarpNotFoundException, InvalidWorldException;
/**
* Gets a list of warps
diff --git a/Essentials/src/com/earth2me/essentials/api/InvalidWorldException.java b/Essentials/src/com/earth2me/essentials/api/InvalidWorldException.java
new file mode 100644
index 000000000..dba6f4be6
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/api/InvalidWorldException.java
@@ -0,0 +1,16 @@
+package com.earth2me.essentials.api;
+
+import static com.earth2me.essentials.I18n._;
+
+public class InvalidWorldException extends Exception {
+ private final String world;
+
+ public InvalidWorldException(final String world) {
+ super(_("invalidWorld"));
+ this.world = world;
+ }
+
+ public String getWorld() {
+ return this.world;
+ }
+}