blob: 68d17838188d69ab6b7ed4038f80fce1752583d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package net.ess3.commands;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.api.IWarps;
import net.ess3.permissions.Permissions;
import net.ess3.utils.Util;
import org.bukkit.Location;
public class Commandsetwarp extends EssentialsCommand
{
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
if (Util.isInt(args[0]))
{
throw new NoSuchFieldException(_("Invalid warp name!"));
}
final Location loc = user.getPlayer().getLocation();
final IWarps warps = ess.getWarps();
Location warpLoc = null;
try
{
warpLoc = warps.getWarp(args[0]);
}
catch (WarpNotFoundException ex)
{
}
if (warpLoc == null || Permissions.WARP_OVERWRITE.isAuthorized(user, args[0]))
{
warps.setWarp(args[0], loc);
}
else
{
throw new Exception(_("You cannot overwrite that warp."));
}
user.sendMessage(_("Warp {0} set.", args[0]));
}
}
|