/*
 * This file is part of LuckPerms, licensed under the MIT License.
 *
 *  Copyright (c) lucko (Luck) <luck@lucko.me>
 *  Copyright (c) contributors
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in all
 *  copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 *  SOFTWARE.
 */

package me.lucko.luckperms.bukkit.calculator;

import com.google.common.collect.ImmutableList;

import me.lucko.luckperms.bukkit.LPBukkitPlugin;
import me.lucko.luckperms.bukkit.context.BukkitContextManager;
import me.lucko.luckperms.common.cacheddata.CacheMetadata;
import me.lucko.luckperms.common.calculator.CalculatorFactory;
import me.lucko.luckperms.common.calculator.PermissionCalculator;
import me.lucko.luckperms.common.calculator.processor.MapProcessor;
import me.lucko.luckperms.common.calculator.processor.PermissionProcessor;
import me.lucko.luckperms.common.calculator.processor.RegexProcessor;
import me.lucko.luckperms.common.calculator.processor.WildcardProcessor;
import me.lucko.luckperms.common.config.ConfigKeys;
import me.lucko.luckperms.common.model.HolderType;

import net.luckperms.api.query.QueryOptions;

public class BukkitCalculatorFactory implements CalculatorFactory {
    private final LPBukkitPlugin plugin;

    public BukkitCalculatorFactory(LPBukkitPlugin plugin) {
        this.plugin = plugin;
    }

    @Override
    public PermissionCalculator build(QueryOptions queryOptions, CacheMetadata metadata) {
        ImmutableList.Builder<PermissionProcessor> processors = ImmutableList.builder();

        processors.add(new MapProcessor());

        if (this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_CHILD_PERMISSIONS)) {
            processors.add(new ChildProcessor(this.plugin));
        }

        if (this.plugin.getConfiguration().get(ConfigKeys.APPLYING_REGEX)) {
            processors.add(new RegexProcessor());
        }

        if (this.plugin.getConfiguration().get(ConfigKeys.APPLYING_WILDCARDS)) {
            processors.add(new WildcardProcessor());
        }

        if (metadata.getHolderType() == HolderType.USER) {
            boolean op = queryOptions.option(BukkitContextManager.OP_OPTION).orElse(false);
            if (this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) {
                processors.add(new DefaultsProcessor(this.plugin, op));
            }

            if (op) {
                processors.add(new OpProcessor());
            }
        }

        return new PermissionCalculator(this.plugin, metadata, processors.build());
    }
}

@@ -1976,59 +1976,8 @@
 eys;
-%0Aimport me.lucko.luckperms.common.model.HolderType;
 %0A%0Aim
@@ -2919,71 +2919,8 @@
  %7D%0A%0A
-        if (metadata.getHolderType() == HolderType.USER) %7B%0A    
     
@@ -3003,20 +3003,16 @@
 false);%0A
-    
         
@@ -3102,36 +3102,32 @@
 ) %7B%0A            
-    
 processors.add(n
@@ -3170,35 +3170,27 @@
 ));%0A        
-  
-  
 %7D%0A%0A
-    
         if (
@@ -3191,28 +3191,24 @@
   if (op) %7B%0A
-    
             
@@ -3246,22 +3246,8 @@
 ));%0A
-            %7D%0A
     

Fix support for setting vault npc op status