package com.Acrobot.Breeze.Utils;

import com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestHolder;
import com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestState;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;

import java.util.function.BiFunction;

public class ImplementationAdapter {

    private static BiFunction<Inventory, Boolean, InventoryHolder> HOLDER_PROVIDER;
    private static BiFunction<Block, Boolean, BlockState> STATE_PROVIDER;

    static {
        try {
            InventoryHolder.class.getMethod("getHolder", boolean.class);
            HOLDER_PROVIDER = PaperLatestHolder.PROVIDER;
        } catch (NoSuchMethodException e) {
            HOLDER_PROVIDER = (inventory, useSnapshot) -> inventory.getHolder();
        }
        try {
            Block.class.getMethod("getState", boolean.class);
            STATE_PROVIDER = PaperLatestState.PROVIDER;
        } catch (NoSuchMethodException e) {
            STATE_PROVIDER = (block, useSnapshot) -> block.getState();
        }
    }

    /**
     * Get the inventory's holder.
     * @param inventory     The inventory
     * @param useSnapshot   Whether or not the holder should be a snapshot (if possible)
     * @return The inventory's holder
     */
    public static InventoryHolder getHolder(Inventory inventory, boolean useSnapshot) {
        return HOLDER_PROVIDER.apply(inventory, useSnapshot);
    }

    /**
     * Get a block state
     * @param block         The block to get the state from
     * @param useSnapshot   Whether or not the state should be a snapshot (if possible)
     * @return The block's state
     */
    public static BlockState getState(Block block, boolean useSnapshot) {
        return STATE_PROVIDER.apply(block, useSnapshot);
    }
}

@@ -32,155 +32,8 @@
 s;%0A%0A
-import com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestHolder;%0Aimport com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestState;%0A
 impo
@@ -464,22 +464,16 @@
 nventory
-Holder
 .class.g
@@ -526,350 +526,827 @@
     
-HOLDER_PROVIDER = PaperLatestHolder.PROVIDER;%0A        %7D catch (NoSuchMethodException e) %7B%0A            HOLDER_PROVIDER = (inventory, useSnapshot) -%3E inventory.getHolder();%0A        %7D%0A        try %7B%0A            Block.class.getMethod(%22getState%22, boolean.class);%0A            STATE_PROVIDER = PaperLatestState.PROVIDER;%0A        %7D catch (NoSuchMethod
+Class c = Class.forName(%22com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestHolder%22);%0A            HOLDER_PROVIDER = (BiFunction%3CInventory, Boolean, InventoryHolder%3E) c.getDeclaredField(%22PROVIDER%22).get(null);%0A        %7D catch (NoSuchMethodException %7C ClassNotFoundException %7C NoSuchFieldException %7C IllegalAccessException e) %7B%0A            HOLDER_PROVIDER = (inventory, useSnapshot) -%3E inventory.getHolder();%0A        %7D%0A        try %7B%0A            Block.class.getMethod(%22getState%22, boolean.class);%0A            Class c = Class.forName(%22com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestState%22);%0A            STATE_PROVIDER = (BiFunction%3CBlock, Boolean, BlockState%3E) c.getDeclaredField(%22PROVIDER%22).get(null);%0A        %7D catch (NoSuchMethodException %7C ClassNotFoundException %7C NoSuchFieldException %7C IllegalAccess
 Exce

Fix adapter backwards compatiblity (and getHolder loading 🙈)