Gamemode sign, standard sign permissions.

This commit is contained in:
KHobbits 2011-11-16 00:21:55 +00:00
parent e4c3f7b115
commit c0d046841f
3 changed files with 37 additions and 1 deletions

View File

@ -38,7 +38,6 @@ public class Commandgamemode extends EssentialsCommand
}
}
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
//TODO: add this to messages?
sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName()));
}
}

View File

@ -0,0 +1,36 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.GameMode;
public class SignGameMode extends EssentialsSign
{
public SignGameMode()
{
super("GameMode");
}
@Override
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
validateTrade(sign, 1, 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);
charge.isAffordableFor(player);
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
player.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName()));
charge.charge(player);
return true;
}
}

View File

@ -7,6 +7,7 @@ public enum Signs
BUY(new SignBuy()),
DISPOSAL(new SignDisposal()),
FREE(new SignFree()),
GAMEMODE(new SignGameMode()),
HEAL(new SignHeal()),
MAIL(new SignMail()),
PROTECTION(new SignProtection()),