本文整理汇总了Java中com.sk89q.minecraft.util.commands.CommandContext.getJoinedStrings方法的典型用法代码示例。如果您正苦于以下问题:Java CommandContext.getJoinedStrings方法的具体用法?Java CommandContext.getJoinedStrings怎么用?Java CommandContext.getJoinedStrings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.minecraft.util.commands.CommandContext
的用法示例。
在下文中一共展示了CommandContext.getJoinedStrings方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: featureCommand
import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
aliases = {"feature", "fl"},
desc = "Prints information regarding a specific feature",
min = 1,
max = -1
)
@CommandPermissions(Permissions.MAPDEV)
public void featureCommand(CommandContext args, CommandSender sender) throws CommandException {
final String slug = args.getJoinedStrings(0);
final Optional<Feature<?>> feature = matchManager.getCurrentMatch(sender).features().bySlug(slug);
if(feature.isPresent()) {
sender.sendMessage(ChatColor.GOLD + slug + ChatColor.GRAY + " corresponds to: " + ChatColor.WHITE + feature.get().toString());
} else {
sender.sendMessage(ChatColor.RED + "No feature by the name of " + ChatColor.GOLD + slug + ChatColor.RED + " was found.");
}
}
示例2: message
import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
aliases = {"msg", "message", "whisper", "pm", "tell", "dm"},
usage = "<target> <message...>",
desc = "Private message a user",
min = 2,
max = -1
)
@CommandPermissions("projectares.msg")
public void message(final CommandContext args, final CommandSender sender) throws CommandException {
final Player player = CommandUtils.senderToPlayer(sender);
final Identity from = identityProvider.currentIdentity(player);
final String content = args.getJoinedStrings(1);
executor.callback(
userFinder.findUser(sender, args, 0),
CommandFutureCallback.onSuccess(sender, args, response -> {
whisperSender.send(sender, from, identityProvider.createIdentity(response), content);
})
);
}
示例3: 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;
}
示例4: alias
import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
aliases = {"alias"},
desc = "Rename a team",
usage = "<old name> <new name>",
min = 2,
max = -1
)
@CommandPermissions("pgm.team.alias")
public void alias(CommandContext args, CommandSender sender) throws CommandException, SuggestException {
TeamMatchModule tmm = utils.module();
Match match = tmm.getMatch();
Team team = utils.teamArgument(args, 0);
String newName = args.getJoinedStrings(1);
if(newName.length() > 32) {
throw new CommandException("Team name cannot be longer than 32 characters");
}
if(teams.stream().anyMatch(t -> t.getName().equalsIgnoreCase(newName))) {
throw new TranslatableCommandException("command.team.alias.nameAlreadyUsed", newName);
}
String oldName = team.getColoredName();
team.setName(newName);
match.sendMessage(oldName + ChatColor.GRAY + " renamed to " + team.getColoredName());
}
示例5: 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;
}
示例6: 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;
}
示例7: reply
import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
@Command(
aliases = {"reply", "r"},
usage = "<message...>",
desc = "Reply to last user",
min = 1,
max = -1
)
@CommandPermissions("projectares.msg")
public void reply(final CommandContext args, final CommandSender sender) throws CommandException {
final Player player = CommandUtils.senderToPlayer(sender);
final User user = userStore.getUser(player);
final Audience audience = audiences.get(sender);
final String content = args.getJoinedStrings(0);
executor.callback(
whisperService.forReply(user),
CommandFutureCallback.<Whisper>onSuccess(sender, args, original -> {
final Identity from, to;
if(user.equals(original.sender_uid())) {
// Follow-up of previously sent message
from = formatter.senderIdentity(original);
to = formatter.recipientIdentity(original);
} else {
// Reply to received message
from = formatter.recipientIdentity(original);
to = formatter.senderIdentity(original);
}
whisperSender.send(sender, from, to, content);
}).onFailure(NotFound.class, e -> formatter.noReply(sender))
);
}
示例8: throwError
import com.sk89q.minecraft.util.commands.CommandContext; //导入方法依赖的package包/类
private void throwError(CommandContext args, CommandSender sender, String type) {
final String message;
if(args.argsLength() == 0) {
message = "Test " + type + " error from " + sender.getName();
} else {
message = args.getJoinedStrings(0);
}
throw new RuntimeException(message);
}