private void refreshAutoOp(Player player, boolean callerIsSync) {
        if (!callerIsSync && this.plugin.getBootstrap().isServerStopping()) {
            return;
        }

        User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());

        boolean value;
        if (user != null) {
            QueryOptions queryOptions = this.plugin.getContextManager().getQueryOptions(player);
            Map<String, Boolean> permData = user.getCachedData().getPermissionData(queryOptions).getPermissionMap();
            value = permData.getOrDefault(NODE, false);
        } else {
            value = false;
        }

        if (callerIsSync) {
            player.setOp(value);
        } else {
            this.plugin.getBootstrap().getScheduler().executeSync(() -> player.setOp(value));
        }
    }
Implements the LuckPerms auto op feature.
bukkit/src/main/java/me/lucko/luckperms/bukkit/listeners/BukkitAutoOpListener.java