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


Java CommandContext.getSuggestionContext方法代码示例

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


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

示例1: all

import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
    aliases = "all",
    usage = "<model>",
    desc = "List all stored instances of a model",
    min = 1,
    max = 1
)
public List<String> all(CommandContext args, CommandSender sender) throws CommandException {
    final String modelName = args.getString(0, "");

    if(args.getSuggestionContext() != null) {
        return completeModel(modelName);
    }
    for(Model doc : parseModel(modelName).store().get().set()) {
        sender.sendMessage(new Component(doc._id() + " " + doc.toShortString()));
    }
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:19,代码来源:ModelCommands.java

示例2: refresh

import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
    aliases = "refresh",
    usage = "<model>",
    desc = "Refresh a model store from the API",
    min = 1,
    max = 1
)
public List<String> refresh(CommandContext args, CommandSender sender) throws CommandException {
    final String modelName = args.getString(0, "");

    if(args.getSuggestionContext() != null) {
        return completeModel(modelName);
    }

    final ModelMeta<?, ?> model = parseModel(modelName);
    sender.sendMessage("Refreshing model " + model.name() + "...");
    syncExecutor.callback(
        model.store().get().refreshAll(),
        response -> sender.sendMessage("Refreshed " + response.documents().size() + " " + model.name() + " document(s)")
    );
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:23,代码来源:ModelCommands.java

示例3: play

import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
    aliases = { "play", "replay" },
    desc = "Play a game",
    usage = "[game]",
    min = 0,
    max = -1
)
public List<String> play(final CommandContext args, final CommandSender sender) throws CommandException {
    final String name = args.argsLength() > 0 ? args.getRemainingString(0) : "";
    if(args.getSuggestionContext() != null) {
        return StringUtils.complete(name, ticketBooth.allGames(sender).stream().map(Game::name));
    }

    ticketBooth.playGame(CommandUtils.senderToPlayer(sender), name);
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:TicketCommands.java

示例4: watch

import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
    aliases = { "watch" },
    desc = "Spectate a game",
    usage = "[game]",
    min = 0,
    max = -1
)
public List<String> watch(final CommandContext args, final CommandSender sender) throws CommandException {
    final String name = args.argsLength() > 0 ? args.getRemainingString(0) : "";
    if(args.getSuggestionContext() != null) {
        return StringUtils.complete(name, ticketBooth.allGames(sender).stream().map(Game::name));
    }

    ticketBooth.watchGame(CommandUtils.senderToPlayer(sender), name);
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:TicketCommands.java

示例5: setnext

import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
    aliases = {"setnext", "sn"},
    desc = "Sets the next map.  Note that the rotation will go to this map then resume as normal.",
    usage = "[map name]",
    flags = "f",
    min = 1,
    max = -1
)
@CommandPermissions("pgm.next.set")
public List<String> setnext(CommandContext args, CommandSender sender) throws CommandException {
    final String mapName = args.argsLength() > 0 ? args.getJoinedStrings(0) : "";
    if(args.getSuggestionContext() != null) {
        return CommandUtils.completeMapName(mapName);
    }

    MatchManager mm = PGM.getMatchManager();
    boolean restartQueued = restartManager.isRestartRequested(ServerDoc.Restart.Priority.NORMAL);

    if (restartQueued && !args.hasFlag('f')) {
        throw new CommandException(PGMTranslations.get().t("command.admin.setNext.restartQueued", sender));
    }

    mm.setNextMap(CommandUtils.getMap(mapName, sender));
    if (restartQueued) {
        restartManager.cancelRestart();
        sender.sendMessage(ChatColor.GREEN + PGMTranslations.get().t("command.admin.cancelRestart.restartUnqueued", sender));
    }
    sender.sendMessage(ChatColor.DARK_PURPLE + PGMTranslations.get().t("command.admin.set.success", sender, ChatColor.GOLD + mm.getNextMap().getInfo().name + ChatColor.DARK_PURPLE));
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:31,代码来源:AdminCommands.java

示例6: errorsCommand

import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
    aliases = {"errors", "xmlerrors"},
    usage = "[-p page] [map name]",
    desc = "Reads back XML errors",
    min = 0,
    max = -1,
    flags = "p:"
)
@CommandPermissions(Permissions.MAPERRORS)
public List<String> errorsCommand(CommandContext args, final CommandSender sender) throws CommandException {
    final String mapName = args.argsLength() > 0 ? args.getJoinedStrings(0) : "";
    if(args.getSuggestionContext() != null) {
        return tc.oc.pgm.commands.CommandUtils.completeMapName(mapName);
    }

    Multimap<MapDefinition, MapLogRecord> errors = mapErrorTracker.getErrors();
    PGMMap filterMap = null;
    if(!mapName.isEmpty()) {
        filterMap = tc.oc.pgm.commands.CommandUtils.getMap(mapName, sender);
        Multimap<MapDefinition, MapLogRecord> filtered = ArrayListMultimap.create();
        filtered.putAll(filterMap, errors.get(filterMap));
        errors = filtered;
    }

    new PrettyPaginatedResult<Map.Entry<MapDefinition, MapLogRecord>>(filterMap == null ? "Map Errors (" + errors.keySet().size() + " maps)"
                                                                                        : filterMap.getName() + " Errors") {
        @Override
        public String format(Map.Entry<MapDefinition, MapLogRecord> entry, int index) {
            return entry.getValue().getLegacyFormattedMessage();
        }

        @Override
        public String formatEmpty() {
            return ChatColor.GREEN + PGMTranslations.get().t("command.development.listErrors.noErrors", sender);
        }
    }.display(new BukkitWrappedCommandSender(sender), errors.entries(), args.getFlagInteger('p', 1));
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:39,代码来源:MapDevelopmentCommands.java

示例7: cycle

import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
    aliases = {"cycle"},
    desc = "Queues a cycle to the next map in a certain amount of seconds",
    usage = "[seconds] [mapname]",
    flags = "f"
)
@CommandPermissions(PERMISSION)
public List<String> cycle(CommandContext args, CommandSender sender) throws CommandException {
    if(args.getSuggestionContext() != null) {
        if(args.getSuggestionContext().getIndex() >= 1) {
            return CommandUtils.completeMapName(args.getJoinedStrings(1));
        }
        return null;
    }

    // Try to parse "<seconds> [mapname]", fall back to "<mapname>"
    // So the map can be given without the time

    Duration countdown;
    try {
        countdown = tc.oc.commons.bukkit.commands.CommandUtils.getDuration(args, 0);
    } catch(CommandException e) {
        countdown = null;
    }

    int index = countdown == null ? 0 : 1;
    String mapName = index < args.argsLength() ? args.getJoinedStrings(index) : null;

    cycle(sender, countdown, mapName == null ? null : CommandUtils.getMap(mapName, sender), args.hasFlag('f'));
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:32,代码来源:CycleCommands.java


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