mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-06 15:52:03 +00:00
优化插件启动过程
This commit is contained in:
@@ -2,11 +2,13 @@ package net.momirealms.craftengine.bukkit.compatibility;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.momirealms.craftengine.bukkit.block.BukkitBlockManager;
|
||||
import net.momirealms.craftengine.bukkit.block.entity.renderer.element.BukkitBlockEntityElementConfigs;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.*;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.legacy.slimeworld.LegacySlimeFormatStorageAdaptor;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.leveler.*;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.model.bettermodel.BetterModelBlockEntityElementConfig;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.model.bettermodel.BetterModelModel;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.model.bettermodel.BetterModelUtils;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.model.modelengine.ModelEngineBlockEntityElementConfig;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.model.modelengine.ModelEngineModel;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.model.modelengine.ModelEngineUtils;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.mythicmobs.MythicItemDropListener;
|
||||
@@ -68,16 +70,6 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.initSlimeWorldHook();
|
||||
if (this.isPluginEnabled("PlaceholderAPI")) {
|
||||
PlaceholderAPIUtils.registerExpansions(this.plugin);
|
||||
this.hasPlaceholderAPI = true;
|
||||
logHook("PlaceholderAPI");
|
||||
}
|
||||
if (this.isPluginEnabled("Skript")) {
|
||||
SkriptHook.register();
|
||||
logHook("Skript");
|
||||
}
|
||||
// WorldEdit
|
||||
// FastAsyncWorldEdit
|
||||
if (this.isPluginEnabled("FastAsyncWorldEdit")) {
|
||||
@@ -91,16 +83,48 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
this.initWorldEditHook();
|
||||
logHook("WorldEdit");
|
||||
}
|
||||
if (this.hasPlugin("BetterModel")) {
|
||||
BukkitBlockEntityElementConfigs.register(Key.of("craftengine:better_model"), new BetterModelBlockEntityElementConfig.Factory());
|
||||
logHook("BetterModel");
|
||||
}
|
||||
if (this.hasPlugin("ModelEngine")) {
|
||||
BukkitBlockEntityElementConfigs.register(Key.of("craftengine:model_engine"), new ModelEngineBlockEntityElementConfig.Factory());
|
||||
logHook("ModelEngine");
|
||||
}
|
||||
if (this.hasPlugin("CustomNameplates")) {
|
||||
registerTagResolverProvider(new CustomNameplateProviders.Background());
|
||||
registerTagResolverProvider(new CustomNameplateProviders.Nameplate());
|
||||
registerTagResolverProvider(new CustomNameplateProviders.Bubble());
|
||||
logHook("CustomNameplates");
|
||||
}
|
||||
Key worldGuardRegion = Key.of("worldguard:region");
|
||||
if (this.hasPlugin("WorldGuard")) {
|
||||
EventConditions.register(worldGuardRegion, new WorldGuardRegionCondition.FactoryImpl<>());
|
||||
LootConditions.register(worldGuardRegion, new WorldGuardRegionCondition.FactoryImpl<>());
|
||||
logHook("WorldGuard");
|
||||
} else {
|
||||
EventConditions.register(worldGuardRegion, new AlwaysFalseCondition.FactoryImpl<>());
|
||||
LootConditions.register(worldGuardRegion, new AlwaysFalseCondition.FactoryImpl<>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDelayedEnable() {
|
||||
this.initSlimeWorldHook();
|
||||
if (this.isPluginEnabled("PlaceholderAPI")) {
|
||||
PlaceholderAPIUtils.registerExpansions(this.plugin);
|
||||
this.hasPlaceholderAPI = true;
|
||||
logHook("PlaceholderAPI");
|
||||
}
|
||||
this.initItemHooks();
|
||||
|
||||
if (this.isPluginEnabled("LuckPerms")) {
|
||||
this.initLuckPermsHook();
|
||||
logHook("LuckPerms");
|
||||
}
|
||||
if (this.isPluginEnabled("Skript")) {
|
||||
SkriptHook.register();
|
||||
logHook("Skript");
|
||||
}
|
||||
if (this.isPluginEnabled("AuraSkills")) {
|
||||
this.registerLevelerProvider("AuraSkills", new AuraSkillsLevelerProvider());
|
||||
logHook("AuraSkills");
|
||||
@@ -133,33 +157,10 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
new MythicItemDropListener(this.plugin);
|
||||
logHook("MythicMobs");
|
||||
}
|
||||
Key worldGuardRegion = Key.of("worldguard:region");
|
||||
if (this.isPluginEnabled("WorldGuard")) {
|
||||
EventConditions.register(worldGuardRegion, new WorldGuardRegionCondition.FactoryImpl<>());
|
||||
LootConditions.register(worldGuardRegion, new WorldGuardRegionCondition.FactoryImpl<>());
|
||||
logHook("WorldGuard");
|
||||
} else {
|
||||
EventConditions.register(worldGuardRegion, new AlwaysFalseCondition.FactoryImpl<>());
|
||||
LootConditions.register(worldGuardRegion, new AlwaysFalseCondition.FactoryImpl<>());
|
||||
}
|
||||
if (this.isPluginEnabled("BetterModel")) {
|
||||
BetterModelUtils.registerConstantBlockEntityRender();
|
||||
logHook("BetterModel");
|
||||
}
|
||||
if (this.isPluginEnabled("ModelEngine")) {
|
||||
ModelEngineUtils.registerConstantBlockEntityRender();
|
||||
logHook("ModelEngine");
|
||||
}
|
||||
if (this.isPluginEnabled("QuickShop-Hikari")) {
|
||||
new QuickShopItemExpressionHandler(this.plugin).register();
|
||||
logHook("QuickShop-Hikari");
|
||||
}
|
||||
if (this.isPluginEnabled("CustomNameplates")) {
|
||||
registerTagResolverProvider(new CustomNameplateProviders.Background());
|
||||
registerTagResolverProvider(new CustomNameplateProviders.Nameplate());
|
||||
registerTagResolverProvider(new CustomNameplateProviders.Bubble());
|
||||
logHook("CustomNameplates");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,11 +2,11 @@ package net.momirealms.craftengine.bukkit.compatibility.model.bettermodel;
|
||||
|
||||
import kr.toxicity.model.api.BetterModel;
|
||||
import kr.toxicity.model.api.data.renderer.ModelRenderer;
|
||||
import net.momirealms.craftengine.bukkit.block.entity.renderer.element.BukkitBlockEntityElementConfigs;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class BetterModelUtils {
|
||||
public final class BetterModelUtils {
|
||||
|
||||
private BetterModelUtils() {}
|
||||
|
||||
public static void bindModel(Entity base, String id) {
|
||||
ModelRenderer renderer = BetterModel.plugin().modelManager().model(id);
|
||||
@@ -15,8 +15,4 @@ public class BetterModelUtils {
|
||||
}
|
||||
renderer.create(base);
|
||||
}
|
||||
|
||||
public static void registerConstantBlockEntityRender() {
|
||||
BukkitBlockEntityElementConfigs.register(Key.of("craftengine:better_model"), new BetterModelBlockEntityElementConfig.Factory());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package net.momirealms.craftengine.bukkit.compatibility.model.modelengine;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import net.momirealms.craftengine.bukkit.block.entity.renderer.element.BukkitBlockEntityElementConfigs;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class ModelEngineUtils {
|
||||
public final class ModelEngineUtils {
|
||||
|
||||
private ModelEngineUtils() {}
|
||||
|
||||
public static void bindModel(Entity base, String id) {
|
||||
ModeledEntity modeledEntity = ModelEngineAPI.createModeledEntity(base);
|
||||
@@ -26,8 +26,4 @@ public class ModelEngineUtils {
|
||||
}
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public static void registerConstantBlockEntityRender() {
|
||||
BukkitBlockEntityElementConfigs.register(Key.of("craftengine:model_engine"), new ModelEngineBlockEntityElementConfig.Factory());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user