mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 20:25:13 +00:00
NpcAPI:
Added functions for adding keywords to global script running ++ addGlobalObject(String,Object) ++ removeGlobalObject(String) ++ getEngineObjects()
This commit is contained in:
1 parent
718a867411
commit
7a715ef308
4 files changed
+20
-1
No files matched your search
@@ -155,6 +155,9 @@ public class ScriptContainer {
|
||||
}
|
||||
|
||||
engine.put("API", NpcAPI.Instance());
|
||||
for (Map.Entry<String,Object> engineObjects : NpcAPI.engineObjects.entrySet()) {
|
||||
engine.put(engineObjects.getKey(),engineObjects.getValue());
|
||||
}
|
||||
|
||||
Current = this;
|
||||
CurrentType = type;
|
||||
|
||||
@@ -153,6 +153,9 @@ public class DataScript implements IScriptHandler {
|
||||
engine.put("EntityType", entities);
|
||||
engine.put("RoleType", roles);
|
||||
engine.put("JobType", jobs);
|
||||
for (Map.Entry<String,Object> engineObjects : NpcAPI.engineObjects.entrySet()) {
|
||||
engine.put(engineObjects.getKey(),engineObjects.getValue());
|
||||
}
|
||||
script.run(engine);
|
||||
|
||||
if(clientNeedsUpdate){
|
||||
|
||||
@@ -58,6 +58,7 @@ import java.util.*;
|
||||
|
||||
public class NpcAPI extends AbstractNpcAPI {
|
||||
private static final Map<Integer, ScriptWorld> worldCache = new LRUHashMap<>(10);
|
||||
public static final HashMap<String,Object> engineObjects = new HashMap<>();
|
||||
public static final EventBus EVENT_BUS = new EventBus();
|
||||
private static AbstractNpcAPI instance = null;
|
||||
|
||||
@@ -68,6 +69,18 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
worldCache.clear();
|
||||
}
|
||||
|
||||
public void addGlobalObject(String key, Object obj) {
|
||||
NpcAPI.engineObjects.put(key,obj);
|
||||
}
|
||||
|
||||
public void removeGlobalObject(String key) {
|
||||
NpcAPI.engineObjects.remove(key);
|
||||
}
|
||||
|
||||
public HashMap<String,Object> getEngineObjects() {
|
||||
return NpcAPI.engineObjects;
|
||||
}
|
||||
|
||||
public long sizeOfObject(Object obj) {
|
||||
return ObjectSizeCalculator.getObjectSize(obj);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user