mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-27 14:13:11 +02:00
Add support for IPostRegisterRunnable.
Allows to register with the generic instance registry for another class, after component registration, with implementing this method.
This commit is contained in:
parent
d521a99ffc
commit
d5b45e53f9
@ -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();
|
||||
|
||||
}
|
@ -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
|
||||
*
|
||||
|
@ -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.<br>
|
||||
* 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.<br>
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user