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


Java CommandSource.hasPermission方法代码示例

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


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

示例1: parseValue

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Nullable
@Override
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
    String arg = args.next().toLowerCase();

    // Try
    GameRegistry registry = Sponge.getRegistry();
    Optional<? extends CatalogType> catalogType = registry.getType(this.type, arg);
    if (!catalogType.isPresent() && !arg.contains(":")) {
        catalogType = registry.getType(this.type, "minecraft:" + arg);
        if (!catalogType.isPresent()) {
            catalogType = registry.getType(this.type, "happytrails:" + arg);
        }
    }

    final String trimmedId = catalogType
        .map(trail -> trail.getId().contains(":") ? trail.getId().split(":")[1] : trail.getId())
        .orElse("");
    if (catalogType.isPresent() && source.hasPermission(this.permissionPrefix + trimmedId)) {
        return catalogType.get();
    }

    throw args.createError(Text.of(TextColors.RED, ""));
}
 
开发者ID:gabizou,项目名称:HappyTrails,代码行数:25,代码来源:TrailCommands.java

示例2: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (src.hasPermission("*") || src.hasPermission("listener.admin"))
	{
	Boolean clear = SwitchSQL.Clearqueue();
	if(clear){
		src.sendMessage(Text.of("Cleared successful"));
		return CommandResult.success();
	}
	else{
		src.sendMessage(Text.of("Cleared fail"));
		return CommandResult.empty();
	}
	}else{
		src.sendMessage(Text.of("You don't have permission"));
	return CommandResult.empty();
	}
}
 
开发者ID:Mineaurion,项目名称:AurionVoteListener,代码行数:19,代码来源:ClearqueueCmd.java

示例3: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if ((src.hasPermission("*")) || (src.hasPermission("listener.admin")))
	{
		String player = args.<String>getOne("player").get();
		int vote = args.<Integer>getOne("vote").get();	
		long CurrentMiliseconde = System.currentTimeMillis();
		boolean succes = SwitchSQL.Voted(player, vote, CurrentMiliseconde);
		if(succes){
			src.sendMessage(Text.of("Vote set for "+player+" : "+String.valueOf(vote)));
			return CommandResult.success();
		}else{
			src.sendMessage(Text.of("an error has occurred"));
			return CommandResult.success();
		}
	}else{
		src.sendMessage(Text.of("You don't have permission"));
	return CommandResult.empty();
	}
}
 
开发者ID:Mineaurion,项目名称:AurionVoteListener,代码行数:21,代码来源:SetVoteCmd.java

示例4: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	if (src.hasPermission("*") || src.hasPermission("listener.admin"))
	{
	Boolean clear = SwitchSQL.Cleartotals();
	if(clear){
		src.sendMessage(Text.of("Cleared successful"));
		return CommandResult.success();
	}
	else{
		src.sendMessage(Text.of("Cleared fail"));
		return CommandResult.empty();
	}
	}else{
		src.sendMessage(Text.of("You don't have permission"));
	return CommandResult.empty();
	}
	
}
 
开发者ID:Mineaurion,项目名称:AurionVoteListener,代码行数:20,代码来源:CleartotalsCmd.java

示例5: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
    Optional<User> user = commandContext.getOne("player");

    if (!user.isPresent()) {
        commandSource.sendMessage(Text.of("You need to be in game or specify a player for this command to work."));
        return CommandResult.empty();
    }
    if (commandSource.hasPermission("huskycrates.keybal.others") && user.get() != commandSource) {
        commandSource.sendMessage(Text.of(TextColors.GREEN,user.get().getName() + "'s Key Balance"));
    }else{
        commandSource.sendMessage(Text.of(TextColors.GREEN,"Your Key Balance"));
    }
    boolean atleastOne = false;
    for(String vcid : HuskyCrates.instance.crateUtilities.getCrateTypes()) {
        VirtualCrate vc = HuskyCrates.instance.crateUtilities.getVirtualCrate(vcid);
        int keys = vc.getVirtualKeyBalance(user.get());
        if(keys > 0){
            atleastOne = true;
            commandSource.sendMessage(Text.of("  ", TextSerializers.FORMATTING_CODE.deserialize(vc.displayName), ": " + keys + " (id: " + vc.id + ") "));
        }
    }
    if(!atleastOne){
        if (commandSource.hasPermission("huskycrates.keybal.others") && user.get() != commandSource) {
            commandSource.sendMessage(Text.of(TextColors.GRAY, TextStyles.ITALIC,user.get().getName() + " currently has no virtual keys."));
        }else{
            commandSource.sendMessage(Text.of(TextColors.GRAY, TextStyles.ITALIC,"You currently have no virtual keys."));
        }

    }
    return CommandResult.success();
}
 
开发者ID:codeHusky,项目名称:HuskyCrates-Sponge,代码行数:32,代码来源:KeyBal.java

示例6: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    final Player player_args = args.<Player>getOne("player").orElse(null);
    if (src.hasPermission(VTPermissions.COMMAND_BACKPACKLOCK)) {
        if (player_args != null) {
            if (args.hasAny("l") || args.hasAny("u")) {
                if (args.hasAny("l")) {
                    if (!Tools.backpackchecklock(player_args, this.vt)) {
                        this.bplock(player_args, src);
                    }
                }
                if (args.hasAny("u")) {
                    if (Tools.backpackchecklock(player_args, this.vt)) {
                        this.bpunlock(player_args, src);
                    }
                }
            } else {
                if (Tools.backpackchecklock(player_args, this.vt)) {
                    this.bpunlock(player_args, src);
                } else {
                    this.bplock(player_args, src);
                }
            }
        }
    } else {
        throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
    }
    return CommandResult.success();
}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:30,代码来源:BackpackLockCMD.java

示例7: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (src.hasPermission(VTPermissions.COMMAND_MAIN)) {
    } else {
        throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
    }

    return CommandResult.success();
}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:10,代码来源:MainCMD.java

示例8: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (src instanceof Player) {
        if (src.hasPermission(VTPermissions.COMMAND_ANVIL)) {
            final VirtualAnvil VA = new VirtualAnvil(Tools.getPlayerE(src, this.vt));

            return inv.Open(src, VA, "minecraft:anvil", "Virtual Anvil");
        } else {
            throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
        }
    } else {
        throw new CommandException(Text.of("You can't use this command if you are not a player!"));
    }

}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:16,代码来源:AnvilCMD.java

示例9: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (src instanceof Player) {
        if (src.hasPermission(VTPermissions.COMMAND_ENDERCHEST)) {
            return inv.Open(src, args, "enderchest");
        } else {
            throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
        }
    } else {
        throw new CommandException(Text.of("You can't use this command if you are not a player!"));
    }
}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:13,代码来源:EnderChestCMD.java

示例10: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    if (src instanceof Player) {
        if (src.hasPermission(VTPermissions.COMMAND_WORKBENCH)) {
            return inv.Open(src, new VirtualWorkbench(Tools.getPlayerE(src, this.vt)), "minecraft:crafting_table", "Workbench");
        } else {
            throw new CommandPermissionException(Text.of("You don't have permission to use this command."));
        }
    } else {
        throw new CommandException(Text.of("You can't use this command if you are not a player!"));
    }

}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:14,代码来源:WorkbenchCMD.java

示例11: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	boolean hasAnyPermission = false;
	Text text = Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "Available commands: ");
	if (src.hasPermission(Permissions.LOOKUP.get())) {
		hasAnyPermission = true;
		text = Text.of(text, Text.NEW_LINE, CommandInspect.getHelpEntry(), Text.NEW_LINE, CommandLookup.getHelpEntry());
	}
	if (src.hasPermission(Permissions.FILTER.get())) {
		hasAnyPermission = true;
		text = Text.of(text, Text.NEW_LINE, CommandFilter.getHelpEntry());
	}
	if (src.hasPermission(Permissions.LOOKUP.get())) {
		text = Text.of(text, Text.NEW_LINE, CommandPage.getHelpEntry(), Text.NEW_LINE, CommandNextPage.getHelpEntry(), Text.NEW_LINE,
				CommandPrevPage.getHelpEntry());
	}
	if (src.hasPermission(Permissions.PURGE.get())) {
		hasAnyPermission = true;
		text = Text.of(text, Text.NEW_LINE, CommandPurge.getHelpEntry());
	}
	
	if (hasAnyPermission) {
		text = Text.of(text, Text.NEW_LINE, getHelpEntry());
	} else {
		text = Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "AdamantineShield v",
				Sponge.getPluginManager().getPlugin("adamantineshield").get().getVersion().get());
	}
	
	src.sendMessage(text);
	return CommandResult.success();
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:32,代码来源:CommandMain.java

示例12: hasPermission

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
public static boolean hasPermission(CommandSource src, String permission) {
	return src.hasPermission(permission);
}
 
开发者ID:DevOnTheRocks,项目名称:StickyChunk,代码行数:4,代码来源:Permissions.java

示例13: execute

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
/**
 * Callback for the execution of a command.
 *
 * @param src  The commander who is executing this command
 * @param args The parsed command arguments for this command
 * @return the result of executing this command
 * @throws CommandException If a user-facing error occurs while executing this command
 */
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
	boolean hasPerms = false;
	List<Text> helpContents = Lists.newArrayList();

	helpContents.add(Text.of(
		TextColors.WHITE, "StickyChunk's region selection tool is set to: ",
		Text.builder("Blaze Rod").color(TextColors.GOLD)
			.onHover(TextActions.showItem(ItemStack.builder().itemType(ItemTypes.BLAZE_ROD).build().createSnapshot())))
	);

	if (src.hasPermission(Permissions.COMMAND_LIST)) {
		helpContents.add(Text.of(
			Text.NEW_LINE,
			TextColors.GOLD, Text.builder("/sc list").onClick(TextActions.runCommand("/sc list")),
			TextColors.GRAY, (src.hasPermission(Permissions.COMMAND_LIST_OTHERS)) ? " [user]" : Text.EMPTY,
			TextColors.DARK_GRAY, " - ",
			TextColors.WHITE, CommandList.helpText
		));
		hasPerms = true;
	}

	if (src.hasPermission(Permissions.COMMAND_CREATE)) {
		helpContents.add(Text.of(
			Text.NEW_LINE,
			TextColors.GOLD, Text.builder("/sc load").onClick(TextActions.suggestCommand("/sc load")),
			TextColors.GRAY, " [world|personal]",
			TextColors.DARK_GRAY, " - ",
			TextColors.WHITE, CommandLoad.helpText
		));
		hasPerms = true;
	}

	if (src.hasPermission(Permissions.COMMAND_CREATE)) {
		helpContents.add(Text.of(
			Text.NEW_LINE,
			TextColors.GOLD, Text.builder("/sc loadarea").onClick(TextActions.suggestCommand("/sc loadarea")),
			TextColors.GRAY, " [world|personal]",
			TextColors.DARK_GRAY, " - ",
			TextColors.WHITE, CommandLoadRange.helpText
		));
		hasPerms = true;
	}

	if (src.hasPermission(Permissions.COMMAND_DELETE)) {
		helpContents.add(Text.of(
			Text.NEW_LINE,
			TextColors.GOLD, Text.builder("/sc unload").onClick(TextActions.suggestCommand("/sc unload")),
			TextColors.GRAY, " [all]",
			TextColors.DARK_GRAY, " - ",
			TextColors.WHITE, CommandUnload.helpText
		));
		hasPerms = true;
	}

	if (hasPerms) {
		PaginationList.builder()
			.title(Text.of(TextColors.GOLD, NAME, " Help"))
			.padding(Text.of(TextColors.GOLD, TextStyles.STRIKETHROUGH, "-"))
			.contents(helpContents)
			.sendTo(src);
	} else {
		src.sendMessage(Text.of(NAME + " " + VERSION));
	}

	return CommandResult.success();
}
 
开发者ID:DevOnTheRocks,项目名称:StickyChunk,代码行数:75,代码来源:CommandPersist.java

示例14: canUseCamera

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
public Boolean canUseCamera(CommandSource src){
    return this.getPermission().equals("") || src.hasPermission(this.getPermission());
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:4,代码来源:Camera.java

示例15: hasPermission

import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public boolean hasPermission(CommandSource source) {
    return source.hasPermission("mcrmb.admin");
}
 
开发者ID:txgs888,项目名称:McrmbCore_Sponge,代码行数:5,代码来源:SetupCommand.java


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