mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-25 02:54:27 +00:00
Add Script Context and better parsing for d.ts handling
This commit is contained in:
1 parent
a5c02e6c94
commit
78f7fa65f1
13 files changed
+831
-67
No files matched your search
@@ -23,6 +23,7 @@ import noppes.npcs.client.gui.util.script.interpreter.type.*;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.type.synthetic.SyntheticField;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.type.synthetic.SyntheticMethod;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.type.synthetic.SyntheticType;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -125,6 +126,10 @@ public class ScriptDocument {
|
||||
// Script language: "ECMAScript", "Groovy", etc.
|
||||
private String language = "ECMAScript";
|
||||
|
||||
// Script context: NPC, PLAYER, BLOCK, ITEM, etc.
|
||||
// Determines which hooks and event types are available
|
||||
private ScriptContext scriptContext = ScriptContext.GLOBAL;
|
||||
|
||||
// Layout properties
|
||||
public int lineHeight = 13;
|
||||
public int totalHeight;
|
||||
@@ -170,6 +175,25 @@ public class ScriptDocument {
|
||||
return "ECMAScript".equalsIgnoreCase(language);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the script context (NPC, PLAYER, BLOCK, ITEM, etc.).
|
||||
* This determines which hooks and event types are available for autocomplete.
|
||||
*
|
||||
* @param context The script context
|
||||
*/
|
||||
public void setScriptContext(ScriptContext context) {
|
||||
this.scriptContext = context != null ? context : ScriptContext.GLOBAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current script context.
|
||||
*
|
||||
* @return The script context (NPC, PLAYER, BLOCK, ITEM, etc.)
|
||||
*/
|
||||
public ScriptContext getScriptContext() {
|
||||
return scriptContext;
|
||||
}
|
||||
|
||||
// ==================== TEXT MANAGEMENT ====================
|
||||
|
||||
public void setText(String text) {
|
||||
@@ -686,11 +710,13 @@ public class ScriptDocument {
|
||||
JSDocInfo jsDoc = jsDocParser.extractJSDocBefore(text, m.start());
|
||||
|
||||
// For JS hooks, infer parameter types from registry
|
||||
// Use the script context's namespaces (e.g., ["IPlayerEvent", "IAnimationEvent"]) for lookup
|
||||
List<FieldInfo> params = new ArrayList<>();
|
||||
TypeInfo returnType = TypeInfo.fromPrimitive("void");
|
||||
List<String> namespaces = scriptContext != null ? scriptContext.getNamespaces() : Collections.singletonList("Global");
|
||||
|
||||
if (typeResolver.isJSHook(funcName)) {
|
||||
List<JSTypeRegistry.HookSignature> sigs = typeResolver.getJSHookSignatures(funcName);
|
||||
if (typeResolver.isJSHook(namespaces, funcName)) {
|
||||
List<JSTypeRegistry.HookSignature> sigs = typeResolver.getJSHookSignatures(namespaces, funcName);
|
||||
if (!sigs.isEmpty()) {
|
||||
JSTypeRegistry.HookSignature sig = sigs.get(0);
|
||||
documentation = sig.doc;
|
||||
|
||||
+28
-1
@@ -4,6 +4,7 @@ import noppes.npcs.client.ClientProxy;
|
||||
import noppes.npcs.client.gui.util.script.JavaTextContainer;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.field.FieldInfo;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.method.MethodInfo;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -31,10 +32,13 @@ public class ScriptTextContainer extends JavaTextContainer {
|
||||
public static boolean USE_NEW_INTERPRETER = true;
|
||||
|
||||
private ScriptDocument document;
|
||||
|
||||
|
||||
/** The scripting language: "ECMAScript", "Groovy", etc. */
|
||||
private String language = "ECMAScript";
|
||||
|
||||
/** The script context: NPC, PLAYER, BLOCK, ITEM, etc. */
|
||||
private ScriptContext scriptContext = ScriptContext.GLOBAL;
|
||||
|
||||
public ScriptTextContainer(String text) {
|
||||
super(text);
|
||||
if (USE_NEW_INTERPRETER) {
|
||||
@@ -68,6 +72,28 @@ public class ScriptTextContainer extends JavaTextContainer {
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the script context (NPC, PLAYER, BLOCK, ITEM, etc.).
|
||||
* This determines which hooks and event types are available for autocomplete.
|
||||
*
|
||||
* @param context The script context
|
||||
*/
|
||||
public void setScriptContext(ScriptContext context) {
|
||||
this.scriptContext = context != null ? context : ScriptContext.GLOBAL;
|
||||
if (document != null) {
|
||||
document.setScriptContext(this.scriptContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current script context.
|
||||
*
|
||||
* @return The script context (NPC, PLAYER, BLOCK, ITEM, etc.)
|
||||
*/
|
||||
public ScriptContext getScriptContext() {
|
||||
return scriptContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int width, int height) {
|
||||
if (!USE_NEW_INTERPRETER) {
|
||||
@@ -103,6 +129,7 @@ public class ScriptTextContainer extends JavaTextContainer {
|
||||
}
|
||||
|
||||
document = new ScriptDocument(this.text, this.language);
|
||||
document.setScriptContext(this.scriptContext);
|
||||
init(width, height);
|
||||
}
|
||||
|
||||
|
||||
+224
-14
@@ -27,10 +27,18 @@ public class JSTypeRegistry {
|
||||
// Type aliases (simple name -> full type name)
|
||||
private final Map<String, String> typeAliases = new HashMap<>();
|
||||
|
||||
// Hook function signatures: functionName -> list of (paramName, paramType) pairs
|
||||
// Multiple entries for overloaded hooks
|
||||
// Context-aware hook function signatures: namespace -> functionName -> list of signatures
|
||||
// The namespace is the event interface name (e.g., "INpcEvent", "IPlayerEvent")
|
||||
// This allows any mod to register hooks without modifying an enum
|
||||
private final Map<String, Map<String, List<HookSignature>>> contextHooks = new LinkedHashMap<>();
|
||||
|
||||
// Legacy hook storage: functionName -> list of (paramName, paramType) pairs
|
||||
// Kept for backward compatibility with code that doesn't use contexts
|
||||
private final Map<String, List<HookSignature>> hooks = new LinkedHashMap<>();
|
||||
|
||||
// Fallback namespace for hooks that don't match a specific context
|
||||
private static final String GLOBAL_NAMESPACE = "Global";
|
||||
|
||||
// Global object instances: name -> type (e.g., "API" -> "AbstractNpcAPI")
|
||||
// These are treated as instance objects, not static classes
|
||||
private final Map<String, String> globalEngineObjects = new LinkedHashMap<>();
|
||||
@@ -275,11 +283,23 @@ public class JSTypeRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a hook function signature.
|
||||
* Register a hook function signature with a namespace.
|
||||
*
|
||||
* @param namespace The event interface namespace (e.g., "INpcEvent", "IPlayerEvent")
|
||||
* @param functionName The hook function name (e.g., "interact", "damaged")
|
||||
* @param paramName The parameter name (e.g., "event")
|
||||
* @param paramType The parameter type (e.g., "INpcEvent.InteractEvent")
|
||||
*/
|
||||
public void registerHook(String functionName, String paramName, String paramType) {
|
||||
hooks.computeIfAbsent(functionName, k -> new ArrayList<>())
|
||||
.add(new HookSignature(paramName, paramType));
|
||||
public void registerHook(String namespace, String functionName, String paramName, String paramType) {
|
||||
HookSignature sig = new HookSignature(paramName, paramType, null, namespace);
|
||||
|
||||
// Add to context-specific map
|
||||
contextHooks.computeIfAbsent(namespace, k -> new LinkedHashMap<>())
|
||||
.computeIfAbsent(functionName, k -> new ArrayList<>())
|
||||
.add(sig);
|
||||
|
||||
// Also add to legacy hooks map for backward compatibility
|
||||
hooks.computeIfAbsent(functionName, k -> new ArrayList<>()).add(sig);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -369,7 +389,190 @@ public class JSTypeRegistry {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// ==================== Context-Aware Hook Methods ====================
|
||||
|
||||
/**
|
||||
* Get hook signatures for a specific script context.
|
||||
* Falls back to GLOBAL context if not found in the specified context.
|
||||
*
|
||||
* @param namespace The event interface namespace (e.g., "INpcEvent", "IPlayerEvent")
|
||||
* @param functionName The hook function name
|
||||
* @return List of hook signatures, or empty list if not found
|
||||
*/
|
||||
public List<HookSignature> getHookSignatures(String namespace, String functionName) {
|
||||
// First try the specific namespace
|
||||
Map<String, List<HookSignature>> namespaceMap = contextHooks.get(namespace);
|
||||
if (namespaceMap != null) {
|
||||
List<HookSignature> sigs = namespaceMap.get(functionName);
|
||||
if (sigs != null && !sigs.isEmpty()) {
|
||||
return sigs;
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to GLOBAL namespace
|
||||
if (!GLOBAL_NAMESPACE.equals(namespace)) {
|
||||
Map<String, List<HookSignature>> globalMap = contextHooks.get(GLOBAL_NAMESPACE);
|
||||
if (globalMap != null) {
|
||||
List<HookSignature> sigs = globalMap.get(functionName);
|
||||
if (sigs != null && !sigs.isEmpty()) {
|
||||
return sigs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a function name is a known hook in a specific namespace.
|
||||
*
|
||||
* @param namespace The event interface namespace
|
||||
* @param functionName The hook function name
|
||||
* @return true if the hook exists in this namespace or GLOBAL
|
||||
*/
|
||||
public boolean isHook(String namespace, String functionName) {
|
||||
return !getHookSignatures(namespace, functionName).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter type for a hook function in a specific namespace.
|
||||
* Falls back to GLOBAL namespace if not found.
|
||||
*
|
||||
* @param namespace The event interface namespace
|
||||
* @param functionName The hook function name
|
||||
* @return The parameter type, or null if not found
|
||||
*/
|
||||
public String getHookParameterType(String namespace, String functionName) {
|
||||
List<HookSignature> sigs = getHookSignatures(namespace, functionName);
|
||||
if (!sigs.isEmpty()) {
|
||||
return sigs.get(0).paramType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all hook names for a specific namespace.
|
||||
*
|
||||
* @param namespace The event interface namespace
|
||||
* @return Set of hook function names available in this namespace
|
||||
*/
|
||||
public Set<String> getHookNames(String namespace) {
|
||||
Set<String> names = new HashSet<>();
|
||||
|
||||
// Add hooks from the specific namespace
|
||||
Map<String, List<HookSignature>> namespaceMap = contextHooks.get(namespace);
|
||||
if (namespaceMap != null) {
|
||||
names.addAll(namespaceMap.keySet());
|
||||
}
|
||||
|
||||
// Also add GLOBAL hooks
|
||||
if (!GLOBAL_NAMESPACE.equals(namespace)) {
|
||||
Map<String, List<HookSignature>> globalMap = contextHooks.get(GLOBAL_NAMESPACE);
|
||||
if (globalMap != null) {
|
||||
names.addAll(globalMap.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all hooks organized by namespace.
|
||||
*
|
||||
* @return Map of namespace -> hookName -> signatures
|
||||
*/
|
||||
public Map<String, Map<String, List<HookSignature>>> getAllContextHooks() {
|
||||
return Collections.unmodifiableMap(contextHooks);
|
||||
}
|
||||
|
||||
// ==================== MULTI-NAMESPACE LOOKUP (for ScriptContext) ====================
|
||||
|
||||
/**
|
||||
* Get hook signatures by searching through multiple namespaces.
|
||||
* This is used when a ScriptContext has multiple event types (e.g., Player has
|
||||
* IPlayerEvent, IAnimationEvent, IPartyEvent, etc.)
|
||||
*
|
||||
* @param namespaces List of namespaces to search (in priority order)
|
||||
* @param functionName The hook function name
|
||||
* @return List of hook signatures from the first matching namespace, or empty list
|
||||
*/
|
||||
public List<HookSignature> getHookSignatures(List<String> namespaces, String functionName) {
|
||||
// Search through all namespaces in order
|
||||
for (String namespace : namespaces) {
|
||||
Map<String, List<HookSignature>> namespaceMap = contextHooks.get(namespace);
|
||||
if (namespaceMap != null) {
|
||||
List<HookSignature> sigs = namespaceMap.get(functionName);
|
||||
if (sigs != null && !sigs.isEmpty()) {
|
||||
return sigs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to GLOBAL namespace
|
||||
Map<String, List<HookSignature>> globalMap = contextHooks.get(GLOBAL_NAMESPACE);
|
||||
if (globalMap != null) {
|
||||
List<HookSignature> sigs = globalMap.get(functionName);
|
||||
if (sigs != null && !sigs.isEmpty()) {
|
||||
return sigs;
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a function name is a known hook in any of the given namespaces.
|
||||
*
|
||||
* @param namespaces List of namespaces to search
|
||||
* @param functionName The hook function name
|
||||
* @return true if the hook exists in any namespace or GLOBAL
|
||||
*/
|
||||
public boolean isHook(List<String> namespaces, String functionName) {
|
||||
return !getHookSignatures(namespaces, functionName).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter type for a hook function, searching through multiple namespaces.
|
||||
*
|
||||
* @param namespaces List of namespaces to search
|
||||
* @param functionName The hook function name
|
||||
* @return The parameter type, or null if not found
|
||||
*/
|
||||
public String getHookParameterType(List<String> namespaces, String functionName) {
|
||||
List<HookSignature> sigs = getHookSignatures(namespaces, functionName);
|
||||
if (!sigs.isEmpty()) {
|
||||
return sigs.get(0).paramType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all hook names available in any of the given namespaces.
|
||||
*
|
||||
* @param namespaces List of namespaces to search
|
||||
* @return Set of hook function names available in these namespaces
|
||||
*/
|
||||
public Set<String> getHookNames(List<String> namespaces) {
|
||||
Set<String> names = new HashSet<>();
|
||||
|
||||
// Add hooks from all specified namespaces
|
||||
for (String namespace : namespaces) {
|
||||
Map<String, List<HookSignature>> namespaceMap = contextHooks.get(namespace);
|
||||
if (namespaceMap != null) {
|
||||
names.addAll(namespaceMap.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
// Also add GLOBAL hooks
|
||||
Map<String, List<HookSignature>> globalMap = contextHooks.get(GLOBAL_NAMESPACE);
|
||||
if (globalMap != null) {
|
||||
names.addAll(globalMap.keySet());
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve all type parameters for all types.
|
||||
* Called after all .d.ts files are loaded (Phase 2).
|
||||
@@ -530,31 +733,38 @@ public class JSTypeRegistry {
|
||||
types.clear();
|
||||
typeAliases.clear();
|
||||
hooks.clear();
|
||||
contextHooks.clear();
|
||||
globalEngineObjects.clear();
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a hook function signature.
|
||||
* Represents a hook function signature with its namespace.
|
||||
*/
|
||||
public static class HookSignature {
|
||||
public final String paramName;
|
||||
public final String paramType;
|
||||
public final String doc;
|
||||
|
||||
public final String namespace; // The event interface namespace (e.g., "INpcEvent")
|
||||
|
||||
public HookSignature(String paramName, String paramType) {
|
||||
this(paramName, paramType, null);
|
||||
this(paramName, paramType, null, GLOBAL_NAMESPACE);
|
||||
}
|
||||
|
||||
|
||||
public HookSignature(String paramName, String paramType, String doc) {
|
||||
this(paramName, paramType, doc, GLOBAL_NAMESPACE);
|
||||
}
|
||||
|
||||
public HookSignature(String paramName, String paramType, String doc, String namespace) {
|
||||
this.paramName = paramName;
|
||||
this.paramType = paramType;
|
||||
this.doc = doc;
|
||||
this.namespace = namespace != null ? namespace : GLOBAL_NAMESPACE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return paramName + ": " + paramType;
|
||||
return paramName + ": " + paramType + " [" + namespace + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
+55
-14
@@ -44,9 +44,15 @@ public class TypeScriptDefinitionParser {
|
||||
|
||||
private static final Pattern GLOBAL_FUNCTION_PATTERN = Pattern.compile(
|
||||
"function\\s+(\\w+)\\s*\\(([^)]*)\\)\\s*:\\s*([^;]+);");
|
||||
|
||||
|
||||
private static final Pattern GLOBAL_TYPE_ALIAS_PATTERN = Pattern.compile(
|
||||
"type\\s+(\\w+)\\s*=\\s*import\\(['\"]([^'\"]+)['\"]\\)\\.([\\w.]+);");
|
||||
|
||||
// Pattern for context-namespaced hooks like: declare namespace INpcEvent { ... }
|
||||
// Matches any "declare namespace <Name> {" where Name starts with I and contains Event,
|
||||
// or any other namespace pattern used for hooks
|
||||
private static final Pattern HOOKS_NAMESPACE_PATTERN = Pattern.compile(
|
||||
"declare\\s+namespace\\s+(I\\w*Event|\\w+)\\s*\\{", Pattern.MULTILINE);
|
||||
|
||||
private final JSTypeRegistry registry;
|
||||
|
||||
@@ -129,21 +135,56 @@ public class TypeScriptDefinitionParser {
|
||||
|
||||
/**
|
||||
* Parse hooks.d.ts to extract function signatures for JS hooks.
|
||||
*
|
||||
* Hooks are organized by their parent event interface, with the interface name
|
||||
* used directly as the namespace. Any mod can register its own event interfaces
|
||||
* and they will be automatically parsed:
|
||||
*
|
||||
* declare namespace INpcEvent {
|
||||
* function interact(event: INpcEvent.InteractEvent): void;
|
||||
* function init(event: INpcEvent.InitEvent): void;
|
||||
* }
|
||||
*
|
||||
* declare namespace IPlayerEvent {
|
||||
* function interact(event: IPlayerEvent.InteractEvent): void;
|
||||
* }
|
||||
*
|
||||
* declare namespace IDBCEvent {
|
||||
* function customHook(event: IDBCEvent.CustomEvent): void;
|
||||
* }
|
||||
*
|
||||
* The namespace name is stored as a string, allowing dynamic registration
|
||||
* without requiring enum modifications.
|
||||
*/
|
||||
private void parseHooksFile(String content) {
|
||||
Matcher m = GLOBAL_FUNCTION_PATTERN.matcher(content);
|
||||
while (m.find()) {
|
||||
String funcName = m.group(1);
|
||||
String params = m.group(2);
|
||||
String returnType = m.group(3).trim();
|
||||
|
||||
// Parse parameter - format is "paramName: TypeName"
|
||||
if (!params.isEmpty()) {
|
||||
String[] parts = params.split(":\\s*", 2);
|
||||
if (parts.length == 2) {
|
||||
String paramName = parts[0].trim();
|
||||
String paramType = parts[1].trim();
|
||||
registry.registerHook(funcName, paramName, paramType);
|
||||
// Parse namespaced hooks (e.g., declare namespace INpcEvent { ... })
|
||||
// The namespace name is used directly - any event interface can register hooks
|
||||
Matcher namespaceMatcher = HOOKS_NAMESPACE_PATTERN.matcher(content);
|
||||
while (namespaceMatcher.find()) {
|
||||
String namespace = namespaceMatcher.group(1); // e.g., "INpcEvent", "IPlayerEvent", "IDBCEvent"
|
||||
|
||||
// Find the body of this namespace
|
||||
int bodyStart = namespaceMatcher.end();
|
||||
int bodyEnd = findMatchingBrace(content, bodyStart - 1);
|
||||
if (bodyEnd > bodyStart) {
|
||||
String namespaceBody = content.substring(bodyStart, bodyEnd);
|
||||
|
||||
// Parse functions within this namespace
|
||||
Matcher funcMatcher = GLOBAL_FUNCTION_PATTERN.matcher(namespaceBody);
|
||||
while (funcMatcher.find()) {
|
||||
String funcName = funcMatcher.group(1);
|
||||
String params = funcMatcher.group(2);
|
||||
|
||||
// Parse parameter - format is "paramName: TypeName"
|
||||
if (!params.isEmpty()) {
|
||||
String[] parts = params.split(":\\s*", 2);
|
||||
if (parts.length == 2) {
|
||||
String paramName = parts[0].trim();
|
||||
String paramType = parts[1].trim();
|
||||
// Register hook with the namespace string directly
|
||||
registry.registerHook(namespace, funcName, paramName, paramType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +166,106 @@ public class TypeResolver {
|
||||
return getJSTypeRegistry().getHookSignatures(functionName);
|
||||
}
|
||||
|
||||
// ==================== CONTEXT-AWARE HOOK METHODS ====================
|
||||
|
||||
/**
|
||||
* Check if a function name is a known JS hook in a specific script context.
|
||||
* Falls back to GLOBAL context if not found in the specified context.
|
||||
*
|
||||
* @param namespace The event interface namespace (e.g., "INpcEvent", "IPlayerEvent")
|
||||
* @param functionName The function name to check
|
||||
* @return true if it's a known hook in this namespace
|
||||
*/
|
||||
public boolean isJSHook(String namespace, String functionName) {
|
||||
return getJSTypeRegistry().isHook(namespace, functionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter type for a JS hook function in a specific namespace.
|
||||
* Falls back to "Global" namespace if not found in the specified namespace.
|
||||
*
|
||||
* @param namespace The event interface namespace (e.g., "INpcEvent", "IPlayerEvent")
|
||||
* @param functionName The hook function name
|
||||
* @return The parameter type, or null if not a hook
|
||||
*/
|
||||
public String getJSHookParameterType(String namespace, String functionName) {
|
||||
return getJSTypeRegistry().getHookParameterType(namespace, functionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hook signatures for a JS function in a specific namespace.
|
||||
* Falls back to "Global" namespace if not found in the specified namespace.
|
||||
*
|
||||
* @param namespace The event interface namespace (e.g., "INpcEvent", "IPlayerEvent")
|
||||
* @param functionName The hook function name
|
||||
* @return List of hook signatures
|
||||
*/
|
||||
public List<JSTypeRegistry.HookSignature> getJSHookSignatures(String namespace, String functionName) {
|
||||
return getJSTypeRegistry().getHookSignatures(namespace, functionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all hook names available in a specific namespace.
|
||||
*
|
||||
* @param namespace The event interface namespace
|
||||
* @return Set of hook function names
|
||||
*/
|
||||
public Set<String> getJSHookNames(String namespace) {
|
||||
return getJSTypeRegistry().getHookNames(namespace);
|
||||
}
|
||||
|
||||
// ==================== MULTI-NAMESPACE HOOK METHODS ====================
|
||||
|
||||
/**
|
||||
* Check if a function name is a known JS hook in any of the provided namespaces.
|
||||
* Checks namespaces in order, returning true on first match.
|
||||
* Falls back to GLOBAL namespace if not found in any specified namespace.
|
||||
*
|
||||
* @param namespaces The list of event interface namespaces to search (e.g., ["IPlayerEvent", "IAnimationEvent"])
|
||||
* @param functionName The function name to check
|
||||
* @return true if it's a known hook in any of the namespaces
|
||||
*/
|
||||
public boolean isJSHook(List<String> namespaces, String functionName) {
|
||||
return getJSTypeRegistry().isHook(namespaces, functionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter type for a JS hook function, searching multiple namespaces.
|
||||
* Checks namespaces in order, returning the first match found.
|
||||
* Falls back to "Global" namespace if not found in any specified namespace.
|
||||
*
|
||||
* @param namespaces The list of event interface namespaces to search
|
||||
* @param functionName The hook function name
|
||||
* @return The parameter type, or null if not a hook
|
||||
*/
|
||||
public String getJSHookParameterType(List<String> namespaces, String functionName) {
|
||||
return getJSTypeRegistry().getHookParameterType(namespaces, functionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hook signatures for a JS function, searching multiple namespaces.
|
||||
* Checks namespaces in order, returning signatures from the first matching namespace.
|
||||
* Falls back to "Global" namespace if not found in any specified namespace.
|
||||
*
|
||||
* @param namespaces The list of event interface namespaces to search
|
||||
* @param functionName The hook function name
|
||||
* @return List of hook signatures
|
||||
*/
|
||||
public List<JSTypeRegistry.HookSignature> getJSHookSignatures(List<String> namespaces, String functionName) {
|
||||
return getJSTypeRegistry().getHookSignatures(namespaces, functionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all hook names available in any of the provided namespaces.
|
||||
* Combines hook names from all specified namespaces.
|
||||
*
|
||||
* @param namespaces The list of event interface namespaces
|
||||
* @return Combined set of hook function names from all namespaces
|
||||
*/
|
||||
public Set<String> getJSHookNames(List<String> namespaces) {
|
||||
return getJSTypeRegistry().getHookNames(namespaces);
|
||||
}
|
||||
|
||||
// ==================== CACHE MANAGEMENT ====================
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user