mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-12-04 16:44:00 +01:00
11.5.1
This commit is contained in:
parent
f8e865aa0c
commit
e9e5c2cf43
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 11.5.1
|
||||||
|
- Added support for new Slimefun API
|
||||||
|
|
||||||
## 11.5.0
|
## 11.5.0
|
||||||
- Added support for AdvancedChests (thanks to its author)
|
- Added support for AdvancedChests (thanks to its author)
|
||||||
|
|
||||||
|
6
pom.xml
6
pom.xml
@ -9,7 +9,7 @@
|
|||||||
<name>ChestSort</name>
|
<name>ChestSort</name>
|
||||||
<url>https://www.chestsort.de</url>
|
<url>https://www.chestsort.de</url>
|
||||||
<description>Allows automatic chest sorting!</description>
|
<description>Allows automatic chest sorting!</description>
|
||||||
<version>11.5.0</version>
|
<version>11.5.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -239,9 +239,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TheBusyBiscuit</groupId>
|
<groupId>com.github.Slimefun</groupId>
|
||||||
<artifactId>Slimefun4</artifactId>
|
<artifactId>Slimefun4</artifactId>
|
||||||
<version>RC-15</version>
|
<version>RC-28</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -1,12 +1,42 @@
|
|||||||
package de.jeff_media.chestsort.hooks;
|
package de.jeff_media.chestsort.hooks;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
import org.bukkit.Bukkit;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class SlimeFunHook {
|
public class SlimeFunHook {
|
||||||
|
|
||||||
public static boolean isSlimefunBackpack(ItemStack item) {
|
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