Java Code Examples for com.velocitypowered.api.command.CommandSource#hasPermission()

The following examples show how to use com.velocitypowered.api.command.CommandSource#hasPermission() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SkinCommand.java    From SkinsRestorerX with GNU General Public License v3.0 6 votes vote down vote up
@Subcommand("set") @CommandPermission("%skinSetOther")
@CommandCompletion("@players")
@Description("%helpSkinSetOther")
@Syntax("<target> <skin/url>")
public void onSkinSetOther(CommandSource source, OnlinePlayer target, String skin) {
    if (Config.PER_SKIN_PERMISSIONS && Config.USE_NEW_PERMISSIONS) {
        if (!source.hasPermission("skinsrestorer.skin." + skin)) {
            if (!getSenderName(source).equals(target.getPlayer().getUsername()) || (!source.hasPermission("skinsrestorer.ownskin") && !skin.equalsIgnoreCase(getSenderName(source)))) {
                source.sendMessage(LegacyComponentSerializer.legacy().deserialize(Locale.PLAYER_HAS_NO_PERMISSION_SKIN));
                return;
            }
        }
    }

    plugin.getService().execute(() -> {
        if (this.setSkin(source, target.getPlayer(), skin)) {
            if (!getSenderName(source).equals(target.getPlayer().getUsername())) {
                source.sendMessage(LegacyComponentSerializer.legacy().deserialize(Locale.ADMIN_SET_SKIN.replace("%player", target.getPlayer().getUsername())));
            }
        }
    });
}
 
Example 2
Source File: GeyserVelocityCommandExecutor.java    From Geyser with MIT License 5 votes vote down vote up
@Override
public void execute(CommandSource source, String[] args) {
    if (args.length > 0) {
        if (getCommand(args[0]) != null) {
            if (!source.hasPermission(getCommand(args[0]).getPermission())) {
                source.sendMessage(TextComponent.of(ChatColor.RED + "You do not have permission to execute this command!"));
                return;
            }
            getCommand(args[0]).execute(new VelocityCommandSender(source), args);
        }
    } else {
        getCommand("help").execute(new VelocityCommandSender(source), args);
    }
}
 
Example 3
Source File: VelocitySenderFactory.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
protected boolean hasPermission(CommandSource source, String node) {
    return source.hasPermission(node);
}
 
Example 4
Source File: NVReloadCmd.java    From NuVotifier with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean hasPermission(CommandSource sender, @NonNull String[] args) {
    return sender.hasPermission("nuvotifier.reload");
}
 
Example 5
Source File: TestVoteCmd.java    From NuVotifier with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
    return source.hasPermission("nuvotifier.testvote");
}