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
|
package com.earth2me.essentials.signs;
import com.earth2me.essentials.api.ChargeException;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IUser;
public class SignSell extends EssentialsSign
{
public SignSell()
{
super("Sell");
}
@Override
protected boolean onSignCreate(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
{
validateTrade(sign, 1, 2, player, ess);
validateTrade(sign, 3, ess);
return true;
}
@Override
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
{
final Trade charge = getTrade(sign, 1, 2, player, ess);
final Trade money = getTrade(sign, 3, ess);
charge.isAffordableFor(player);
money.pay(player);
charge.charge(player);
Trade.log("Sign", "Sell", "Interact", username, charge, username, money, sign.getBlock().getLocation(), ess);
return true;
}
}
|