Search in sources :

Example 1 with GuiStyle

use of mcjty.lib.gui.GuiStyle in project RFTools by McJty.

the class CmdSetStyle method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 2) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    if (!(sender instanceof EntityPlayer)) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "This command only works as a player!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    EntityPlayer player = (EntityPlayer) sender;
    PreferencesProperties properties = McJtyLib.getPreferencesProperties(player);
    if (args.length < 2) {
        GuiStyle style = properties.getStyle();
        ITextComponent component = new TextComponentString(TextFormatting.YELLOW + "Current GUI style: " + style.getStyle());
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    String s = fetchString(sender, args, 1, "");
    boolean b = properties.setStyle(s);
    if (!b) {
        String buf = "";
        for (GuiStyle style : GuiStyle.values()) {
            buf = buf + " " + style.getStyle();
        }
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Unknown style! Options:" + buf);
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
    }
}
Also used : PreferencesProperties(mcjty.lib.preferences.PreferencesProperties) GuiStyle(mcjty.lib.gui.GuiStyle) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

GuiStyle (mcjty.lib.gui.GuiStyle)1 PreferencesProperties (mcjty.lib.preferences.PreferencesProperties)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 TextComponentString (net.minecraft.util.text.TextComponentString)1