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>
|
<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>13.0.2</version>
|
<version>13.0.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -234,13 +234,6 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</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>
|
<dependency>
|
||||||
<groupId>at.pcgamingfreaks</groupId>
|
<groupId>at.pcgamingfreaks</groupId>
|
||||||
<artifactId>Minepacks-API</artifactId>
|
<artifactId>Minepacks-API</artifactId>
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
package de.jeff_media.chestsort;
|
package de.jeff_media.chestsort;
|
||||||
|
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksPlugin;
|
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.AdminCommand;
|
||||||
import de.jeff_media.chestsort.commands.ChestSortCommand;
|
import de.jeff_media.chestsort.commands.ChestSortCommand;
|
||||||
import de.jeff_media.chestsort.commands.InvSortCommand;
|
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.JeffLib;
|
||||||
import de.jeff_media.jefflib.McVersion;
|
import de.jeff_media.jefflib.McVersion;
|
||||||
import de.jeff_media.jefflib.NBTAPI;
|
import de.jeff_media.jefflib.NBTAPI;
|
||||||
import de.jeff_media.updatechecker.UpdateChecker;
|
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -2,32 +2,46 @@ package de.jeff_media.chestsort.hooks;
|
|||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.shampaggon.crackshot.CSUtility;
|
|
||||||
|
|
||||||
import de.jeff_media.chestsort.ChestSortPlugin;
|
import de.jeff_media.chestsort.ChestSortPlugin;
|
||||||
|
|
||||||
public class CrackShotHook {
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
final ChestSortPlugin plugin;
|
|
||||||
CSUtility crackShotUtility = null;
|
|
||||||
|
|
||||||
public CrackShotHook(ChestSortPlugin plugin) {
|
public class CrackShotHook {
|
||||||
this.plugin=plugin;
|
|
||||||
|
final ChestSortPlugin plugin;
|
||||||
if(plugin.isHookCrackShot()) {
|
Class<?> csUtilityClass = null;
|
||||||
crackShotUtility = new CSUtility();
|
Object crackShotUtility = null;
|
||||||
plugin.getLogger().info("Successfully hooked into CrackShot");
|
Method getWeaponTitle = null;
|
||||||
}
|
|
||||||
}
|
public CrackShotHook(ChestSortPlugin plugin) {
|
||||||
|
this.plugin=plugin;
|
||||||
// Will return when not a weapon
|
|
||||||
public String getCrackShotWeaponName(ItemStack item) {
|
if(plugin.isHookCrackShot()) {
|
||||||
if(crackShotUtility == null || !plugin.isHookCrackShot()) {
|
try {
|
||||||
return null;
|
csUtilityClass = Class.forName("com.shampaggon.crackshot.CSUtility");
|
||||||
}
|
crackShotUtility = csUtilityClass.getConstructor().newInstance();
|
||||||
|
getWeaponTitle = csUtilityClass.getMethod("getWeaponTitle", ItemStack.class);
|
||||||
// Will be null if not a weapon
|
plugin.getLogger().info("Successfully hooked into CrackShot");
|
||||||
return crackShotUtility.getWeaponTitle(item);
|
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ignored) {
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Will return when not a weapon
|
||||||
|
public String getCrackShotWeaponName(ItemStack item) {
|
||||||
|
if(getWeaponTitle == null || !plugin.isHookCrackShot()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Will be null if not a weapon
|
||||||
|
try {
|
||||||
|
return (String) getWeaponTitle.invoke(crackShotUtility,item);
|
||||||
|
} catch (InvocationTargetException | IllegalAccessException ignored) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user