mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-06-26 06:14:44 +02:00
Fix adapter backwards compatiblity (and getHolder loading 🙈)
This commit is contained in:
parent
65df4c40c6
commit
320d9ad9fb
|
@ -1,7 +1,5 @@
|
||||||
package com.Acrobot.Breeze.Utils;
|
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.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
@ -16,15 +14,17 @@ public class ImplementationAdapter {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
InventoryHolder.class.getMethod("getHolder", boolean.class);
|
Inventory.class.getMethod("getHolder", boolean.class);
|
||||||
HOLDER_PROVIDER = PaperLatestHolder.PROVIDER;
|
Class c = Class.forName("com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestHolder");
|
||||||
} catch (NoSuchMethodException e) {
|
HOLDER_PROVIDER = (BiFunction<Inventory, Boolean, InventoryHolder>) c.getDeclaredField("PROVIDER").get(null);
|
||||||
|
} catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||||
HOLDER_PROVIDER = (inventory, useSnapshot) -> inventory.getHolder();
|
HOLDER_PROVIDER = (inventory, useSnapshot) -> inventory.getHolder();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Block.class.getMethod("getState", boolean.class);
|
Block.class.getMethod("getState", boolean.class);
|
||||||
STATE_PROVIDER = PaperLatestState.PROVIDER;
|
Class c = Class.forName("com.Acrobot.Breeze.Utils.ImplementationFeatures.PaperLatestState");
|
||||||
} catch (NoSuchMethodException e) {
|
STATE_PROVIDER = (BiFunction<Block, Boolean, BlockState>) c.getDeclaredField("PROVIDER").get(null);
|
||||||
|
} catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||||
STATE_PROVIDER = (block, useSnapshot) -> block.getState();
|
STATE_PROVIDER = (block, useSnapshot) -> block.getState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user