TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java

52 lines
1 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Warps;
2011-11-18 17:42:26 +00:00
import org.bukkit.Location;
import org.bukkit.Server;
public class Commandsetwarp extends EssentialsCommand
{
public Commandsetwarp()
{
super("setwarp");
}
@Override
2011-12-01 13:42:39 +00:00
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
if (args[0].matches("[0-9]+")) {
throw new NotEnoughArgumentsException();
}
2011-12-01 13:42:39 +00:00
final Location loc = user.getLocation();
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]));
}
}