mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-27 06:20:02 +00:00
IrisSafeguard Prototype idea
This commit is contained in:
1 parent
15e6750e11
commit
46ee7a5983
5 files changed
+186
-6
No files matched your search
@@ -38,6 +38,8 @@ import com.volmit.iris.engine.object.IrisDimension;
|
|||||||
import com.volmit.iris.engine.object.IrisWorld;
|
import com.volmit.iris.engine.object.IrisWorld;
|
||||||
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
||||||
import com.volmit.iris.engine.platform.DummyChunkGenerator;
|
import com.volmit.iris.engine.platform.DummyChunkGenerator;
|
||||||
|
import com.volmit.iris.engine.safeguard.IrisSafeguard;
|
||||||
|
import com.volmit.iris.engine.safeguard.ServerBoot;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.exceptions.IrisException;
|
import com.volmit.iris.util.exceptions.IrisException;
|
||||||
@@ -85,10 +87,15 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.lang.management.OperatingSystemMXBean;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
|
||||||
|
import static com.volmit.iris.engine.safeguard.ServerBoot.passedserversoftware;
|
||||||
|
|
||||||
@SuppressWarnings("CanBeFinal")
|
@SuppressWarnings("CanBeFinal")
|
||||||
public class Iris extends VolmitPlugin implements Listener {
|
public class Iris extends VolmitPlugin implements Listener {
|
||||||
public static final String OVERWORLD_TAG = "3620";
|
public static final String OVERWORLD_TAG = "3620";
|
||||||
@@ -308,6 +315,9 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
public static void info(String format, Object... args) {
|
public static void info(String format, Object... args) {
|
||||||
msg(C.WHITE + String.format(format, args));
|
msg(C.WHITE + String.format(format, args));
|
||||||
}
|
}
|
||||||
|
public static void safeguard(String format, Object... args) {
|
||||||
|
msg(C.RESET + String.format(format, args));
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void later(NastyRunnable object) {
|
public static void later(NastyRunnable object) {
|
||||||
@@ -455,6 +465,9 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
J.s(this::setupPapi);
|
J.s(this::setupPapi);
|
||||||
J.a(ServerConfigurator::configure, 20);
|
J.a(ServerConfigurator::configure, 20);
|
||||||
splash();
|
splash();
|
||||||
|
ServerBoot.unstablemode();
|
||||||
|
ServerBoot.supportedserversoftware();
|
||||||
|
ServerBoot.incompatiblepluginset();
|
||||||
autoStartStudio();
|
autoStartStudio();
|
||||||
checkForBukkitWorlds();
|
checkForBukkitWorlds();
|
||||||
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
|
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
|
||||||
@@ -542,6 +555,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
enable();
|
enable();
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
|
IrisSafeguard.IrisSafeguardSystem();
|
||||||
setupChecks();
|
setupChecks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,12 +728,10 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @NoArgsConstructor
|
|
||||||
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()};
|
||||||
};
|
String[] splashstable = {
|
||||||
String[] splash = {
|
|
||||||
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 + " .(((()))). ",
|
||||||
padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.IRIS + " .((((((())))))). ",
|
padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.IRIS + " .((((((())))))). ",
|
||||||
@@ -732,8 +744,37 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
padd + C.GRAY + "" + C.IRIS + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@",
|
padd + C.GRAY + "" + C.IRIS + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@",
|
||||||
padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
|
padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
|
||||||
};
|
};
|
||||||
//@done
|
|
||||||
Iris.info("Server type & version: " + Bukkit.getVersion());
|
String[] splashunstable = {
|
||||||
|
padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@",
|
||||||
|
padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.RED + " .(((()))). ",
|
||||||
|
padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.RED + " .((((((())))))). ",
|
||||||
|
padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + C.RED + " ((((((((())))))))) " + C.GRAY + " @",
|
||||||
|
padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + C.RED + " ((((((((-))))))))) " + C.GRAY + " @@",
|
||||||
|
padd + C.GRAY + "@@@&&" + C.RED + " ((((((({ })))))))) " + C.GRAY + " &&@@@",
|
||||||
|
padd + C.GRAY + "@@" + C.RED + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@",
|
||||||
|
padd + C.GRAY + "@" + C.RED + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@",
|
||||||
|
padd + C.GRAY + "" + C.RED + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@",
|
||||||
|
padd + C.GRAY + "" + C.RED + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@",
|
||||||
|
padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
|
||||||
|
};
|
||||||
|
String[] splash = unstablemode ? splashunstable : splashstable; // Choose the appropriate splash array based on unstablemode
|
||||||
|
|
||||||
|
|
||||||
|
long maxMemory = Runtime.getRuntime().maxMemory() / (1024 * 1024);
|
||||||
|
OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
|
||||||
|
String osArch = osBean.getArch();
|
||||||
|
String osName = osBean.getName();
|
||||||
|
|
||||||
|
if (!passedserversoftware) {
|
||||||
|
Iris.info("Server type & version: " + C.RED + Bukkit.getVersion());
|
||||||
|
} else { Iris.info("Server type & version: " + Bukkit.getVersion()); }
|
||||||
|
|
||||||
|
Iris.info("Server OS: " + osName + " (" + osArch + ")");
|
||||||
|
Iris.info("Process Memory: " + maxMemory + " MB");
|
||||||
|
if (maxMemory < 5999) {
|
||||||
|
Iris.warn("6GB+ Ram is recommended");
|
||||||
|
}
|
||||||
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
|
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
|
||||||
Iris.info("Java version: " + getJavaVersion());
|
Iris.info("Java version: " + getJavaVersion());
|
||||||
Iris.info("Custom Biomes: " + INMS.get().countCustomBiomes());
|
Iris.info("Custom Biomes: " + INMS.get().countCustomBiomes());
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.volmit.iris.core.tools.IrisToolbelt;
|
|||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
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.ServerBoot;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.decree.DecreeContext;
|
import com.volmit.iris.util.decree.DecreeContext;
|
||||||
import com.volmit.iris.util.decree.DecreeExecutor;
|
import com.volmit.iris.util.decree.DecreeExecutor;
|
||||||
@@ -47,6 +48,8 @@ import java.io.IOException;
|
|||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import static com.volmit.iris.engine.safeguard.ServerBoot.multiverse;
|
||||||
|
|
||||||
@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command")
|
@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command")
|
||||||
public class CommandIris implements DecreeExecutor {
|
public class CommandIris implements DecreeExecutor {
|
||||||
private CommandStudio studio;
|
private CommandStudio studio;
|
||||||
@@ -67,6 +70,14 @@ 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){
|
||||||
|
sender().sendMessage(C.RED + "Your server has a incompatibility that may corrupt all worlds on the server if not handled properly.");
|
||||||
|
sender().sendMessage(C.RED + "its heavily advised for you to take action. see log for full detail");
|
||||||
|
Iris.safeguard(C.RED + "----------------------------------------------------------------");
|
||||||
|
Iris.safeguard(C.RED + "Command ran: /iris create");
|
||||||
|
ServerBoot.incompatiblepluginset();
|
||||||
|
Iris.safeguard(C.RED + "----------------------------------------------------------------");
|
||||||
|
}
|
||||||
if (name.equals("iris")) {
|
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 + "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?");
|
sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?");
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.volmit.iris.engine.safeguard;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
|
||||||
|
public class IrisSafeguard {
|
||||||
|
// more planned and WIP
|
||||||
|
public static boolean unstablemode = false;
|
||||||
|
public static void IrisSafeguardSystem() {
|
||||||
|
Iris.info("Enabled Iris SafeGuard");
|
||||||
|
ServerBoot.bootcheck();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.volmit.iris.engine.safeguard;
|
||||||
|
|
||||||
|
public class SafeguardUtils {
|
||||||
|
public static void resetdatapacks(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package com.volmit.iris.engine.safeguard;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.util.format.C;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import static com.volmit.iris.Iris.instance;
|
||||||
|
import static com.volmit.iris.engine.safeguard.IrisSafeguard.unstablemode;
|
||||||
|
|
||||||
|
public class ServerBoot {
|
||||||
|
public static boolean multiverse = false;
|
||||||
|
public static boolean dynmap = false;
|
||||||
|
public static boolean terraform = false;
|
||||||
|
public static boolean stratos = false;
|
||||||
|
|
||||||
|
protected static boolean safeguardPassed;
|
||||||
|
public static boolean passedserversoftware = true;
|
||||||
|
protected static byte count;
|
||||||
|
|
||||||
|
public static void bootcheck() {
|
||||||
|
Iris.info("Checking for possible conflicts..");
|
||||||
|
org.bukkit.plugin.PluginManager pluginManager = Bukkit.getPluginManager();
|
||||||
|
Plugin[] plugins = pluginManager.getPlugins();
|
||||||
|
|
||||||
|
StringBuilder pluginList = new StringBuilder("Plugin list: ");
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
for (Plugin plugin : plugins) {
|
||||||
|
String pluginName = plugin.getName();
|
||||||
|
if (pluginName.equalsIgnoreCase("Multiverse-Core")) {
|
||||||
|
multiverse = true;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if (pluginName.equalsIgnoreCase("Dynmap")) {
|
||||||
|
dynmap = true;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if (pluginName.equalsIgnoreCase("TerraformGenerator")) {
|
||||||
|
terraform = true;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if (pluginName.equalsIgnoreCase("Stratos")) {
|
||||||
|
stratos = true;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
pluginList.append(pluginName).append(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
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"))
|
||||||
|
{
|
||||||
|
unstablemode = true;
|
||||||
|
passedserversoftware = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
safeguardPassed = (count == 0);
|
||||||
|
if(!safeguardPassed){
|
||||||
|
unstablemode = true;
|
||||||
|
}
|
||||||
|
if (unstablemode){
|
||||||
|
Iris.safeguard("Unstable mode has been activated.");
|
||||||
|
}
|
||||||
|
Iris.safeguard(pluginList.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void unstablemode(){
|
||||||
|
if (unstablemode) {
|
||||||
|
Iris.safeguard(C.DARK_RED + "Iris is running in Unstable Mode");
|
||||||
|
} else {
|
||||||
|
Iris.safeguard(C.BLUE + "Iris is running Stable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void supportedserversoftware(){
|
||||||
|
if (!passedserversoftware) {
|
||||||
|
Iris.safeguard(C.DARK_RED + "Server is running unsupported server software");
|
||||||
|
Iris.safeguard(C.RED + "Supported: Purpur, Pufferfish, Paper, Spigot, Bukkit");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void incompatiblepluginset(){
|
||||||
|
|
||||||
|
if (safeguardPassed) {
|
||||||
|
Iris.safeguard(C.BLUE + "0 Conflicts found");
|
||||||
|
} else {
|
||||||
|
Iris.safeguard(C.DARK_RED + "" + count + " Conflicts found");
|
||||||
|
unstablemode = true;
|
||||||
|
|
||||||
|
if (multiverse) {
|
||||||
|
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 (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 or LiveAtlas.");
|
||||||
|
}
|
||||||
|
if (terraform || stratos) {
|
||||||
|
Iris.safeguard(C.YELLOW + "Terraform Generator / Stratos");
|
||||||
|
Iris.safeguard(C.YELLOW + "- Iris is not compatible with other worldgen plugins.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user