feat(module): implement isProtected method in AbstractModule and G2DRendererModule
This commit is contained in:
@@ -24,6 +24,10 @@ public abstract class AbstractModule {
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean isProtected() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onLoad() {
|
||||
|
||||
|
||||
@@ -117,6 +117,10 @@ public class ModuleServiceImpl implements ModuleService, ApplicationListener<Con
|
||||
LOGGER.debug("AbstractModule not loaded: " + id);
|
||||
return;
|
||||
}
|
||||
if (module.isProtected() && this.modulesActiveView.stream().anyMatch(m -> m.getId().equals(id))) {
|
||||
LOGGER.info("Cannot unload protected active module {}", id);
|
||||
return;
|
||||
}
|
||||
|
||||
this.changeActiveState(id, false);
|
||||
this.modulesAll.remove(module);
|
||||
@@ -147,6 +151,9 @@ public class ModuleServiceImpl implements ModuleService, ApplicationListener<Con
|
||||
.findAny()
|
||||
.ifPresentOrElse(module -> {
|
||||
if (!active) {
|
||||
if (module.isProtected()) {
|
||||
return;
|
||||
}
|
||||
if (module instanceof final AbstractClientModule clientModule) {
|
||||
this.changeDisplayState(clientModule.getId(), false);
|
||||
}
|
||||
|
||||
@@ -395,6 +395,11 @@ public class G2DRenderer implements Renderer {
|
||||
|
||||
public static class G2DRendererModule extends AbstractClientModule {
|
||||
|
||||
@Override
|
||||
public boolean isProtected() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysDisplay() {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user