@Override
        public boolean test(CommandSourceStack source) {
            if (source.getEntity() instanceof ServerPlayer) {
                ServerPlayer player = (ServerPlayer) source.getEntity();
                Tristate state = Tristate.UNDEFINED;
                // If player is still connecting and has not been added to world then check LP user directly
                if (!player.isAddedToWorld()) {
                    User user = this.plugin.getUserManager().getIfLoaded(player.getUUID());
                    if (user == null) {
                        // Should never happen but just in case...
                        return false;
                    }
                    state = user.getCachedData().getPermissionData().checkPermission(permission);
                } else {
                    UserCapability user = UserCapabilityImpl.get(player);
                    state = user.checkPermission(this.permission);
                }

                if (state != Tristate.UNDEFINED) {
                    return state.asBoolean() && this.delegate.test(source.withPermission(4));
                }
            }

            return this.delegate.test(source);
        }
Injected {@link CommandNode#getRequirement() requirement} that checks for a permission, before
delegating to the existing requirement.
forge/src/main/java/me/lucko/luckperms/forge/util/BrigadierInjector.java