Changed how ServerBootSFG Works Part1.

Added More warnings and Checks.
Improved Unstable Colored text.
Text for console and Player errors when in unstable.
This commit is contained in:
RePixelatedMC
2023-10-28 20:49:47 +02:00
parent dd124fab33
commit a12cb59a51
4 changed files with 98 additions and 30 deletions
+7 -2
View File
@@ -470,7 +470,7 @@ public class Iris extends VolmitPlugin implements Listener {
splash(); splash();
ServerBootSFG.UnstableMode(); ServerBootSFG.UnstableMode();
ServerBootSFG.SupportedServerSoftware(); ServerBootSFG.SupportedServerSoftware();
ServerBootSFG.printincompatiblepluginWarnings(); ServerBootSFG.printIncompatiblePluginWarnings();
autoStartStudio(); autoStartStudio();
checkForBukkitWorlds(); checkForBukkitWorlds();
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName()); IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
@@ -738,6 +738,10 @@ public class Iris extends VolmitPlugin implements Listener {
String padd = Form.repeat(" ", 8); String padd = Form.repeat(" ", 8);
String padd2 = Form.repeat(" ", 4); String padd2 = Form.repeat(" ", 4);
String[] info = {"", "", "", "", "", padd2 + C.IRIS + " Iris", padd2 + C.GRAY + " by " + "<rainbow>Volmit Software", padd2 + C.GRAY + " v" + C.IRIS + getDescription().getVersion()}; String[] info = {"", "", "", "", "", padd2 + C.IRIS + " Iris", padd2 + C.GRAY + " by " + "<rainbow>Volmit Software", padd2 + C.GRAY + " v" + C.IRIS + getDescription().getVersion()};
if (unstablemode) {
info = new String[]{"", "", "", "", "", padd2 + C.RED + " Iris", padd2 + C.GRAY + " by " + C.DARK_RED + "Volmit Software", padd2 + C.GRAY + " v" + C.RED + getDescription().getVersion()};
}
String[] splashstable = { String[] splashstable = {
padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@", padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@",
padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.IRIS + " .(((()))). ", padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.IRIS + " .(((()))). ",
@@ -778,7 +782,8 @@ public class Iris extends VolmitPlugin implements Listener {
} else { Iris.info("Server type & version: " + Bukkit.getVersion()); } } else { Iris.info("Server type & version: " + Bukkit.getVersion()); }
Iris.info("Server OS: " + osName + " (" + osArch + ")"); Iris.info("Server OS: " + osName + " (" + osArch + ")");
Iris.info("Server Cpu: " + C.BLUE + getCPUModel()); if(unstablemode) Iris.info("Server Cpu: " + C.RED + getCPUModel());
if(!unstablemode) Iris.info("Server Cpu: " + C.BLUE + getCPUModel());
Iris.info("Process Threads: " + getCPUThreads()); Iris.info("Process Threads: " + getCPUThreads());
Iris.info("Process Memory: " + maxMemory + " MB"); Iris.info("Process Memory: " + maxMemory + " MB");
if (maxMemory < 5999) { if (maxMemory < 5999) {
@@ -43,7 +43,6 @@ import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.jobs.QueueJob; import com.volmit.iris.util.scheduling.jobs.QueueJob;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
@@ -55,7 +54,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import static com.volmit.iris.core.tools.IrisBenchmarking.inProgress; import static com.volmit.iris.core.tools.IrisBenchmarking.inProgress;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.runBenchmark; import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
import static com.volmit.iris.engine.safeguard.ServerBootSFG.multiverse; import static com.volmit.iris.engine.safeguard.ServerBootSFG.multiverse;
@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command") @Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command")
@@ -81,24 +80,34 @@ public class CommandIris implements DecreeExecutor {
@Param(description = "The seed to generate the world with", defaultValue = "1337") @Param(description = "The seed to generate the world with", defaultValue = "1337")
long seed long seed
) { ) {
if (multiverse){ if(sender() instanceof Player) {
sender().sendMessage(C.RED + "Your server has an incompatibility that may corrupt all worlds on the server if not handled properly."); if (multiverse) {
sender().sendMessage(C.RED + "it is strongly advised for you to take action. see log for full detail"); sender().sendMessage(C.RED + "Your server has an incompatibility that may corrupt all worlds on the server if not handled properly.");
Iris.safeguard(C.RED + "----------------------------------------------------------------"); sender().sendMessage(C.RED + "it is strongly advised for you to take action. see log for full detail");
Iris.safeguard(C.RED + "Command ran: /iris create"); sender().sendMessage(C.RED + "----------------------------------------------------------------");
ServerBootSFG.printincompatiblepluginWarnings(); sender().sendMessage(C.RED + "Command ran: /iris create");
Iris.safeguard(C.RED + "----------------------------------------------------------------"); sender().sendMessage(C.RED + ServerBootSFG.MSGIncompatiblePluginWarnings());
} sender().sendMessage(C.RED + "----------------------------------------------------------------");
if (name.equals("iris")) { }
sender().sendMessage(C.RED + "You cannot use the world name \"iris\" for creating worlds as Iris uses this directory for studio worlds."); if (unstablemode && !multiverse) {
sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?"); sender().sendMessage(C.RED + "Your server is experiencing an incompatibility with the Iris plugin.");
return; sender().sendMessage(C.RED + "Please rectify this problem to avoid further complications.");
} sender().sendMessage(C.RED + "----------------------------------------------------------------");
if (name.equals("Benchmark")) { sender().sendMessage(C.RED + "Command ran: /iris create");
sender().sendMessage(C.RED + "You cannot use the world name \"Benchmark\" for creating worlds as Iris uses this directory for Benchmarking Packs."); sender().sendMessage(C.RED + ServerBootSFG.MSGIncompatiblePluginWarnings());
sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?"); sender().sendMessage(C.RED + "----------------------------------------------------------------");
return; }
} }
if (name.equals("iris")) {
sender().sendMessage(C.RED + "You cannot use the world name \"iris\" for creating worlds as Iris uses this directory for studio worlds.");
sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?");
return;
}
if (name.equals("Benchmark")) {
sender().sendMessage(C.RED + "You cannot use the world name \"Benchmark\" for creating worlds as Iris uses this directory for Benchmarking Packs.");
sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?");
return;
}
if (new File(Bukkit.getWorldContainer(), name).exists()) { if (new File(Bukkit.getWorldContainer(), name).exists()) {
sender().sendMessage(C.RED + "That folder already exists!"); sender().sendMessage(C.RED + "That folder already exists!");
@@ -26,6 +26,7 @@ import com.volmit.iris.core.pregenerator.PregenTask;
import com.volmit.iris.core.service.StudioSVC; import com.volmit.iris.core.service.StudioSVC;
import com.volmit.iris.engine.object.IrisDimension; import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.platform.PlatformChunkGenerator; import com.volmit.iris.engine.platform.PlatformChunkGenerator;
import com.volmit.iris.engine.safeguard.ServerBootSFG;
import com.volmit.iris.util.exceptions.IrisException; import com.volmit.iris.util.exceptions.IrisException;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
@@ -47,6 +48,7 @@ import java.util.function.Supplier;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmark; import static com.volmit.iris.core.tools.IrisPackBenchmarking.benchmark;
import static com.volmit.iris.core.tools.IrisPackBenchmarking.loaded; import static com.volmit.iris.core.tools.IrisPackBenchmarking.loaded;
import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
/** /**
* Makes it a lot easier to setup an engine, world, studio or whatever * Makes it a lot easier to setup an engine, world, studio or whatever
@@ -108,6 +110,13 @@ public class IrisCreator {
*/ */
IrisPackBenchmarking PackBench = new IrisPackBenchmarking(); IrisPackBenchmarking PackBench = new IrisPackBenchmarking();
public World create() throws IrisException { public World create() throws IrisException {
if (unstablemode){
Iris.info(C.RED + "Your server is experiencing an incompatibility with the Iris plugin. Please rectify this problem to avoid further complications.");
Iris.info(C.RED + "----------------------------------------------------------------");
Iris.info(C.RED + "Operation ran: Loading Iris World..");
ServerBootSFG.printIncompatiblePluginWarnings();
Iris.info(C.RED + "----------------------------------------------------------------");
}
if (Bukkit.isPrimaryThread()) { if (Bukkit.isPrimaryThread()) {
throw new IrisException("You cannot invoke create() on the main thread."); throw new IrisException("You cannot invoke create() on the main thread.");
} }
@@ -7,6 +7,10 @@ import com.volmit.iris.util.format.C;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
import static com.volmit.iris.Iris.dump;
import static com.volmit.iris.Iris.instance; import static com.volmit.iris.Iris.instance;
import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode; import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
@@ -15,8 +19,7 @@ public class ServerBootSFG {
public static boolean dynmap = false; public static boolean dynmap = false;
public static boolean terraform = false; public static boolean terraform = false;
public static boolean stratos = false; public static boolean stratos = false;
public static boolean correctversion = true; public static boolean unsuportedversion = false;
protected static boolean safeguardPassed; protected static boolean safeguardPassed;
public static boolean passedserversoftware = true; public static boolean passedserversoftware = true;
protected static byte count; protected static byte count;
@@ -26,8 +29,7 @@ public class ServerBootSFG {
org.bukkit.plugin.PluginManager pluginManager = Bukkit.getPluginManager(); org.bukkit.plugin.PluginManager pluginManager = Bukkit.getPluginManager();
Plugin[] plugins = pluginManager.getPlugins(); Plugin[] plugins = pluginManager.getPlugins();
if (INMS.get() instanceof NMSBinding1X) { if (INMS.get() instanceof NMSBinding1X) {
unstablemode = true; unsuportedversion = true;
correctversion = false;
} }
StringBuilder pluginList = new StringBuilder("Plugin list: "); StringBuilder pluginList = new StringBuilder("Plugin list: ");
@@ -52,8 +54,11 @@ public class ServerBootSFG {
count++; count++;
} }
pluginList.append(pluginName).append(", "); pluginList.append(pluginName).append(", ");
Iris.safeguard(pluginList.toString());
} }
if (unsuportedversion) count++;
if ( if (
!instance.getServer().getVersion().contains("Purpur") && !instance.getServer().getVersion().contains("Purpur") &&
!instance.getServer().getVersion().contains("Paper") && !instance.getServer().getVersion().contains("Paper") &&
@@ -61,18 +66,15 @@ public class ServerBootSFG {
!instance.getServer().getVersion().contains("Pufferfish") && !instance.getServer().getVersion().contains("Pufferfish") &&
!instance.getServer().getVersion().contains("Bukkit")) !instance.getServer().getVersion().contains("Bukkit"))
{ {
unstablemode = true;
passedserversoftware = false; passedserversoftware = false;
count++;
} }
safeguardPassed = (count == 0); safeguardPassed = (count == 0);
if(!safeguardPassed){ if(!safeguardPassed){
unstablemode = true; unstablemode = true;
}
if (unstablemode){
Iris.safeguard("Unstable mode has been activated."); Iris.safeguard("Unstable mode has been activated.");
} }
Iris.safeguard(pluginList.toString());
} }
public static void UnstableMode(){ public static void UnstableMode(){
@@ -88,7 +90,8 @@ public class ServerBootSFG {
Iris.safeguard(C.RED + "Supported: Purpur, Pufferfish, Paper, Spigot, Bukkit"); Iris.safeguard(C.RED + "Supported: Purpur, Pufferfish, Paper, Spigot, Bukkit");
} }
} }
public static void printincompatiblepluginWarnings(){ public static void printIncompatiblePluginWarnings(){
// String SupportedIrisVersion = getDescription().getVersion(); //todo Automatic version
if (safeguardPassed) { if (safeguardPassed) {
Iris.safeguard(C.BLUE + "0 Conflicts found"); Iris.safeguard(C.BLUE + "0 Conflicts found");
@@ -110,6 +113,48 @@ public class ServerBootSFG {
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 (unsuportedversion) {
Iris.safeguard(C.RED + "Server Version");
Iris.safeguard(C.RED + "- Iris only supports 1.19.2 > 1.20.2");
}
if (!passedserversoftware) {
Iris.safeguard(C.RED + "Unsupported Server Software");
Iris.safeguard(C.RED + "- Please consider using Paper or Purpur instead.");
// todo Add a cmd to show all issues?
}
} }
} }
public static String MSGIncompatiblePluginWarnings(){
StringBuilder stringBuilder = new StringBuilder();
List<String> incompatibleList = new ArrayList<>();
if (multiverse) {
String incompatibility1 = "Multiverse";
stringBuilder.append(incompatibility1).append(", ");
incompatibleList.add(incompatibility1);
}
if(dynmap) {
String incompatibility2 = "Dynmap";
stringBuilder.append(incompatibility2).append(", ");
incompatibleList.add(incompatibility2);
}
if (terraform) {
String incompatibility3 = "Terraform";
stringBuilder.append(incompatibility3).append(", ");
incompatibleList.add(incompatibility3);
}
if(stratos){
String incompatibility4 = "Stratos";
stringBuilder.append(incompatibility4).append(", ");
incompatibleList.add(incompatibility4);
}
String MSGIncompatiblePlugins = stringBuilder.toString();
return MSGIncompatiblePlugins;
}
} }