Java Code Examples for net.minecraft.command.ICommandSender

The following are top voted examples for showing how to use net.minecraft.command.ICommandSender. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: World-Border   File: CmdBypasslist.java   View source code 6 votes vote down vote up
@Override
public void execute(final ICommandSender sender, EntityPlayerMP player, List<String> params, String worldName)
{
    final UUID[] uuids = Config.getPlayerBypassList();
    if (uuids.length == 0)
    {
        Util.chat(sender, "Players with border bypass enabled: <none>");
        return;
    }

    try
    {
        String[] names = Profiles.fetchNames(uuids);
        String   list  = Arrays.toString(names);

        Util.chat(sender, "Players with border bypass enabled: " + list);
    }
    catch (Exception ex)
    {
        sendErrorAndHelp(sender, "Failed to look up names for the UUIDs in the border bypass list: " + ex.getMessage());
    }
}
 
Example 2
Project: BaseClient   File: CommandWhitelist.java   View source code 6 votes vote down vote up
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, new String[] {"on", "off", "list", "add", "remove", "reload"});
    }
    else
    {
        if (args.length == 2)
        {
            if (args[0].equals("remove"))
            {
                return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getConfigurationManager().getWhitelistedPlayerNames());
            }

            if (args[0].equals("add"))
            {
                return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getPlayerProfileCache().getUsernames());
            }
        }

        return null;
    }
}
 
Example 3
Project: CustomWorldGen   File: CommandScoreboard.java   View source code 6 votes vote down vote up
protected void resetPlayerScore(ICommandSender sender, String[] p_184912_2_, int p_184912_3_, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    String s = getEntityName(server, sender, p_184912_2_[p_184912_3_++]);

    if (p_184912_2_.length > p_184912_3_)
    {
        ScoreObjective scoreobjective = this.convertToObjective(p_184912_2_[p_184912_3_++], false, server);
        scoreboard.removeObjectiveFromEntity(s, scoreobjective);
        notifyCommandListener(sender, this, "commands.scoreboard.players.resetscore.success", new Object[] {scoreobjective.getName(), s});
    }
    else
    {
        scoreboard.removeObjectiveFromEntity(s, (ScoreObjective)null);
        notifyCommandListener(sender, this, "commands.scoreboard.players.reset.success", new Object[] {s});
    }
}
 
Example 4
Project: Backmemed   File: CommandPardonIp.java   View source code 6 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 5
Project: Backmemed   File: CommandScoreboard.java   View source code 6 votes vote down vote up
protected void listObjectives(ICommandSender sender, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    Collection<ScoreObjective> collection = scoreboard.getScoreObjectives();

    if (collection.isEmpty())
    {
        throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]);
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.DARK_GREEN);
        sender.addChatMessage(textcomponenttranslation);

        for (ScoreObjective scoreobjective : collection)
        {
            sender.addChatMessage(new TextComponentTranslation("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.getName(), scoreobjective.getDisplayName(), scoreobjective.getCriteria().getName()}));
        }
    }
}
 
Example 6
Project: DecompiledMinecraft   File: CommandSetDefaultSpawnpoint.java   View source code 6 votes vote down vote up
/**
 * 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())});
}
 
Example 7
Project: World-Border   File: CmdDynmapmsg.java   View source code 6 votes vote down vote up
@Override
public void execute(ICommandSender sender, EntityPlayerMP player, List<String> params, String worldName)
{
    StringBuilder message = new StringBuilder();
    boolean first = true;
    for (String param : params)
    {
        if (!first)
            message.append(" ");
        message.append(param);
        first = false;
    }

    Config.setDynmapMessage(message.toString());

    if (player != null)
        cmdStatus(sender);
}
 
Example 8
Project: CustomWorldGen   File: CommandAchievement.java   View source code 6 votes vote down vote up
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
    if (args.length == 1)
    {
        /**
         * Returns a List of strings (chosen from the given strings) which the last word in the given string array
         * is a beginning-match for. (Tab completion).
         */
        return getListOfStringsMatchingLastWord(args, new String[] {"give", "take"});
    }
    else if (args.length != 2)
    {
        return args.length == 3 ? getListOfStringsMatchingLastWord(args, server.getAllUsernames()) : Collections.<String>emptyList();
    }
    else
    {
        List<String> list = Lists.<String>newArrayList();

        for (StatBase statbase : AchievementList.ACHIEVEMENTS)
        {
            list.add(statbase.statId);
        }

        return getListOfStringsMatchingLastWord(args, list);
    }
}
 
Example 9
Project: BaseClient   File: CommandScoreboard.java   View source code 6 votes vote down vote up
protected void func_175779_n(ICommandSender p_175779_1_, String[] p_175779_2_, int p_175779_3_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    String s = getPlayerName(p_175779_1_, p_175779_2_[p_175779_3_++]);

    if (s.length() > 40)
    {
        throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
    }
    else
    {
        ScoreObjective scoreobjective = this.getObjective(p_175779_2_[p_175779_3_], false);

        if (scoreobjective.getCriteria() != IScoreObjectiveCriteria.TRIGGER)
        {
            throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
        }
        else
        {
            Score score = scoreboard.getValueFromObjective(s, scoreobjective);
            score.setLocked(false);
            notifyOperators(p_175779_1_, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
        }
    }
}
 
Example 10
Project: Backmemed   File: CommandDeOp.java   View source code 6 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 11
Project: NemesisSystem   File: NemesisSystemCommand.java   View source code 6 votes vote down vote up
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);
}
 
Example 12
Project: DecompiledMinecraft   File: CommandSetDefaultSpawnpoint.java   View source code 6 votes vote down vote up
/**
 * 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())});
}
 
Example 13
Project: DecompiledMinecraft   File: CommandWhitelist.java   View source code 6 votes vote down vote up
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, new String[] {"on", "off", "list", "add", "remove", "reload"});
    }
    else
    {
        if (args.length == 2)
        {
            if (args[0].equals("remove"))
            {
                return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getConfigurationManager().getWhitelistedPlayerNames());
            }

            if (args[0].equals("add"))
            {
                return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getPlayerProfileCache().getUsernames());
            }
        }

        return null;
    }
}
 
Example 14
Project: StructPro   File: Evaluator.java   View source code 6 votes vote down vote up
/** Generate world region. Very high-weight for cpu-calculation resources command
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execGen(Variables vars, ICommandSender sender) {
    int size = vars.get(new String[]{"size", "s", "length", "radius", "r"}, 16);
    int startX = vars.get(new String[]{"startx", "sx"}, 0);
    int startZ = vars.get(new String[]{"startz", "sz"}, 0);
    boolean stop = vars.get(new String[]{"stop", "end", "finish"}, false);
    boolean skip = vars.get(new String[]{"skip"}, false);
    int progress = vars.get(new String[]{"progress"}, 0);
    int step = Math.min(Math.max(1, vars.get(new String[]{"step", "delta"}, 32)), 4096);
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "ยง4No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdGen(world, startX, startZ, step, size, stop, skip, progress));
}
 
Example 15
Project: BaseClient   File: CommandScoreboard.java   View source code 6 votes vote down vote up
protected void resetPlayers(ICommandSender p_147187_1_, String[] p_147187_2_, int p_147187_3_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    String s = getEntityName(p_147187_1_, p_147187_2_[p_147187_3_++]);

    if (p_147187_2_.length > p_147187_3_)
    {
        ScoreObjective scoreobjective = this.getObjective(p_147187_2_[p_147187_3_++], false);
        scoreboard.removeObjectiveFromEntity(s, scoreobjective);
        notifyOperators(p_147187_1_, this, "commands.scoreboard.players.resetscore.success", new Object[] {scoreobjective.getName(), s});
    }
    else
    {
        scoreboard.removeObjectiveFromEntity(s, (ScoreObjective)null);
        notifyOperators(p_147187_1_, this, "commands.scoreboard.players.reset.success", new Object[] {s});
    }
}
 
Example 16
Project: Backmemed   File: CommandPardonPlayer.java   View source code 6 votes vote down vote up
/**
 * 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]);
    }
}
 
Example 17
Project: CreeperHostGui   File: CommandInvite.java   View source code 6 votes vote down vote up
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, new String[]{"list", "add", "remove", "reload"});
    }
    else
    {
        if (args.length == 2)
        {
            if ("remove".equals(args[0]))
            {
                return getListOfStringsMatchingLastWord(args, server.getPlayerList().getWhitelistedPlayerNames());
            }

            if ("add".equals(args[0]))
            {
                return getListOfStringsMatchingLastWord(args, server.getPlayerProfileCache().getUsernames());
            }
        }

        return Collections.emptyList();
    }
}
 
Example 18
Project: BaseClient   File: CommandAchievement.java   View source code 6 votes vote down vote up
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, new String[] {"give", "take"});
    }
    else if (args.length != 2)
    {
        return args.length == 3 ? getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()) : null;
    }
    else
    {
        List<String> list = Lists.<String>newArrayList();

        for (StatBase statbase : StatList.allStats)
        {
            list.add(statbase.statId);
        }

        return getListOfStringsMatchingLastWord(args, list);
    }
}
 
Example 19
Project: BaseClient   File: CommandPublishLocalServer.java   View source code 5 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    String s = MinecraftServer.getServer().shareToLAN(WorldSettings.GameType.SURVIVAL, false);

    if (s != null)
    {
        notifyOperators(sender, this, "commands.publish.started", new Object[] {s});
    }
    else
    {
        notifyOperators(sender, this, "commands.publish.failed", new Object[0]);
    }
}
 
Example 20
Project: craftsman   File: Cube.java   View source code 5 votes vote down vote up
@Override
public void doCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {     
    FstPlayer player = new FstPlayer(sender);
    player.runIfAirOrBlockHeld(() -> {
        doCommandWithoutCheckingBlock(player, args); 
    });
}
 
Example 21
Project: BaseClient   File: CommandScoreboard.java   View source code 5 votes vote down vote up
protected void func_175781_o(ICommandSender p_175781_1_, String[] p_175781_2_, int p_175781_3_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    String s = getEntityName(p_175781_1_, p_175781_2_[p_175781_3_++]);

    if (s.length() > 40)
    {
        throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
    }
    else
    {
        ScoreObjective scoreobjective = this.getObjective(p_175781_2_[p_175781_3_++], false);

        if (!scoreboard.entityHasObjective(s, scoreobjective))
        {
            throw new CommandException("commands.scoreboard.players.test.notFound", new Object[] {scoreobjective.getName(), s});
        }
        else
        {
            int i = p_175781_2_[p_175781_3_].equals("*") ? Integer.MIN_VALUE : parseInt(p_175781_2_[p_175781_3_]);
            ++p_175781_3_;
            int j = p_175781_3_ < p_175781_2_.length && !p_175781_2_[p_175781_3_].equals("*") ? parseInt(p_175781_2_[p_175781_3_], i) : Integer.MAX_VALUE;
            Score score = scoreboard.getValueFromObjective(s, scoreobjective);

            if (score.getScorePoints() >= i && score.getScorePoints() <= j)
            {
                notifyOperators(p_175781_1_, this, "commands.scoreboard.players.test.success", new Object[] {Integer.valueOf(score.getScorePoints()), Integer.valueOf(i), Integer.valueOf(j)});
            }
            else
            {
                throw new CommandException("commands.scoreboard.players.test.failed", new Object[] {Integer.valueOf(score.getScorePoints()), Integer.valueOf(i), Integer.valueOf(j)});
            }
        }
    }
}
 
Example 22
Project: CustomWorldGen   File: CommandScoreboard.java   View source code 5 votes vote down vote up
protected void removeObjective(ICommandSender sender, String p_184905_2_, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    ScoreObjective scoreobjective = this.convertToObjective(p_184905_2_, false, server);
    scoreboard.removeObjective(scoreobjective);
    notifyCommandListener(sender, this, "commands.scoreboard.objectives.remove.success", new Object[] {p_184905_2_});
}
 
Example 23
Project: Backmemed   File: CommandSaveOff.java   View source code 5 votes vote down vote up
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    boolean flag = false;

    for (int i = 0; i < server.worldServers.length; ++i)
    {
        if (server.worldServers[i] != null)
        {
            WorldServer worldserver = server.worldServers[i];

            if (!worldserver.disableLevelSaving)
            {
                worldserver.disableLevelSaving = true;
                flag = true;
            }
        }
    }

    if (flag)
    {
        notifyCommandListener(sender, this, "commands.save.disabled", new Object[0]);
    }
    else
    {
        throw new CommandException("commands.save-off.alreadyOff", new Object[0]);
    }
}
 
Example 24
Project: CustomWorldGen   File: CommandStop.java   View source code 5 votes vote down vote up
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (server.worldServers != null)
    {
        notifyCommandListener(sender, this, "commands.stop.start", new Object[0]);
    }

    server.initiateShutdown();
}
 
Example 25
Project: CustomWorldGen   File: CommandBroadcast.java   View source code 5 votes vote down vote up
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length > 0 && args[0].length() > 0)
    {
        ITextComponent itextcomponent = getChatComponentFromNthArg(sender, args, 0, true);
        server.getPlayerList().sendChatMsg(new TextComponentTranslation("chat.type.announcement", new Object[] {sender.getDisplayName(), itextcomponent}));
    }
    else
    {
        throw new WrongUsageException("commands.say.usage", new Object[0]);
    }
}
 
Example 26
Project: DecompiledMinecraft   File: CommandSaveOn.java   View source code 5 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    MinecraftServer minecraftserver = MinecraftServer.getServer();
    boolean flag = false;

    for (int i = 0; i < minecraftserver.worldServers.length; ++i)
    {
        if (minecraftserver.worldServers[i] != null)
        {
            WorldServer worldserver = minecraftserver.worldServers[i];

            if (worldserver.disableLevelSaving)
            {
                worldserver.disableLevelSaving = false;
                flag = true;
            }
        }
    }

    if (flag)
    {
        notifyOperators(sender, this, "commands.save.enabled", new Object[0]);
    }
    else
    {
        throw new CommandException("commands.save-on.alreadyOn", new Object[0]);
    }
}
 
Example 27
Project: Bewitchment   File: CommandIncantation.java   View source code 5 votes vote down vote up
@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());
	}
}
 
Example 28
Project: World-Border   File: CmdHelp.java   View source code 5 votes vote down vote up
@Override
public void cmdStatus(ICommandSender sender)
{
    String commands = WorldBorder.COMMAND.getCommandNames().toString().replace(", ", C_DESC + ", " + C_CMD);
    Util.chat(sender, C_HEAD + "Commands: " + C_CMD + commands.substring(1, commands.length() - 1));
    Util.chat(sender, "Example, for info on \"set\" command: " + cmd(sender) + nameEmphasized() + C_CMD + "set");
    Util.chat(sender, C_HEAD + "For a full command example list, simply run the root " + cmd(sender) + C_HEAD + "command by itself with nothing specified.");
}
 
Example 29
Project: BaseClient   File: CommandSaveOn.java   View source code 5 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    MinecraftServer minecraftserver = MinecraftServer.getServer();
    boolean flag = false;

    for (int i = 0; i < minecraftserver.worldServers.length; ++i)
    {
        if (minecraftserver.worldServers[i] != null)
        {
            WorldServer worldserver = minecraftserver.worldServers[i];

            if (worldserver.disableLevelSaving)
            {
                worldserver.disableLevelSaving = false;
                flag = true;
            }
        }
    }

    if (flag)
    {
        notifyOperators(sender, this, "commands.save.enabled", new Object[0]);
    }
    else
    {
        throw new CommandException("commands.save-on.alreadyOn", new Object[0]);
    }
}
 
Example 30
Project: World-Border   File: CmdDenypearl.java   View source code 5 votes vote down vote up
@Override
public void execute(ICommandSender sender, EntityPlayerMP player, List<String> params, String worldName)
{
    Config.setDenyEnderpearl( strAsBool( params.get(0) ) );

    if (player != null)
    {
        Log.info(
            (Config.getDenyEnderpearl() ? "Enabled" : "Disabled")
            + " direct cancellation of ender pearls thrown past the border at the command of player \""
            + player.getDisplayName() + "\"."
        );
        cmdStatus(sender);
    }
}
 
Example 31
Project: VillagerTrades   File: ModCommand.java   View source code 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
	World world = sender.getEntityWorld();
	if (!world.isRemote)
	{

		if (args.length == 0)
		{
			for (Map.Entry<Integer, String> kvp : VillagerRegistryHelper.getProfessionIdsAndNamesSortedById())
			{
				sender.sendMessage(new TextComponentString(kvp.getKey() + ": " + kvp.getValue()));
			}
			return;
		}

		if (args.length == 2 && args[0].equals("profession"))
		{
			VillagerProfession profession = VillagerRegistryHelper.getProfession(args[1]);
			if (profession != null)
			{
				for (VillagerCareer career : new VTTVillagerProfession(profession).getCareers())
				{
					VTTVillagerCareer vttCareer = new VTTVillagerCareer(career);
					sender.sendMessage(new TextComponentString(vttCareer.getId() + ": " + vttCareer.getName()));
					sender.sendMessage(new TextComponentString("   " + vttCareer.getCareerLevels() + " levels"));
				}
			}
		}

	}
}
 
Example 32
Project: RenderPlayerMod-1.8.9   File: RenderPlayer.java   View source code 5 votes vote down vote up
public void processCommand(ICommandSender sender, String[] args) {
	if(args.length > 0) {
		if(args[0].equalsIgnoreCase("right")) {
		}

		if(args[0].equalsIgnoreCase("left")) {
		}
	}
	ChatHandler.send(RenderPlayerMod.getPrefix() + "&cUsage: /renderplayer <right|left>");
	return;
}
 
Example 33
Project: connor41-etfuturum2   File: SetPlayerModelCommand.java   View source code 5 votes vote down vote up
@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 34
Project: MeeCreeps   File: CommandTestApi.java   View source code 5 votes vote down vote up
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
    if (sender instanceof EntityPlayerMP) {
        return ((EntityPlayerMP) sender).capabilities.isCreativeMode && sender.canUseCommand(2, "");
    } else {
        return sender.canUseCommand(2, "creep_test");
    }
}
 
Example 35
Project: DecompiledMinecraft   File: CommandEmote.java   View source code 5 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length <= 0)
    {
        throw new WrongUsageException("commands.me.usage", new Object[0]);
    }
    else
    {
        IChatComponent ichatcomponent = getChatComponentFromNthArg(sender, args, 0, !(sender instanceof EntityPlayer));
        MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentTranslation("chat.type.emote", new Object[] {sender.getDisplayName(), ichatcomponent}));
    }
}
 
Example 36
Project: StructPro   File: Evaluator.java   View source code 5 votes vote down vote up
/** Paste something to the world
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execPaste(Variables vars, ICommandSender sender) {
    Random random = new Random();
    String name = vars.get(new String[]{"name"}, "");
    UBlockPos where = new UBlockPos(0, 0, 0);
    if (sender instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        where = new UBlockPos((int)player.posX, (int)player.posY, (int)player.posZ);
    }
    int posX = vars.get(new String[]{"posx", "px", "x"}, where.getX());
    int posY = vars.get(new String[]{"posy", "py", "y"}, where.getY());
    int posZ = vars.get(new String[]{"posz", "pz", "z"}, where.getZ());
    int rotateX = vars.get(new String[]{"rotatex", "rotx", "rx"}, 0);
    int rotateY = vars.get(new String[]{"rotatey", "roty", "ry"}, random.nextInt() % 4);
    int rotateZ = vars.get(new String[]{"rotatez", "rotz", "rz"}, 0);
    boolean flipX = vars.get(new String[]{"flipx", "fx"},  random.nextBoolean());
    boolean flipY = vars.get(new String[]{"flipy", "fy"}, false);
    boolean flipZ = vars.get(new String[]{"flipz", "fz"}, random.nextBoolean());
    boolean isVillage = vars.get(new String[]{"village", "town", "city"}, false);
    boolean isInsecure = vars.get(new String[]{"insecure"}, false);
    posY = vars.get(new String[]{"auto"}, false) ? 0 : posY;
    if (vars.get(new String[]{"wand"}, false) && sender instanceof EntityPlayer && wand.containsKey(sender)) {
        UBlockPos pos = wand.get(sender).getValue();
        posX = pos.getX(); posY = pos.getY(); posZ = pos.getZ();
    }
    String worldName = vars.get(new String[]{"world"});
    UWorld world = worldName == null ? new UWorld(sender.getEntityWorld()) : UWorld.getWorld(worldName);
    if (world == null) {
        feedback(sender, "No matching world");
        return;
    }
    feedback(sender, Evaluator.cmdPaste(world, name, posX, posY, posZ, rotateX, rotateY, rotateZ, flipX, flipY, flipZ, isVillage, isInsecure));
}
 
Example 37
Project: CustomWorldGen   File: CommandMessage.java   View source code 5 votes vote down vote up
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
    /**
     * Returns a List of strings (chosen from the given strings) which the last word in the given string array is a
     * beginning-match for. (Tab completion).
     */
    return getListOfStringsMatchingLastWord(args, server.getAllUsernames());
}
 
Example 38
Project: World-Border   File: CmdKnockback.java   View source code 5 votes vote down vote up
@Override
public void cmdStatus(ICommandSender sender)
{
    double kb = Config.getKnockBack();
    if (kb < 1)
        Util.chat(sender, C_HEAD + "Knockback is set to 0, disabling border enforcement.");
    else
        Util.chat(sender, C_HEAD + "Knockback is set to " + kb + " blocks inside the border.");
}
 
Example 39
Project: Ye-Olde-Chat   File: CommandSetRoleplayMode.java   View source code 5 votes vote down vote up
@Override
public void processCommand(ICommandSender par1ICommandSender,
		String[] par2ArrayOfStr) {
	EntityPlayer player = (EntityPlayer) par1ICommandSender;
	PlayerRoleplayMode props = PlayerRoleplayMode.get(player);
	props.setRoleplayMode(!props.getRoleplayMode(), true);
	player.addChatComponentMessage(new ChatComponentText("Your nickname is now:"
		+ "."));
}
 
Example 40
Project: BaseClient   File: CommandPardonIp.java   View source code 4 votes vote down vote up
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    return args.length == 1 ? getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys()) : null;
}