• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CommandPermissionException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CommandPermissionException类属于org.spongepowered.api.command包,在下文中一共展示了CommandPermissionException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: backpackcheck

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的package包/类
private void backpackcheck(Player player) throws CommandException {
    Path file = Paths.get(this.vt.getConfigPath() + File.separator + "backpacks" + File.separator + player.getUniqueId().toString() + ".backpack");
    if (!Files.exists(file)) {
        throw new CommandPermissionException(Text.of("Sorry there is no backpack data for " + player.getName()));
    } else {
        String content = null;
        try {
            content = new String(Files.readAllBytes(file), "UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (content == "{}") {
            throw new CommandPermissionException(Text.of("Sorry there is no backpack data for " + player.getName()));
        }
    }
}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:17,代码来源:BackpackCMD.java


示例2: process

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的package包/类
@Override public CommandResult process(CommandSource source, String arguments) throws CommandException {
    // Get the first argument, is it a child?
    final CommandArgs args = new CommandArgs(arguments, tokenizer.tokenize(arguments, false));

    Optional<CommandSpec> optionalSpec = getSpec(args);
    if (optionalSpec.isPresent()) {
        CommandSpec spec = optionalSpec.get();
        CommandContext context = new CommandContext();
        spec.checkPermission(source);
        spec.populateContext(source, args, context);
        return spec.getExecutor().execute(source, context);
    }

    if (testPermission(source)) {
        // Else, what do we want to do here?
        source.sendMessage(Text.of("Phonon from Nucleus."));
        return CommandResult.success();
    }

    throw new CommandPermissionException();
}
 
开发者ID:NucleusPowered,项目名称:Phonon,代码行数:22,代码来源:PhononCommand.java


示例3: backpackchecklock

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的package包/类
private void backpackchecklock(Player player) throws CommandException {

        Path file = Paths.get(this.vt.getConfigPath() + File.separator + "backpacks" + File.separator + player.getUniqueId().toString() + ".lock");
        if (Files.exists(file)) {
            throw new CommandPermissionException(Text.of("Sorry currently your backpack is locked."));
        }
    }
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:8,代码来源:BackpackCMD.java


示例4: execute

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的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


示例5: execute

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的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


示例6: execute

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的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


示例7: execute

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的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


示例8: execute

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的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


示例9: execute

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的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


示例10: execute

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    List<Text> cmdList = COMMAND_LIST.apply(src);

    if(cmdList.isEmpty())
        throw new CommandPermissionException();

    plugin.getPagination().builder()
            .contents(cmdList)
            .title(Text.of(GRAY, "HelpTickets Commands"))
            .paddingString("=")
            .sendTo(src);
    return CommandResult.success();
}
 
开发者ID:xDotDash,项目名称:HelpTicketsOld,代码行数:15,代码来源:CommandTicket.java


示例11: execute

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext ctx) {
    List<User> userValues = new ArrayList<>(ctx.getAll("user"));
    WorldProperties worldProperties = ctx.<WorldProperties>getOne("world").orElse(null);
    User user = null;
    if (userValues.size() > 0) {
        user = userValues.get(0);
    }
    if (src instanceof Player) {
        this.displayOwned = true;
    }

    if (user == null) {
        if (!(src instanceof Player)) {
            GriefPreventionPlugin.sendMessage(src, GriefPreventionPlugin.instance.messageData.commandPlayerInvalid.toText());
            return CommandResult.success();
        }

        user = (User) src;
    }
    if (worldProperties == null) {
        worldProperties = Sponge.getServer().getDefaultWorld().get();
    }

    // otherwise if no permission to delve into another player's claims data or self
    if (!src.hasPermission(GPPermissions.COMMAND_CLAIM_LIST)) {
        try {
            throw new CommandPermissionException();
        } catch (CommandPermissionException e) {
            src.sendMessage(e.getText());
            return CommandResult.success();
        }
    }

    String arguments = "";
    if (user != null) {
        arguments = user.getName();
    }
    if (worldProperties != null) {
        if (arguments.isEmpty()) {
            arguments = worldProperties.getWorldName();
        } else {
            arguments += " " + worldProperties.getWorldName();
        }
    }

    this.canListOthers = src.hasPermission(GPPermissions.LIST_OTHER_CLAIMS);
    this.canListAdmin = src.hasPermission(GPPermissions.LIST_OTHER_CLAIMS);
    showClaimList(src, user, this.forcedType, worldProperties);
    return CommandResult.success();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:52,代码来源:CommandClaimList.java


示例12: checkPlayerPermission

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的package包/类
public void checkPlayerPermission(Subject player) throws CommandPermissionException {
    if (settings.getGeneral().isPlayerPermissions() && !player.hasPermission(permission)) {
        throw new CommandPermissionException();
    }
}
 
开发者ID:games647,项目名称:FlexibleLogin,代码行数:6,代码来源:AbstractCommand.java


示例13: checkPermSuffix

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的package包/类
default void checkPermSuffix(CommandSource sender, String suffix) throws CommandException {
    String perm = getBasePermission() + "." + suffix;
    if (!sender.hasPermission(perm)) {
        throw new CommandPermissionException();
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:7,代码来源:HighPermCommand.java


示例14: checkPermission

import org.spongepowered.api.command.CommandPermissionException; //导入依赖的package包/类
default void checkPermission(CommandSource sender, String permission) throws CommandException {
    if (!sender.hasPermission(permission)) {
        throw new CommandPermissionException();
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:6,代码来源:HighCommand.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BundleRequirement类代码示例发布时间:2022-05-23
下一篇:
Java PodamFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap