Merge pull request #3216 from 811Alex/misconfwarn

Add warning for ClientUpdateComponent misconfiguration, related to disable-webserver
This commit is contained in:
mikeprimm 2020-12-30 18:50:46 -06:00 committed by GitHub
commit 5e5316d1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.StreamSupport;
public class ComponentManager {
public Set<Component> components = new HashSet<Component>();
@ -38,10 +39,14 @@ public class ComponentManager {
components.clear();
}
public Iterable<Component> getComponents(Class<Component> c) {
public Iterable<Component> getComponents(Class<? extends Component> c) {
List<Component> list = componentLookup.get(c.toString());
if (list == null)
return new ArrayList<Component>();
return list;
}
public Boolean isLoaded(Class<? extends Component> c){
return StreamSupport.stream(getComponents(c).spliterator(), false).count() > 0;
}
}

View File

@ -159,6 +159,9 @@ public class DynmapCore implements DynmapCommonAPI {
private String[] deftriggers = { };
private Boolean webserverCompConfigWarn = false;
private final String CompConfigWiki = "https://github.com/webbukkit/dynmap/wiki/Component-Configuration";
/* Constructor for core */
public DynmapCore() {
}
@ -615,6 +618,27 @@ public class DynmapCore implements DynmapCommonAPI {
if (!configuration.getBoolean("disable-webserver", false)) {
startWebserver();
if(!componentManager.isLoaded(InternalClientUpdateComponent.class)) {
Log.warning("Using internal server, but " + InternalClientUpdateComponent.class.toString() + " is DISABLED!");
webserverCompConfigWarn = true;
}
if(componentManager.isLoaded(JsonFileClientUpdateComponent.class)) {
Log.warning("Using internal server, but " + JsonFileClientUpdateComponent.class.toString() + " is ENABLED!");
}
}
else {
if(componentManager.isLoaded(InternalClientUpdateComponent.class)) {
Log.warning("Using external server, but " + InternalClientUpdateComponent.class.toString() + " is ENABLED!");
}
if(!componentManager.isLoaded(JsonFileClientUpdateComponent.class)) {
Log.warning("Using external server, but " + JsonFileClientUpdateComponent.class.toString() + " is DISABLED!");
webserverCompConfigWarn = true;
}
}
if(webserverCompConfigWarn){
Log.warning("If the website is missing files or not loading/updating, this might be why.");
Log.warning("For more info, read this: " + CompConfigWiki);
webserverCompConfigWarn = false;
}
/* Add login/logoff listeners */