/** * Callback for when the command is executed */ @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if(args.length < 1) { sender.addChatMessage(new TextComponentString(CommandBase.joinNiceStringFromCollection(commandMap.keySet()))); } else { ICommand cmd = getCommandMap().get(args[0]); if(cmd == null) { throw new CommandException("commands.tree_base.invalid_cmd", args[0]); } else if(!cmd.checkPermission(server, sender)) { throw new CommandException("commands.generic.permission"); } else { cmd.execute(server, sender, shiftArgs(args)); } } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 0) { throw new CommandException("nosubcommandspecified"); } final Optional<CommandBase> first = childCommands .stream() .sorted(Comparator.comparing(ICommand::getCommandName)) .filter(command -> command.getCommandName().equals(args[0])) .findFirst(); if (!first.isPresent()) { throw new CommandException("nosuchsubcommand"); } final CommandBase commandBase = first.get(); final String[] parameters = Arrays.copyOfRange(args, 1, args.length); commandBase.execute(server, sender, parameters); }
@Override public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) { if (args.length <= 1) { return childCommands .stream() .map(ICommand::getCommandName) .sorted() .filter(command -> command.startsWith(args[0])) .collect(Collectors.toList()); } final Optional<CommandBase> first = childCommands .stream() .sorted(Comparator.comparing(ICommand::getCommandName)) .filter(command -> command.getCommandName() == args[0]) .findFirst(); if (!first.isPresent()) { return Lists.newArrayList(); } final String[] parameters = Arrays.copyOfRange(args, 1, args.length - 2); return first.get().getTabCompletionOptions(server, sender, parameters, pos); }
/** * Execute the command * * This method basically delegates the execution to the matched sub-command, * if the command was found, otherwise it shows usage message. */ @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 1) { throw new WrongUsageException(this.getCommandUsage(sender)); } CommandBase command = this.subcommands.get(args[0]); if (args.length == 2 && args[1].equals("-h")) { throw new WrongUsageException(command.getCommandUsage(sender)); } if (command != null) { command.execute(server, sender, dropFirstArgument(args)); return; } throw new WrongUsageException(this.getCommandUsage(sender)); }
/** * Create an actor from command line arguments (i.e. String array). * Description of every element in array: * * 1. Ignored (since it's filename) * 2. Name tag * 3. Model name * 4. Skin resource location * 5. Invincible flag (boolean) * * And of course, all of those arguments are optional (i.e. have default * values). */ public static EntityActor actorFromArgs(String[] args, World world) throws CommandException { EntityActor actor = null; String name = args.length >= 2 ? args[1] : ""; String model = args.length >= 3 ? args[2] : ""; String skin = args.length >= 4 ? args[3] : ""; boolean invincible = args.length >= 5 ? CommandBase.parseBoolean(args[4]) : false; actor = new EntityActor(world); actor.modify(MorphUtils.morphFromModel(model, skin), false, false, true); actor.setEntityInvulnerable(invincible); actor.setCustomNameTag(name); return actor; }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 1) { throw new WrongUsageException(this.getCommandUsage(sender)); } EntityPlayer player = getCommandSenderAsPlayer(sender); if (args.length >= 4) { BlockPos pos = CommandBase.parseBlockPos(sender, args, 1, false); TileEntity tile = sender.getEntityWorld().getTileEntity(pos); if (tile instanceof TileEntityDirector) { ((TileEntityDirector) tile).startRecording(args[0], player); } } else { CommonProxy.manager.startRecording(args[0], player, Mode.ACTIONS, true, null); } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { EntityPlayerMP player = CommandBase.getCommandSenderAsPlayer(sender); if(args.length == 0) { throw new WrongUsageException("No parameters given!"); } String newName = Strings.join(args, " ").trim(); if(newName.isEmpty()) { return; } ItemStack itemStack = player.getHeldItemMainhand(); if(itemStack != null) { itemStack.setStackDisplayName(newName); } }
private void execute_expand(String[] args, EntityPlayerMP player, ICommandSender sender) throws CommandException { if(args.length == 2) { int value = CommandBase.parseInt(args[1]); int[] bounds = WandItem.getBoundsFromPlayerOrNull(player); if(bounds == null) { throw new WrongUsageException("You didn't select a region with your wand."); } int ix = bounds[0] - value; int iy = bounds[1] - value; int iz = bounds[2] - value; int ax = bounds[3] + value; int ay = bounds[4] + value; int az = bounds[5] + value; WandItem.setBounds(player, ix, iy, iz, ax, ay, az); return; } else { throw new WrongUsageException("Missing parameters! /tc_wand expand <val>"); } }
private void execute_expand_h(String[] args, EntityPlayerMP player, ICommandSender sender) throws CommandException { if(args.length == 2) { int value = CommandBase.parseInt(args[1]); int[] bounds = WandItem.getBoundsFromPlayerOrNull(player); if(bounds == null) { throw new WrongUsageException("You didn't select a region with your wand."); } int ix = bounds[0] - value; int iy = bounds[1]; int iz = bounds[2] - value; int ax = bounds[3] + value; int ay = bounds[4]; int az = bounds[5] + value; WandItem.setBounds(player, ix, iy, iz, ax, ay, az); return; } else { throw new WrongUsageException("Missing parameters! /tc_wand expand <val>"); } }
private void execute_expand_v(String[] args, EntityPlayerMP player, ICommandSender sender) throws CommandException { if(args.length == 2) { int value = CommandBase.parseInt(args[1], 0, 128); int[] bounds = WandItem.getBoundsFromPlayerOrNull(player); if(bounds == null) { throw new WrongUsageException("You didn't select a region with your wand."); } int ix = bounds[0]; int iy = bounds[1] - value; int iz = bounds[2]; int ax = bounds[3]; int ay = bounds[4] + value; int az = bounds[5]; WandItem.setBounds(player, ix, iy, iz, ax, ay, az); return; } else { throw new WrongUsageException("Missing parameters! /tc_wand expand <val>"); } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { // Pattern Matching? // 0 1 -> [strength] // 1 2 -> <entity> [strength] // 3 4 -> <x> <y> <z> [strength] // entities = PlayerSelector.matchEntities(sender, args[0], Entity.class); // if(args.length != 3) { // throw new CommandException("Wrong number of parameters: " + args.length + " given, 3 needed."); // } { BlockPos originPos = sender.getPosition(); CoordinateArg posX = CommandBase.parseCoordinate(originPos.getX(), args[0], false); CoordinateArg posY = CommandBase.parseCoordinate(originPos.getY(), args[1], false); CoordinateArg posZ = CommandBase.parseCoordinate(originPos.getZ(), args[2], false); BlockPos pos = new BlockPos(posX.getAmount(), posY.getAmount(), posZ.getAmount()); sender.getEntityWorld().createExplosion(null, pos.getX(), pos.getY(), pos.getZ(), 10f, false); } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if(args.length != 6) { throw new CommandException("Wrong number of parameters: " + args.length + " given, 6 needed."); } BlockPos originPos = sender.getPosition(); CoordinateArg minX = CommandBase.parseCoordinate(originPos.getX(), args[0], false); CoordinateArg minY = CommandBase.parseCoordinate(originPos.getY(), args[1], false); CoordinateArg minZ = CommandBase.parseCoordinate(originPos.getZ(), args[2], false); CoordinateArg maxX = CommandBase.parseCoordinate(originPos.getX(), args[3], false); CoordinateArg maxY = CommandBase.parseCoordinate(originPos.getY(), args[4], false); CoordinateArg maxZ = CommandBase.parseCoordinate(originPos.getZ(), args[5], false); int ix = Math.min((int)minX.getAmount(), (int)maxX.getAmount()); int iy = Math.min((int)minY.getAmount(), (int)maxY.getAmount()); int iz = Math.min((int)minZ.getAmount(), (int)maxZ.getAmount()); int ax = Math.max((int)minX.getAmount(), (int)maxX.getAmount()); int ay = Math.max((int)minY.getAmount(), (int)maxY.getAmount()); int az = Math.max((int)minZ.getAmount(), (int)maxZ.getAmount()); Invoke.trigger(new CommandSenderInvokeSource(sender), ix, iy, iz, ax, ay, az, EnumTriggerState.ON); }
@Override public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { if (args.length == 1) { return getListOfStringsFromIterableMatchingLastWord(args, commands); } else if (args.length >= 2) { for (CommandBase command : subCommands) { if (command.getCommandName().equalsIgnoreCase(args[0])) { return command.addTabCompletionOptions(commandSender, args); } } } return null; }
@Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { if (args.length != 4 || (!("add").equals(args[1]) && !("set").equals(args[1])) || (!("current").equals(args[2]) && !("max").equals(args[2]))) { throw new WrongUsageException(getCommandUsage(sender)); } EntityPlayerMP commandSender = CommandBase.getCommandSenderAsPlayer(sender); EntityPlayerMP player = CommandBase.getPlayer(sender, args[0]); ZSSPlayerInfo info = ZSSPlayerInfo.get(player); boolean max = ("max").equals(args[2]); boolean add = ("add").equals(args[1]); int mp = CommandBase.parseInt(args[3]); if (mp < 0 && !add) { throw new CommandException("commands.zssmagic.negative", args[2]); } if (add) { mp += (max ? info.getMaxMagic() : info.getCurrentMagic()); } if (max) { info.setMaxMagic(mp); mp = Math.round(info.getMaxMagic()); } else { info.setCurrentMagic(mp); mp = Math.round(info.getCurrentMagic()); } PlayerUtils.sendTranslatedChat(commandSender, "commands.zssmagic.success", player.getName(), args[2], mp); }
public List func_71558_b(ICommandSender p_71558_1_, String p_71558_2_) { String[] var3 = p_71558_2_.split(" ", -1); String var4 = var3[0]; if(var3.length == 1) { ArrayList var8 = new ArrayList(); Iterator var6 = this.field_71562_a.entrySet().iterator(); while(var6.hasNext()) { Entry var7 = (Entry)var6.next(); if(CommandBase.func_71523_a(var4, (String)var7.getKey()) && ((ICommand)var7.getValue()).func_71519_b(p_71558_1_)) { var8.add(var7.getKey()); } } return var8; } else { if(var3.length > 1) { ICommand var5 = (ICommand)this.field_71562_a.get(var4); if(var5 != null) { return var5.func_71516_a(p_71558_1_, func_71559_a(var3)); } } return null; } }
@SubscribeEvent public void onServerCommand(CommandEvent event){ EntityPlayerMP player; try { player = CommandBase.getCommandSenderAsPlayer(event.sender); } catch (PlayerNotFoundException e) { e.printStackTrace(); return; } String cmd = event.command.getCommandName(); for (String s : event.parameters) cmd += " " + s; GriefGuardian._dal.logAction( player, Actions.COMMAND, (int)Math.floor(player.posX), (int)Math.floor(player.posY), (int)Math.floor(player.posZ), null, cmd ); }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) throws CommandException { if (params.length != 1 && params.length != 2) throw error("openblocks.misc.command.invalid"); String playerName = params[0]; EntityPlayerMP player = CommandBase.getPlayer(server, sender, playerName); String effectName = (params.length > 1)? params[1] : null; IFlimFlamDescription meta; if (effectName == null) { meta = CollectionUtils.getRandom(FlimFlamRegistry.instance.getFlimFlams()); effectName = meta.name(); } else { meta = FlimFlamRegistry.instance.getFlimFlamByName(effectName); if (meta == null) throw error("openblocks.misc.command.no_flim_flam"); } if (meta.action().execute(player)) { respond(sender, "openblocks.misc.command.flim_flam_source", playerName, effectName); if (!player.equals(sender)) respond(player, "openblocks.misc.command.flim_flam_target"); } else throw error("openblocks.misc.command.flim_flam_failed"); }
private static List<IBlockState> parseBlockDesc(String blockDesc) throws Exception { final List<String> blockDescParts = Splitter.on('#').splitToList(blockDesc); final String blockId = blockDescParts.get(0); Block block = Block.REGISTRY.getObject(new ResourceLocation(blockId)); if (block == Blocks.AIR) { Log.warn("Can't find block %s", blockId); return Collections.emptyList(); } if (blockDescParts.size() == 1) { return block.getBlockState().getValidStates(); } else { final String stateDesc = blockDescParts.get(1); return ImmutableList.of(CommandBase.convertArgToBlockState(block, stateDesc)); } }
public static Coord getLocation(ICommandContext context, List<String> args) throws NumberInvalidException, PlayerNotFoundException{ ArgumentParser ap = new ArgumentParser(args); Coord pos = context.getPos(); if(ap.match(0, "here") || ap.match(0, "nearby")){ return new Coord((int) pos.getX(), 0, (int) pos.getZ()); } else { try { int x = CommandBase.parseInt(ap.get(0)); int z = CommandBase.parseInt(ap.get(1)); return new Coord(x, 0, z); } catch (NumberInvalidException e) { context.sendMessage("Failure: Invalid Coords: X Z", MessageType.ERROR); throw(e); } } }
@HarshenCommand public static void pontuslevel(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { EntityPlayer player = args.length == 1 ? CommandBase.getCommandSenderAsPlayer(sender) : CommandBase.getPlayer(server, sender, args[0]); String rawInt = args[args.length == 1 ? 0 : 1]; int i = CommandBase.parseInt(rawInt); player.getEntityData().setInteger("PontusBiomeLevel", i); HarshenNetwork.sendToPlayer(player, new MessagePacketPlayerHasAccess(player)); HandlerPontusAllowed.setAllowed(player, i); message(sender, "success", player.getName(), i); }
@HarshenCommandTabList public static List<String> loadstructure_tabList(MinecraftServer server, ICommandSender sender, String[] args, BlockPos targetPos) { ArrayList<String> stringList = new ArrayList<>(); if(args.length == 1) for(ICommandStructure structure : ICommandStructure.ALL_STRUCTURES) stringList.add(structure.structureName()); else if(args.length < 5) stringList.addAll(CommandBase.getTabCompletionCoordinate(args, 1, targetPos)); return stringList; }
@Override protected void keyTyped(char typedChar, int keyCode) throws IOException { if(keyCode == Keyboard.KEY_TAB) { this.textInput.setMaxStringLength(60); ArrayList<String> stringList = new ArrayList<>(); if(dictonaryList.isEmpty()) { stringList.addAll(CommandBase.getListOfStringsMatchingLastWord(HarshenUtils.listOf(this.textInput.getText()), Block.REGISTRY.getKeys())); for(String s : HarshenUtils.getAllOreDictionaryList()) for(ItemStack stack : OreDictionary.getOres(s)) if(Block.getBlockFromItem(stack.getItem()) != Blocks.AIR) stringList.add(s); dictonaryList = CommandBase.getListOfStringsMatchingLastWord(HarshenUtils.listOf(this.textInput.getText()), stringList); } if(!dictonaryList.isEmpty()) this.textInput.setText(dictonaryList.get(timeOver++%dictonaryList.size())); } else { timeOver = 0; dictonaryList.clear(); } if(keyCode == Keyboard.KEY_RETURN) closeGui(); this.textInput.textboxKeyTyped(typedChar, keyCode); super.keyTyped(typedChar, keyCode); }
/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 4) { throw new WrongUsageException("commands.teleport.usage", new Object[0]); } else { Entity entity = getEntity(server, sender, args[0]); if (entity.world != null) { int i = 4096; Vec3d vec3d = sender.getPositionVector(); int j = 1; CommandBase.CoordinateArg commandbase$coordinatearg = parseCoordinate(vec3d.xCoord, args[j++], true); CommandBase.CoordinateArg commandbase$coordinatearg1 = parseCoordinate(vec3d.yCoord, args[j++], -4096, 4096, false); CommandBase.CoordinateArg commandbase$coordinatearg2 = parseCoordinate(vec3d.zCoord, args[j++], true); Entity entity1 = sender.getCommandSenderEntity() == null ? entity : sender.getCommandSenderEntity(); CommandBase.CoordinateArg commandbase$coordinatearg3 = parseCoordinate(args.length > j ? (double)entity1.rotationYaw : (double)entity.rotationYaw, args.length > j ? args[j] : "~", false); ++j; CommandBase.CoordinateArg commandbase$coordinatearg4 = parseCoordinate(args.length > j ? (double)entity1.rotationPitch : (double)entity.rotationPitch, args.length > j ? args[j] : "~", false); doTeleport(entity, commandbase$coordinatearg, commandbase$coordinatearg1, commandbase$coordinatearg2, commandbase$coordinatearg3, commandbase$coordinatearg4); notifyCommandListener(sender, this, "commands.teleport.success.coordinates", new Object[] {entity.getName(), Double.valueOf(commandbase$coordinatearg.getResult()), Double.valueOf(commandbase$coordinatearg1.getResult()), Double.valueOf(commandbase$coordinatearg2.getResult())}); } } }
@Override public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) { if (args.length <= 1) return CommandBase.getListOfStringsMatchingLastWord(args, getCommandNames()); String[] players = WorldBorder.SERVER.getAllUsernames(); return CommandBase.getListOfStringsMatchingLastWord(args, players); }
/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 4) { throw new WrongUsageException("commands.teleport.usage", new Object[0]); } else { Entity entity = getEntity(server, sender, args[0]); if (entity.worldObj != null) { int i = 4096; Vec3d vec3d = sender.getPositionVector(); int j = 1; CommandBase.CoordinateArg commandbase$coordinatearg = parseCoordinate(vec3d.xCoord, args[j++], true); CommandBase.CoordinateArg commandbase$coordinatearg1 = parseCoordinate(vec3d.yCoord, args[j++], -4096, 4096, false); CommandBase.CoordinateArg commandbase$coordinatearg2 = parseCoordinate(vec3d.zCoord, args[j++], true); Entity entity1 = sender.getCommandSenderEntity() == null ? entity : sender.getCommandSenderEntity(); CommandBase.CoordinateArg commandbase$coordinatearg3 = parseCoordinate(args.length > j ? (double)entity1.rotationYaw : (double)entity.rotationYaw, args.length > j ? args[j] : "~", false); ++j; CommandBase.CoordinateArg commandbase$coordinatearg4 = parseCoordinate(args.length > j ? (double)entity1.rotationPitch : (double)entity.rotationPitch, args.length > j ? args[j] : "~", false); doTeleport(entity, commandbase$coordinatearg, commandbase$coordinatearg1, commandbase$coordinatearg2, commandbase$coordinatearg3, commandbase$coordinatearg4); notifyCommandListener(sender, this, "commands.teleport.success.coordinates", new Object[] {entity.getName(), Double.valueOf(commandbase$coordinatearg.getResult()), Double.valueOf(commandbase$coordinatearg1.getResult()), Double.valueOf(commandbase$coordinatearg2.getResult())}); } } }
public static String makeListReadable(Collection<?> list){ List<String> strings = Lists.newArrayList(); for(Object obj : list){ strings.add(""+obj.toString()); } return CommandBase.joinNiceStringFromCollection(strings); }
@Override public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) { if (sender instanceof EntityPlayer) { return args.length == 1 ? CommandBase.getListOfStringsMatchingLastWord(args,FriendHandler.getFriendStringListFor(server, ((EntityPlayer)sender).getUniqueID())) : null; } return args.length == 1 ? CommandBase.getListOfStringsMatchingLastWord(args, server.getAllUsernames()) : null; }
@Override public void processSubCommand(final @Nonnull ICommandSender sender, final @Nonnull String[] args) { final String joint = CommandBase.func_82360_a(sender, args, 0); GuiMain.setContentId(joint); CurrentMode.instance.setState(CurrentMode.State.PREVIEW, false); if (!(WFrame.getCurrent() instanceof GuiMain)) Client.openEditor(); }
@EventHandler public void onServerStarting(FMLServerStartingEvent event) { List<CommandBase> childCommands = Lists.newArrayList(); MinecraftForge.EVENT_BUS.post(new RegisterShearMadnessCommandEvent(childCommands)); event.registerServerCommand(new ShearMadnessCommand(childCommands)); }
@SubscribeEvent public void onCommandSentEvent(CommandEvent event) { if (event.getCommand() instanceof CommandClearInventory) { if (event.getParameters().length <= 1) { EntityPlayerMP entityplayermp = null; try { entityplayermp = event.getParameters().length == 0 ? CommandBase.getCommandSenderAsPlayer(event.getSender()) : CommandBase.getPlayer(FMLCommonHandler.instance().getMinecraftServerInstance(), event.getSender(), event.getParameters()[0]); } catch (Throwable var9) { return; } PlayerAether playerAether = PlayerAether.get(entityplayermp); if (playerAether != null) { if (playerAether.accessories.getFieldCount() != 0) { playerAether.accessories.clear(); CommandBase.notifyCommandListener(entityplayermp, event.getCommand(), "Cleared the accessories of " + entityplayermp.getName(), new Object[] {}); } } } } }
/** * Automated way to output command's and sub-commands' usage messages. * */ @Override public String getCommandUsage(ICommandSender sender) { String message = I18n.format(this.getHelp()) + "\n\n"; for (CommandBase command : this.subcommands.values()) { message += I18n.format(command.getCommandUsage(sender)).split("\n")[0] + "\n"; } return message.trim(); }
@Override public void executeCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { String filename = args[0]; int tick = CommandBase.parseInt(args[1], 0); Record record = CommandRecord.getRecord(filename); if (tick < 0 || tick >= record.actions.size()) { throw new CommandException("record.tick_out_range", tick, record.actions.size() - 1); } this.removeActions(args, record, tick); }
/** * Remove action(s) from given record at given tick */ private void removeActions(String[] args, Record record, int tick) throws CommandException { if (args.length > 2) { int index = CommandBase.parseInt(args[2]); List<Action> actions = record.actions.get(tick); if (actions == null) { throw new CommandException("record.already_empty", args[1], args[0]); } if (index < 0 && index >= actions.size()) { throw new CommandException("record.index_out_range", index, actions.size() - 1); } /* Remove action at given tick */ if (actions.size() <= 1) { record.actions.set(tick, null); } else { actions.remove(index); } } else { /* Remove all actions at tick */ record.actions.set(tick, null); } record.dirty = true; }
@Override public void executeCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { String filename = args[0]; int tick = CommandBase.parseInt(args[1], 0); Record record = CommandRecord.getRecord(filename); if (tick < 0 || tick >= record.actions.size()) { throw new CommandException("record.tick_out_range", tick); } if (!Action.TYPES.containsKey(args[2])) { throw new CommandException("record.wrong_action", args[2]); } try { Action action = Action.fromType(Action.TYPES.get(args[2]).byteValue()); if (args.length > 3) { action.fromNBT(JsonToNBT.getTagFromJson(CommandMorph.mergeArgs(args, 3))); } record.addAction(tick, action); record.dirty = true; } catch (Exception e) { throw new CommandException("record.add", args[2], e.getMessage()); } }
/** * Register a command to be automatically be registered on server startup * * @param command * the {@link CommandBase} to be registered */ public static void registerCommand(CommandBase command) { if (!commands.contains(command)) { echo("Registering chat command: " + command.getCommandName()); commands.add(command); } else { echo("Chat command already registered: " + command.getCommandName()); } }
/** * Unregister a command so it isn't added on server startup * * @param command * the {@link CommandBase} to be removed */ public static void unregisterCommand(CommandBase command) { if (commands.contains(command)) { echo("Unegistering chat command: " + command.getCommandName()); commands.remove(command); } else { echo("Chat command already unregistered: " + command.getCommandName()); } }
@SuppressWarnings("javadoc") @EventHandler public static final void addCommandsToServer(FMLServerStartingEvent evt) { echo("Loading server commands"); for (CommandBase command : commands) { evt.registerServerCommand(command); debug("Command registered to server: " + command.getCommandName()); } }
@Override public List addTabCompletionOptions(ICommandSender sender, String[] args) { if (args.length <= 1) return CommandBase.getListOfStringsFromIterableMatchingLastWord(args, getCommandNames()); String[] players = WorldBorder.SERVER.getAllUsernames(); return CommandBase.getListOfStringsMatchingLastWord(args, players); }
static EnumDifficulty getDifficultyFromCommand(String str) throws CommandException { if (str.equalsIgnoreCase("peaceful") || str.equalsIgnoreCase("p")) { return EnumDifficulty.PEACEFUL; } if (str.equalsIgnoreCase("easy") || str.equalsIgnoreCase("e")) { return EnumDifficulty.EASY; } if (str.equalsIgnoreCase("normal") || str.equalsIgnoreCase("n")) { return EnumDifficulty.NORMAL; } if (str.equalsIgnoreCase("hard") || str.equalsIgnoreCase("h")) { return EnumDifficulty.HARD; } return EnumDifficulty.getDifficultyEnum(CommandBase.parseInt(str, 0, 3)); }