本文整理汇总了Java中org.spongepowered.api.command.args.CommandContext.getAll方法的典型用法代码示例。如果您正苦于以下问题:Java CommandContext.getAll方法的具体用法?Java CommandContext.getAll怎么用?Java CommandContext.getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.command.args.CommandContext
的用法示例。
在下文中一共展示了CommandContext.getAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.spongepowered.api.command.args.CommandContext; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) {
src.sendMessage(Text.of(TextColors.RED, "Lookups can only be performed by players"));
return CommandResult.empty();
}
Player p = (Player) src;
Collection<String> filters = args.getAll("filter");
FilterSet filterSet = new FilterSet(plugin, p, true);
FilterParser.parse(filters, filterSet, p);
new RollbackJob(plugin, p, filterSet, true);
return CommandResult.success();
}
示例2: execute
import org.spongepowered.api.command.args.CommandContext; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) {
src.sendMessage(Text.of(TextColors.RED, "Lookups can only be performed by players"));
return CommandResult.empty();
}
Player p = (Player) src;
Collection<String> filters = args.getAll("filter");
FilterSet filterSet = new FilterSet(plugin, p, true);
FilterParser.parse(filters, filterSet, p);
new RollbackJob(plugin, p, filterSet, false);
return CommandResult.success();
}
示例3: execute
import org.spongepowered.api.command.args.CommandContext; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) {
src.sendMessage(Text.of(TextColors.RED, "Lookups can only be performed by players"));
return CommandResult.empty();
}
Player p = (Player) src;
Collection<String> filters = args.getAll("filter");
LookupResult lookup = LookupResultManager.instance().getLookupResult(p);
if (lookup == null) {
src.sendMessage(Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "You have no lookup history!"));
return CommandResult.empty();
}
FilterSet filterSet = new FilterSet(plugin, p, false);
filterSet.forceLookupType(lookup.getLookupType());
FilterParser.parse(filters, filterSet, p);
lookup.filterResult(filterSet);
lookup.showPage(p, 1);
return CommandResult.success();
}
示例4: execute
import org.spongepowered.api.command.args.CommandContext; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
Collection<WorldProperties> worlds;
if (args.hasAny(PARAM_WORLD)) {
worlds = args.<WorldProperties>getAll(PARAM_WORLD);
} else if (args.hasAny(PARAM_ALL)) {
worlds = Sponge.getGame().getServer().getAllWorldProperties();
} else if (src instanceof Locatable) {
worlds = Collections.singleton(((Player) src).getWorld().getProperties());
} else
throw new CommandException(Text.of("You have to enter a world when using this from the console!"), true);
final boolean mode = args.<Boolean>getOne(PARAM_MODE).get();
final String permission = BASE_PERMISSION + '.' + (mode ? "enable" : "disable") + '.';
final List<String> worldNames = worlds.stream().map(WorldProperties::getWorldName)
.filter(world -> src.hasPermission(permission + world)).collect(Collectors.toList());
worldNames.stream().forEach(world -> AuraSunDial.getConfig().setWorld(world, mode));
AuraSunDial.getConfig().save();
if (worldNames.size() > 0) {
src.sendMessage(Text.of((mode ? "Enabled" : "Disabled") + " realtime on these worlds: "
+ worldNames.stream().collect(Collectors.joining(", "))));
} else
throw new CommandPermissionException();
return CommandResult.successCount(worldNames.size());
}
示例5: execute
import org.spongepowered.api.command.args.CommandContext; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) {
src.sendMessage(Text.of(TextColors.RED, "Lookups can only be performed by players"));
return CommandResult.empty();
}
Player p = (Player) src;
Collection<String> filters = args.getAll("filter");
FilterSet filterSet = new FilterSet(plugin, p, true);
FilterParser.parse(filters, filterSet, p);
p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
LookupResult lookup;
Connection c = plugin.getDatabase().getConnection();
try {
int worldId = Database.worldCache.getDataId(c, p.getWorld().getUniqueId().toString());
ResultSet r = c.createStatement().executeQuery(QueryHelper.getLookupQuery(filterSet, p, worldId));
if (filterSet.getLookupType() == LookupType.ITEM_LOOKUP)
lookup = new ContainerLookupResult(r);
else
lookup = new BlockLookupResult(r);
LookupResultManager.instance().setLookupResult(p, lookup);
r.close();
c.close();
} catch (SQLException e) {
e.printStackTrace();
p.sendMessage(Text.of(TextColors.DARK_AQUA, "[AC] ", TextColors.RED, "A database error has occurred! Contact your server administrator!"));
return;
}
lookup.showPage(p, 1);
});
return CommandResult.success();
}
示例6: processAliasCommand
import org.spongepowered.api.command.args.CommandContext; //导入方法依赖的package包/类
private CommandResult processAliasCommand(String name, CommandSource src, CommandContext args) throws CommandException
{
Collection<Player> players = args.getAll("player");
for (Player player : players)
{
commandManager.process(src, "virtualchest open " + name + " " + player.getName());
}
return CommandResult.success();
}