mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Default value for [gamemode] sign
New syntax: [gamemode] / <mode> / [price]
This commit is contained in:
parent
7a96fd1dce
commit
3dbabfa11d
1 changed files with 16 additions and 6 deletions
|
@ -19,20 +19,27 @@ public class SignGameMode extends EssentialsSign
|
|||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
validateTrade(sign, 1, ess);
|
||||
{
|
||||
final String gamemode = sign.getLine(1);
|
||||
if (gamemode.isEmpty())
|
||||
{
|
||||
sign.setLine(1, "Survival");
|
||||
}
|
||||
|
||||
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, 1, ess);
|
||||
final String mode = sign.getLine(2).trim();
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
final String mode = sign.getLine(1).trim();
|
||||
|
||||
if (mode.isEmpty())
|
||||
{
|
||||
throw new SignException(_("invalidSignLine", 3));
|
||||
throw new SignException(_("invalidSignLine", 2));
|
||||
}
|
||||
|
||||
charge.isAffordableFor(player);
|
||||
|
@ -43,7 +50,7 @@ public class SignGameMode extends EssentialsSign
|
|||
return true;
|
||||
}
|
||||
|
||||
private void performSetMode(String mode, Player player)
|
||||
private void performSetMode(String mode, Player player) throws SignException
|
||||
{
|
||||
if (mode.contains("survi") || mode.equalsIgnoreCase("0"))
|
||||
{
|
||||
|
@ -57,5 +64,8 @@ public class SignGameMode extends EssentialsSign
|
|||
{
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
else {
|
||||
throw new SignException(_("invalidSignLine", 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue