mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-24 17:39:30 +00:00
Merge pull request #362 from jhqwqmc/dev
fix(bukkit): 修复构建 MythicMobs 物品
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 slimefun
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -72,6 +73,12 @@ 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")
|
||||
// Slimefun
|
||||
compileOnly("io.github.Slimefun:Slimefun4:RC-32")
|
||||
}
|
||||
|
||||
java {
|
||||
|
||||
@@ -263,6 +263,18 @@ 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");
|
||||
}
|
||||
if (this.isPluginEnabled("Slimefun")) {
|
||||
itemManager.registerExternalItemSource(new SlimefunSource());
|
||||
logHook("Slimefun");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.item;
|
||||
|
||||
import io.lumine.mythic.api.adapters.AbstractPlayer;
|
||||
import io.lumine.mythic.api.skills.SkillCaster;
|
||||
import io.lumine.mythic.bukkit.BukkitAdapter;
|
||||
import io.lumine.mythic.bukkit.MythicBukkit;
|
||||
import io.lumine.mythic.core.drops.DropMetadataImpl;
|
||||
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 MythicMobsSource implements ExternalItemSource<ItemStack> {
|
||||
private MythicBukkit mythicBukkit;
|
||||
|
||||
@@ -20,7 +27,18 @@ public class MythicMobsSource implements ExternalItemSource<ItemStack> {
|
||||
if (mythicBukkit == null || mythicBukkit.isClosed()) {
|
||||
this.mythicBukkit = MythicBukkit.inst();
|
||||
}
|
||||
return mythicBukkit.getItemManager().getItemStack(id);
|
||||
return Optional.ofNullable(context.player())
|
||||
.map(p -> (Player) p.platformPlayer())
|
||||
.map(p -> {
|
||||
AbstractPlayer target = BukkitAdapter.adapt(p);
|
||||
SkillCaster caster = mythicBukkit.getSkillManager().getCaster(target);
|
||||
DropMetadataImpl meta = new DropMetadataImpl(caster, target);
|
||||
return mythicBukkit.getItemManager().getItem(id)
|
||||
.map(i -> i.generateItemStack(meta, 1))
|
||||
.map(BukkitAdapter::adapt)
|
||||
.orElse(null);
|
||||
})
|
||||
.orElseGet(() -> mythicBukkit.getItemManager().getItemStack(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.item;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemSource;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class SlimefunSource implements ExternalItemSource<ItemStack> {
|
||||
|
||||
@Override
|
||||
public String plugin() {
|
||||
return "slimefun";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack build(String id, ItemBuildContext context) {
|
||||
return Optional.ofNullable(SlimefunItem.getById(id)).map(SlimefunItem::getItem).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id(ItemStack item) {
|
||||
return Optional.ofNullable(SlimefunItem.getByItem(item)).map(SlimefunItem::getId).orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import java.util.function.Predicate;
|
||||
* Concurrent hashtable implementation supporting mapping UUID values onto non-null Object
|
||||
* values with support for multiple writer and multiple reader threads.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ConcurrentUUID2ReferenceChainedHashTable<V> implements Iterable<ConcurrentUUID2ReferenceChainedHashTable.TableEntry<V>> {
|
||||
protected static final int DEFAULT_CAPACITY = 16;
|
||||
protected static final float DEFAULT_LOAD_FACTOR = 0.75f;
|
||||
|
||||
Reference in New Issue
Block a user