Added global API.getActionManager()

This commit is contained in:
bigguy345 committed 2025-06-28 10:06:14 +03:00
1 parent 6de09c1ee4
commit e001beb6ba
3 files changed
+16 -2

No files matched your search

@@ -11,13 +11,22 @@ 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 java.net.InetAddress;
import java.net.UnknownHostException;
public class ServerTickHandler {
@SubscribeEvent
public void onServerTick(TickEvent.WorldTickEvent event) {
public void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == Phase.END) {
NpcAPI.actionManager.tick(MinecraftServer.getServer().getTickCounter());
}
}
@SubscribeEvent
public void onWorldTick(TickEvent.WorldTickEvent event) {
if (event.phase == Phase.START) {
NPCSpawning.findChunksForSpawning((WorldServer) event.world);
}
@@ -79,6 +79,7 @@ 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 ScriptedActionManager actionManager = new ScriptedActionManager();
private static AbstractNpcAPI instance = null;
private final static String API_USER_AGENT = "CNPC+API";
@@ -559,6 +560,10 @@ public class NpcAPI extends AbstractNpcAPI {
return container instanceof ContainerNpcInterface ? ContainerNpcInterface.getOrCreateIContainer((ContainerNpcInterface) container) : new ScriptContainer(container);
}
public IActionManager getActionManager() {
return actionManager;
}
private void checkWorld() {
if (CustomNpcs.getServer() == null || CustomNpcs.getServer().isServerStopped()) {
throw new CustomNPCsException("No world is loaded right now");