From b67044984385d63708193c381d59dd14610d634c Mon Sep 17 00:00:00 2001 From: Alex811 <811alex@gmail.com> Date: Sat, 19 Dec 2020 15:14:32 +0200 Subject: [PATCH] Add warning for ClientUpdateComponent misconfiguration, related to disable-webserver --- .../java/org/dynmap/ComponentManager.java | 7 +++++- .../src/main/java/org/dynmap/DynmapCore.java | 24 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/DynmapCore/src/main/java/org/dynmap/ComponentManager.java b/DynmapCore/src/main/java/org/dynmap/ComponentManager.java index ce737940..c9f10465 100644 --- a/DynmapCore/src/main/java/org/dynmap/ComponentManager.java +++ b/DynmapCore/src/main/java/org/dynmap/ComponentManager.java @@ -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 components = new HashSet(); @@ -38,10 +39,14 @@ public class ComponentManager { components.clear(); } - public Iterable getComponents(Class c) { + public Iterable getComponents(Class c) { List list = componentLookup.get(c.toString()); if (list == null) return new ArrayList(); return list; } + + public Boolean isLoaded(Class c){ + return StreamSupport.stream(getComponents(c).spliterator(), false).count() > 0; + } } diff --git a/DynmapCore/src/main/java/org/dynmap/DynmapCore.java b/DynmapCore/src/main/java/org/dynmap/DynmapCore.java index b559af40..91ff49fe 100644 --- a/DynmapCore/src/main/java/org/dynmap/DynmapCore.java +++ b/DynmapCore/src/main/java/org/dynmap/DynmapCore.java @@ -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() { } @@ -610,6 +613,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 */