net.minecraft.command.WrongUsageException Java Examples
The following examples show how to use
net.minecraft.command.WrongUsageException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandSignals.java From Signals with GNU General Public License v3.0 | 6 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException{ if(args.length == 0) throw new WrongUsageException("command.signals.noArgs"); String subCommand = args[0]; if(subCommand.equals("rebuildNetwork")) { RailNetworkManager.getServerInstance().rebuildNetwork(); sender.sendMessage(new TextComponentTranslation("command.signals.networkCleared")); } else if(subCommand.equals("debug") && sender.getName().startsWith("Player" /* Playerx */)) { if(debug(server, sender, args)) { sender.sendMessage(new TextComponentString("DEBUG EXECUTED")); } else { sender.sendMessage(new TextComponentString("Could not execute debug!")); } } else { throw new WrongUsageException("command.signals.invalidSubCommand", subCommand); } }
Example #2
Source File: CommandDebug.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, @NotNull String[] args) throws WrongUsageException { if (args.length < 2) throw new WrongUsageException(getUsage(sender)); ModuleInstance module = ModuleRegistry.INSTANCE.getModule(args[1]); if (module == null) { notifyCommandListener(sender, this, "wizardry.command." + getName() + ".module_not_found"); return; } notifyCommandListener(sender, this, TextFormatting.YELLOW + " ________________________________________________\\\\"); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | " + TextFormatting.GRAY + "Module " + module.getReadableName() + ":"); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Description " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getDescription()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Item Stack " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getItemStack().getDisplayName()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Burnout Fill " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getBurnoutFill()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | | |_ " + TextFormatting.DARK_GREEN + "Burnout Multiplier" + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getBurnoutMultiplier()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Mana Drain " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getManaDrain()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | | |_" + TextFormatting.DARK_GREEN + "Mana Multiplier " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getManaMultiplier()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Power Multiplier " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getPowerMultiplier()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Charge Up Time " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getChargeupTime()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Cooldown Time " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getCooldownTime()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Primary Color " + TextFormatting.GRAY + " | " + TextFormatting.RED + module.getPrimaryColor().getRed() + TextFormatting.GRAY + ", " + TextFormatting.GREEN + module.getPrimaryColor().getGreen() + TextFormatting.GRAY + ", " + TextFormatting.BLUE + module.getPrimaryColor().getBlue()); notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Secondary Color " + TextFormatting.GRAY + " | " + TextFormatting.RED + module.getSecondaryColor().getRed() + TextFormatting.GRAY + ", " + TextFormatting.GREEN + module.getSecondaryColor().getGreen() + TextFormatting.GRAY + ", " + TextFormatting.BLUE + module.getSecondaryColor().getBlue()); if (!module.getAttributeModifiers().isEmpty()) notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Default AttributeRegistry"); for (AttributeModifier attributeModifier : module.getAttributeModifiers()) notifyCommandListener(sender, this, TextFormatting.YELLOW + " | | |_ " + TextFormatting.GRAY + attributeModifier.toString()); ModuleInstanceModifier[] modifierList = module.applicableModifiers(); if (modifierList != null) { notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Applicable Modifiers "); for (ModuleInstanceModifier modifier : modifierList) notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.DARK_GREEN + modifier.getNBTKey()); } notifyCommandListener(sender, this, TextFormatting.YELLOW + " |________________________________________________//"); }
Example #3
Source File: ToroQuestCommand.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (!(sender instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) sender; if (args.length < 1) { throw new WrongUsageException("commands.tq.usage", new Object[0]); } String command = args[0]; System.out.println("command " + command); if ("rep".equals(command)) { adjustRep(server, player, args); } else if ("list".equals(command)) { listCommand(player, args); } else if ("gen".equals(command)) { genCommand(player, args); } else if ("gui".equals(command)) { guiCommand(player, args); } else if ("quest".equals(command)) { questCommand(player, args); } else if ("book".equals(command)) { bookCommand(player, args); } else { throw new WrongUsageException("commands.tq.usage", new Object[0]); } }
Example #4
Source File: ToroQuestCommand.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
private void genCommand(EntityPlayer player, String[] args) throws CommandException { if (args.length < 2) { throw new WrongUsageException("commands.tq.usage", new Object[0]); } String structure = args[1]; if ("throne_room".equals(structure)) { new ThroneRoomGenerator().generate(player.getEntityWorld(), player.getEntityWorld().rand, player.getPosition()); return; } if ("mage_tower".equals(structure)) { new MageTowerGenerator().generate(player.getEntityWorld(), player.getEntityWorld().rand, player.getPosition()); return; } if ("bastions_lair".equals(structure)) { new BastionsLairGenerator().generate(player.getEntityWorld(), player.getEntityWorld().rand, player.getPosition()); return; } if ("monolith".equals(structure)) { new MonolithGenerator().generate(player.getEntityWorld(), player.getEntityWorld().rand, player.getPosition()); return; } if ("graveyard".equals(structure)) { new GraveyardGenerator().generate(player.getEntityWorld(), player.getEntityWorld().rand, player.getPosition()); return; } throw new WrongUsageException("commands.tq.usage", new Object[0]); }
Example #5
Source File: ToroQuestCommand.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
private void guiCommand(EntityPlayer player, String[] args) throws CommandException { if (args.length < 2) { throw new WrongUsageException("commans.tq.usage", new Object[0]); } String type = args[1]; if ("lord".equals(type)) { player.openGui(ToroQuest.INSTANCE, VillageLordGuiHandler.getGuiID(), player.world, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ()); return; } throw new WrongUsageException("commands.tq.usage", new Object[0]); }
Example #6
Source File: SetPlayerModelCommand.java From Et-Futurum with The Unlicense | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] args) { if (args.length != 1 || !"alex".equals(args[0].toLowerCase()) && !"steve".equals(args[0].toLowerCase())) throw new WrongUsageException(getCommandUsage(sender)); if (sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) sender; NBTTagCompound nbt = player.getEntityData(); boolean isAlex = "alex".equals(args[0].toLowerCase()); nbt.setBoolean(MODEL_KEY, isAlex); EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex)); } }
Example #7
Source File: NewSpawnPlatformCommand.java From YUNoMakeGoodMap with Apache License 2.0 | 5 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length != 2) throw new WrongUsageException(getUsage(sender)); EntityPlayer player = getPlayer(server, sender, args[1]); if (player != null) { PlacementSettings settings = new PlacementSettings(); WorldServer world = (WorldServer) sender.getEntityWorld(); int platformNumber = SpawnPlatformSavedData.get(world).addAndGetPlatformNumber(); BlockPos pos = getPositionOfPlatform(world, platformNumber); Template temp = StructureUtil.loadTemplate(new ResourceLocation(args[0]), world, true); BlockPos spawn = StructureUtil.findSpawn(temp, settings); spawn = spawn == null ? pos : spawn.add(pos); sender.sendMessage(new TextComponentString("Building \"" + args[0] + "\" at " + pos.toString())); temp.addBlocksToWorld(world, pos, settings, 2); //Push to world, with no neighbor notifications! world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall! if (player instanceof EntityPlayerMP) { ((EntityPlayerMP) player).setPositionAndUpdate(spawn.getX() + 0.5, spawn.getY() + 1.6, spawn.getZ() + 0.5); } player.setSpawnChunk(spawn, true, world.provider.getDimension()); } else { throw new WrongUsageException(getUsage(sender)); } }
Example #8
Source File: CommandNBTEdit.java From NBTEdit with GNU General Public License v3.0 | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] var2) { if (sender instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP)sender; if (var2.length == 3) { int x = parseInt(sender,var2[0]); int y = parseInt(sender,var2[1]); int z = parseInt(sender,var2[2]); NBTEdit.log(Level.FINE, sender.getCommandSenderName() + " issued command \"/nbtedit " + x + " " + y + " " + z + "\""); new TileRequestPacket(x, y, z).handleServerSide(player); } else if (var2.length == 1) { int entityID = (var2[0].equalsIgnoreCase("me")) ? player.getEntityId() : parseIntWithMin(sender, var2[0], 0); NBTEdit.log(Level.FINE, sender.getCommandSenderName() + " issued command \"/nbtedit " + entityID + "\""); new EntityRequestPacket(entityID).handleServerSide(player); } else if (var2.length == 0) { NBTEdit.log(Level.FINE, sender.getCommandSenderName() + " issued command \"/nbtedit\""); NBTEdit.DISPATCHER.sendTo(new MouseOverPacket(), player); } else { String s = ""; for (int i =0; i < var2.length; ++i) { s += var2[i]; if (i != var2.length - 1) s += " "; } NBTEdit.log(Level.FINE, sender.getCommandSenderName() + " issued invalid command \"/nbtedit " + s + "\""); throw new WrongUsageException("Pass 0, 1, or 3 integers -- ex. /nbtedit", new Object[0]); } } }
Example #9
Source File: CommandGetGlobalVariable.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] args){ if(sender instanceof EntityPlayerMP) { if(args.length != 1) throw new WrongUsageException("command.deliverAmazon.args"); String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0]; ChunkPosition pos = GlobalVariableManager.getInstance().getPos(varName); ItemStack stack = GlobalVariableManager.getInstance().getItem(varName); NetworkHandler.sendTo(new PacketCommandGetGlobalVariableOutput(varName, pos, stack), (EntityPlayerMP)sender); } }
Example #10
Source File: CommandSetGlobalVariable.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void processCommand(ICommandSender sender, String[] args){ if(args.length != 4) throw new WrongUsageException("command.deliverAmazon.args"); String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0]; ChunkPosition newPos = new ChunkPosition(parseInt(sender, args[1]), parseInt(sender, args[2]), parseInt(sender, args[3])); GlobalVariableManager.getInstance().set(varName, newPos); sender.addChatMessage(new ChatComponentTranslation("command.setGlobalVariable.output", varName, newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ)); }
Example #11
Source File: HICommand.java From HoloInventory with MIT License | 5 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (isOP(sender)) throw new CommandException(getUsage(sender)); else if (args.length == 0 || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("h") || args[0].equalsIgnoreCase("?")) showHelp(sender); else if (args[0].equalsIgnoreCase("ban")) { ServerEventHandler.catchNext = ServerEventHandler.Type.BAN; sender.sendMessage(new TextComponentString("Right click a block.").setStyle(new Style().setColor(TextFormatting.AQUA))); } else if (args[0].equalsIgnoreCase("unban")) { if (args.length == 1) { ServerEventHandler.catchNext = ServerEventHandler.Type.UNBAN; sender.sendMessage(new TextComponentString("Right click a block.").setStyle(new Style().setColor(TextFormatting.AQUA))); } else { boolean wasBanned = Helper.banned.remove(args[1]); if (wasBanned) sender.sendMessage(new TextComponentString("Unbanned " + args[1]).setStyle(new Style().setColor(TextFormatting.GREEN))); else sender.sendMessage(new TextComponentString(args[1] + " is not banned.").setStyle(new Style().setColor(TextFormatting.RED))); } } else if (args[0].equalsIgnoreCase("list")) { sender.sendMessage(new TextComponentString(HoloInventory.MODID.concat(" banlist:")).setStyle(new Style().setColor(TextFormatting.AQUA))); for (String type : Helper.banned) { sender.sendMessage(new TextComponentString(type)); } } else throw new WrongUsageException(getUsage(sender)); }
Example #12
Source File: PlatformCommand.java From YUNoMakeGoodMap with Apache License 2.0 | 4 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 1) throw new WrongUsageException(getUsage(sender)); String cmd = args[0].toLowerCase(Locale.ENGLISH); if ("list".equals(cmd)) { sender.sendMessage(new TextComponentString("Known Platforms:")); for (ResourceLocation rl : getPlatforms()) { sender.sendMessage(new TextComponentString(" " + rl.toString())); } } else if ("spawn".equals(cmd) || "preview".equals(cmd)) { if (args.length < 2) throw new WrongUsageException(getUsage(sender)); Entity ent = sender.getCommandSenderEntity(); PlacementSettings settings = new PlacementSettings(); WorldServer world = (WorldServer)sender.getEntityWorld(); if (args.length >= 3) { //TODO: Preview doesnt quite work correctly with rotations.... String rot = args[2].toLowerCase(Locale.ENGLISH); if ("0".equals(rot) || "none".equals(rot)) settings.setRotation(Rotation.NONE); else if ("90".equals(rot)) settings.setRotation(Rotation.CLOCKWISE_90); else if ("180".equals(rot)) settings.setRotation(Rotation.CLOCKWISE_180); else if ("270".equals(rot)) settings.setRotation(Rotation.COUNTERCLOCKWISE_90); else throw new WrongUsageException("Only rotations none, 0, 90, 180, and 270 allowed."); } BlockPos pos; if (args.length >= 6) pos = CommandBase.parseBlockPos(sender, args, 3, false); else if (ent != null) pos = ent.getPosition(); else throw new WrongUsageException("Must specify a position if the command sender is not an entity"); Template temp = StructureUtil.loadTemplate(new ResourceLocation(args[1]), world, true); BlockPos spawn = StructureUtil.findSpawn(temp, settings); if (spawn != null) pos = pos.subtract(spawn); if ("spawn".equals(cmd)) { sender.sendMessage(new TextComponentString("Building \"" + args[1] +"\" at " + pos.toString())); temp.addBlocksToWorld(world, pos, settings, 2); //Push to world, with no neighbor notifications! world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall! } else { BlockPos tpos = pos.down(); if (spawn != null) tpos = tpos.add(spawn); sender.sendMessage(new TextComponentString("Previewing \"" + args[1] +"\" at " + pos.toString())); world.setBlockState(tpos, Blocks.STRUCTURE_BLOCK.getDefaultState().withProperty(BlockStructure.MODE, TileEntityStructure.Mode.LOAD)); TileEntityStructure te = (TileEntityStructure)world.getTileEntity(tpos); if (spawn != null) te.setPosition(te.getPosition().subtract(spawn)); te.setSize(temp.getSize()); te.setMode(Mode.LOAD); te.markDirty(); } } else throw new WrongUsageException(getUsage(sender)); }
Example #13
Source File: CommandAmazonDelivery.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void processCommand(ICommandSender sender, String[] args){ if(args.length < 2) throw new WrongUsageException("command.deliverAmazon.args"); int x, y, z; int curArg; String regex = "-?\\d+"; if(args[0].matches(regex)) { if(args.length < 4) throw new WrongUsageException("command.deliverAmazon.args"); if(!args[1].matches(regex) || !args[2].matches(regex)) throw new WrongUsageException("command.deliverAmazon.coords"); x = Integer.parseInt(args[0]); y = Integer.parseInt(args[1]); z = Integer.parseInt(args[2]); curArg = 3; } else { EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(args[0]); if(player != null) { x = (int)Math.floor(player.posX); y = (int)Math.floor(player.posY) + 1; z = (int)Math.floor(player.posZ); curArg = 1; } else { throw new WrongUsageException("command.deliverAmazon.playerName"); } } if(args.length < curArg + 3) throw new WrongUsageException("command.deliverAmazon.args"); if(!args[curArg].matches(regex) || !args[curArg + 1].matches(regex) || !args[curArg + 2].matches(regex)) throw new WrongUsageException("command.deliverAmazon.coords"); TileEntity te = sender.getEntityWorld().getTileEntity(Integer.parseInt(args[curArg]), Integer.parseInt(args[curArg + 1]), Integer.parseInt(args[curArg + 2])); IInventory inv = IOHelper.getInventoryForTE(te); if(inv != null) { List<ItemStack> deliveredStacks = new ArrayList<ItemStack>(); for(int i = 0; i < inv.getSizeInventory() && deliveredStacks.size() < 65; i++) { if(inv.getStackInSlot(i) != null) deliveredStacks.add(inv.getStackInSlot(i)); } if(deliveredStacks.size() > 0) { PneumaticRegistry.getInstance().deliverItemsAmazonStyle(sender.getEntityWorld(), x, y, z, deliveredStacks.toArray(new ItemStack[deliveredStacks.size()])); sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.success")); } else { sender.addChatMessage(new ChatComponentTranslation("command.deliverAmazon.noItems")); } } else { throw new WrongUsageException("command.deliverAmazon.noInventory"); } }
Example #14
Source File: UpdateChecker.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void processCommand(ICommandSender icommandsender, String[] astring){ if(astring.length > 0 && astring[0].equalsIgnoreCase("changelog")) { if(astring.length > 1) { if(astring[1].equalsIgnoreCase("additions")) { if(instance().additions.size() > 0) { sendMessage(icommandsender, "-----Additions-----"); sendMessage(icommandsender, instance().additions); } else { sendMessage(icommandsender, "No additions in the newest PneumaticCraft. :("); } } else if(astring[1].equalsIgnoreCase("apichanges")) { if(instance().apiChanges.size() > 0) { sendMessage(icommandsender, "-----API Changes-----"); sendMessage(icommandsender, instance().apiChanges); } else { sendMessage(icommandsender, "No API changes in the newest PneumaticCraft."); } } else if(astring[1].equalsIgnoreCase("bugfixes")) { if(instance().bugfixes.size() > 0) { sendMessage(icommandsender, "-----Bugfixes-----"); sendMessage(icommandsender, instance().bugfixes); } else { sendMessage(icommandsender, "No bugfixes in the newest PneumaticCraft."); } } else if(astring[1].equalsIgnoreCase("true")) { sendMessage(icommandsender, "You'll now get a notification when a new version of PneumaticCraft is released. Checking now..."); Config.config.get(Configuration.CATEGORY_GENERAL, "Enable Update Checker", true).set(true); Config.config.save(); //if(Config.enableUpdateChecker) FMLCommonHandler.instance().bus().unregister(instance()); causes NPE for some reason... INSTANCE = new UpdateChecker();//reset variables, prevent thread from running twice. instance().displayDelay = 0; FMLCommonHandler.instance().bus().register(instance()); instance().start(); Config.enableUpdateChecker = true; } else if(astring[1].equalsIgnoreCase("false")) { sendMessage(icommandsender, "You'll no longer get a notification when there's a new version of PneumaticCraft available."); Config.config.get(Configuration.CATEGORY_GENERAL, "Enable Update Checker", true).set(false); Config.config.save(); // if(Config.enableUpdateChecker) FMLCommonHandler.instance().bus().unregister(instance());//save cpu time by unsubscribing to the tickevent. //causes NPE for some reason. Config.enableUpdateChecker = false; } else { throw new WrongUsageException(getCommandUsage(icommandsender)); } } else { if(instance().additions.size() > 0) { sendMessage(icommandsender, "-----Additions-----"); sendMessage(icommandsender, instance().additions); } if(instance().apiChanges.size() > 0) { sendMessage(icommandsender, "-----API Changes-----"); sendMessage(icommandsender, instance().apiChanges); } if(instance().bugfixes.size() > 0) { sendMessage(icommandsender, "-----Bugfixes-----"); sendMessage(icommandsender, instance().bugfixes); } } } else { throw new WrongUsageException(getCommandUsage(icommandsender)); } }