diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/feature/IPostRegisterRunnable.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/feature/IPostRegisterRunnable.java new file mode 100644 index 00000000..d0fb74c0 --- /dev/null +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/feature/IPostRegisterRunnable.java @@ -0,0 +1,15 @@ +package fr.neatmonster.nocheatplus.components.registry.feature; + +/** + * Call runPostRegister, after ordinary steps of component registration have + * taken place. This doesn't necessarily way for sub-component that register on + * the next tick. + * + * @author asofold + * + */ +public interface IPostRegisterRunnable { + + public void runPostRegister(); + +} diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/feature/IRegisterAsGenericInstance.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/feature/IRegisterAsGenericInstance.java index f4e19ef9..d93bac82 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/feature/IRegisterAsGenericInstance.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/registry/feature/IRegisterAsGenericInstance.java @@ -15,7 +15,8 @@ package fr.neatmonster.nocheatplus.components.registry.feature; /** - * Register this instance as generic instance (for the class of this instance). + * Register this instance as generic instance (for the class of this instance), + * once passed to a component registry that supports this. * * @author asofold * diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java index 506d29fb..cbb0fc34 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java @@ -87,6 +87,7 @@ import fr.neatmonster.nocheatplus.components.registry.feature.DisableListener; import fr.neatmonster.nocheatplus.components.registry.feature.IHoldSubComponents; import fr.neatmonster.nocheatplus.components.registry.feature.INeedConfig; import fr.neatmonster.nocheatplus.components.registry.feature.INotifyReload; +import fr.neatmonster.nocheatplus.components.registry.feature.IPostRegisterRunnable; import fr.neatmonster.nocheatplus.components.registry.feature.IRegisterAsGenericInstance; import fr.neatmonster.nocheatplus.components.registry.feature.JoinLeaveListener; import fr.neatmonster.nocheatplus.components.registry.feature.MCAccessHolder; @@ -435,8 +436,9 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI { /** * Convenience method to add components according to implemented interfaces, * like Listener, INotifyReload, INeedConfig.
- * For the NoCheatPlus instance this must be done after the configuration has been initialized. - * This will also register ComponentRegistry instances if given. + * For the NoCheatPlus instance this must be done after the configuration + * has been initialized. This will also register ComponentRegistry instances + * if given. */ @Override public boolean addComponent(final Object obj) { @@ -446,8 +448,12 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI { /** * Convenience method to add components according to implemented interfaces, * like Listener, INotifyReload, INeedConfig.
- * For the NoCheatPlus instance this must be done after the configuration has been initialized. - * @param allowComponentRegistry Only registers ComponentRegistry instances if this is set to true. + * For the NoCheatPlus instance this must be done after the configuration + * has been initialized. + * + * @param allowComponentRegistry + * Only registers ComponentRegistry instances if this is set to + * true. */ @Override public boolean addComponent(final Object obj, final boolean allowComponentRegistry) { @@ -534,6 +540,12 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI { if (added) { allComponents.add(obj); } + + // Post register hooks. + if (obj instanceof IPostRegisterRunnable) { + ((IPostRegisterRunnable) obj).runPostRegister(); + } + return added; }