mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 12:23:59 +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
|
@ -20,19 +20,26 @@ public class SignGameMode extends EssentialsSign
|
||||||
@Override
|
@Override
|
||||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
|
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 Trade charge = getTrade(sign, 2, ess);
|
||||||
final String mode = sign.getLine(2).trim();
|
final String mode = sign.getLine(1).trim();
|
||||||
|
|
||||||
if (mode.isEmpty())
|
if (mode.isEmpty())
|
||||||
{
|
{
|
||||||
throw new SignException(_("invalidSignLine", 3));
|
throw new SignException(_("invalidSignLine", 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
charge.isAffordableFor(player);
|
charge.isAffordableFor(player);
|
||||||
|
@ -43,7 +50,7 @@ public class SignGameMode extends EssentialsSign
|
||||||
return true;
|
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"))
|
if (mode.contains("survi") || mode.equalsIgnoreCase("0"))
|
||||||
{
|
{
|
||||||
|
@ -57,5 +64,8 @@ public class SignGameMode extends EssentialsSign
|
||||||
{
|
{
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
throw new SignException(_("invalidSignLine", 2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue