mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 10:59:07 +00:00
更正命名
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.block.BukkitBlockManager;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.CustomFishingProvider;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.MMOItemsProvider;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.MythicMobsProvider;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.NeigeItemsProvider;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.CustomFishingSource;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.MMOItemsSource;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.MythicMobsSource;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.item.NeigeItemsSource;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.legacy.slimeworld.LegacySlimeFormatStorageAdaptor;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.leveler.*;
|
||||
import net.momirealms.craftengine.bukkit.compatibility.model.bettermodel.BetterModelModel;
|
||||
@@ -130,7 +130,7 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
logHook("EcoJobs");
|
||||
}
|
||||
if (this.isPluginEnabled("MythicMobs")) {
|
||||
BukkitItemManager.instance().registerExternalItemProvider(new MythicMobsProvider());
|
||||
BukkitItemManager.instance().registerExternalItemSource(new MythicMobsSource());
|
||||
new MythicMobsListener(this.plugin);
|
||||
logHook("MythicMobs");
|
||||
}
|
||||
@@ -247,15 +247,15 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
|
||||
private void initItemHooks() {
|
||||
BukkitItemManager itemManager = BukkitItemManager.instance();
|
||||
if (this.isPluginEnabled("NeigeItems")) {
|
||||
itemManager.registerExternalItemProvider(new NeigeItemsProvider());
|
||||
itemManager.registerExternalItemSource(new NeigeItemsSource());
|
||||
logHook("NeigeItems");
|
||||
}
|
||||
if (this.isPluginEnabled("MMOItems")) {
|
||||
itemManager.registerExternalItemProvider(new MMOItemsProvider());
|
||||
itemManager.registerExternalItemSource(new MMOItemsSource());
|
||||
logHook("MMOItems");
|
||||
}
|
||||
if (this.isPluginEnabled("CustomFishing")) {
|
||||
itemManager.registerExternalItemProvider(new CustomFishingProvider());
|
||||
itemManager.registerExternalItemSource(new CustomFishingSource());
|
||||
logHook("CustomFishing");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.item;
|
||||
|
||||
import net.momirealms.craftengine.core.item.ExternalItemProvider;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemSource;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class CustomFishingProvider implements ExternalItemProvider<ItemStack> {
|
||||
public class CustomFishingSource implements ExternalItemSource<ItemStack> {
|
||||
@Override
|
||||
public String plugin() {
|
||||
return "customfishing";
|
||||
@@ -3,7 +3,7 @@ package net.momirealms.craftengine.bukkit.compatibility.item;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemProvider;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemSource;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
public class MMOItemsProvider implements ExternalItemProvider<ItemStack> {
|
||||
public class MMOItemsSource implements ExternalItemSource<ItemStack> {
|
||||
|
||||
@Override
|
||||
public String plugin() {
|
||||
@@ -1,12 +1,12 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.item;
|
||||
|
||||
import io.lumine.mythic.bukkit.MythicBukkit;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemProvider;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemSource;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MythicMobsProvider implements ExternalItemProvider<ItemStack> {
|
||||
public class MythicMobsSource implements ExternalItemSource<ItemStack> {
|
||||
private MythicBukkit mythicBukkit;
|
||||
|
||||
@Override
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.craftengine.bukkit.compatibility.item;
|
||||
|
||||
import net.momirealms.craftengine.core.item.ExternalItemProvider;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemSource;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -8,7 +8,7 @@ import pers.neige.neigeitems.manager.ItemManager;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class NeigeItemsProvider implements ExternalItemProvider<ItemStack> {
|
||||
public class NeigeItemsSource implements ExternalItemSource<ItemStack> {
|
||||
|
||||
@Override
|
||||
public String plugin() {
|
||||
@@ -81,15 +81,15 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
||||
@Override
|
||||
public void delayedLoad() {
|
||||
super.delayedLoad();
|
||||
List<ExternalItemProvider<ItemStack>> sources = new ArrayList<>();
|
||||
List<ExternalItemSource<ItemStack>> sources = new ArrayList<>();
|
||||
for (String externalSource : Config.recipeIngredientSources()) {
|
||||
String sourceId = externalSource.toLowerCase(Locale.ENGLISH);
|
||||
ExternalItemProvider<ItemStack> provider = getExternalItemProvider(sourceId);
|
||||
ExternalItemSource<ItemStack> provider = getExternalItemSource(sourceId);
|
||||
if (provider != null) {
|
||||
sources.add(provider);
|
||||
}
|
||||
}
|
||||
this.factory.resetRecipeIngredientSources(sources.isEmpty() ? null : sources.toArray(new ExternalItemProvider[0]));
|
||||
this.factory.resetRecipeIngredientSources(sources.isEmpty() ? null : sources.toArray(new ExternalItemSource[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,14 +6,13 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflect
|
||||
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MBuiltInRegistries;
|
||||
import net.momirealms.craftengine.bukkit.util.ItemTags;
|
||||
import net.momirealms.craftengine.bukkit.util.KeyUtils;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemProvider;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemSource;
|
||||
import net.momirealms.craftengine.core.item.ItemFactory;
|
||||
import net.momirealms.craftengine.core.item.ItemKeys;
|
||||
import net.momirealms.craftengine.core.item.ItemWrapper;
|
||||
import net.momirealms.craftengine.core.item.data.JukeboxPlayable;
|
||||
import net.momirealms.craftengine.core.item.setting.EquipmentData;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.util.CharacterUtils;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.StringUtils;
|
||||
import net.momirealms.craftengine.core.util.UniqueKey;
|
||||
@@ -21,13 +20,12 @@ import net.momirealms.sparrow.nbt.Tag;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class BukkitItemFactory<W extends ItemWrapper<ItemStack>> extends ItemFactory<W, ItemStack> {
|
||||
private boolean hasExternalRecipeSource = false;
|
||||
private ExternalItemProvider<ItemStack>[] recipeIngredientSources = null;
|
||||
private ExternalItemSource<ItemStack>[] recipeIngredientSources = null;
|
||||
|
||||
protected BukkitItemFactory(CraftEngine plugin) {
|
||||
super(plugin);
|
||||
@@ -58,7 +56,7 @@ public abstract class BukkitItemFactory<W extends ItemWrapper<ItemStack>> extend
|
||||
}
|
||||
}
|
||||
|
||||
public void resetRecipeIngredientSources(ExternalItemProvider<ItemStack>[] recipeIngredientSources) {
|
||||
public void resetRecipeIngredientSources(ExternalItemSource<ItemStack>[] recipeIngredientSources) {
|
||||
if (recipeIngredientSources == null || recipeIngredientSources.length == 0) {
|
||||
this.recipeIngredientSources = null;
|
||||
this.hasExternalRecipeSource = false;
|
||||
@@ -99,7 +97,7 @@ public abstract class BukkitItemFactory<W extends ItemWrapper<ItemStack>> extend
|
||||
@Override
|
||||
protected UniqueKey recipeIngredientID(W item) {
|
||||
if (this.hasExternalRecipeSource) {
|
||||
for (ExternalItemProvider<ItemStack> source : this.recipeIngredientSources) {
|
||||
for (ExternalItemSource<ItemStack> source : this.recipeIngredientSources) {
|
||||
String id = source.id(item.getItem());
|
||||
if (id != null) {
|
||||
return UniqueKey.create(Key.of(source.plugin(), StringUtils.toLowerCase(id)));
|
||||
|
||||
@@ -45,7 +45,7 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
||||
|
||||
private final ItemParser itemParser;
|
||||
private final EquipmentParser equipmentParser;
|
||||
protected final Map<String, ExternalItemProvider<I>> externalItemProviders = new HashMap<>();
|
||||
protected final Map<String, ExternalItemSource<I>> externalItemSources = new HashMap<>();
|
||||
protected final Map<String, Function<Object, ItemDataModifier<I>>> dataFunctions = new HashMap<>();
|
||||
protected final Map<Key, CustomItem<I>> customItems = new HashMap<>();
|
||||
protected final Map<Key, List<UniqueKey>> customItemTags = new HashMap<>();
|
||||
@@ -99,15 +99,15 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalItemProvider<I> getExternalItemProvider(String name) {
|
||||
return this.externalItemProviders.get(name);
|
||||
public ExternalItemSource<I> getExternalItemSource(String name) {
|
||||
return this.externalItemSources.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerExternalItemProvider(ExternalItemProvider<I> externalItemProvider) {
|
||||
if (!ResourceLocation.isValidNamespace(externalItemProvider.plugin())) return false;
|
||||
if (this.externalItemProviders.containsKey(externalItemProvider.plugin())) return false;
|
||||
this.externalItemProviders.put(externalItemProvider.plugin(), externalItemProvider);
|
||||
public boolean registerExternalItemSource(ExternalItemSource<I> externalItemSource) {
|
||||
if (!ResourceLocation.isValidNamespace(externalItemSource.plugin())) return false;
|
||||
if (this.externalItemSources.containsKey(externalItemSource.plugin())) return false;
|
||||
this.externalItemSources.put(externalItemSource.plugin(), externalItemSource);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -511,7 +511,7 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
|
||||
Map<String, Object> data = MiscUtils.castToMap(obj, false);
|
||||
String plugin = data.get("plugin").toString();
|
||||
String id = data.get("id").toString();
|
||||
ExternalItemProvider<I> provider = AbstractItemManager.this.getExternalItemProvider(plugin.toLowerCase(Locale.ENGLISH));
|
||||
ExternalItemSource<I> provider = AbstractItemManager.this.getExternalItemSource(plugin.toLowerCase(Locale.ENGLISH));
|
||||
return new ExternalModifier<>(id, Objects.requireNonNull(provider, "Item provider " + plugin + " not found"));
|
||||
}, "external");
|
||||
if (VersionHelper.isOrAbove1_20_5()) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.momirealms.craftengine.core.item;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ExternalItemProvider<I> {
|
||||
public interface ExternalItemSource<I> {
|
||||
|
||||
String plugin();
|
||||
|
||||
@@ -61,9 +61,9 @@ public interface ItemManager<T> extends Manageable, ModelGenerator {
|
||||
|
||||
Key customItemId(T itemStack);
|
||||
|
||||
ExternalItemProvider<T> getExternalItemProvider(String name);
|
||||
ExternalItemSource<T> getExternalItemSource(String name);
|
||||
|
||||
boolean registerExternalItemProvider(ExternalItemProvider<T> externalItemProvider);
|
||||
boolean registerExternalItemSource(ExternalItemSource<T> externalItemSource);
|
||||
|
||||
Optional<Equipment> getEquipment(Key key);
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package net.momirealms.craftengine.core.item.modifier;
|
||||
|
||||
import net.momirealms.craftengine.core.item.ExternalItemProvider;
|
||||
import net.momirealms.craftengine.core.item.ExternalItemSource;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.item.ItemBuildContext;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
|
||||
public class ExternalModifier<I> implements ItemDataModifier<I> {
|
||||
private final String id;
|
||||
private final ExternalItemProvider<I> provider;
|
||||
private final ExternalItemSource<I> provider;
|
||||
|
||||
public ExternalModifier(String id, ExternalItemProvider<I> provider) {
|
||||
public ExternalModifier(String id, ExternalItemSource<I> provider) {
|
||||
this.id = id;
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.momirealms.craftengine.core.plugin.classpath.ClassPathAppender;
|
||||
import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager;
|
||||
import net.momirealms.craftengine.core.plugin.command.sender.SenderFactory;
|
||||
import net.momirealms.craftengine.core.plugin.compatibility.CompatibilityManager;
|
||||
import net.momirealms.craftengine.core.plugin.compatibility.PluginTaskRegistry;
|
||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||
import net.momirealms.craftengine.core.plugin.config.template.TemplateManager;
|
||||
import net.momirealms.craftengine.core.plugin.config.template.TemplateManagerImpl;
|
||||
@@ -37,6 +38,7 @@ import net.momirealms.craftengine.core.sound.SoundManager;
|
||||
import net.momirealms.craftengine.core.world.WorldManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.core.Logger;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -73,6 +75,9 @@ public abstract class CraftEngine implements Plugin {
|
||||
protected GlobalVariableManager globalVariableManager;
|
||||
protected ProjectileManager projectileManager;
|
||||
|
||||
private final PluginTaskRegistry preLoadTaskRegistry = new PluginTaskRegistry();
|
||||
private final PluginTaskRegistry postLoadTaskRegistry = new PluginTaskRegistry();
|
||||
|
||||
private final Consumer<CraftEngine> reloadEventDispatcher;
|
||||
private boolean isReloading;
|
||||
private boolean isInitializing;
|
||||
@@ -205,6 +210,7 @@ public abstract class CraftEngine implements Plugin {
|
||||
this.commandManager.registerDefaultFeatures();
|
||||
// delay the reload so other plugins can register some custom parsers
|
||||
this.scheduler.sync().runDelayed(() -> {
|
||||
this.preLoadTaskRegistry.executeTasks();
|
||||
this.registerDefaultParsers();
|
||||
// hook external item plugins
|
||||
this.itemManager.delayedInit();
|
||||
@@ -231,6 +237,7 @@ public abstract class CraftEngine implements Plugin {
|
||||
// set up some platform extra tasks
|
||||
this.platformDelayedEnable();
|
||||
this.isInitializing = false;
|
||||
this.postLoadTaskRegistry.executeTasks();
|
||||
this.scheduler.executeAsync(() -> this.packManager.initCachedAssets());
|
||||
});
|
||||
}
|
||||
@@ -462,4 +469,14 @@ public abstract class CraftEngine implements Plugin {
|
||||
public Platform platform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public PluginTaskRegistry preLoadTaskRegistry() {
|
||||
return preLoadTaskRegistry;
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public PluginTaskRegistry postLoadTaskRegistry() {
|
||||
return postLoadTaskRegistry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.momirealms.craftengine.core.pack.PackManager;
|
||||
import net.momirealms.craftengine.core.plugin.classpath.ClassPathAppender;
|
||||
import net.momirealms.craftengine.core.plugin.command.sender.SenderFactory;
|
||||
import net.momirealms.craftengine.core.plugin.compatibility.CompatibilityManager;
|
||||
import net.momirealms.craftengine.core.plugin.compatibility.PluginTaskRegistry;
|
||||
import net.momirealms.craftengine.core.plugin.config.Config;
|
||||
import net.momirealms.craftengine.core.plugin.config.template.TemplateManager;
|
||||
import net.momirealms.craftengine.core.plugin.context.GlobalVariableManager;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package net.momirealms.craftengine.core.plugin.compatibility;
|
||||
|
||||
public final class PluginTask {
|
||||
private final Runnable task;
|
||||
private final Priority priority;
|
||||
private final String plugin;
|
||||
|
||||
private PluginTask(Runnable task, String plugin, Priority priority) {
|
||||
this.task = task;
|
||||
this.priority = priority;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static PluginTask create(Runnable task, String plugin, Priority priority) {
|
||||
return new PluginTask(task, plugin, priority);
|
||||
}
|
||||
|
||||
public static PluginTask create(Runnable task, String plugin) {
|
||||
return new PluginTask(task, plugin, Priority.tail());
|
||||
}
|
||||
|
||||
public String plugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public Priority priority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public Runnable task() {
|
||||
return task;
|
||||
}
|
||||
|
||||
public static class Priority {
|
||||
public enum Position {
|
||||
BEFORE_PLUGIN,
|
||||
AFTER_PLUGIN,
|
||||
HEAD,
|
||||
TAIL
|
||||
}
|
||||
|
||||
private final Position position;
|
||||
private final String relativePlugin;
|
||||
|
||||
private Priority(Position position, String relativePlugin) {
|
||||
this.position = position;
|
||||
this.relativePlugin = relativePlugin;
|
||||
}
|
||||
|
||||
public static Priority before(String pluginName) {
|
||||
return new Priority(Position.BEFORE_PLUGIN, pluginName);
|
||||
}
|
||||
|
||||
public static Priority after(String pluginName) {
|
||||
return new Priority(Position.AFTER_PLUGIN, pluginName);
|
||||
}
|
||||
|
||||
public static Priority head() {
|
||||
return new Priority(Position.HEAD, null);
|
||||
}
|
||||
|
||||
public static Priority tail() {
|
||||
return new Priority(Position.TAIL, null);
|
||||
}
|
||||
|
||||
Position position() {
|
||||
return position;
|
||||
}
|
||||
|
||||
String relativePlugin() {
|
||||
return relativePlugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package net.momirealms.craftengine.core.plugin.compatibility;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class PluginTaskRegistry {
|
||||
private static class Node {
|
||||
final PluginTask task;
|
||||
Node prev;
|
||||
Node next;
|
||||
|
||||
Node(PluginTask task) {
|
||||
this.task = task;
|
||||
}
|
||||
}
|
||||
|
||||
private final Node head = new Node(null); // 哨兵头节点
|
||||
private final Node tail = new Node(null); // 哨兵尾节点
|
||||
private final Map<String, Node> pluginNodeMap = new HashMap<>();
|
||||
|
||||
public PluginTaskRegistry() {
|
||||
head.next = tail;
|
||||
tail.prev = head;
|
||||
}
|
||||
|
||||
public void registerTask(PluginTask task) {
|
||||
PluginTask.Priority priority = task.priority();
|
||||
Node newNode = new Node(task);
|
||||
String pluginName = task.plugin();
|
||||
|
||||
if (this.pluginNodeMap.containsKey(pluginName)) {
|
||||
throw new IllegalArgumentException("Duplicate task for plugin: " + pluginName);
|
||||
}
|
||||
|
||||
switch (priority.position()) {
|
||||
case HEAD:
|
||||
insertAfter(this.head, newNode);
|
||||
break;
|
||||
case TAIL:
|
||||
insertBefore(this.tail, newNode);
|
||||
break;
|
||||
case BEFORE_PLUGIN:
|
||||
Node targetBefore = this.pluginNodeMap.get(priority.relativePlugin());
|
||||
if (targetBefore == null) {
|
||||
throw new IllegalArgumentException("Target plugin not found: " + priority.relativePlugin());
|
||||
}
|
||||
insertBefore(targetBefore, newNode);
|
||||
break;
|
||||
case AFTER_PLUGIN:
|
||||
Node targetAfter =this. pluginNodeMap.get(priority.relativePlugin());
|
||||
if (targetAfter == null) {
|
||||
throw new IllegalArgumentException("Target plugin not found: " + priority.relativePlugin());
|
||||
}
|
||||
insertAfter(targetAfter, newNode);
|
||||
break;
|
||||
}
|
||||
|
||||
this.pluginNodeMap.put(pluginName, newNode);
|
||||
}
|
||||
|
||||
private void insertAfter(Node existing, Node newNode) {
|
||||
newNode.next = existing.next;
|
||||
newNode.prev = existing;
|
||||
existing.next.prev = newNode;
|
||||
existing.next = newNode;
|
||||
}
|
||||
|
||||
private void insertBefore(Node existing, Node newNode) {
|
||||
newNode.prev = existing.prev;
|
||||
newNode.next = existing;
|
||||
existing.prev.next = newNode;
|
||||
existing.prev = newNode;
|
||||
}
|
||||
|
||||
public void executeTasks() {
|
||||
try {
|
||||
Node current = head.next;
|
||||
while (current != tail) {
|
||||
current.task.task().run();
|
||||
current = current.next;
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
// 不要管其他插件的异常,应该他们自己处理
|
||||
}
|
||||
}
|
||||
|
||||
public String getExecutionOrder() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Node current = head.next;
|
||||
while (current != tail) {
|
||||
sb.append(current.task.plugin());
|
||||
if (current.next != tail) sb.append(" -> ");
|
||||
current = current.next;
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user