Adding permissions for overwriting exisitng warps

essentials.warp.overwrite.[warpname] will allow overwrting of exsiting warps
essentials.warp.overwrite.* for all warps
Adding WarpNotFoundException class
This commit is contained in:
ementalo 2012-03-14 21:16:22 +00:00
parent 267495a406
commit 6cf2bb5cd9
9 changed files with 42 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Warps;
import org.bukkit.Location;
import org.bukkit.Server;
@ -26,7 +27,25 @@ public class Commandsetwarp extends EssentialsCommand
}
final Location loc = user.getLocation();
ess.getWarps().setWarp(args[0], loc);
final Warps warps = ess.getWarps();
Location warpLoc = null;
try
{
warpLoc = warps.getWarp(args[0]);
}
catch (WarpNotFoundException ex)
{
}
if (warpLoc == null || user.hasPermission("essentials.warp.overwrite." + args[0]))
{
warps.setWarp(args[0], loc);
}
else
{
throw new Exception(_("warpOverwrite"));
}
user.sendMessage(_("warpSet", args[0]));
}
}

View file

@ -0,0 +1,15 @@
package com.earth2me.essentials.commands;
public class WarpNotFoundException extends Exception
{
public WarpNotFoundException()
{
super("Warp not found");
}
public WarpNotFoundException(String message)
{
super(message);
}
}