Search in sources :

Example 6 with PlayerPreferencesProperties

use of mcjty.lib.preferences.PlayerPreferencesProperties in project RFTools by McJty.

the class CmdSetStyle method execute.

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

Aggregations

PlayerPreferencesProperties (mcjty.lib.preferences.PlayerPreferencesProperties)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 ChatComponentText (net.minecraft.util.ChatComponentText)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 PlayerExtendedProperties (mcjty.rftools.playerprops.PlayerExtendedProperties)2 GuiStyle (mcjty.lib.gui.GuiStyle)1 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)1 RenderItem (net.minecraft.client.renderer.entity.RenderItem)1 Item (net.minecraft.item.Item)1 IIcon (net.minecraft.util.IIcon)1 IExtendedEntityProperties (net.minecraftforge.common.IExtendedEntityProperties)1