@@ -35,7 +35,7 @@ public abstract class BasePeripheral<O extends IPeripheralOwner> implements IBas
3535 protected final O owner ;
3636 protected final List <BoundMethod > pluggedMethods = new ArrayList <>();
3737 protected boolean initialized = false ;
38- protected List <IPeripheralPlugin > plugins = null ;
38+ protected final List <IPeripheralPlugin > plugins = new ArrayList <>() ;
3939 protected String [] methodNames = new String [0 ];
4040
4141 protected BasePeripheral (String type , @ NotNull O owner ) {
@@ -49,11 +49,9 @@ protected void tryBuildPlugins() {
4949 }
5050 this .initialized = true ;
5151 this .pluggedMethods .clear ();
52- if (this .plugins != null ) {
53- this .plugins .stream ()
54- .filter (plugin -> plugin .isSuitable (this ))
55- .forEach (plugin -> this .pluggedMethods .addAll (plugin .getMethods ()));
56- }
52+ this .plugins .stream ()
53+ .filter (plugin -> plugin .isSuitable (this ))
54+ .forEach (plugin -> this .pluggedMethods .addAll (plugin .getMethods ()));
5755 owner .getAbilities ().forEach (ability -> {
5856 if (ability instanceof IPeripheralPlugin peripheralPlugin ) {
5957 this .pluggedMethods .addAll (peripheralPlugin .getMethods ());
@@ -63,8 +61,7 @@ protected void tryBuildPlugins() {
6361 }
6462
6563 protected void addPlugin (@ NotNull IPeripheralPlugin plugin ) {
66- if (plugins == null ) plugins = new ArrayList <>();
67- plugins .add (plugin );
64+ this .plugins .add (plugin );
6865 IPeripheralOperation <?>[] operations = plugin .getOperations ();
6966 if (operations != null ) {
7067 OperationAbility operationAbility = owner .getAbility (PeripheralOwnerAbility .OPERATION );
0 commit comments