From 7224ca43f3535fd8511a821a8ac1bf73fc353286 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Mon, 20 Sep 2021 07:14:31 -0400 Subject: [PATCH] Auto configuration modes --- .../volmit/iris/core/ServerConfigurator.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/com/volmit/iris/core/ServerConfigurator.java diff --git a/src/main/java/com/volmit/iris/core/ServerConfigurator.java b/src/main/java/com/volmit/iris/core/ServerConfigurator.java new file mode 100644 index 000000000..113b433b8 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/ServerConfigurator.java @@ -0,0 +1,54 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.util.plugin; + +import com.volmit.iris.Iris; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +public class ServerConfigurator { + public void increaseKeepAliveSpigot() throws IOException, InvalidConfigurationException { + File spigotConfig = new File("spigot.yml"); + FileConfiguration f = new YamlConfiguration(); + f.load(spigotConfig); + long tt = f.getLong("settings.timeout-time"); + + if(tt < TimeUnit.MINUTES.toMillis(7)) + { + Iris.warn("Updating spigot.yml timeout-time: " + tt + " -> " + TimeUnit.MINUTES.toMillis(5) + " (5 minutes). You can disable this change (autoconfigureServer) in Iris settings, then change back the value."); + } + } + + public void increasePaperWatchdog() throws IOException, InvalidConfigurationException { + File spigotConfig = new File("spigot.yml"); + FileConfiguration f = new YamlConfiguration(); + f.load(spigotConfig); + long tt = f.getLong("settings.watchdog.early-warning-delay"); + + if(tt < TimeUnit.MINUTES.toMillis(3)) + { + Iris.warn("Updating paper.yml watchdog early-warning-delay: " + tt + " -> " + TimeUnit.MINUTES.toMillis(3) + " (3 minutes). You can disable this change (autoconfigureServer) in Iris settings, then change back the value."); + } + } +}