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: BaseClient   File: CommandWhitelist.java   Source Code and License 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 2
Project: CustomWorldGen   File: CommandScoreboard.java   Source Code and License 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 3
Project: Backmemed   File: CommandPardonIp.java   Source Code and License 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 4
Project: Backmemed   File: CommandScoreboard.java   Source Code and License 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 5
Project: World-Border   File: CmdDynmapmsg.java   Source Code and License 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 6
Project: CustomWorldGen   File: CommandAchievement.java   Source Code and License 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 7
Project: BaseClient   File: CommandScoreboard.java   Source Code and License 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 8
Project: Backmemed   File: CommandDeOp.java   Source Code and License 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 9
Project: NemesisSystem   File: NemesisSystemCommand.java   Source Code and License 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 10
Project: StructPro   File: Evaluator.java   Source Code and License 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 11
Project: BaseClient   File: CommandScoreboard.java   Source Code and License 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 12
Project: Backmemed   File: CommandPardonPlayer.java   Source Code and License 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 13
Project: CreeperHostGui   File: CommandInvite.java   Source Code and License 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 14
Project: BaseClient   File: CommandAchievement.java   Source Code and License 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 15
Project: BaseClient   File: CommandPublishLocalServer.java   Source Code and License 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 16
Project: craftsman   File: Cube.java   Source Code and License 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 17
Project: World-Border   File: CmdBypasslist.java   Source Code and License 5 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 18
Project: BaseClient   File: CommandScoreboard.java   Source Code and License 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 19
Project: CustomWorldGen   File: CommandScoreboard.java   Source Code and License 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 20
Project: Backmemed   File: CommandSaveOff.java   Source Code and License 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 21
Project: CustomWorldGen   File: CommandStop.java   Source Code and License 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 22
Project: CustomWorldGen   File: CommandBroadcast.java   Source Code and License 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 23
Project: Bewitchment   File: CommandIncantation.java   Source Code and License 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 24
Project: World-Border   File: CmdHelp.java   Source Code and License 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 25
Project: BaseClient   File: CommandSaveOn.java   Source Code and License 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 26
Project: World-Border   File: CmdDenypearl.java   Source Code and License 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 27
Project: VillagerTrades   File: ModCommand.java   Source Code and License 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 28
Project: RenderPlayerMod-1.8.9   File: RenderPlayer.java   Source Code and License 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 29
Project: connor41-etfuturum2   File: SetPlayerModelCommand.java   Source Code and License 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 30
Project: MeeCreeps   File: CommandTestApi.java   Source Code and License 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 31
Project: StructPro   File: Evaluator.java   Source Code and License 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 32
Project: CustomWorldGen   File: CommandMessage.java   Source Code and License 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 33
Project: World-Border   File: CmdKnockback.java   Source Code and License 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 34
Project: Ye-Olde-Chat   File: CommandSetRoleplayMode.java   Source Code and License 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 35
Project: BaseClient   File: CommandPardonIp.java   Source Code and License 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;
}
 
Example 36
Project: BaseClient   File: CommandListBans.java   Source Code and License 4 votes vote down vote up
/**
 * Returns true if the given command sender is allowed to use this command.
 */
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
    return (MinecraftServer.getServer().getConfigurationManager().getBannedIPs().isLanServer() || MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().isLanServer()) && super.canCommandSenderUseCommand(sender);
}
 
Example 37
Project: BaseClient   File: TileEntitySign.java   Source Code and License 4 votes vote down vote up
public boolean executeCommand(final EntityPlayer playerIn)
{
    ICommandSender icommandsender = new ICommandSender()
    {
        public String getName()
        {
            return playerIn.getName();
        }
        public IChatComponent getDisplayName()
        {
            return playerIn.getDisplayName();
        }
        public void addChatMessage(IChatComponent component)
        {
        }
        public boolean canCommandSenderUseCommand(int permLevel, String commandName)
        {
            return permLevel <= 2;
        }
        public BlockPos getPosition()
        {
            return TileEntitySign.this.pos;
        }
        public Vec3 getPositionVector()
        {
            return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
        }
        public World getEntityWorld()
        {
            return playerIn.getEntityWorld();
        }
        public Entity getCommandSenderEntity()
        {
            return playerIn;
        }
        public boolean sendCommandFeedback()
        {
            return false;
        }
        public void setCommandStat(CommandResultStats.Type type, int amount)
        {
            TileEntitySign.this.stats.func_179672_a(this, type, amount);
        }
    };

    for (int i = 0; i < this.signText.length; ++i)
    {
        ChatStyle chatstyle = this.signText[i] == null ? null : this.signText[i].getChatStyle();

        if (chatstyle != null && chatstyle.getChatClickEvent() != null)
        {
            ClickEvent clickevent = chatstyle.getChatClickEvent();

            if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)
            {
                MinecraftServer.getServer().getCommandManager().executeCommand(icommandsender, clickevent.getValue());
            }
        }
    }

    return true;
}
 
Example 38
Project: BaseClient   File: TileEntitySign.java   Source Code and License 4 votes vote down vote up
public void readFromNBT(NBTTagCompound compound)
{
    this.isEditable = false;
    super.readFromNBT(compound);
    ICommandSender icommandsender = new ICommandSender()
    {
        public String getName()
        {
            return "Sign";
        }
        public IChatComponent getDisplayName()
        {
            return new ChatComponentText(this.getName());
        }
        public void addChatMessage(IChatComponent component)
        {
        }
        public boolean canCommandSenderUseCommand(int permLevel, String commandName)
        {
            return true;
        }
        public BlockPos getPosition()
        {
            return TileEntitySign.this.pos;
        }
        public Vec3 getPositionVector()
        {
            return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
        }
        public World getEntityWorld()
        {
            return TileEntitySign.this.worldObj;
        }
        public Entity getCommandSenderEntity()
        {
            return null;
        }
        public boolean sendCommandFeedback()
        {
            return false;
        }
        public void setCommandStat(CommandResultStats.Type type, int amount)
        {
        }
    };

    for (int i = 0; i < 4; ++i)
    {
        String s = compound.getString("Text" + (i + 1));

        try
        {
            IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);

            try
            {
                this.signText[i] = ChatComponentProcessor.processComponent(icommandsender, ichatcomponent, (Entity)null);
            }
            catch (CommandException var7)
            {
                this.signText[i] = ichatcomponent;
            }
        }
        catch (JsonParseException var8)
        {
            this.signText[i] = new ChatComponentText(s);
        }
    }

    this.stats.readStatsFromNBT(compound);
}
 
Example 39
Project: BaseClient   File: ChatComponentProcessor.java   Source Code and License 4 votes vote down vote up
public static IChatComponent processComponent(ICommandSender commandSender, IChatComponent component, Entity entityIn) throws CommandException
{
    IChatComponent ichatcomponent = null;

    if (component instanceof ChatComponentScore)
    {
        ChatComponentScore chatcomponentscore = (ChatComponentScore)component;
        String s = chatcomponentscore.getName();

        if (PlayerSelector.hasArguments(s))
        {
            List<Entity> list = PlayerSelector.<Entity>matchEntities(commandSender, s, Entity.class);

            if (list.size() != 1)
            {
                throw new EntityNotFoundException();
            }

            s = ((Entity)list.get(0)).getName();
        }

        ichatcomponent = entityIn != null && s.equals("*") ? new ChatComponentScore(entityIn.getName(), chatcomponentscore.getObjective()) : new ChatComponentScore(s, chatcomponentscore.getObjective());
        ((ChatComponentScore)ichatcomponent).setValue(chatcomponentscore.getUnformattedTextForChat());
    }
    else if (component instanceof ChatComponentSelector)
    {
        String s1 = ((ChatComponentSelector)component).getSelector();
        ichatcomponent = PlayerSelector.matchEntitiesToChatComponent(commandSender, s1);

        if (ichatcomponent == null)
        {
            ichatcomponent = new ChatComponentText("");
        }
    }
    else if (component instanceof ChatComponentText)
    {
        ichatcomponent = new ChatComponentText(((ChatComponentText)component).getChatComponentText_TextValue());
    }
    else
    {
        if (!(component instanceof ChatComponentTranslation))
        {
            return component;
        }

        Object[] aobject = ((ChatComponentTranslation)component).getFormatArgs();

        for (int i = 0; i < aobject.length; ++i)
        {
            Object object = aobject[i];

            if (object instanceof IChatComponent)
            {
                aobject[i] = processComponent(commandSender, (IChatComponent)object, entityIn);
            }
        }

        ichatcomponent = new ChatComponentTranslation(((ChatComponentTranslation)component).getKey(), aobject);
    }

    ChatStyle chatstyle = component.getChatStyle();

    if (chatstyle != null)
    {
        ichatcomponent.setChatStyle(chatstyle.createShallowCopy());
    }

    for (IChatComponent ichatcomponent1 : component.getSiblings())
    {
        ichatcomponent.appendSibling(processComponent(commandSender, ichatcomponent1, entityIn));
    }

    return ichatcomponent;
}
 
Example 40
Project: BaseClient   File: CommandPardonIp.java   Source Code and License 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;
}
 
Example 41
Project: HardVox   File: ParserContext.java   Source Code and License 4 votes vote down vote up
public ParserContext(MinecraftServer server, ICommandSender sender, BlockPos targetPos, String[] text) {
    this.server = server;
    this.sender = sender;
    this.targetPos = targetPos;
    this.text = text;
}
 
Example 42
Project: BaseClient   File: CommandSaveAll.java   Source Code and License 4 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    MinecraftServer minecraftserver = MinecraftServer.getServer();
    sender.addChatMessage(new ChatComponentTranslation("commands.save.start", new Object[0]));

    if (minecraftserver.getConfigurationManager() != null)
    {
        minecraftserver.getConfigurationManager().saveAllPlayerData();
    }

    try
    {
        for (int i = 0; i < minecraftserver.worldServers.length; ++i)
        {
            if (minecraftserver.worldServers[i] != null)
            {
                WorldServer worldserver = minecraftserver.worldServers[i];
                boolean flag = worldserver.disableLevelSaving;
                worldserver.disableLevelSaving = false;
                worldserver.saveAllChunks(true, (IProgressUpdate)null);
                worldserver.disableLevelSaving = flag;
            }
        }

        if (args.length > 0 && "flush".equals(args[0]))
        {
            sender.addChatMessage(new ChatComponentTranslation("commands.save.flushStart", new Object[0]));

            for (int j = 0; j < minecraftserver.worldServers.length; ++j)
            {
                if (minecraftserver.worldServers[j] != null)
                {
                    WorldServer worldserver1 = minecraftserver.worldServers[j];
                    boolean flag1 = worldserver1.disableLevelSaving;
                    worldserver1.disableLevelSaving = false;
                    worldserver1.saveChunkData();
                    worldserver1.disableLevelSaving = flag1;
                }
            }

            sender.addChatMessage(new ChatComponentTranslation("commands.save.flushEnd", new Object[0]));
        }
    }
    catch (MinecraftException minecraftexception)
    {
        notifyOperators(sender, this, "commands.save.failed", new Object[] {minecraftexception.getMessage()});
        return;
    }

    notifyOperators(sender, this, "commands.save.success", new Object[0]);
}
 
Example 43
Project: AuthMod   File: Commandlogout.java   Source Code and License 4 votes vote down vote up
public boolean func_184882_a(MinecraftServer server, ICommandSender sender)
{
  return true;
}
 
Example 44
Project: BaseClient   File: CommandTestForBlock.java   Source Code and License 4 votes vote down vote up
/**
 * Gets the usage string for the command.
 */
public String getCommandUsage(ICommandSender sender)
{
    return "commands.testforblock.usage";
}
 
Example 45
Project: CustomWorldGen   File: CommandBanIp.java   Source Code and License 4 votes vote down vote up
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
    return args.length == 1 ? getListOfStringsMatchingLastWord(args, server.getAllUsernames()) : Collections.<String>emptyList();
}
 
Example 46
Project: youtube-chat-for-minecraft   File: YouTubeCommand.java   Source Code and License 4 votes vote down vote up
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
  return true;
}
 
Example 47
Project: Uranium   File: CraftSimpleCommandMap.java   Source Code and License 4 votes vote down vote up
public void setVanillaConsoleSender(ICommandSender console)
{
    this.vanillaConsoleSender = console;
}
 
Example 48
Project: Backmemed   File: CommandSaveOff.java   Source Code and License 4 votes vote down vote up
/**
 * Gets the usage string for the command.
 */
public String getCommandUsage(ICommandSender sender)
{
    return "commands.save-off.usage";
}
 
Example 49
Project: BaseClient   File: TileEntitySign.java   Source Code and License 4 votes vote down vote up
public void readFromNBT(NBTTagCompound compound)
{
    this.isEditable = false;
    super.readFromNBT(compound);
    ICommandSender icommandsender = new ICommandSender()
    {
        public String getName()
        {
            return "Sign";
        }
        public IChatComponent getDisplayName()
        {
            return new ChatComponentText(this.getName());
        }
        public void addChatMessage(IChatComponent component)
        {
        }
        public boolean canCommandSenderUseCommand(int permLevel, String commandName)
        {
            return true;
        }
        public BlockPos getPosition()
        {
            return TileEntitySign.this.pos;
        }
        public Vec3 getPositionVector()
        {
            return new Vec3((double)TileEntitySign.this.pos.getX() + 0.5D, (double)TileEntitySign.this.pos.getY() + 0.5D, (double)TileEntitySign.this.pos.getZ() + 0.5D);
        }
        public World getEntityWorld()
        {
            return TileEntitySign.this.worldObj;
        }
        public Entity getCommandSenderEntity()
        {
            return null;
        }
        public boolean sendCommandFeedback()
        {
            return false;
        }
        public void setCommandStat(CommandResultStats.Type type, int amount)
        {
        }
    };

    for (int i = 0; i < 4; ++i)
    {
        String s = compound.getString("Text" + (i + 1));

        try
        {
            IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);

            try
            {
                this.signText[i] = ChatComponentProcessor.processComponent(icommandsender, ichatcomponent, (Entity)null);
            }
            catch (CommandException var7)
            {
                this.signText[i] = ichatcomponent;
            }
        }
        catch (JsonParseException var8)
        {
            this.signText[i] = new ChatComponentText(s);
        }
    }

    this.stats.readStatsFromNBT(compound);
}
 
Example 50
Project: youtube-chat-for-minecraft   File: YouTubeCommand.java   Source Code and License 4 votes vote down vote up
@Override
public String getUsage(ICommandSender sender) {
  return getName() + " [start|stop|logout|echoStart|echoStop]";
}
 
Example 51
Project: NemesisSystem   File: NemesisSystemCommand.java   Source Code and License 4 votes vote down vote up
private void enchant(ICommandSender sender) throws CommandException {
	if (sender instanceof EntityPlayer) {
		NemesisUtil.enchantItems(getHotBarItems(getCommandSenderAsPlayer(sender)));
		logHotBarItems(getCommandSenderAsPlayer(sender));
	}
}
 
Example 52
Project: Ye-Olde-Chat   File: CommandGetRoleplayMode.java   Source Code and License 4 votes vote down vote up
@Override
public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) {
	return super.canCommandSenderUseCommand(par1ICommandSender);
}
 
Example 53
Project: harshencastle   File: CommandHarshenCastleLoader.java   Source Code and License 4 votes vote down vote up
public static void sendMessage(ICommandSender sender, String translationSuffix, Object... args) {
	notifyCommandListener(sender, new CommandHarshenCastleLoader(), "commands.harshencastle." + Thread.currentThread().getStackTrace()[3].getMethodName() + "." + translationSuffix, args);
}
 
Example 54
Project: Backmemed   File: CommandAchievement.java   Source Code and License 4 votes vote down vote up
/**
 * Gets the usage string for the command.
 */
public String getCommandUsage(ICommandSender sender)
{
    return "commands.achievement.usage";
}
 
Example 55
Project: CustomWorldGen   File: CommandSetDefaultSpawnpoint.java   Source Code and License 4 votes vote down vote up
/**
 * Gets the usage string for the command.
 */
public String getCommandUsage(ICommandSender sender)
{
    return "commands.setworldspawn.usage";
}
 
Example 56
Project: FundamentalChemistry   File: Command.java   Source Code and License 4 votes vote down vote up
@Override
public List<String> addTabCompletionOptions(ICommandSender sender,
		String[] args, BlockPos pos) {
	// TODO Auto-generated method stub
	return new ArrayList<String>();
}
 
Example 57
Project: BaseClient   File: CommandScoreboard.java   Source Code and License 4 votes vote down vote up
protected void setPlayer(ICommandSender p_147197_1_, String[] p_147197_2_, int p_147197_3_) throws CommandException
{
    String s = p_147197_2_[p_147197_3_ - 1];
    int i = p_147197_3_;
    String s1 = getEntityName(p_147197_1_, p_147197_2_[p_147197_3_++]);

    if (s1.length() > 40)
    {
        throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s1, Integer.valueOf(40)});
    }
    else
    {
        ScoreObjective scoreobjective = this.getObjective(p_147197_2_[p_147197_3_++], true);
        int j = s.equalsIgnoreCase("set") ? parseInt(p_147197_2_[p_147197_3_++]) : parseInt(p_147197_2_[p_147197_3_++], 0);

        if (p_147197_2_.length > p_147197_3_)
        {
            Entity entity = func_175768_b(p_147197_1_, p_147197_2_[i]);

            try
            {
                NBTTagCompound nbttagcompound = JsonToNBT.getTagFromJson(buildString(p_147197_2_, p_147197_3_));
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                entity.writeToNBT(nbttagcompound1);

                if (!NBTUtil.func_181123_a(nbttagcompound, nbttagcompound1, true))
                {
                    throw new CommandException("commands.scoreboard.players.set.tagMismatch", new Object[] {s1});
                }
            }
            catch (NBTException nbtexception)
            {
                throw new CommandException("commands.scoreboard.players.set.tagError", new Object[] {nbtexception.getMessage()});
            }
        }

        Scoreboard scoreboard = this.getScoreboard();
        Score score = scoreboard.getValueFromObjective(s1, scoreobjective);

        if (s.equalsIgnoreCase("set"))
        {
            score.setScorePoints(j);
        }
        else if (s.equalsIgnoreCase("add"))
        {
            score.increseScore(j);
        }
        else
        {
            score.decreaseScore(j);
        }

        notifyOperators(p_147197_1_, this, "commands.scoreboard.players.set.success", new Object[] {scoreobjective.getName(), s1, Integer.valueOf(score.getScorePoints())});
    }
}
 
Example 58
Project: InControl   File: CmdDebug.java   Source Code and License 4 votes vote down vote up
@Override
public String getUsage(ICommandSender sender) {
    return "ctrldebug";
}
 
Example 59
Project: CustomWorldGen   File: CommandSetBlock.java   Source Code and License 4 votes vote down vote up
/**
 * Gets the usage string for the command.
 */
public String getCommandUsage(ICommandSender sender)
{
    return "commands.setblock.usage";
}
 
Example 60
Project: StructPro   File: Evaluator.java   Source Code and License 4 votes vote down vote up
/** Showing warning message about unknown command
 * @param vars Variables to parse arguments
 * @param sender Who sends the command
 */
static void execUnknown(Variables vars, ICommandSender sender) {
    String cmd = vars.get(new String[]{"command"}, "");
    feedback(sender, "§4Unknown command§2 " + cmd);
}