All external scripts of type "Java" are now synced to client on login/script reload

This commit is contained in:
bigguy345 committed 2025-12-15 10:28:17 +02:00
1 parent 8a2ba6ae4e
commit a8b3c0b8d4
4 files changed
+49 -27

No files matched your search

@@ -7,15 +7,11 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.SyncController;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.WorldServer;
import noppes.npcs.client.AnalyticsTracking;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.action.ActionManager;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class ServerTickHandler {
@SubscribeEvent
@@ -64,6 +60,7 @@ public class ServerTickHandler {
ProfileController.Instance.login(player);
SyncController.beginLogin(player);
SyncController.syncEffects(player);
ScriptController.Instance.syncClientScripts(player);
}
@SubscribeEvent
@@ -3,7 +3,9 @@ package noppes.npcs.controllers;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import jdk.nashorn.api.scripting.ClassFilter;
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
import kamkeel.npcs.network.packets.request.script.ScriptFilesPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
@@ -230,6 +232,14 @@ public class ScriptController {
customNPCThread.execute(this::saveGlobalNpcScripts);
}
public void syncClientScripts(EntityPlayerMP player) {
if (player != null) {
ScriptFilesPacket.sendToPlayer(player, "Java");
} else {
ScriptFilesPacket.sendToAll("Java");
}
}
public void loadCategories() {
dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts");
if (!dir.exists())