mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
feat: add Nexo support
This commit is contained in:
@@ -26,6 +26,8 @@ allprojects {
|
||||
// UpdateChecker
|
||||
maven("https://repo.jeff-media.com/public")
|
||||
|
||||
maven("https://repo.nexomc.com/snapshots/")
|
||||
|
||||
// Geary & Backup ProtocolLib repo
|
||||
maven("https://repo.mineinabyss.com/releases/")
|
||||
maven("https://repo.mineinabyss.com/snapshots/")
|
||||
@@ -74,6 +76,7 @@ allprojects {
|
||||
compileOnly("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:24.1.0")
|
||||
compileOnly("io.th0rgal:oraxen:1.182.0")
|
||||
compileOnly("com.nexomc:nexo:0.1.0-dev.0")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.6.3-beta-14")
|
||||
compileOnly("com.mineinabyss:geary-papermc:0.31.0-dev.4")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.13")
|
||||
@@ -193,7 +196,8 @@ bukkit {
|
||||
"LibsDisguises",
|
||||
"Denizen",
|
||||
"MMOItems",
|
||||
"Eco"
|
||||
"Eco",
|
||||
"Nexo"
|
||||
)
|
||||
version = "${project.version}"
|
||||
loadBefore = listOf(
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.HashMap;
|
||||
public class Hooks {
|
||||
|
||||
private static final HashMap<String, Hook> hooks = new HashMap<>();
|
||||
private static final HookNexo NEXO_HOOK = new HookNexo();
|
||||
private static final HookOraxen ORAXEN_HOOK = new HookOraxen();
|
||||
private static final HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
|
||||
private static final HookGeary GEARY_HOOK = new HookGeary();
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package me.lojosho.hibiscuscommons.hooks.items;
|
||||
|
||||
import com.nexomc.nexo.api.NexoItems;
|
||||
import com.nexomc.nexo.api.events.NexoItemsLoadedEvent;
|
||||
import com.nexomc.nexo.items.ItemBuilder;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hook;
|
||||
import me.lojosho.hibiscuscommons.hooks.HookFlag;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A hook that integrates the plugin {@link com.nexomc.nexo.NexoPlugin NexoPlugin} to provide custom items
|
||||
*/
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
public class HookNexo extends Hook {
|
||||
private boolean loaded = false;
|
||||
public HookNexo() {
|
||||
super("nexo", HookFlag.ITEM_SUPPORT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.nexomc.nexo.NexoPlugin NexoPlugin}
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItem(@NotNull String itemId) {
|
||||
return NexoItems.optionalItemFromId(itemId).map(ItemBuilder::build).orElse(loaded ? new ItemStack(Material.AIR) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemString(ItemStack itemStack) {
|
||||
if (itemStack == null) return null;
|
||||
if (!itemStack.hasItemMeta()) return null;
|
||||
return NexoItems.idFromItem(itemStack);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLoadItems(NexoItemsLoadedEvent event) {
|
||||
loaded = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user