mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 04:57:27 +00:00
Moved NpcAPI.actionManager to ActionManager.GLOBAL
This commit is contained in:
1 parent
70f0ab1e6f
commit
91dc56bf87
3 files changed
+19
-7
No files matched your search
@@ -11,7 +11,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.client.AnalyticsTracking;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.controllers.data.action.ActionManager;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
@@ -21,7 +21,7 @@ public class ServerTickHandler {
|
||||
@SubscribeEvent
|
||||
public void onServerTick(TickEvent.ServerTickEvent event) {
|
||||
if (event.phase == Phase.END) {
|
||||
NpcAPI.actionManager.tick();
|
||||
ActionManager.GLOBAL.tick();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -79,7 +79,6 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
private static final CacheHashMap<ItemStack, CacheHashMap.CachedObject<ScriptItemStack>> scriptItemCache = new CacheHashMap<>(60 * 1000);
|
||||
public static final HashMap<String, Object> engineObjects = new HashMap<>();
|
||||
public static final EventBus EVENT_BUS = new EventBus();
|
||||
public static final ActionManager actionManager = new ActionManager();
|
||||
private static AbstractNpcAPI instance = null;
|
||||
|
||||
private final static String API_USER_AGENT = "CNPC+API";
|
||||
@@ -569,10 +568,7 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
}
|
||||
|
||||
public IActionManager getActionManager() {
|
||||
if (actionManager.getName().isEmpty())
|
||||
actionManager.setName("Global");
|
||||
|
||||
return actionManager;
|
||||
return ActionManager.GLOBAL;
|
||||
}
|
||||
|
||||
private void checkWorld() {
|
||||
|
||||
Reference in new issue
Block a user