Skip to content

Commit 89bdb2a

Browse files
Boy0000LichtHund
andauthored
feat: add Nexo support without breaking Java 11 compatibility (#181)
Co-authored-by: Matt <matt.mmor@gmail.com>
1 parent b6e5ad2 commit 89bdb2a

File tree

6 files changed

+62
-5
lines changed

6 files changed

+62
-5
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v4
18-
- name: Set up JDK 17
18+
- name: Set up JDK 21
1919
uses: actions/setup-java@v4
2020
with:
21-
java-version: '17'
21+
java-version: '21'
2222
distribution: 'temurin'
2323

2424
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
@@ -59,10 +59,10 @@ jobs:
5959

6060
steps:
6161
- uses: actions/checkout@v4
62-
- name: Set up JDK 17
62+
- name: Set up JDK 21
6363
uses: actions/setup-java@v4
6464
with:
65-
java-version: '17'
65+
java-version: '21'
6666
distribution: 'temurin'
6767

6868
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ repositories {
1818
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
1919
maven("https://repo.glaremasters.me/repository/public/")
2020
maven("https://nexus.phoenixdevt.fr/repository/maven-public/")
21+
maven("https://repo.nexomc.com/releases/")
2122
maven("https://repo.oraxen.com/releases")
2223
maven("https://jitpack.io")
2324
}
@@ -30,6 +31,7 @@ dependencies {
3031

3132
compileOnly(libs.headdb)
3233
compileOnly(libs.itemsadder)
34+
compileOnly(libs.nexo)
3335
compileOnly(libs.oraxen)
3436
compileOnly(libs.mythiclib)
3537
compileOnly(libs.mmoitems)
@@ -55,6 +57,7 @@ tasks {
5557
java {
5658
sourceCompatibility = JavaVersion.VERSION_11
5759
targetCompatibility = JavaVersion.VERSION_11
60+
disableAutoTargetJvm()
5861
}
5962

6063
processResources {

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ vault = "1.7.1"
55
authlib = "1.5.25"
66
headdb = "1.3.2"
77
itemsadder = "3.6.3-beta-14"
8+
nexo = "1.1.0"
89
oraxen = "1.159.0"
910
mythiclib = "1.7.1-SNAPSHOT"
1011
mmoitems = "6.10-SNAPSHOT"
@@ -24,6 +25,7 @@ vault = { module = "com.github.milkbowl:VaultAPI", version.ref = "vault" }
2425
authlib = { module = "com.mojang:authlib", version.ref = "authlib" }
2526
headdb = { module = "com.arcaniax:HeadDatabase-API", version.ref = "headdb" }
2627
itemsadder = { module = "com.github.LoneDev6:api-itemsadder", version.ref = "itemsadder" }
28+
nexo = { module = "com.nexomc:nexo", version.ref = "nexo" }
2729
oraxen = { module = "com.github.oraxen:oraxen", version.ref = "oraxen" }
2830
mythiclib = { module = "io.lumine:MythicLib-dist", version.ref = "mythiclib"}
2931
mmoitems = { module = "net.Indyuce:MMOItems-API", version.ref = "mmoitems" }

src/main/java/com/extendedclip/deluxemenus/DeluxeMenus.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ private void setUpItemHooks() {
269269
this.itemHooks.put("itemsadder", new ItemsAdderHook());
270270
}
271271

272+
if (Bukkit.getPluginManager().isPluginEnabled("Nexo")) {
273+
this.itemHooks.put("nexo", new NexoHook());
274+
}
275+
272276
if (Bukkit.getPluginManager().isPluginEnabled("Oraxen")) {
273277
this.itemHooks.put("oraxen", new OraxenHook());
274278
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.extendedclip.deluxemenus.hooks;
2+
3+
import com.extendedclip.deluxemenus.cache.SimpleCache;
4+
import com.nexomc.nexo.api.NexoItems;
5+
import com.nexomc.nexo.items.ItemBuilder;
6+
import org.bukkit.Material;
7+
import org.bukkit.inventory.ItemStack;
8+
import org.jetbrains.annotations.NotNull;
9+
10+
import java.util.Map;
11+
import java.util.concurrent.ConcurrentHashMap;
12+
13+
public class NexoHook implements ItemHook, SimpleCache {
14+
15+
private final Map<String, ItemStack> cache = new ConcurrentHashMap<>();
16+
17+
@Override
18+
public ItemStack getItem(@NotNull String... arguments) {
19+
if (arguments.length == 0) {
20+
return new ItemStack(Material.STONE);
21+
}
22+
23+
final ItemStack item = cache.computeIfAbsent(arguments[0], (id) -> {
24+
final ItemBuilder builder = NexoItems.itemFromId(id);
25+
return (builder == null) ? null : builder.build().clone();
26+
});
27+
28+
return (item == null) ? new ItemStack(Material.STONE) : item.clone();
29+
}
30+
31+
@Override
32+
public boolean itemMatchesIdentifiers(@NotNull ItemStack item, @NotNull String... arguments) {
33+
if (arguments.length == 0) {
34+
return false;
35+
}
36+
return arguments[0].equalsIgnoreCase(NexoItems.idFromItem(item));
37+
}
38+
39+
@Override
40+
public String getPrefix() {
41+
return "nexo-";
42+
}
43+
44+
@Override
45+
public void clearCache() {
46+
cache.clear();
47+
}
48+
}

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: DeluxeMenus
33
main: com.extendedclip.deluxemenus.DeluxeMenus
44
version: ${version}
55
authors: [ HelpChat ]
6-
softdepend: [ PlaceholderAPI, Vault, HeadDatabase, ItemsAdder, Oraxen, ExecutableItems, ExecutableBlocks, Score, SimpleItemGenerator, MMOItems ]
6+
softdepend: [ PlaceholderAPI, Vault, HeadDatabase, ItemsAdder, Nexo, Oraxen, ExecutableItems, ExecutableBlocks, Score, SimpleItemGenerator, MMOItems ]
77
description: All in one inventory menu system
88
commands:
99
deluxemenus:

0 commit comments

Comments
 (0)