Skip to content

Commit

Permalink
misc: 更多的调整
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Feb 19, 2025
1 parent 9b757df commit 3a3ea42
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/main/java/xyz/nifeather/morph/FeatherMorphMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,31 +239,32 @@ protected void enable()

dependencyManager.cache(mirrorExecutorHub = new ExecutorHub());

dependencyManager.cache(new FeatherMorphAPI(this));

var mirrorProcessor = new InteractionMirrorProcessor();

// Commands
var lifecycleManager = this.getLifecycleManager();
lifecycleManager.registerEventHandler(LifecycleEvents.COMMANDS, event ->
cmdHelper.register(event));

var listeners = new Listener[]
{
playerTracker,
mirrorProcessor,
new CommonEventProcessor(),
new RevealingEventProcessor(),
new DisguiseAnimationProcessor(),
new ForcedDisguiseProcessor(),
new PlayerSkinProcessor(),
entityProcessor = new EntityProcessor()
};

//注册EventProcessor
this.schedule(() ->
{
registerListeners(new Listener[]
{
playerTracker,
mirrorProcessor,
new CommonEventProcessor(),
new RevealingEventProcessor(),
new DisguiseAnimationProcessor(),
new ForcedDisguiseProcessor(),
new PlayerSkinProcessor(),
entityProcessor = new EntityProcessor()
});
registerListeners(listeners);

clientHandler.reAuthPlayers(Bukkit.getOnlinePlayers());
dependencyManager.cache(new FeatherMorphAPI(this));
});

pluginEnableDone.set(true);
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/xyz/nifeather/morph/api/FeatherMorphAPI.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package xyz.nifeather.morph.api;

import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectLists;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.nifeather.morph.FeatherMorphMain;
import xyz.nifeather.morph.api.direct.FeatherMorphDirectAccess;
import xyz.nifeather.morph.api.utilties.v0.UtilitiesAlpha;

import java.util.List;

@ApiStatus.Experimental
public class FeatherMorphAPI
{
//region static stuffs
Expand All @@ -22,6 +28,13 @@ public static FeatherMorphAPI instance()
@Nullable
private static FeatherMorphAPI instance;

private static final List<Runnable> hooks = ObjectLists.synchronize(new ObjectArrayList<>());

public static void runWhenAPILoaded(Runnable runnable)
{
hooks.add(runnable);
}

//endregion static stuffs

@NotNull
Expand All @@ -38,6 +51,7 @@ public FeatherMorphAPI(FeatherMorphMain plugin)
utilsAlpha = new UtilitiesAlpha(directAccess);

instance = this;
hooks.forEach(Runnable::run);
}

/**
Expand Down

0 comments on commit 3a3ea42

Please sign in to comment.