From 320d9ad9fb98160cb350ae18908a95f9f1ffba9f Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Thu, 28 Jan 2021 17:33:40 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20adapter=20backwards=20compatiblity=20(and?= =?UTF-8?q?=20getHolder=20loading=20=F0=9F=99=88)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Breeze/Utils/ImplementationAdapter.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/Acrobot/Breeze/Utils/ImplementationAdapter.java b/src/main/java/com/Acrobot/Breeze/Utils/ImplementationAdapter.java index 2403551..2075380 100644 --- a/src/main/java/com/Acrobot/Breeze/Utils/ImplementationAdapter.java +++ b/src/main/java/com/Acrobot/Breeze/Utils/ImplementationAdapter.java @@ -1,7 +1,5 @@ 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; @@ -16,15 +14,17 @@ public class ImplementationAdapter { static { try { - InventoryHolder.class.getMethod("getHolder", boolean.class); - HOLDER_PROVIDER = PaperLatestHolder.PROVIDER; - } catch (NoSuchMethodException e) { + Inventory.class.getMethod("getHolder", boolean.class); + Class c = Class.forName("com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestHolder"); + HOLDER_PROVIDER = (BiFunction) c.getDeclaredField("PROVIDER").get(null); + } catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { HOLDER_PROVIDER = (inventory, useSnapshot) -> inventory.getHolder(); } try { Block.class.getMethod("getState", boolean.class); - STATE_PROVIDER = PaperLatestState.PROVIDER; - } catch (NoSuchMethodException e) { + Class c = Class.forName("com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestState"); + STATE_PROVIDER = (BiFunction) c.getDeclaredField("PROVIDER").get(null); + } catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { STATE_PROVIDER = (block, useSnapshot) -> block.getState(); } }