protected < X extends IzouPermissionException > void registerOrThrow ( AddOnModel addOn , Supplier < X > exceptionSupplier , Function < PluginDescriptor , Boolean > checkPermission ) { getMain ( ) . getAddOnManager ( ) . getPluginWrapper ( addOn ) . map ( PluginWrapper :: getDescriptor ) . map ( checkPermission ) . ifPresent ( allowedToRun -> { if ( allowedToRun ) { registerAddOn ( addOn ) ; } else { throw exceptionSupplier . get ( ) ; } } ) ; }
registers the addon if checkPermission returns true else throws the exception provided by the exceptionSupplier . If the Addon was not added through PF4J it gets ignored