feat(module): implement isProtected method in AbstractModule and G2DRendererModule

This commit is contained in:
extio-de
2026-02-08 15:33:03 +01:00
parent ebe096e454
commit eebe4b7815
3 changed files with 16 additions and 0 deletions

View File

@@ -24,6 +24,10 @@ public abstract class AbstractModule {
public String getId() {
return this.id;
}
public boolean isProtected() {
return false;
}
public void onLoad() {

View File

@@ -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);
}

View File

@@ -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;