Fixing setwarp command.

This commit is contained in:
KHobbits 2012-03-15 02:12:43 +00:00
parent b85756f8b1
commit 5d79863cfc
3 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials; package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.WarpNotFoundException;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
@ -48,7 +49,7 @@ public class Warps implements IConf
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp)); EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
if (conf == null) if (conf == null)
{ {
throw new Exception(_("warpNotExist")); throw new WarpNotFoundException();
} }
return conf.getLocation(null, server); return conf.getLocation(null, server);
} }

View File

@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.Warps; import com.earth2me.essentials.Warps;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
@ -34,11 +35,11 @@ public class Commandsetwarp extends EssentialsCommand
{ {
warpLoc = warps.getWarp(args[0]); warpLoc = warps.getWarp(args[0]);
} }
catch (WarpNotFoundException ex) catch (Exception ex)
{ {
} }
if (warpLoc == null || user.hasPermission("essentials.warp.overwrite." + args[0])) if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.sanitizeFileName(args[0])))
{ {
warps.setWarp(args[0], loc); warps.setWarp(args[0], loc);
} }

View File

@ -1,11 +1,12 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
public class WarpNotFoundException extends Exception public class WarpNotFoundException extends Exception
{ {
public WarpNotFoundException() public WarpNotFoundException()
{ {
super("Warp not found"); super(_("warpNotExist"));
} }
public WarpNotFoundException(String message) public WarpNotFoundException(String message)