/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 1 && args[0].length() > 0) { GameProfile gameprofile = server.getPlayerList().getOppedPlayers().getGameProfileFromName(args[0]); if (gameprofile == null) { throw new CommandException("commands.deop.failed", new Object[] {args[0]}); } else { server.getPlayerList().removeOp(gameprofile); notifyCommandListener(sender, this, "commands.deop.success", new Object[] {args[0]}); } } else { throw new WrongUsageException("commands.deop.usage", new Object[0]); } }
/** * Callback when the command is invoked */ public void processCommand(ICommandSender sender, String[] args) throws CommandException { if (args.length == 1 && args[0].length() > 0) { MinecraftServer minecraftserver = MinecraftServer.getServer(); GameProfile gameprofile = minecraftserver.getConfigurationManager().getOppedPlayers().getGameProfileFromName(args[0]); if (gameprofile == null) { throw new CommandException("commands.deop.failed", new Object[] {args[0]}); } else { minecraftserver.getConfigurationManager().removeOp(gameprofile); notifyOperators(sender, this, "commands.deop.success", new Object[] {args[0]}); } } else { throw new WrongUsageException("commands.deop.usage", new Object[0]); } }
/** * Callback when the command is invoked */ public void processCommand(ICommandSender sender, String[] args) throws CommandException { if (args.length < 2) { throw new WrongUsageException("commands.tellraw.usage", new Object[0]); } else { EntityPlayer entityplayer = getPlayer(sender, args[0]); String s = buildString(args, 1); try { IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s); entityplayer.addChatMessage(ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayer)); } catch (JsonParseException jsonparseexception) { Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception); throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()}); } } }
/** * Callback when the command is invoked */ public void processCommand(ICommandSender sender, String[] args) throws CommandException { if (args.length == 1 && args[0].length() > 0) { MinecraftServer minecraftserver = MinecraftServer.getServer(); GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(args[0]); if (gameprofile == null) { throw new CommandException("commands.op.failed", new Object[] {args[0]}); } else { minecraftserver.getConfigurationManager().addOp(gameprofile); notifyOperators(sender, this, "commands.op.success", new Object[] {args[0]}); } } else { throw new WrongUsageException("commands.op.usage", new Object[0]); } }
private void handleTracking(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length != 3) { throw new WrongUsageException("commands.forge.usage.tracking"); } String type = args[1]; int duration = parseInt(args[2], 1, 60); if ("te".equals(type)) { doTurnOnTileEntityTracking(server, sender, duration); } else { throw new WrongUsageException("commands.forge.usage.tracking"); } }
/** * Callback when the command is invoked */ public void processCommand(ICommandSender sender, String[] args) throws CommandException { BlockPos blockpos; if (args.length == 0) { blockpos = getCommandSenderAsPlayer(sender).getPosition(); } else { if (args.length != 3 || sender.getEntityWorld() == null) { throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]); } blockpos = parseBlockPos(sender, args, 0, true); } sender.getEntityWorld().setSpawnPoint(blockpos); MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos)); notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())}); }
/** * Callback when the command is invoked */ public void processCommand(ICommandSender sender, String[] args) throws CommandException { if (args.length == 1 && args[0].length() > 1) { Matcher matcher = CommandBanIp.field_147211_a.matcher(args[0]); if (matcher.matches()) { MinecraftServer.getServer().getConfigurationManager().getBannedIPs().removeEntry(args[0]); notifyOperators(sender, this, "commands.unbanip.success", new Object[] {args[0]}); } else { throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]); } } else { throw new WrongUsageException("commands.unbanip.usage", new Object[0]); } }
/** * Callback when the command is invoked */ public void processCommand(ICommandSender sender, String[] args) throws CommandException { if (args.length == 1 && args[0].length() > 0) { MinecraftServer minecraftserver = MinecraftServer.getServer(); GameProfile gameprofile = minecraftserver.getConfigurationManager().getBannedPlayers().isUsernameBanned(args[0]); if (gameprofile == null) { throw new CommandException("commands.unban.failed", new Object[] {args[0]}); } else { minecraftserver.getConfigurationManager().getBannedPlayers().removeEntry(gameprofile); notifyOperators(sender, this, "commands.unban.success", new Object[] {args[0]}); } } else { throw new WrongUsageException("commands.unban.usage", new Object[0]); } }
/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 2) { throw new WrongUsageException("commands.tellraw.usage", new Object[0]); } else { EntityPlayer entityplayer = getPlayer(server, sender, args[0]); String s = buildString(args, 1); try { ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s); entityplayer.addChatMessage(TextComponentUtils.processComponent(sender, itextcomponent, entityplayer)); } catch (JsonParseException jsonparseexception) { /** * Convert a JsonParseException into a user-friendly exception */ throw toSyntaxException(jsonparseexception); } } }
/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 1 && args[0].length() > 1) { Matcher matcher = CommandBanIp.IP_PATTERN.matcher(args[0]); if (matcher.matches()) { server.getPlayerList().getBannedIPs().removeEntry(args[0]); notifyCommandListener(sender, this, "commands.unbanip.success", new Object[] {args[0]}); } else { throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]); } } else { throw new WrongUsageException("commands.unbanip.usage", new Object[0]); } }
private void setSteps(IIfEntryStore store, ICommandSender sender, String act, String res) throws CommandException { int steps; switch (act) { case "unlock": steps = PurMag.INSTANCE.getIfRegistry().getEntry(res).getSteps().size(); break; case "lock": steps = 0; break; default: throw new WrongUsageException(getUsage(sender)); } store.setSteps(res, steps); }
private void spawn(ICommandSender sender, String[] args) throws CommandException { if (!(sender instanceof EntityPlayer)) { return; } if (args.length != 2) { throw new WrongUsageException("commands.nemesis_system.usage"); } EntityPlayer player = getCommandSenderAsPlayer(sender); World world = player.world; INemesisRegistry registry = NemesisRegistryProvider.get(world); NemesisEntry nemesis = registry.getByName(args[1]); SpawnHandler.spawnNemesis(world, player.getPosition(), nemesis); }
/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 1 && args[0].length() > 0) { GameProfile gameprofile = server.getPlayerProfileCache().getGameProfileForUsername(args[0]); if (gameprofile == null) { throw new CommandException("commands.op.failed", new Object[] {args[0]}); } else { server.getPlayerList().addOp(gameprofile); notifyCommandListener(sender, this, "commands.op.success", new Object[] {args[0]}); } } else { throw new WrongUsageException("commands.op.usage", new Object[0]); } }
private void gui(ICommandSender sender, String[] args) throws CommandException { if (!(sender instanceof EntityPlayer)) { return; } EntityPlayerMP player = getCommandSenderAsPlayer(sender); if (args.length == 1) { NemesisSystem.NETWORK.sendTo(new MessageOpenNemesisGui(player), player); return; } if (args.length == 2) { NemesisEntry nemesis = NemesisRegistryProvider.get(player.world).getByName(args[1]); NemesisKnowledge knowledge = DiscoveryUtil.getGetPlayerKnowledgeOfNemesis(player, nemesis.getId()); if (knowledge == null) { knowledge = new NemesisKnowledge(); } NemesisSystem.NETWORK.sendTo(new MessageOpenNemesisDetailsGui(nemesis, knowledge), player); return; } throw new WrongUsageException("commands.nemesis_system.usage"); }
/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { BlockPos blockpos; if (args.length == 0) { blockpos = getCommandSenderAsPlayer(sender).getPosition(); } else { if (args.length != 3 || sender.getEntityWorld() == null) { throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]); } blockpos = parseBlockPos(sender, args, 0, true); } sender.getEntityWorld().setSpawnPoint(blockpos); server.getPlayerList().sendPacketToAllPlayers(new SPacketSpawnPosition(blockpos)); notifyCommandListener(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())}); }
/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 2) { throw new WrongUsageException("commands.tellraw.usage", new Object[0]); } else { EntityPlayer entityplayer = getPlayer(server, sender, args[0]); String s = buildString(args, 1); try { ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s); entityplayer.addChatMessage(TextComponentUtils.processComponent(sender, itextcomponent, entityplayer)); } catch (JsonParseException jsonparseexception) { throw toSyntaxException(jsonparseexception); } } }
private void create(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length != 3) { throw new WrongUsageException("commands.nemesis_system.usage"); } int x, z, dimension; if (sender instanceof EntityPlayer) { EntityPlayer player = getCommandSenderAsPlayer(sender); x = player.getPosition().getX(); z = player.getPosition().getZ(); dimension = player.dimension; } else { x = 0; z = 0; dimension = 0; } NemesisEntry nemesis = NemesisBuilder .build(sender.getEntityWorld(), args[1], sender.getEntityWorld().rand.nextBoolean(), dimension, i(args[2]), x, z); nemesis.register(server.getWorld(senderDimId(sender))); notifyCommandListener(sender, this, "commands.nemesis_system.success.create", nemesis.toString()); }
/** * Callback for when the command is executed */ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 1 && args[0].length() > 0) { GameProfile gameprofile = server.getPlayerList().getBannedPlayers().getBannedProfile(args[0]); if (gameprofile == null) { throw new CommandException("commands.unban.failed", new Object[] {args[0]}); } else { server.getPlayerList().getBannedPlayers().removeEntry(gameprofile); notifyCommandListener(sender, this, "commands.unban.success", new Object[] {args[0]}); } } else { throw new WrongUsageException("commands.unban.usage", new Object[0]); } }
@Override public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 2) { final EntityPlayer player = getPlayer(server, sender, args[0]); final String stage = args[1]; if (!PlayerDataHandler.getStageData(player).hasUnlockedStage(stage)) { throw new CommandException("commands.gamestage.check.failure", new Object[] { player.getDisplayName(), stage }); } notifyCommandListener(sender, this, "commands.gamestage.check.success", new Object[] { player.getDisplayName(), stage }); } else { throw new WrongUsageException("commands.gamestage.check.usage", new Object[0]); } }
@Override public void execute (MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 2) { final EntityPlayer player = getPlayer(server, sender, args[0]); final String stageName = args[1]; PlayerDataHandler.getStageData(player).unlockStage(stageName); if (player instanceof EntityPlayerMP) { GameStages.NETWORK.sendTo(new PacketStage(stageName, true), (EntityPlayerMP) player); } player.sendMessage(new TextComponentTranslation("commands.gamestage.add.target", stageName)); if (player != sender) { sender.sendMessage(new TextComponentTranslation("commands.gamestage.add.sender", stageName, player.getDisplayNameString())); } } else { throw new WrongUsageException("commands.gamestage.add.usage", new Object[0]); } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { try { EntityPlayerMP entityplayermp = args.length > 0 ? getPlayer(server, sender, args[0]) : getCommandSenderAsPlayer(sender); entityplayermp.getCapability(TF2weapons.PLAYER_CAP, null).highestBossLevel.clear(); Chunk chunk=entityplayermp.world.getChunkFromBlockCoords(entityplayermp.getPosition()); int australium=0; for(int x=0;x<16;x++){ for(int y=0;y<128;y++){ for(int z=0;z<16;z++){ if(chunk.getBlockState(x, y, z).getBlock()==TF2weapons.blockAustraliumOre) australium++; } } } notifyCommandListener(sender, this, "commands.resetbossstat.success",entityplayermp.getName()); } catch (Exception e) { throw new WrongUsageException(getUsage(sender), new Object[0]); } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { 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]; BlockPos pos = GlobalVariableManager.getInstance().getPos(varName); ItemStack stack = GlobalVariableManager.getInstance().getItem(varName); NetworkHandler.sendTo(new PacketCommandGetGlobalVariableOutput(varName, pos, stack), (EntityPlayerMP) sender); } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length != 4) throw new WrongUsageException("command.deliverAmazon.args"); String varName = args[0].startsWith("#") ? args[0].substring(1) : args[0]; BlockPos newPos = new BlockPos(parseInt(args[1]), parseInt(args[2]), parseInt(args[3])); GlobalVariableManager.getInstance().set(varName, newPos); sender.sendMessage(new TextComponentTranslation("command.setGlobalVariable.output", varName, newPos.getX(), newPos.getY(), newPos.getZ())); }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 1) throw new WrongUsageException("commands.incantation.usage"); if (sender.getCommandSenderEntity() == null) return; final String command = args[0]; if (ModCommands.commands.containsKey(command)) { ModCommands.commands.get(command).cast(server, sender, args); } else { throw new CommandException("commands.incantation.notFound", sender.getName()); } }