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(""));
}
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);
}
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;
}
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;
}
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;
}
Aggregations