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
|
package net.ess3.signs.signs;
import static net.ess3.I18n._;
import org.bukkit.World;
import net.ess3.api.ChargeException;
import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import net.ess3.economy.Trade;
import net.ess3.signs.EssentialsSign;
public class SignWeather extends EssentialsSign
{
public SignWeather()
{
super("Weather");
}
@Override
protected boolean onSignCreate(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
{
validateTrade(sign, 2, ess);
final String timeString = sign.getLine(1);
if ("Sun".equalsIgnoreCase(timeString))
{
sign.setLine(1, "§2Sun");
return true;
}
if ("Storm".equalsIgnoreCase(timeString))
{
sign.setLine(1, "§2Storm");
return true;
}
throw new SignException(_("onlySunStorm"));
}
@Override
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
{
final Trade charge = getTrade(sign, 2, ess);
charge.isAffordableFor(player);
final String weatherString = sign.getLine(1);
final World world = player.getPlayer().getWorld();
if ("§2Sun".equalsIgnoreCase(weatherString))
{
world.setStorm(false);
charge.charge(player);
return true;
}
if ("§2Storm".equalsIgnoreCase(weatherString))
{
world.setStorm(true);
charge.charge(player);
return true;
}
throw new SignException(_("onlySunStorm"));
}
}
|