mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-12-03 08:03:26 +01:00
11.5.1
This commit is contained in:
parent
f8e865aa0c
commit
e9e5c2cf43
@ -1,5 +1,8 @@
|
||||
# Changelog
|
||||
|
||||
## 11.5.1
|
||||
- Added support for new Slimefun API
|
||||
|
||||
## 11.5.0
|
||||
- Added support for AdvancedChests (thanks to its author)
|
||||
|
||||
|
6
pom.xml
6
pom.xml
@ -9,7 +9,7 @@
|
||||
<name>ChestSort</name>
|
||||
<url>https://www.chestsort.de</url>
|
||||
<description>Allows automatic chest sorting!</description>
|
||||
<version>11.5.0</version>
|
||||
<version>11.5.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
@ -239,9 +239,9 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.TheBusyBiscuit</groupId>
|
||||
<groupId>com.github.Slimefun</groupId>
|
||||
<artifactId>Slimefun4</artifactId>
|
||||
<version>RC-15</version>
|
||||
<version>RC-28</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -1,12 +1,42 @@
|
||||
package de.jeff_media.chestsort.hooks;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class SlimeFunHook {
|
||||
|
||||
public static boolean isSlimefunBackpack(ItemStack item) {
|
||||
return SlimefunItem.getByItem(item) instanceof SlimefunBackpack;
|
||||
|
||||
if(Bukkit.getPluginManager().getPlugin("Slimefun") == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// New Slimefun API
|
||||
try {
|
||||
final Class<?> slimefunItemClass = Class.forName("io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem");
|
||||
final Class<?> slimefunBackpackClass = Class.forName("io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack");
|
||||
final Method getByItemMethod = slimefunItemClass.getMethod("getByItem", ItemStack.class);
|
||||
final Object result = getByItemMethod.invoke(null, item);
|
||||
if(result == null) return false;
|
||||
return slimefunBackpackClass.isInstance(result);
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
// Old Slimefun API
|
||||
try {
|
||||
final Class<?> slimefunItemClass = Class.forName("me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem");
|
||||
final Class<?> slimefunBackpackClass = Class.forName("io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack");
|
||||
final Method getByItemMethod = slimefunItemClass.getMethod("getByItem", ItemStack.class);
|
||||
final Object result = getByItemMethod.invoke(null, item);
|
||||
if(result == null) return false;
|
||||
return slimefunBackpackClass.isInstance(result);
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user