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() {
|
public String getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isProtected() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ public class ModuleServiceImpl implements ModuleService, ApplicationListener<Con
|
|||||||
LOGGER.debug("AbstractModule not loaded: " + id);
|
LOGGER.debug("AbstractModule not loaded: " + id);
|
||||||
return;
|
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.changeActiveState(id, false);
|
||||||
this.modulesAll.remove(module);
|
this.modulesAll.remove(module);
|
||||||
@@ -147,6 +151,9 @@ public class ModuleServiceImpl implements ModuleService, ApplicationListener<Con
|
|||||||
.findAny()
|
.findAny()
|
||||||
.ifPresentOrElse(module -> {
|
.ifPresentOrElse(module -> {
|
||||||
if (!active) {
|
if (!active) {
|
||||||
|
if (module.isProtected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (module instanceof final AbstractClientModule clientModule) {
|
if (module instanceof final AbstractClientModule clientModule) {
|
||||||
this.changeDisplayState(clientModule.getId(), false);
|
this.changeDisplayState(clientModule.getId(), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,6 +395,11 @@ public class G2DRenderer implements Renderer {
|
|||||||
|
|
||||||
public static class G2DRendererModule extends AbstractClientModule {
|
public static class G2DRendererModule extends AbstractClientModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isProtected() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAlwaysDisplay() {
|
public boolean isAlwaysDisplay() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user