本文整理汇总了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, ""));
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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!"));
}
}
示例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!"));
}
}
示例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!"));
}
}
示例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();
}
示例12: hasPermission
import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
public static boolean hasPermission(CommandSource src, String permission) {
return src.hasPermission(permission);
}
示例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();
}
示例14: canUseCamera
import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
public Boolean canUseCamera(CommandSource src){
return this.getPermission().equals("") || src.hasPermission(this.getPermission());
}
示例15: hasPermission
import org.spongepowered.api.command.CommandSource; //导入方法依赖的package包/类
@Override
public boolean hasPermission(CommandSource source) {
return source.hasPermission("mcrmb.admin");
}