Skip to content

Commit

Permalink
refactor: box api update and release v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyGon committed Nov 2, 2022
1 parent 3881bc5 commit dfa916e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "net.okocraft.boxtradestick"
version = "1.0-SNAPSHOT"
version = "1.0"

repositories {
mavenCentral()
Expand All @@ -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")
Expand Down
17 changes: 3 additions & 14 deletions src/main/java/net/okocraft/boxtradestick/BoxUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,9 @@ public static Optional<BoxItem> 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) {
Expand Down

0 comments on commit dfa916e

Please sign in to comment.