mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 06:29:41 +00:00
Null out the loader.
This commit is contained in:
1 parent
b4608ffe19
commit
4d825b6cf3
6 files changed
+55
-15
No files matched your search
@@ -4,6 +4,8 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.github.somehussar.janinoloader.api.script.IScriptBodyBuilder;
|
||||
import io.github.somehussar.janinoloader.api.script.IScriptClassBody;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.addon.DBCAddon;
|
||||
import kamkeel.npcs.addon.client.DBCClient;
|
||||
@@ -157,9 +159,12 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||
import noppes.npcs.scripted.event.NpcEvent;
|
||||
import noppes.npcs.util.GameProfileAlt;
|
||||
import org.codehaus.commons.compiler.Sandbox;
|
||||
import somehussar.janino.wrapper.AbstractNPCJavaHandler;
|
||||
import somehussar.janino.wrapper.NPCWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.Permissions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashMap;
|
||||
@@ -247,6 +252,20 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
if (!this.isRemote() && this.wrappedNPC == null) {
|
||||
this.wrappedNPC = new ScriptNpc<>(this);
|
||||
}
|
||||
if (!this.isRemote()) {
|
||||
IScriptClassBody<AbstractNPCJavaHandler> javaCompiler = IScriptBodyBuilder.getBuilder(AbstractNPCJavaHandler.class, CustomNpcs.getDynamicCompiler())
|
||||
.setDefaultImports("noppes.npcs.api.event.INpcEvent").build();
|
||||
javaCompiler.setScript("" +
|
||||
"" +
|
||||
"void onInteract(INpcEvent.InteractEvent event) {" +
|
||||
" event.getNpc().say(\"Lol this is from a script!\");" +
|
||||
"}" +
|
||||
"");
|
||||
|
||||
Permissions permissions = new Permissions();
|
||||
Sandbox sandbox = new Sandbox(permissions);
|
||||
this.janinoHandler = new NPCWrapper(sandbox, javaCompiler);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user