當前位置: 首頁>>代碼示例>>Java>>正文


Java ICommandSender類代碼示例

本文整理匯總了Java中net.minecraft.command.ICommandSender的典型用法代碼示例。如果您正苦於以下問題:Java ICommandSender類的具體用法?Java ICommandSender怎麽用?Java ICommandSender使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ICommandSender類屬於net.minecraft.command包,在下文中一共展示了ICommandSender類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
@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());
    }
}
 
開發者ID:abused,項目名稱:World-Border,代碼行數:23,代碼來源:CmdBypasslist.java

示例2: addTabCompletionOptions

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
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;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:25,代碼來源:CommandWhitelist.java

示例3: resetPlayerScore

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
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});
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:18,代碼來源:CommandScoreboard.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
{
    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]);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:25,代碼來源:CommandPardonIp.java

示例5: 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:sudofox,項目名稱:Backmemed,代碼行數:22,代碼來源:CommandScoreboard.java

示例6: processCommand

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
/**
 * 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())});
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:26,代碼來源:CommandSetDefaultSpawnpoint.java

示例7: execute

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
@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);
}
 
開發者ID:abused,項目名稱:World-Border,代碼行數:19,代碼來源:CmdDynmapmsg.java

示例8: getTabCompletionOptions

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:27,代碼來源:CommandAchievement.java

示例9: func_175779_n

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
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});
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:26,代碼來源:CommandScoreboard.java

示例10: 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 && 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]);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:25,代碼來源:CommandDeOp.java

示例11: spawn

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
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);
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:18,代碼來源:NemesisSystemCommand.java

示例12: execGen

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
/** 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));
}
 
開發者ID:ternsip,項目名稱:StructPro,代碼行數:21,代碼來源:Evaluator.java

示例13: resetPlayers

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
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});
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:18,代碼來源:CommandScoreboard.java

示例14: 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 && 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]);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:25,代碼來源:CommandPardonPlayer.java

示例15: getTabCompletions

import net.minecraft.command.ICommandSender; //導入依賴的package包/類
@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();
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:26,代碼來源:CommandInvite.java


注:本文中的net.minecraft.command.ICommandSender類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。