Moved NpcAPI.actionManager to ActionManager.GLOBAL

This commit is contained in:
bigguy345 committed 2025-07-08 14:34:39 +03:00
1 parent 70f0ab1e6f
commit 91dc56bf87
3 files changed
+19 -7

No files matched your search

@@ -7,6 +7,7 @@ import noppes.npcs.api.handler.data.IActionQueue;
import noppes.npcs.api.handler.data.actions.IConditionalAction;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.data.action.action.ConditionalAction;
import noppes.npcs.scripted.NpcAPI;
import java.util.*;
import java.util.function.Consumer;
@@ -21,6 +22,8 @@ import java.util.function.Function;
* - cancellation & clearing
*/
public class ActionManager implements IActionManager {
public static final ActionManager GLOBAL = new ActionManager("GLOBAL");
protected boolean isWorking = false;
public ActionLogger LOGGER = new ActionLogger(this);
protected String name = "";
@@ -33,6 +36,19 @@ public class ActionManager implements IActionManager {
protected boolean debug;
protected ScriptContainer reportTo;
private static final Map<Object, IActionListener> listeners = new WeakHashMap<>();
public IActionListener getOrCreateListener(Object obj) {
return listeners.computeIfAbsent(obj, o -> new ActionListener(o));
}
public ActionManager() {
}
public ActionManager(String name) {
this.name = name;
}
@Override
public IActionManager start() {