当前位置: 首页>>代码示例>>Java>>正文


Java ICommandSender.addChatMessage方法代码示例

本文整理汇总了Java中net.minecraft.command.ICommandSender.addChatMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ICommandSender.addChatMessage方法的具体用法?Java ICommandSender.addChatMessage怎么用?Java ICommandSender.addChatMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.command.ICommandSender的用法示例。


在下文中一共展示了ICommandSender.addChatMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listObjectives

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
protected void listObjectives(ICommandSender p_147196_1_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    Collection<ScoreObjective> collection = scoreboard.getScoreObjectives();

    if (collection.size() <= 0)
    {
        throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]);
    }
    else
    {
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())});
        chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
        p_147196_1_.addChatMessage(chatcomponenttranslation);

        for (ScoreObjective scoreobjective : collection)
        {
            p_147196_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.getName(), scoreobjective.getDisplayName(), scoreobjective.getCriteria().getName()}));
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:22,代码来源:CommandScoreboard.java

示例2: listObjectives

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
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()}));
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:CommandScoreboard.java

示例3: processCommand

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    int i = MinecraftServer.getServer().getCurrentPlayerCount();
    sender.addChatMessage(new ChatComponentTranslation("commands.players.list", new Object[] {Integer.valueOf(i), Integer.valueOf(MinecraftServer.getServer().getMaxPlayers())}));
    sender.addChatMessage(new ChatComponentText(MinecraftServer.getServer().getConfigurationManager().func_181058_b(args.length > 0 && "uuids".equalsIgnoreCase(args[0]))));
    sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, i);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:11,代码来源:CommandListPlayers.java

示例4: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    int i = server.getCurrentPlayerCount();
    sender.addChatMessage(new TextComponentTranslation("commands.players.list", new Object[] {Integer.valueOf(i), Integer.valueOf(server.getMaxPlayers())}));
    sender.addChatMessage(new TextComponentString(server.getPlayerList().getFormattedListOfPlayers(args.length > 0 && "uuids".equalsIgnoreCase(args[0]))));
    sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, i);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:11,代码来源:CommandListPlayers.java

示例5: listPlayers

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
protected void listPlayers(ICommandSender p_147195_1_, String[] p_147195_2_, int p_147195_3_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();

    if (p_147195_2_.length > p_147195_3_)
    {
        String s = getEntityName(p_147195_1_, p_147195_2_[p_147195_3_]);
        Map<ScoreObjective, Score> map = scoreboard.getObjectivesForEntity(s);
        p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, map.size());

        if (map.size() <= 0)
        {
            throw new CommandException("commands.scoreboard.players.list.player.empty", new Object[] {s});
        }

        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.players.list.player.count", new Object[] {Integer.valueOf(map.size()), s});
        chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
        p_147195_1_.addChatMessage(chatcomponenttranslation);

        for (Score score : map.values())
        {
            p_147195_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.players.list.player.entry", new Object[] {Integer.valueOf(score.getScorePoints()), score.getObjective().getDisplayName(), score.getObjective().getName()}));
        }
    }
    else
    {
        Collection<String> collection = scoreboard.getObjectiveNames();
        p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection.size());

        if (collection.size() <= 0)
        {
            throw new CommandException("commands.scoreboard.players.list.empty", new Object[0]);
        }

        ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.scoreboard.players.list.count", new Object[] {Integer.valueOf(collection.size())});
        chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
        p_147195_1_.addChatMessage(chatcomponenttranslation1);
        p_147195_1_.addChatMessage(new ChatComponentText(joinNiceString(collection.toArray())));
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:41,代码来源:CommandScoreboard.java

示例6: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length >= 1 && "ips".equalsIgnoreCase(args[0]))
    {
        sender.addChatMessage(new TextComponentTranslation("commands.banlist.ips", new Object[] {Integer.valueOf(server.getPlayerList().getBannedIPs().getKeys().length)}));
        sender.addChatMessage(new TextComponentString(joinNiceString(server.getPlayerList().getBannedIPs().getKeys())));
    }
    else
    {
        sender.addChatMessage(new TextComponentTranslation("commands.banlist.players", new Object[] {Integer.valueOf(server.getPlayerList().getBannedPlayers().getKeys().length)}));
        sender.addChatMessage(new TextComponentString(joinNiceString(server.getPlayerList().getBannedPlayers().getKeys())));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:CommandListBans.java

示例7: processCommand

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length >= 1 && args[0].equalsIgnoreCase("ips"))
    {
        sender.addChatMessage(new ChatComponentTranslation("commands.banlist.ips", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys().length)}));
        sender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys())));
    }
    else
    {
        sender.addChatMessage(new ChatComponentTranslation("commands.banlist.players", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getKeys().length)}));
        sender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getKeys())));
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:17,代码来源:CommandListBans.java

示例8: processCommand

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 2)
    {
        throw new WrongUsageException("commands.message.usage", new Object[0]);
    }
    else
    {
        EntityPlayer entityplayer = getPlayer(sender, args[0]);

        if (entityplayer == sender)
        {
            throw new PlayerNotFoundException("commands.message.sameTarget", new Object[0]);
        }
        else
        {
            IChatComponent ichatcomponent = getChatComponentFromNthArg(sender, args, 1, !(sender instanceof EntityPlayer));
            ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.message.display.incoming", new Object[] {sender.getDisplayName(), ichatcomponent.createCopy()});
            ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.message.display.outgoing", new Object[] {entityplayer.getDisplayName(), ichatcomponent.createCopy()});
            chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true));
            chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true));
            entityplayer.addChatMessage(chatcomponenttranslation);
            sender.addChatMessage(chatcomponenttranslation1);
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:30,代码来源:CommandMessage.java

示例9: chat

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/**
 * Sends an automatically translated and formatted message to a command sender
 * @param sender Target to send message to
 * @param msg String or language key to broadcast
 */
public static void chat(ICommandSender sender, String msg, Object... parts)
{
    String translated = translate(msg);

    // Consoles require ANSI coloring for formatting
    if (sender instanceof DedicatedServer)
        Log.info( removeFormatting(translated), parts );
    else
    {
        translated = String.format(translated, parts);
        sender.addChatMessage( new TextComponentString(translated) );
    }
}
 
开发者ID:abused,项目名称:World-Border,代码行数:19,代码来源:Util.java

示例10: processCommand

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (args.length < 1)
    {
        throw new WrongUsageException("creeperhostserver.commands.invite.usage", new Object[0]);
    }
    else
    {
        if ("list".equals(args[0]))
        {
            sender.addChatMessage(new ChatComponentTranslation("creeperhostserver.commands.invite.list", new Object[]{MinecraftServer.getServer().getConfigurationManager().func_152598_l().length, server.func_152358_ax().func_152654_a().length}));
            String[] astring = server.getConfigurationManager().func_152598_l();
            sender.addChatMessage(new ChatComponentText(joinNiceString(astring)));
        }
        else if ("add".equals(args[0]))
        {
            if (args.length < 2)
            {
                throw new WrongUsageException("creeperhostserver.commands.invite.add.usage", new Object[0]);
            }

            GameProfile gameprofile = server.func_152358_ax().func_152655_a(args[1]);

            if (gameprofile == null)
            {
                throw new CommandException("creeperhostserver.commands.invite.add.failed", new Object[]{args[1]});
            }

            server.getConfigurationManager().func_152601_d(gameprofile);
            inviteUser(gameprofile);
            func_152373_a(sender, this, "creeperhostserver.commands.invite.add.success", new Object[]{args[1]});
        }
        else if ("remove".equals(args[0]))
        {
            if (args.length < 2)
            {
                throw new WrongUsageException("creeperhostserver.commands.invite.remove.usage", new Object[0]);
            }

            GameProfile gameprofile1 = server.getConfigurationManager().func_152599_k().func_152706_a(args[1]);

            if (gameprofile1 == null)
            {
                throw new CommandException("creeperhostserver.commands.invite.remove.failed", new Object[]{args[1]});
            }

            server.getConfigurationManager().func_152597_c(gameprofile1);
            removeUser(gameprofile1);
            func_152373_a(sender, this, "creeperhostserver.commands.invite.remove.success", new Object[]{args[1]});
        }
        else if ("reload".equals(args[0]))
        {
            String[] prevNames = MinecraftServer.getServer().getConfigurationManager().func_152598_l();
            server.getConfigurationManager().loadWhiteList();
            reloadInvites(prevNames);
            func_152373_a(sender, this, "creeperhostserver.commands.invite.reloaded", new Object[0]);
        }
        else
        {
            throw new WrongUsageException("creeperhostserver.commands.invite.usage", new Object[0]);
        }
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:66,代码来源:CommandInvite.java

示例11: sendPlayer

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
public static void sendPlayer(final @Nonnull ICommandSender target, final @Nonnull ChatBuilder chat) {
	target.addChatMessage(chat.build());
}
 
开发者ID:Team-Fruit,项目名称:McHeliPrivacyShield,代码行数:4,代码来源:ChatBuilder.java

示例12: func_175780_b

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
private boolean func_175780_b(ICommandSender p_175780_1_, String[] p_175780_2_) throws CommandException
{
    int i = -1;

    for (int j = 0; j < p_175780_2_.length; ++j)
    {
        if (this.isUsernameIndex(p_175780_2_, j) && "*".equals(p_175780_2_[j]))
        {
            if (i >= 0)
            {
                throw new CommandException("commands.scoreboard.noMultiWildcard", new Object[0]);
            }

            i = j;
        }
    }

    if (i < 0)
    {
        return false;
    }
    else
    {
        List<String> list1 = Lists.newArrayList(this.getScoreboard().getObjectiveNames());
        String s = p_175780_2_[i];
        List<String> list = Lists.<String>newArrayList();

        for (String s1 : list1)
        {
            p_175780_2_[i] = s1;

            try
            {
                this.processCommand(p_175780_1_, p_175780_2_);
                list.add(s1);
            }
            catch (CommandException commandexception)
            {
                ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(commandexception.getMessage(), commandexception.getErrorObjects());
                chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
                p_175780_1_.addChatMessage(chatcomponenttranslation);
            }
        }

        p_175780_2_[i] = s;
        p_175780_1_.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, list.size());

        if (list.size() == 0)
        {
            throw new WrongUsageException("commands.scoreboard.allMatchesFailed", new Object[0]);
        }
        else
        {
            return true;
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:58,代码来源:CommandScoreboard.java

示例13: doTurnOnTileEntityTracking

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
private void doTurnOnTileEntityTracking(MinecraftServer server, ICommandSender sender, int duration)
{
    ForgeTimeTracker.tileEntityTrackingDuration = duration;
    ForgeTimeTracker.tileEntityTracking = true;
    sender.addChatMessage(new TextComponentTranslation("commands.forge.tracking.te.enabled", duration));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:7,代码来源:ForgeCommand.java

示例14: listTeams

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
protected void listTeams(ICommandSender sender, String[] p_184922_2_, int p_184922_3_, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);

    if (p_184922_2_.length > p_184922_3_)
    {
        ScorePlayerTeam scoreplayerteam = this.convertToTeam(p_184922_2_[p_184922_3_], server);

        if (scoreplayerteam == null)
        {
            return;
        }

        Collection<String> collection = scoreplayerteam.getMembershipCollection();
        sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection.size());

        if (collection.isEmpty())
        {
            throw new CommandException("commands.scoreboard.teams.list.player.empty", new Object[] {scoreplayerteam.getRegisteredName()});
        }

        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.scoreboard.teams.list.player.count", new Object[] {Integer.valueOf(collection.size()), scoreplayerteam.getRegisteredName()});
        textcomponenttranslation.getStyle().setColor(TextFormatting.DARK_GREEN);
        sender.addChatMessage(textcomponenttranslation);
        sender.addChatMessage(new TextComponentString(joinNiceString(collection.toArray())));
    }
    else
    {
        Collection<ScorePlayerTeam> collection1 = scoreboard.getTeams();
        sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection1.size());

        if (collection1.isEmpty())
        {
            throw new CommandException("commands.scoreboard.teams.list.empty", new Object[0]);
        }

        TextComponentTranslation textcomponenttranslation1 = new TextComponentTranslation("commands.scoreboard.teams.list.count", new Object[] {Integer.valueOf(collection1.size())});
        textcomponenttranslation1.getStyle().setColor(TextFormatting.DARK_GREEN);
        sender.addChatMessage(textcomponenttranslation1);

        for (ScorePlayerTeam scoreplayerteam1 : collection1)
        {
            sender.addChatMessage(new TextComponentTranslation("commands.scoreboard.teams.list.entry", new Object[] {scoreplayerteam1.getRegisteredName(), scoreplayerteam1.getTeamName(), Integer.valueOf(scoreplayerteam1.getMembershipCollection().size())}));
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:47,代码来源:CommandScoreboard.java

示例15: execute

import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException("commands.whitelist.usage", new Object[0]);
    }
    else
    {
        if ("on".equals(args[0]))
        {
            server.getPlayerList().setWhiteListEnabled(true);
            notifyCommandListener(sender, this, "commands.whitelist.enabled", new Object[0]);
        }
        else if ("off".equals(args[0]))
        {
            server.getPlayerList().setWhiteListEnabled(false);
            notifyCommandListener(sender, this, "commands.whitelist.disabled", new Object[0]);
        }
        else if ("list".equals(args[0]))
        {
            sender.addChatMessage(new TextComponentTranslation("commands.whitelist.list", new Object[] {Integer.valueOf(server.getPlayerList().getWhitelistedPlayerNames().length), Integer.valueOf(server.getPlayerList().getAvailablePlayerDat().length)}));
            String[] astring = server.getPlayerList().getWhitelistedPlayerNames();
            sender.addChatMessage(new TextComponentString(joinNiceString(astring)));
        }
        else if ("add".equals(args[0]))
        {
            if (args.length < 2)
            {
                throw new WrongUsageException("commands.whitelist.add.usage", new Object[0]);
            }

            GameProfile gameprofile = server.getPlayerProfileCache().getGameProfileForUsername(args[1]);

            if (gameprofile == null)
            {
                throw new CommandException("commands.whitelist.add.failed", new Object[] {args[1]});
            }

            server.getPlayerList().addWhitelistedPlayer(gameprofile);
            notifyCommandListener(sender, this, "commands.whitelist.add.success", new Object[] {args[1]});
        }
        else if ("remove".equals(args[0]))
        {
            if (args.length < 2)
            {
                throw new WrongUsageException("commands.whitelist.remove.usage", new Object[0]);
            }

            GameProfile gameprofile1 = server.getPlayerList().getWhitelistedPlayers().getByName(args[1]);

            if (gameprofile1 == null)
            {
                throw new CommandException("commands.whitelist.remove.failed", new Object[] {args[1]});
            }

            server.getPlayerList().removePlayerFromWhitelist(gameprofile1);
            notifyCommandListener(sender, this, "commands.whitelist.remove.success", new Object[] {args[1]});
        }
        else if ("reload".equals(args[0]))
        {
            server.getPlayerList().reloadWhitelist();
            notifyCommandListener(sender, this, "commands.whitelist.reloaded", new Object[0]);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:69,代码来源:CommandWhitelist.java


注:本文中的net.minecraft.command.ICommandSender.addChatMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。