本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}