Search in sources :

Example 26 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class AbstractCommand method printHelp.

/**
 * Added the help output to the player's chat
 *
 * @param sender - user running the command
 * @param p      - page number to output
 */
protected void printHelp(ICommandSender sender, int p) {
    List<String> items = new ArrayList();
    getHelpOutput(sender, items);
    sender.addChatMessage(new ChatComponentText("====== help -" + getPrefix().replace("/", "") + "- page " + p + " ======"));
    for (int i = 0 + (p * 10); i < 10 + (p * 10) && i < items.size(); i++) {
        sender.addChatMessage(new ChatComponentText(getPrefix() + " " + items.get(i)));
    }
    sender.addChatMessage(new ChatComponentText(""));
}
Also used : ArrayList(java.util.ArrayList) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 27 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandDebugRecipes method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (args != null && args.length > 0 && !"help".equalsIgnoreCase(args[0])) {
        String modID = args[0];
        if (Loader.isModLoaded(modID)) {
            sender.addChatMessage(new ChatComponentText("Checking data...."));
            List<Item> items = InventoryUtility.getItemsForMod(modID);
            if (items != null && !items.isEmpty()) {
                HashMap<Item, List<IRecipe>> itemToRecipes = new HashMap();
                sender.addChatMessage(new ChatComponentText("Found " + items.size() + " items for the mod " + modID + " moving on to processing recipes"));
                for (Item item : items) {
                    List<IRecipe> recipes = InventoryUtility.getRecipesWithOutput(item);
                    if (recipes != null && recipes.size() > 0) {
                        itemToRecipes.put(item, recipes);
                    }
                }
                sender.addChatMessage(new ChatComponentText("Mapped " + itemToRecipes.size() + " entries with recipes"));
                if (args.length == 1 || args[1].equalsIgnoreCase("conflict")) {
                    sender.addChatMessage(new ChatComponentText("Not implemented yet"));
                    return true;
                } else if (args[1].equalsIgnoreCase("missing")) {
                    // TODO add handling for subtypes
                    for (Item item : items) {
                        if (!itemToRecipes.containsKey(item)) {
                            if (item instanceof ItemBlock) {
                                Block block = ((ItemBlock) item).field_150939_a;
                                if (block instanceof BlockTile) {
                                    sender.addChatMessage(new ChatComponentText("Tile[" + ((BlockTile) block).staticTile.name + "] has no recipes for any subtype"));
                                } else {
                                    sender.addChatMessage(new ChatComponentText("Block[" + block.getLocalizedName() + "] has no recipes for any subtype"));
                                }
                            } else {
                                sender.addChatMessage(new ChatComponentText("Item[" + item.getItemStackDisplayName(new ItemStack(item)) + "] has no recipes for any subtype"));
                            }
                        }
                    }
                }
            } else {
                sender.addChatMessage(new ChatComponentText("No items are mapped for the mod[" + modID + "]"));
            }
            return true;
        } else {
            // TODO maybe show closest spelling
            sender.addChatMessage(new ChatComponentText("Failed to find mod[" + modID + "]"));
            return true;
        }
    }
    return handleHelp(sender, args);
}
Also used : HashMap(java.util.HashMap) IRecipe(net.minecraft.item.crafting.IRecipe) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) ItemBlock(net.minecraft.item.ItemBlock) Item(net.minecraft.item.Item) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 28 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class ModularCommandRemoveAdd method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (isHelpCommand(args)) {
        handleHelp(sender, args);
    } else {
        String username = args[0];
        if (username != null && !username.isEmpty()) {
            if (args.length > 1) {
                String command = args[1];
                String[] a = removeFront(args, 2);
                if (!remove && command.equalsIgnoreCase("to") || remove && command.equalsIgnoreCase("from")) {
                    if (args.length > 2) {
                        command = args[2];
                        a = removeFront(a);
                    } else if (remove) {
                        sender.addChatMessage(new ChatComponentText("Need to know what to remove the " + type + " from"));
                        return true;
                    } else {
                        sender.addChatMessage(new ChatComponentText("Need to know what to add the " + type + " to"));
                        return true;
                    }
                }
                for (AbstractCommand c : subCommands) {
                    if (c instanceof SubCommandWithName && c.getCommandName().equalsIgnoreCase(command) && ((SubCommandWithName) c).handleConsoleCommand(sender, username, a)) {
                        return true;
                    }
                }
                sender.addChatMessage(new ChatComponentText("Unknown sub command"));
            } else if (remove) {
                sender.addChatMessage(new ChatComponentText("Need to know what to remove the " + type + " from"));
                return true;
            } else {
                sender.addChatMessage(new ChatComponentText("Need to know what to add the " + type + " to"));
                return true;
            }
        } else {
            sender.addChatMessage(new ChatComponentText("Empty names are not permitted"));
        }
    }
    return true;
}
Also used : AbstractCommand(com.builtbroken.mc.prefab.commands.AbstractCommand) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 29 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandRemoveGroup method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (args.length > 0) {
        String name = args[0];
        if (GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(name) != null) {
            AccessGroup group = new AccessGroup(name);
            if (GroupProfileHandler.GLOBAL.getAccessProfile().removeGroup(group) != null) {
                if (group.getExtendGroup() != null) {
                    int i = 0;
                    for (AccessGroup g : GroupProfileHandler.GLOBAL.getAccessProfile().getGroups()) {
                        if (g.getExtendGroup().getName().equalsIgnoreCase(group.getName())) {
                            i++;
                            g.setToExtend(group.getExtendGroup());
                        }
                    }
                    sender.addChatMessage(new ChatComponentText(i + " groups updated"));
                }
                sender.addChatMessage(new ChatComponentText("Group \'" + name + "\' removed"));
            } else {
                sender.addChatMessage(new ChatComponentText("Error removing group"));
            }
        } else {
            sender.addChatMessage(new ChatComponentText("Group \'" + name + "\' not found"));
        }
    } else {
        sender.addChatMessage(new ChatComponentText("Missing group name"));
    }
    return true;
}
Also used : AccessGroup(com.builtbroken.mc.lib.access.AccessGroup) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 30 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class GSCList method handle.

@Override
public boolean handle(ICommandSender sender, AccessGroup group, String user, String[] args) {
    // TODO add page support, so we don't spam the console
    if (args != null && args.length >= 0) {
        if (args[0].equalsIgnoreCase("perms")) {
            if (group.getNodes() != null && group.getNodes().size() > 0) {
                sender.addChatMessage(new ChatComponentText("==== Permission Nodes ====="));
                for (String node : group.getNodes()) {
                    sender.addChatMessage(new ChatComponentText(node));
                }
                sender.addChatMessage(new ChatComponentText(""));
            } else {
                sender.addChatMessage(new ChatComponentText("No perms to list"));
            }
            return true;
        } else if (args[0].equalsIgnoreCase("users") || args[0].equalsIgnoreCase("members")) {
            if (group.getMembers() != null && group.getMembers().size() > 0) {
                sender.addChatMessage(new ChatComponentText("===== Members ====="));
                for (AccessUser u : group.getMembers()) {
                    sender.addChatMessage(new ChatComponentText(u.getName()));
                }
                sender.addChatMessage(new ChatComponentText(""));
            } else {
                sender.addChatMessage(new ChatComponentText("Group contains no members"));
            }
            return true;
        }
    }
    sender.addChatMessage(new ChatComponentText("Not sure what you want listed"));
    return true;
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText) AccessUser(com.builtbroken.mc.lib.access.AccessUser)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)383 IChatComponent (net.minecraft.util.IChatComponent)55 EntityPlayer (net.minecraft.entity.player.EntityPlayer)43 ChatStyle (net.minecraft.util.ChatStyle)39 ItemStack (net.minecraft.item.ItemStack)36 ClickEvent (net.minecraft.event.ClickEvent)31 World (net.minecraft.world.World)28 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)26 TileEntity (net.minecraft.tileentity.TileEntity)25 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)25 HoverEvent (net.minecraft.event.HoverEvent)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 ArrayList (java.util.ArrayList)17 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)16 Block (net.minecraft.block.Block)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)14 Entity (net.minecraft.entity.Entity)14 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)13 File (java.io.File)12