mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-03 10:50:27 +02: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. */
|
/** All registered components. */
|
||||||
protected Set<Object> allComponents = new LinkedHashSet<Object>(50);
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public <T> Collection<ComponentRegistry<T>> getComponentRegistries(final Class<ComponentRegistry<T>> clazz) {
|
public <T> Collection<ComponentRegistry<T>> getComponentRegistries(final Class<ComponentRegistry<T>> clazz) {
|
||||||
|
@ -432,8 +441,10 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||||
added = true;
|
added = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Components holding more components to register later.
|
||||||
if (obj instanceof IHoldSubComponents){
|
if (obj instanceof IHoldSubComponents){
|
||||||
subComponentholders.add((IHoldSubComponents) obj);
|
subComponentholders.add((IHoldSubComponents) obj);
|
||||||
|
TickTask.addTickListener(onDemandTickListener);
|
||||||
added = true; // Convention.
|
added = true; // Convention.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user