mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-27 10:57:47 +01:00
Use a "temporary" TickListener to process queued IHoldSubComponents
instances.
This commit is contained in:
parent
d15a1d1f9e
commit
a950a2b7f8
@ -339,6 +339,15 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
/** All registered components. */
|
||||
protected Set<Object> allComponents = new LinkedHashSet<Object>(50);
|
||||
|
||||
/** Tick listener that is only needed sometimes (component registration). */
|
||||
protected final TickListener onDemandTickListener = new TickListener() {
|
||||
@Override
|
||||
public void onTick(int tick, long timeLast) {
|
||||
processQueuedSubComponentHolders();
|
||||
TickTask.removeTickListener(this);
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> Collection<ComponentRegistry<T>> getComponentRegistries(final Class<ComponentRegistry<T>> clazz) {
|
||||
@ -432,8 +441,10 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
added = true;
|
||||
}
|
||||
|
||||
// Components holding more components to register later.
|
||||
if (obj instanceof IHoldSubComponents){
|
||||
subComponentholders.add((IHoldSubComponents) obj);
|
||||
TickTask.addTickListener(onDemandTickListener);
|
||||
added = true; // Convention.
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user