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


Java CommandContext.getAll方法代碼示例

本文整理匯總了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();
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:17,代碼來源:CommandUndo.java

示例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();
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:17,代碼來源:CommandRollback.java

示例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();
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:25,代碼來源:CommandFilter.java

示例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());
}
 
開發者ID:AuraDevelopmentTeam,項目名稱:AuraSunDial,代碼行數:31,代碼來源:CommandRealTime.java

示例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();
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:40,代碼來源:CommandLookup.java

示例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();
}
 
開發者ID:ustc-zzzz,項目名稱:VirtualChest,代碼行數:10,代碼來源:VirtualChestCommandAliases.java


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