mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-12-02 15:43:22 +01:00
removed crackshot dependency, fixes #152
This commit is contained in:
parent
31cc62774b
commit
1afec3b34e
9
pom.xml
9
pom.xml
@ -9,7 +9,7 @@
|
||||
<name>ChestSort</name>
|
||||
<url>https://www.chestsort.de</url>
|
||||
<description>Allows automatic chest sorting!</description>
|
||||
<version>13.0.2</version>
|
||||
<version>13.0.3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
@ -234,13 +234,6 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>de.jeff_media.thirdparty</groupId>
|
||||
<artifactId>CrackShot</artifactId>
|
||||
<version>0.98.11</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>--> <!-- not needed anymore, using reflection since crackshot is dead -->
|
||||
|
||||
<dependency>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>Minepacks-API</artifactId>
|
||||
|
@ -28,6 +28,7 @@
|
||||
package de.jeff_media.chestsort;
|
||||
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksPlugin;
|
||||
import com.jeff_media.updatechecker.UpdateChecker;
|
||||
import de.jeff_media.chestsort.commands.AdminCommand;
|
||||
import de.jeff_media.chestsort.commands.ChestSortCommand;
|
||||
import de.jeff_media.chestsort.commands.InvSortCommand;
|
||||
@ -53,7 +54,6 @@ import de.jeff_media.chestsort.utils.Utils;
|
||||
import de.jeff_media.jefflib.JeffLib;
|
||||
import de.jeff_media.jefflib.McVersion;
|
||||
import de.jeff_media.jefflib.NBTAPI;
|
||||
import de.jeff_media.updatechecker.UpdateChecker;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -2,32 +2,46 @@ package de.jeff_media.chestsort.hooks;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.shampaggon.crackshot.CSUtility;
|
||||
|
||||
import de.jeff_media.chestsort.ChestSortPlugin;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class CrackShotHook {
|
||||
|
||||
final ChestSortPlugin plugin;
|
||||
CSUtility crackShotUtility = null;
|
||||
Class<?> csUtilityClass = null;
|
||||
Object crackShotUtility = null;
|
||||
Method getWeaponTitle = null;
|
||||
|
||||
public CrackShotHook(ChestSortPlugin plugin) {
|
||||
this.plugin=plugin;
|
||||
|
||||
if(plugin.isHookCrackShot()) {
|
||||
crackShotUtility = new CSUtility();
|
||||
try {
|
||||
csUtilityClass = Class.forName("com.shampaggon.crackshot.CSUtility");
|
||||
crackShotUtility = csUtilityClass.getConstructor().newInstance();
|
||||
getWeaponTitle = csUtilityClass.getMethod("getWeaponTitle", ItemStack.class);
|
||||
plugin.getLogger().info("Successfully hooked into CrackShot");
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ignored) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Will return when not a weapon
|
||||
public String getCrackShotWeaponName(ItemStack item) {
|
||||
if(crackShotUtility == null || !plugin.isHookCrackShot()) {
|
||||
if(getWeaponTitle == null || !plugin.isHookCrackShot()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Will be null if not a weapon
|
||||
return crackShotUtility.getWeaponTitle(item);
|
||||
try {
|
||||
return (String) getWeaponTitle.invoke(crackShotUtility,item);
|
||||
} catch (InvocationTargetException | IllegalAccessException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user