mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-18 08:35:44 +01:00
New Sign: Repair
Syntax: [repair] / <hand|all> / [cost]
This commit is contained in:
parent
9e975568be
commit
ee608d944a
57
Essentials/src/com/earth2me/essentials/signs/SignRepair.java
Normal file
57
Essentials/src/com/earth2me/essentials/signs/SignRepair.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.commands.Commandrepair;
|
||||
|
||||
|
||||
public class SignRepair extends EssentialsSign
|
||||
{
|
||||
public SignRepair()
|
||||
{
|
||||
super("Repair");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
final String repairTarget = sign.getLine(1);
|
||||
if (repairTarget.isEmpty())
|
||||
{
|
||||
sign.setLine(1, "Hand");
|
||||
}
|
||||
else if (!repairTarget.equalsIgnoreCase("all") && !repairTarget.equalsIgnoreCase("hand") )
|
||||
{
|
||||
throw new SignException(_("invalidSignLine", 2));
|
||||
}
|
||||
validateTrade(sign, 2, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
Commandrepair command = new Commandrepair();
|
||||
command.setEssentials(ess);
|
||||
String[] args = new String[]
|
||||
{
|
||||
sign.getLine(1)
|
||||
};
|
||||
try
|
||||
{
|
||||
command.run(ess.getServer(), player, "repair", args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ public enum Signs
|
||||
KIT(new SignKit()),
|
||||
MAIL(new SignMail()),
|
||||
PROTECTION(new SignProtection()),
|
||||
REPAIR(new SignRepair()),
|
||||
SELL(new SignSell()),
|
||||
SPAWNMOB(new SignSpawnmob()),
|
||||
TIME(new SignTime()),
|
||||
|
@ -219,6 +219,7 @@ enabledSigns:
|
||||
#- gamemode
|
||||
#- heal
|
||||
#- spawnmob
|
||||
#- repair
|
||||
#- time
|
||||
#- weather
|
||||
#- protection
|
||||
|
Loading…
Reference in New Issue
Block a user