From c0fdf23133dcbb36c487847a5cdc82f86204f623 Mon Sep 17 00:00:00 2001 From: RePixelatedMC Date: Sat, 16 Dec 2023 14:32:06 +0100 Subject: [PATCH] cleanup --- .../iris/core/safeguard/IrisSafeguard.java | 1 + .../volmit/iris/core/safeguard/ModesSFG.java | 137 +++++++++--------- .../iris/core/safeguard/PerformanceSFG.java | 8 +- .../iris/core/safeguard/ServerBootSFG.java | 27 ++-- .../volmit/iris/core/safeguard/UtilsSFG.java | 98 ++++++------- 5 files changed, 134 insertions(+), 137 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/core/safeguard/IrisSafeguard.java b/core/src/main/java/com/volmit/iris/core/safeguard/IrisSafeguard.java index d2d9f7a61..4fb25371a 100644 --- a/core/src/main/java/com/volmit/iris/core/safeguard/IrisSafeguard.java +++ b/core/src/main/java/com/volmit/iris/core/safeguard/IrisSafeguard.java @@ -6,6 +6,7 @@ public class IrisSafeguard { public static boolean unstablemode = false; public static boolean warningmode = false; public static boolean stablemode = false; + public static void IrisSafeguardSystem() { Iris.info("Enabled Iris SafeGuard"); ServerBootSFG.BootCheck(); diff --git a/core/src/main/java/com/volmit/iris/core/safeguard/ModesSFG.java b/core/src/main/java/com/volmit/iris/core/safeguard/ModesSFG.java index 299690fb2..3bd04d0db 100644 --- a/core/src/main/java/com/volmit/iris/core/safeguard/ModesSFG.java +++ b/core/src/main/java/com/volmit/iris/core/safeguard/ModesSFG.java @@ -5,76 +5,77 @@ import com.volmit.iris.core.IrisSettings; import com.volmit.iris.util.format.C; public class ModesSFG { - public static void selectMode(){ - if (IrisSafeguard.unstablemode) { - Iris.safeguard(C.DARK_RED + "Iris is running in Unstable Mode"); - unstable(); - } - if (IrisSafeguard.warningmode) { - Iris.safeguard(C.GOLD + "Iris is running in Warning Mode"); - warning(); - } - if (IrisSafeguard.stablemode) { - stable(); - } - } - public static void stable(){ - Iris.safeguard(C.BLUE + "Iris is running Stable"); - } - - public static void unstable() { - - UtilsSFG.printIncompatibleWarnings(); - - if (IrisSafeguard.unstablemode) { - Iris.info(""); - Iris.info(C.DARK_GRAY + "--==<" + C.RED + " IMPORTANT " + C.DARK_GRAY + ">==--"); - Iris.info(C.RED + "Iris is running in unstable mode which may cause the following issues:"); - Iris.info(C.DARK_RED + "Server Issues"); - Iris.info(C.RED + "- Server won't boot"); - Iris.info(C.RED + "- Data Loss"); - Iris.info(C.RED + "- Unexpected behavior."); - Iris.info(C.RED + "- And More..."); - Iris.info(C.DARK_RED + "World Issues"); - Iris.info(C.RED + "- Worlds can't load due to corruption."); - Iris.info(C.RED + "- Worlds may slowly corrupt until they can't load."); - Iris.info(C.RED + "- World data loss."); - Iris.info(C.RED + "- And More..."); - Iris.info(C.DARK_RED + "ATTENTION: " + C.RED + "While running Iris in unstable mode, you won't be eligible for support."); - Iris.info(C.DARK_RED + "CAUSE: " + C.RED + UtilsSFG.MSGIncompatibleWarnings()); - - if (IrisSettings.get().getGeneral().ignoreBootMode) { - Iris.info(C.DARK_RED + "Boot Unstable is set to true, continuing with the startup process."); - } else { - Iris.info(C.DARK_RED + "Go to plugins/iris/settings.json and set ignoreBootMode to true if you wish to proceed."); - while (true) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // Handle interruption - } + public static void selectMode() { + if (IrisSafeguard.unstablemode) { + Iris.safeguard(C.DARK_RED + "Iris is running in Unstable Mode"); + unstable(); + } + if (IrisSafeguard.warningmode) { + Iris.safeguard(C.GOLD + "Iris is running in Warning Mode"); + warning(); + } + if (IrisSafeguard.stablemode) { + stable(); + } } - } - Iris.info(""); - } - } - public static void warning() { + public static void stable() { + Iris.safeguard(C.BLUE + "Iris is running Stable"); + } - UtilsSFG.printIncompatibleWarnings(); + public static void unstable() { - if (IrisSafeguard.warningmode) { - Iris.info(""); - Iris.info(C.DARK_GRAY + "--==<" + C.GOLD + " IMPORTANT " + C.DARK_GRAY + ">==--"); - Iris.info(C.GOLD + "Iris is running in warning mode which may cause the following issues:"); - Iris.info(C.YELLOW + "- Data Loss"); - Iris.info(C.YELLOW + "- Errors"); - Iris.info(C.YELLOW + "- Broken worlds"); - Iris.info(C.YELLOW + "- Unexpected behavior."); - Iris.info(C.YELLOW + "- And perhaps further complications."); - Iris.info(C.GOLD + "ATTENTION: " + C.YELLOW + "While running Iris in unstable mode, you won't be eligible for support."); - Iris.info(C.GOLD + "CAUSE: " + C.YELLOW + UtilsSFG.MSGIncompatibleWarnings()); - Iris.info(""); - } - } + UtilsSFG.printIncompatibleWarnings(); + + if (IrisSafeguard.unstablemode) { + Iris.info(""); + Iris.info(C.DARK_GRAY + "--==<" + C.RED + " IMPORTANT " + C.DARK_GRAY + ">==--"); + Iris.info(C.RED + "Iris is running in unstable mode which may cause the following issues:"); + Iris.info(C.DARK_RED + "Server Issues"); + Iris.info(C.RED + "- Server won't boot"); + Iris.info(C.RED + "- Data Loss"); + Iris.info(C.RED + "- Unexpected behavior."); + Iris.info(C.RED + "- And More..."); + Iris.info(C.DARK_RED + "World Issues"); + Iris.info(C.RED + "- Worlds can't load due to corruption."); + Iris.info(C.RED + "- Worlds may slowly corrupt until they can't load."); + Iris.info(C.RED + "- World data loss."); + Iris.info(C.RED + "- And More..."); + Iris.info(C.DARK_RED + "ATTENTION: " + C.RED + "While running Iris in unstable mode, you won't be eligible for support."); + Iris.info(C.DARK_RED + "CAUSE: " + C.RED + UtilsSFG.MSGIncompatibleWarnings()); + + if (IrisSettings.get().getGeneral().ignoreBootMode) { + Iris.info(C.DARK_RED + "Boot Unstable is set to true, continuing with the startup process."); + } else { + Iris.info(C.DARK_RED + "Go to plugins/iris/settings.json and set ignoreBootMode to true if you wish to proceed."); + while (true) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // Handle interruption + } + } + } + Iris.info(""); + } + } + + public static void warning() { + + UtilsSFG.printIncompatibleWarnings(); + + if (IrisSafeguard.warningmode) { + Iris.info(""); + Iris.info(C.DARK_GRAY + "--==<" + C.GOLD + " IMPORTANT " + C.DARK_GRAY + ">==--"); + Iris.info(C.GOLD + "Iris is running in warning mode which may cause the following issues:"); + Iris.info(C.YELLOW + "- Data Loss"); + Iris.info(C.YELLOW + "- Errors"); + Iris.info(C.YELLOW + "- Broken worlds"); + Iris.info(C.YELLOW + "- Unexpected behavior."); + Iris.info(C.YELLOW + "- And perhaps further complications."); + Iris.info(C.GOLD + "ATTENTION: " + C.YELLOW + "While running Iris in unstable mode, you won't be eligible for support."); + Iris.info(C.GOLD + "CAUSE: " + C.YELLOW + UtilsSFG.MSGIncompatibleWarnings()); + Iris.info(""); + } + } } diff --git a/core/src/main/java/com/volmit/iris/core/safeguard/PerformanceSFG.java b/core/src/main/java/com/volmit/iris/core/safeguard/PerformanceSFG.java index aef67226e..90aab8cf5 100644 --- a/core/src/main/java/com/volmit/iris/core/safeguard/PerformanceSFG.java +++ b/core/src/main/java/com/volmit/iris/core/safeguard/PerformanceSFG.java @@ -1,13 +1,7 @@ package com.volmit.iris.core.safeguard; -import com.volmit.iris.core.IrisSettings; -import oshi.SystemInfo; -import oshi.hardware.GlobalMemory; - -import static com.volmit.iris.util.misc.getHardware.*; - public class PerformanceSFG { - public static void calculatePerformance(){ + public static void calculatePerformance() { } diff --git a/core/src/main/java/com/volmit/iris/core/safeguard/ServerBootSFG.java b/core/src/main/java/com/volmit/iris/core/safeguard/ServerBootSFG.java index 642fb103a..4cf20c30f 100644 --- a/core/src/main/java/com/volmit/iris/core/safeguard/ServerBootSFG.java +++ b/core/src/main/java/com/volmit/iris/core/safeguard/ServerBootSFG.java @@ -7,7 +7,9 @@ import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import java.io.File; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.StringJoiner; import static com.volmit.iris.Iris.getJavaVersion; import static com.volmit.iris.Iris.instance; @@ -54,12 +56,11 @@ public class ServerBootSFG { } } if ( - !instance.getServer().getVersion().contains("Purpur") && - !instance.getServer().getVersion().contains("Paper") && - !instance.getServer().getVersion().contains("Spigot") && - !instance.getServer().getVersion().contains("Pufferfish") && - !instance.getServer().getVersion().contains("Bukkit")) - { + !instance.getServer().getVersion().contains("Purpur") && + !instance.getServer().getVersion().contains("Paper") && + !instance.getServer().getVersion().contains("Spigot") && + !instance.getServer().getVersion().contains("Pufferfish") && + !instance.getServer().getVersion().contains("Bukkit")) { passedserversoftware = false; joiner.add("Server Software"); severityHigh++; @@ -71,12 +72,12 @@ public class ServerBootSFG { severityHigh++; } - if(getJavaVersion() != 17) { + if (getJavaVersion() != 17) { isJDK17 = false; joiner.add("Unsupported Java version"); severityMedium++; } - if(!isJDK()) { + if (!isJDK()) { isJRE = true; joiner.add("Unsupported JDK"); severityMedium++; @@ -86,11 +87,11 @@ public class ServerBootSFG { safeguardPassed = (severityHigh == 0 && severityMedium == 0 && severityLow == 0); count = severityHigh + severityMedium + severityLow; - if(safeguardPassed){ + if (safeguardPassed) { stablemode = true; Iris.safeguard("Stable mode has been activated."); } - if(!safeguardPassed){ + if (!safeguardPassed) { if (severityMedium >= 1 && severityHigh == 0) { warningmode = true; Iris.safeguard("Warning mode has been activated."); @@ -104,9 +105,9 @@ public class ServerBootSFG { public static boolean isJDK() { String path = System.getProperty("sun.boot.library.path"); - if(path != null) { + if (path != null) { String javacPath = ""; - if(path.endsWith(File.separator + "bin")) { + if (path.endsWith(File.separator + "bin")) { javacPath = path; } else { int libIndex = path.lastIndexOf(File.separator + "lib"); diff --git a/core/src/main/java/com/volmit/iris/core/safeguard/UtilsSFG.java b/core/src/main/java/com/volmit/iris/core/safeguard/UtilsSFG.java index 8b94006c8..b0cd659d6 100644 --- a/core/src/main/java/com/volmit/iris/core/safeguard/UtilsSFG.java +++ b/core/src/main/java/com/volmit/iris/core/safeguard/UtilsSFG.java @@ -4,57 +4,57 @@ import com.volmit.iris.Iris; import com.volmit.iris.util.format.C; public class UtilsSFG { - public static void splash(){ - ModesSFG.selectMode(); - } + public static void splash() { + ModesSFG.selectMode(); + } - public static void printIncompatibleWarnings(){ - // String SupportedIrisVersion = getDescription().getVersion(); //todo Automatic version + public static void printIncompatibleWarnings() { + // String SupportedIrisVersion = getDescription().getVersion(); //todo Automatic version - if (ServerBootSFG.safeguardPassed) { - Iris.safeguard(C.BLUE + "0 Conflicts found"); - } else { - if (IrisSafeguard.unstablemode) { - Iris.safeguard(C.DARK_RED + "" + ServerBootSFG.count + " Conflicts found"); - } - if (IrisSafeguard.warningmode) { - Iris.safeguard(C.YELLOW + "" + ServerBootSFG.count + " Conflicts found"); - } + if (ServerBootSFG.safeguardPassed) { + Iris.safeguard(C.BLUE + "0 Conflicts found"); + } else { + if (IrisSafeguard.unstablemode) { + Iris.safeguard(C.DARK_RED + "" + ServerBootSFG.count + " Conflicts found"); + } + if (IrisSafeguard.warningmode) { + Iris.safeguard(C.YELLOW + "" + ServerBootSFG.count + " Conflicts found"); + } - if (ServerBootSFG.incompatibilities.get("Multiverse-Core")) { - Iris.safeguard(C.RED + "Multiverse"); - Iris.safeguard(C.RED + "- The plugin Multiverse is not compatible with the server."); - Iris.safeguard(C.RED + "- If you want to have a world manager, consider using PhantomWorlds or MyWorlds instead."); - } - if (ServerBootSFG.incompatibilities.get("Dynmap")) { - Iris.safeguard(C.RED + "Dynmap"); - Iris.safeguard(C.RED + "- The plugin Dynmap is not compatible with the server."); - Iris.safeguard(C.RED + "- If you want to have a map plugin like Dynmap, consider Bluemap."); - } - if (ServerBootSFG.incompatibilities.get("TerraformGenerator") || ServerBootSFG.incompatibilities.get("Stratos")) { - Iris.safeguard(C.YELLOW + "Terraform Generator / Stratos"); - Iris.safeguard(C.YELLOW + "- Iris is not compatible with other worldgen plugins."); - } - if (ServerBootSFG.unsuportedversion) { - Iris.safeguard(C.RED + "Server Version"); - Iris.safeguard(C.RED + "- Iris only supports 1.19.2 > 1.20.2"); - } - if (!ServerBootSFG.passedserversoftware) { - Iris.safeguard(C.RED + "Unsupported Server Software"); - Iris.safeguard(C.RED + "- Please consider using Paper or Purpur instead."); - } - if (!ServerBootSFG.isJDK17) { - Iris.safeguard(C.YELLOW + "Unsupported java version"); - Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JDK " + Iris.getJavaVersion()); - } - if (!ServerBootSFG.isJRE) { - Iris.safeguard(C.YELLOW + "Unsupported Server JDK"); - Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JRE " + Iris.getJavaVersion()); - } - } - } + if (ServerBootSFG.incompatibilities.get("Multiverse-Core")) { + Iris.safeguard(C.RED + "Multiverse"); + Iris.safeguard(C.RED + "- The plugin Multiverse is not compatible with the server."); + Iris.safeguard(C.RED + "- If you want to have a world manager, consider using PhantomWorlds or MyWorlds instead."); + } + if (ServerBootSFG.incompatibilities.get("Dynmap")) { + Iris.safeguard(C.RED + "Dynmap"); + Iris.safeguard(C.RED + "- The plugin Dynmap is not compatible with the server."); + Iris.safeguard(C.RED + "- If you want to have a map plugin like Dynmap, consider Bluemap."); + } + if (ServerBootSFG.incompatibilities.get("TerraformGenerator") || ServerBootSFG.incompatibilities.get("Stratos")) { + Iris.safeguard(C.YELLOW + "Terraform Generator / Stratos"); + Iris.safeguard(C.YELLOW + "- Iris is not compatible with other worldgen plugins."); + } + if (ServerBootSFG.unsuportedversion) { + Iris.safeguard(C.RED + "Server Version"); + Iris.safeguard(C.RED + "- Iris only supports 1.19.2 > 1.20.2"); + } + if (!ServerBootSFG.passedserversoftware) { + Iris.safeguard(C.RED + "Unsupported Server Software"); + Iris.safeguard(C.RED + "- Please consider using Paper or Purpur instead."); + } + if (!ServerBootSFG.isJDK17) { + Iris.safeguard(C.YELLOW + "Unsupported java version"); + Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JDK " + Iris.getJavaVersion()); + } + if (!ServerBootSFG.isJRE) { + Iris.safeguard(C.YELLOW + "Unsupported Server JDK"); + Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JRE " + Iris.getJavaVersion()); + } + } + } - public static String MSGIncompatibleWarnings() { - return ServerBootSFG.allIncompatibilities; - } + public static String MSGIncompatibleWarnings() { + return ServerBootSFG.allIncompatibilities; + } }