@@ -12,6 +12,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@@ -25,6 +26,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -376,4 +378,19 @@ public class BukkitService implements SettingsDependent {
|
||||
public BanEntry banIp(String ip, String reason, Date expires, String source) {
|
||||
return Bukkit.getServer().getBanList(BanList.Type.IP).addBan(ip, reason, expires, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an optional with a boolean indicating whether bungeecord is enabled or not if the
|
||||
* server implementation is Spigot. Otherwise returns an empty optional.
|
||||
*
|
||||
* @return Optional with configuration value for Spigot, empty optional otherwise
|
||||
*/
|
||||
public Optional<Boolean> isBungeeCordConfiguredForSpigot() {
|
||||
try {
|
||||
YamlConfiguration spigotConfig = Bukkit.spigot().getConfig();
|
||||
return Optional.of(spigotConfig.getBoolean("settings.bungeecord"));
|
||||
} catch (NoSuchMethodError e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package fr.xephi.authme.util;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@@ -23,20 +22,6 @@ public final class Utils {
|
||||
private Utils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the running server instance is craftbukkit or spigot based.
|
||||
*
|
||||
* @return true if the running server instance is spigot-based.
|
||||
*/
|
||||
public static boolean isSpigot() {
|
||||
try {
|
||||
Bukkit.spigot();
|
||||
return true;
|
||||
} catch (NoSuchMethodError e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile Pattern sneaky without throwing Exception.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user