Package org.skriptlang.skript.addon
Class HierarchicalAddonModule
java.lang.Object
org.skriptlang.skript.addon.HierarchicalAddonModule
- All Implemented Interfaces:
AddonModule
- Direct Known Subclasses:
BlockModule,BookModule,BreedingModule,BrewingModule,BukkitModule,CommonModule,DamageSourceModule,DisplayModule,EntityModule,EquippableModule,FishingModule,FurnaceModule,InputModule,InteractionModule,ItemComponentModule,ItemModule,LootTableModule,MiscModule,ParticleModule,PDCModule,PlayerModule,PotionModule,PropertiesModule,SignModule,TagModule,TextModule
An
AddonModule that supports parent/child hierarchies with automatic lifecycle forwarding.
Modules extending this class should:
- Override
children()to declare child modules - Override
canLoadSelf(SkriptAddon),initSelf(SkriptAddon), and/orloadSelf(SkriptAddon)for module-specific loading
Lifecycle methods (canLoad(org.skriptlang.skript.addon.SkriptAddon), init(org.skriptlang.skript.addon.SkriptAddon), load(org.skriptlang.skript.addon.SkriptAddon)) are automatically forwarded to children.
Origin chains are built automatically from the parent hierarchy.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.skriptlang.skript.addon.AddonModule
AddonModule.ModuleOrigin, AddonModule.Registrar -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a module with no parent.protectedHierarchicalAddonModule(@Nullable AddonModule parentModule) Constructs a child module with the given parent. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleancanLoad(SkriptAddon addon) Allow addons to specify whether they can load or not.protected booleancanLoadSelf(SkriptAddon addon) Override for module-specific canLoad logic.children()Override to provide child modules.final voidinit(SkriptAddon addon) Used for loading the components of this module that are needed first or by other modules (e.g.protected voidinitSelf(SkriptAddon addon) Override for module-specific initialization.final voidload(SkriptAddon addon) Used for loading the components (e.g.protected abstract voidloadSelf(SkriptAddon addon) Override for module-specific loading.final AddonModule.ModuleOriginorigin(SkriptAddon addon) @Nullable AddonModuleparent()Returns the parent module, or null if this is a root module.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.skriptlang.skript.addon.AddonModule
moduleRegistry, name, register
-
Constructor Details
-
HierarchicalAddonModule
protected HierarchicalAddonModule()Constructs a module with no parent. -
HierarchicalAddonModule
Constructs a child module with the given parent.- Parameters:
parentModule- The parent module that created this child module.
-
-
Method Details
-
parent
Returns the parent module, or null if this is a root module.- Returns:
- The parent module, or null.
-
children
Override to provide child modules. Default returns an empty list.- Returns:
- An iterable of child modules.
-
canLoadSelf
Override for module-specific canLoad logic. Default returns true.- Parameters:
addon- The addon this module belongs to.- Returns:
- Whether this module can load.
-
canLoad
Description copied from interface:AddonModuleAllow addons to specify whether they can load or not. Called prior toAddonModule.init(SkriptAddon)- Specified by:
canLoadin interfaceAddonModule- Parameters:
addon- The addon this module belongs to.- Returns:
- Whether this module can load.
-
initSelf
Override for module-specific initialization.- Parameters:
addon- The addon this module belongs to.
-
init
Description copied from interface:AddonModuleUsed for loading the components of this module that are needed first or by other modules (e.g. class infos). This method will always be called beforeAddonModule.load(SkriptAddon).- Specified by:
initin interfaceAddonModule- Parameters:
addon- The addon this module belongs to.- See Also:
-
loadSelf
Override for module-specific loading.- Parameters:
addon- The addon this module belongs to.
-
load
Description copied from interface:AddonModuleUsed for loading the components (e.g. syntax) of this module.- Specified by:
loadin interfaceAddonModule- Parameters:
addon- The addon this module belongs to.- See Also:
-
origin
- Specified by:
originin interfaceAddonModule- Returns:
- An origin representing this module.
-