This commit is contained in:
RePixelatedMC
2023-12-16 14:32:06 +01:00
parent 28523a9593
commit c0fdf23133
5 changed files with 134 additions and 137 deletions
@@ -6,6 +6,7 @@ public class IrisSafeguard {
public static boolean unstablemode = false; public static boolean unstablemode = false;
public static boolean warningmode = false; public static boolean warningmode = false;
public static boolean stablemode = false; public static boolean stablemode = false;
public static void IrisSafeguardSystem() { public static void IrisSafeguardSystem() {
Iris.info("Enabled Iris SafeGuard"); Iris.info("Enabled Iris SafeGuard");
ServerBootSFG.BootCheck(); ServerBootSFG.BootCheck();
@@ -5,76 +5,77 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
public class ModesSFG { public class ModesSFG {
public static void selectMode(){ public static void selectMode() {
if (IrisSafeguard.unstablemode) { if (IrisSafeguard.unstablemode) {
Iris.safeguard(C.DARK_RED + "Iris is running in Unstable Mode"); Iris.safeguard(C.DARK_RED + "Iris is running in Unstable Mode");
unstable(); unstable();
} }
if (IrisSafeguard.warningmode) { if (IrisSafeguard.warningmode) {
Iris.safeguard(C.GOLD + "Iris is running in Warning Mode"); Iris.safeguard(C.GOLD + "Iris is running in Warning Mode");
warning(); warning();
} }
if (IrisSafeguard.stablemode) { if (IrisSafeguard.stablemode) {
stable(); 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
}
} }
}
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) { UtilsSFG.printIncompatibleWarnings();
Iris.info("");
Iris.info(C.DARK_GRAY + "--==<" + C.GOLD + " IMPORTANT " + C.DARK_GRAY + ">==--"); if (IrisSafeguard.unstablemode) {
Iris.info(C.GOLD + "Iris is running in warning mode which may cause the following issues:"); Iris.info("");
Iris.info(C.YELLOW + "- Data Loss"); Iris.info(C.DARK_GRAY + "--==<" + C.RED + " IMPORTANT " + C.DARK_GRAY + ">==--");
Iris.info(C.YELLOW + "- Errors"); Iris.info(C.RED + "Iris is running in unstable mode which may cause the following issues:");
Iris.info(C.YELLOW + "- Broken worlds"); Iris.info(C.DARK_RED + "Server Issues");
Iris.info(C.YELLOW + "- Unexpected behavior."); Iris.info(C.RED + "- Server won't boot");
Iris.info(C.YELLOW + "- And perhaps further complications."); Iris.info(C.RED + "- Data Loss");
Iris.info(C.GOLD + "ATTENTION: " + C.YELLOW + "While running Iris in unstable mode, you won't be eligible for support."); Iris.info(C.RED + "- Unexpected behavior.");
Iris.info(C.GOLD + "CAUSE: " + C.YELLOW + UtilsSFG.MSGIncompatibleWarnings()); Iris.info(C.RED + "- And More...");
Iris.info(""); 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("");
}
}
} }
@@ -1,13 +1,7 @@
package com.volmit.iris.core.safeguard; 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 class PerformanceSFG {
public static void calculatePerformance(){ public static void calculatePerformance() {
} }
@@ -7,7 +7,9 @@ import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.io.File; 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.getJavaVersion;
import static com.volmit.iris.Iris.instance; import static com.volmit.iris.Iris.instance;
@@ -54,12 +56,11 @@ public class ServerBootSFG {
} }
} }
if ( if (
!instance.getServer().getVersion().contains("Purpur") && !instance.getServer().getVersion().contains("Purpur") &&
!instance.getServer().getVersion().contains("Paper") && !instance.getServer().getVersion().contains("Paper") &&
!instance.getServer().getVersion().contains("Spigot") && !instance.getServer().getVersion().contains("Spigot") &&
!instance.getServer().getVersion().contains("Pufferfish") && !instance.getServer().getVersion().contains("Pufferfish") &&
!instance.getServer().getVersion().contains("Bukkit")) !instance.getServer().getVersion().contains("Bukkit")) {
{
passedserversoftware = false; passedserversoftware = false;
joiner.add("Server Software"); joiner.add("Server Software");
severityHigh++; severityHigh++;
@@ -71,12 +72,12 @@ public class ServerBootSFG {
severityHigh++; severityHigh++;
} }
if(getJavaVersion() != 17) { if (getJavaVersion() != 17) {
isJDK17 = false; isJDK17 = false;
joiner.add("Unsupported Java version"); joiner.add("Unsupported Java version");
severityMedium++; severityMedium++;
} }
if(!isJDK()) { if (!isJDK()) {
isJRE = true; isJRE = true;
joiner.add("Unsupported JDK"); joiner.add("Unsupported JDK");
severityMedium++; severityMedium++;
@@ -86,11 +87,11 @@ public class ServerBootSFG {
safeguardPassed = (severityHigh == 0 && severityMedium == 0 && severityLow == 0); safeguardPassed = (severityHigh == 0 && severityMedium == 0 && severityLow == 0);
count = severityHigh + severityMedium + severityLow; count = severityHigh + severityMedium + severityLow;
if(safeguardPassed){ if (safeguardPassed) {
stablemode = true; stablemode = true;
Iris.safeguard("Stable mode has been activated."); Iris.safeguard("Stable mode has been activated.");
} }
if(!safeguardPassed){ if (!safeguardPassed) {
if (severityMedium >= 1 && severityHigh == 0) { if (severityMedium >= 1 && severityHigh == 0) {
warningmode = true; warningmode = true;
Iris.safeguard("Warning mode has been activated."); Iris.safeguard("Warning mode has been activated.");
@@ -104,9 +105,9 @@ public class ServerBootSFG {
public static boolean isJDK() { public static boolean isJDK() {
String path = System.getProperty("sun.boot.library.path"); String path = System.getProperty("sun.boot.library.path");
if(path != null) { if (path != null) {
String javacPath = ""; String javacPath = "";
if(path.endsWith(File.separator + "bin")) { if (path.endsWith(File.separator + "bin")) {
javacPath = path; javacPath = path;
} else { } else {
int libIndex = path.lastIndexOf(File.separator + "lib"); int libIndex = path.lastIndexOf(File.separator + "lib");
@@ -4,57 +4,57 @@ import com.volmit.iris.Iris;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
public class UtilsSFG { public class UtilsSFG {
public static void splash(){ public static void splash() {
ModesSFG.selectMode(); ModesSFG.selectMode();
} }
public static void printIncompatibleWarnings(){ public static void printIncompatibleWarnings() {
// String SupportedIrisVersion = getDescription().getVersion(); //todo Automatic version // String SupportedIrisVersion = getDescription().getVersion(); //todo Automatic version
if (ServerBootSFG.safeguardPassed) { if (ServerBootSFG.safeguardPassed) {
Iris.safeguard(C.BLUE + "0 Conflicts found"); Iris.safeguard(C.BLUE + "0 Conflicts found");
} else { } else {
if (IrisSafeguard.unstablemode) { if (IrisSafeguard.unstablemode) {
Iris.safeguard(C.DARK_RED + "" + ServerBootSFG.count + " Conflicts found"); Iris.safeguard(C.DARK_RED + "" + ServerBootSFG.count + " Conflicts found");
} }
if (IrisSafeguard.warningmode) { if (IrisSafeguard.warningmode) {
Iris.safeguard(C.YELLOW + "" + ServerBootSFG.count + " Conflicts found"); Iris.safeguard(C.YELLOW + "" + ServerBootSFG.count + " Conflicts found");
} }
if (ServerBootSFG.incompatibilities.get("Multiverse-Core")) { if (ServerBootSFG.incompatibilities.get("Multiverse-Core")) {
Iris.safeguard(C.RED + "Multiverse"); Iris.safeguard(C.RED + "Multiverse");
Iris.safeguard(C.RED + "- The plugin Multiverse is not compatible with the server."); 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."); Iris.safeguard(C.RED + "- If you want to have a world manager, consider using PhantomWorlds or MyWorlds instead.");
} }
if (ServerBootSFG.incompatibilities.get("Dynmap")) { if (ServerBootSFG.incompatibilities.get("Dynmap")) {
Iris.safeguard(C.RED + "Dynmap"); Iris.safeguard(C.RED + "Dynmap");
Iris.safeguard(C.RED + "- The plugin Dynmap is not compatible with the server."); 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."); 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")) { if (ServerBootSFG.incompatibilities.get("TerraformGenerator") || ServerBootSFG.incompatibilities.get("Stratos")) {
Iris.safeguard(C.YELLOW + "Terraform Generator / Stratos"); Iris.safeguard(C.YELLOW + "Terraform Generator / Stratos");
Iris.safeguard(C.YELLOW + "- Iris is not compatible with other worldgen plugins."); Iris.safeguard(C.YELLOW + "- Iris is not compatible with other worldgen plugins.");
} }
if (ServerBootSFG.unsuportedversion) { if (ServerBootSFG.unsuportedversion) {
Iris.safeguard(C.RED + "Server Version"); Iris.safeguard(C.RED + "Server Version");
Iris.safeguard(C.RED + "- Iris only supports 1.19.2 > 1.20.2"); Iris.safeguard(C.RED + "- Iris only supports 1.19.2 > 1.20.2");
} }
if (!ServerBootSFG.passedserversoftware) { if (!ServerBootSFG.passedserversoftware) {
Iris.safeguard(C.RED + "Unsupported Server Software"); Iris.safeguard(C.RED + "Unsupported Server Software");
Iris.safeguard(C.RED + "- Please consider using Paper or Purpur instead."); Iris.safeguard(C.RED + "- Please consider using Paper or Purpur instead.");
} }
if (!ServerBootSFG.isJDK17) { if (!ServerBootSFG.isJDK17) {
Iris.safeguard(C.YELLOW + "Unsupported java version"); Iris.safeguard(C.YELLOW + "Unsupported java version");
Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JDK " + Iris.getJavaVersion()); Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JDK " + Iris.getJavaVersion());
} }
if (!ServerBootSFG.isJRE) { if (!ServerBootSFG.isJRE) {
Iris.safeguard(C.YELLOW + "Unsupported Server JDK"); Iris.safeguard(C.YELLOW + "Unsupported Server JDK");
Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JRE " + Iris.getJavaVersion()); Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JRE " + Iris.getJavaVersion());
} }
} }
} }
public static String MSGIncompatibleWarnings() { public static String MSGIncompatibleWarnings() {
return ServerBootSFG.allIncompatibilities; return ServerBootSFG.allIncompatibilities;
} }
} }