Merge pull request #460 from main--/2.9

Made the "throws" declaration of getWarps() more specific
This commit is contained in:
Iaccidentally 2013-04-30 08:30:41 -07:00
commit 42dc6a2e07
4 changed files with 27 additions and 5 deletions

View File

@ -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),

View File

@ -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)

View File

@ -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

View File

@ -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;
}
}