mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-28 03:19:14 +00:00
feat(bukkit): 添加 HeadDatabase 和 SX-Item 支持
This commit is contained in:
@@ -15,6 +15,7 @@ repositories {
|
||||
maven("https://repo.dmulloy2.net/repository/public/") // mcmmo required
|
||||
maven("https://repo.auxilor.io/repository/maven-public/") // eco
|
||||
maven("https://repo.hiusers.com/releases") // zaphkiel
|
||||
maven("https://jitpack.io") // sxitem
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -72,6 +73,10 @@ dependencies {
|
||||
compileOnly("ink.ptms:ZaphkielAPI:2.1.0")
|
||||
// WorldGuard
|
||||
compileOnly(files("${rootProject.rootDir}/libs/worldguard-bukkit-7.0.14-dist.jar"))
|
||||
// HeadDatabase
|
||||
compileOnly("com.arcaniax:HeadDatabase-API:1.3.2")
|
||||
// SXItem
|
||||
compileOnly("com.github.Saukiya:SX-Item:4.4.6")
|
||||
}
|
||||
|
||||
java {
|
||||
|
||||
@@ -263,6 +263,14 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
itemManager.registerExternalItemSource(new ZaphkielSource());
|
||||
logHook("Zaphkiel");
|
||||
}
|
||||
if (this.isPluginEnabled("HeadDatabase")) {
|
||||
itemManager.registerExternalItemSource(new HeadDatabaseSource());
|
||||
logHook("HeadDatabase");
|
||||
}
|
||||
if (this.isPluginEnabled("SX-Item")) {
|
||||
itemManager.registerExternalItemSource(new SXItemSource());
|
||||
logHook("SX-Item");
|
||||
}
|
||||
}
|
||||
|
||||
private Plugin getPlugin(String name) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.item;
|
||||
|
||||
import net.momirealms.craftengine.core.item.ExternalItemSource;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import me.arcaniax.hdb.api.HeadDatabaseAPI;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class HeadDatabaseSource implements ExternalItemSource<ItemStack> {
|
||||
private HeadDatabaseAPI api;
|
||||
|
||||
@Override
|
||||
public String plugin() {
|
||||
return "headdatabase";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack build(String id, ItemBuildContext context) {
|
||||
if (api == null) {
|
||||
api = new HeadDatabaseAPI();
|
||||
}
|
||||
return api.getItemHead(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id(ItemStack item) {
|
||||
if (api == null) {
|
||||
api = new HeadDatabaseAPI();
|
||||
}
|
||||
return api.getItemID(item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.item;
|
||||
|
||||
import github.saukiya.sxitem.SXItem;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemSource;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class SXItemSource implements ExternalItemSource<ItemStack> {
|
||||
|
||||
@Override
|
||||
public String plugin() {
|
||||
return "sxitem";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack build(String id, ItemBuildContext context) {
|
||||
return SXItem.getItemManager().getItem(id, Optional.ofNullable(context.player()).map(p -> (Player) p.platformPlayer()).orElse(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id(ItemStack item) {
|
||||
return SXItem.getItemManager().getItemKey(item);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user