diff --git a/build.gradle.kts b/build.gradle.kts index b5b2063..798957d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "net.okocraft.boxtradestick" -version = "1.0-SNAPSHOT" +version = "1.0" repositories { mavenCentral() @@ -21,9 +21,9 @@ dependencies { implementation("com.github.siroshun09.configapi:configapi-yaml:4.6.0") implementation("com.github.siroshun09.translationloader:translationloader:2.0.2") - compileOnly("net.okocraft.box:box-api:5.0.0-rc.5") - compileOnly("net.okocraft.box:box-storage-api:5.0.0-rc.5") - compileOnly("net.okocraft.box:box-stick-feature:5.0.0-rc.5") + compileOnly("net.okocraft.box:box-api:5.0.0-rc.6") + compileOnly("net.okocraft.box:box-storage-api:5.0.0-rc.6") + compileOnly("net.okocraft.box:box-stick-feature:5.0.0-rc.6") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") diff --git a/src/main/java/net/okocraft/boxtradestick/BoxUtil.java b/src/main/java/net/okocraft/boxtradestick/BoxUtil.java index 5b75afe..ab57a96 100644 --- a/src/main/java/net/okocraft/boxtradestick/BoxUtil.java +++ b/src/main/java/net/okocraft/boxtradestick/BoxUtil.java @@ -83,20 +83,9 @@ public static Optional getBoxItem(ItemStack item) { } public static BoxStickItem getBoxStickItem() { - try { - var stickFeature = BOX.getFeatures().stream() - .filter(f -> f instanceof StickFeature) - .map(f -> (StickFeature) f) - .findFirst() - .orElseThrow(() -> new Exception("Stick feature is not loaded")); - - // crying for the fact we need to reflect field;; - var boxStickItemField = stickFeature.getClass().getDeclaredField("boxStickItem"); - boxStickItemField.setAccessible(true); - return (BoxStickItem) boxStickItemField.get(stickFeature); - } catch (Exception e) { - throw new IllegalStateException("Failed to load boxStickItem.", e); - } + return BOX.getFeature(StickFeature.class) + .orElseThrow(() -> new IllegalStateException("Failed to load boxStickItem.")) + .getBoxStickItem(); } public static boolean checkPlayerCondition(@NotNull Player player, @NotNull String permissionNode) {