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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
package com.earth2me.essentials.signs;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
public class SignWarp extends EssentialsSign
{
public SignWarp()
{
super("Warp");
}
@Override
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
validateTrade(sign, 3, ess);
final String warpName = sign.getLine(1);
if (warpName.isEmpty())
{
sign.setLine(1, "§dWarp name!");
return false;
}
else
{
try
{
ess.getWarps().getWarp(warpName);
}
catch (Exception ex)
{
throw new SignException(ex.getMessage(), ex);
}
final String group = sign.getLine(2);
if ("Everyone".equalsIgnoreCase(group))
{
sign.setLine(2, "§2Everyone");
}
return true;
}
}
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
{
final String warpName = sign.getLine(1);
final String group = sign.getLine(2);
if ((!group.isEmpty()
&& ("§2Everyone".equals(group)
|| player.inGroup(group)))
|| (group.isEmpty() && (!ess.getSettings().getPerWarpPermission() || player.isAuthorized("essentials.warp." + warpName))))
{
final Trade charge = getTrade(sign, 3, ess);
try
{
player.getTeleport().warp(warpName, charge);
}
catch (Exception ex)
{
throw new SignException(ex.getMessage(), ex);
}
return true;
}
return false;
}
}
|