#1531 Move spigot detection to BukkitService (#1534)

This commit is contained in:
ljacqu
2018-03-19 23:08:48 +01:00
committed by HexelDev
parent 250bd0d148
commit a1a909c01d
4 changed files with 43 additions and 29 deletions
@@ -4,15 +4,15 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.Argon2;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.Utils;
import org.bukkit.Bukkit;
import javax.inject.Inject;
import java.util.Optional;
/**
* Logs warning messages in cases where the configured values suggest a misconfiguration.
@@ -29,6 +29,9 @@ public class SettingsWarner {
@Inject
private AuthMe authMe;
@Inject
private BukkitService bukkitService;
SettingsWarner() {
}
@@ -54,7 +57,7 @@ public class SettingsWarner {
}
// Warn if spigot.yml has settings.bungeecord set to true but config.yml has Hooks.bungeecord set to false
if (Utils.isSpigot() && Bukkit.spigot().getConfig().getBoolean("settings.bungeecord")
if (isTrue(bukkitService.isBungeeCordConfiguredForSpigot())
&& !settings.getProperty(HooksSettings.BUNGEECORD)) {
ConsoleLogger.warning("Note: Hooks.bungeecord is set to false but your server appears to be running in"
+ " bungeecord mode (see your spigot.yml). In order to allow the datasource caching and the"
@@ -69,4 +72,8 @@ public class SettingsWarner {
authMe.stopOrUnload();
}
}
private static boolean isTrue(Optional<Boolean> value) {
return value.isPresent() && value.get();
}
}