public static void inject(Player player, LuckPermsPermissible newPermissible, PluginLogger logger) throws Exception {

        // get the existing PermissibleBase held by the player
        PermissibleBase oldPermissible = (PermissibleBase) HUMAN_ENTITY_PERMISSIBLE_FIELD.get(player);

        // seems we have already injected into this player.
        if (oldPermissible instanceof LuckPermsPermissible) {
            throw new IllegalStateException("LPPermissible already injected into player " + player.toString());
        }

        Class<? extends PermissibleBase> oldClass = oldPermissible.getClass();
        if (!PermissibleBase.class.equals(oldClass)) {
            logger.warn("Player " + player.getName() + " already has a custom permissible (" + oldClass.getName() + ")!\n" +
                    "This is probably because you have multiple permission plugins installed.\n" +
                    "Please make sure that LuckPerms is the only permission plugin installed on your server!\n" +
                    "(unless you're performing a migration, in which case, just remember to remove your old " +
                    "permission plugin once you're done!)");
        }

        // Move attachments over from the old permissible

        //noinspection unchecked
        List<PermissionAttachment> attachments = (List<PermissionAttachment>) PERMISSIBLE_BASE_ATTACHMENTS_FIELD.get(oldPermissible);

        newPermissible.convertAndAddAttachments(attachments);
        attachments.clear();
        oldPermissible.clearPermissions();

        // Setup the new permissible
        newPermissible.getActive().set(true);
        newPermissible.setOldPermissible(oldPermissible);

        // inject the new instance
        HUMAN_ENTITY_PERMISSIBLE_FIELD.set(player, newPermissible);
    }
Injects a {@link LuckPermsPermissible} into a {@link Player}.

@param player the player to inject into
@param newPermissible the permissible to inject
@param logger the plugin logger
@throws Exception propagates any exceptions which were thrown during injection
bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/PermissibleInjector.java