mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 15:29:54 +00:00
Large Cleanup to Code Imports and Formatting
This commit is contained in:
1 parent
31aac0d6b3
commit
a9b602713c
155 files changed
+4089
-2194
No files matched your search
@@ -1,13 +1,29 @@
|
||||
package noppes.npcs.constants;
|
||||
|
||||
import noppes.npcs.api.event.*;
|
||||
import noppes.npcs.api.event.IAnimationEvent;
|
||||
import noppes.npcs.api.event.IBlockEvent;
|
||||
import noppes.npcs.api.event.ICustomGuiEvent;
|
||||
import noppes.npcs.api.event.IDialogEvent;
|
||||
import noppes.npcs.api.event.IFactionEvent;
|
||||
import noppes.npcs.api.event.IForgeEvent;
|
||||
import noppes.npcs.api.event.IItemEvent;
|
||||
import noppes.npcs.api.event.INpcEvent;
|
||||
import noppes.npcs.api.event.IPartyEvent;
|
||||
import noppes.npcs.api.event.IPlayerEvent;
|
||||
import noppes.npcs.api.event.IProjectileEvent;
|
||||
import noppes.npcs.api.event.IQuestEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Represents a script context that maps to one or more event interface namespaces.
|
||||
*
|
||||
* <p>
|
||||
* A script context can have multiple namespaces because script editors often
|
||||
* support hooks from multiple event types. For example, Player scripts support:
|
||||
* - IPlayerEvent (core player hooks)
|
||||
@@ -15,17 +31,17 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* - IPartyEvent (party hooks)
|
||||
* - ICustomGuiEvent (custom GUI hooks)
|
||||
* - etc.
|
||||
*
|
||||
* <p>
|
||||
* Each context also has a hookContext string used by ScriptHookController for
|
||||
* hook registration and lookup.
|
||||
*
|
||||
* <p>
|
||||
* This is a registerable system - any mod can register their own contexts:
|
||||
*
|
||||
* // Register a new context with multiple namespaces:
|
||||
* ScriptContext.register("DBC", "dbc", IDBCEvent.class, IDBCPlayerEvent.class);
|
||||
*
|
||||
* // Or add namespaces to an existing context:
|
||||
* ScriptContext.PLAYER.addNamespace("IDBCPlayerEvent");
|
||||
* <p>
|
||||
* // Register a new context with multiple namespaces:
|
||||
* ScriptContext.register("DBC", "dbc", IDBCEvent.class, IDBCPlayerEvent.class);
|
||||
* <p>
|
||||
* // Or add namespaces to an existing context:
|
||||
* ScriptContext.PLAYER.addNamespace("IDBCPlayerEvent");
|
||||
*/
|
||||
public class ScriptContext {
|
||||
|
||||
@@ -35,42 +51,42 @@ public class ScriptContext {
|
||||
// ==================== BUILT-IN CONTEXTS ====================
|
||||
|
||||
public static final ScriptContext NPC = register("NPC", "npc",
|
||||
INpcEvent.class,
|
||||
IProjectileEvent.class
|
||||
INpcEvent.class,
|
||||
IProjectileEvent.class
|
||||
);
|
||||
|
||||
public static final ScriptContext PLAYER = register("PLAYER", "player",
|
||||
IPlayerEvent.class,
|
||||
IAnimationEvent.class,
|
||||
IPartyEvent.class,
|
||||
IDialogEvent.class,
|
||||
IQuestEvent.class,
|
||||
IFactionEvent.class,
|
||||
ICustomGuiEvent.class
|
||||
IPlayerEvent.class,
|
||||
IAnimationEvent.class,
|
||||
IPartyEvent.class,
|
||||
IDialogEvent.class,
|
||||
IQuestEvent.class,
|
||||
IFactionEvent.class,
|
||||
ICustomGuiEvent.class
|
||||
);
|
||||
|
||||
public static final ScriptContext BLOCK = register("BLOCK", "block",
|
||||
IBlockEvent.class
|
||||
IBlockEvent.class
|
||||
);
|
||||
|
||||
public static final ScriptContext ITEM = register("ITEM", "item",
|
||||
IItemEvent.class
|
||||
IItemEvent.class
|
||||
);
|
||||
|
||||
public static final ScriptContext FORGE = register("FORGE", "forge",
|
||||
IForgeEvent.class
|
||||
IForgeEvent.class
|
||||
);
|
||||
|
||||
public static final ScriptContext LINKED_ITEM = register("LINKED_ITEM", "linked_item",
|
||||
IItemEvent.class
|
||||
IItemEvent.class
|
||||
);
|
||||
|
||||
public static final ScriptContext RECIPE = register("RECIPE", "recipe",
|
||||
"Recipe"
|
||||
"Recipe"
|
||||
);
|
||||
|
||||
public static final ScriptContext EFFECT = register("EFFECT", "effect",
|
||||
"Effect"
|
||||
"Effect"
|
||||
);
|
||||
|
||||
public static final ScriptContext GLOBAL = register("GLOBAL", "",
|
||||
@@ -79,13 +95,19 @@ public class ScriptContext {
|
||||
|
||||
// ==================== INSTANCE FIELDS ====================
|
||||
|
||||
/** Unique identifier for this context (e.g., "NPC", "PLAYER", "DBC") */
|
||||
/**
|
||||
* Unique identifier for this context (e.g., "NPC", "PLAYER", "DBC")
|
||||
*/
|
||||
public final String id;
|
||||
|
||||
/** Hook context identifier used by ScriptHookController (e.g., "npc", "player") */
|
||||
/**
|
||||
* Hook context identifier used by ScriptHookController (e.g., "npc", "player")
|
||||
*/
|
||||
public final String hookContext;
|
||||
|
||||
/** The event interface namespaces this context supports */
|
||||
/**
|
||||
* The event interface namespaces this context supports
|
||||
*/
|
||||
private final List<String> namespaces;
|
||||
|
||||
// ==================== CONSTRUCTOR ====================
|
||||
@@ -144,9 +166,9 @@ public class ScriptContext {
|
||||
/**
|
||||
* Register a new script context with a hook context and one or more namespaces.
|
||||
*
|
||||
* @param id Unique identifier (e.g., "DBC", "CUSTOM")
|
||||
* @param id Unique identifier (e.g., "DBC", "CUSTOM")
|
||||
* @param hookContext The hook context string for ScriptHookController (e.g., "dbc")
|
||||
* @param namespaces The event interface names (e.g., "IDBCEvent", "IDBCPlayerEvent")
|
||||
* @param namespaces The event interface names (e.g., "IDBCEvent", "IDBCPlayerEvent")
|
||||
* @return The registered ScriptContext
|
||||
*/
|
||||
public static ScriptContext register(String id, String hookContext, String... namespaces) {
|
||||
@@ -158,12 +180,12 @@ public class ScriptContext {
|
||||
/**
|
||||
* Register a new script context using event interface classes.
|
||||
* Automatically extracts the simple name from each class.
|
||||
*
|
||||
* <p>
|
||||
* Example:
|
||||
* ScriptContext.register("NPC", "npc", INpcEvent.class, IProjectileEvent.class);
|
||||
* ScriptContext.register("NPC", "npc", INpcEvent.class, IProjectileEvent.class);
|
||||
*
|
||||
* @param id Unique identifier (e.g., "DBC", "CUSTOM")
|
||||
* @param hookContext The hook context string for ScriptHookController (e.g., "npc")
|
||||
* @param id Unique identifier (e.g., "DBC", "CUSTOM")
|
||||
* @param hookContext The hook context string for ScriptHookController (e.g., "npc")
|
||||
* @param eventClasses The event interface classes (simple names will be extracted)
|
||||
* @return The registered ScriptContext
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user