mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-03 08:26:11 +00:00
Merge pull request #1038 from RePixelatedMC/repixelatedmc
Repixelatedmc
This commit is contained in:
commit
79e198d441
@ -41,6 +41,7 @@ registerCustomOutputTask('Coco', 'D://mcsm/plugins')
|
|||||||
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
|
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
|
||||||
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.4/plugins')
|
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19.4/plugins')
|
||||||
registerCustomOutputTask('CrazyDev22', 'C://Users/Julian/Desktop/server/plugins')
|
registerCustomOutputTask('CrazyDev22', 'C://Users/Julian/Desktop/server/plugins')
|
||||||
|
registerCustomOutputTask('Pixel', 'C://Users/repix/Iris Dimension Engine/1.20.1 - Iris Coding/plugins')
|
||||||
// ========================== UNIX ==============================
|
// ========================== UNIX ==============================
|
||||||
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
|
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
|
||||||
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
|
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"flat IrisDimensions/flat",
|
"flat IrisDimensions/flat",
|
||||||
"redstone IrisDimensions/redstone",
|
"redstone IrisDimensions/redstone",
|
||||||
"mars IrisDimensions/mars",
|
"mars IrisDimensions/mars",
|
||||||
"example IrisDimensions/example"
|
"example IrisDimensions/example",
|
||||||
"newhorizons IrisDimensions/newhorizons",
|
"newhorizons IrisDimensions/newhorizons",
|
||||||
"theend IrisDimensions/theend"
|
"theend IrisDimensions/theend"
|
||||||
]
|
]
|
||||||
|
@ -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 = "3700";
|
public static final String OVERWORLD_TAG = "3700";
|
||||||
@ -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.printincompatiblepluginWarnings();
|
||||||
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());
|
||||||
|
@ -21,10 +21,12 @@ package com.volmit.iris.core.commands;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
|
import com.volmit.iris.core.tools.IrisBenchmarking;
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
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;
|
||||||
@ -46,10 +48,12 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
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.core.tools.IrisBenchmarking.inProgress;
|
||||||
|
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;
|
||||||
@ -60,6 +64,7 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
private CommandWhat what;
|
private CommandWhat what;
|
||||||
private CommandEdit edit;
|
private CommandEdit edit;
|
||||||
private CommandFind find;
|
private CommandFind find;
|
||||||
|
private CommandWorldManager manager;
|
||||||
|
|
||||||
@Decree(description = "Create a new world", aliases = {"+", "c"})
|
@Decree(description = "Create a new world", aliases = {"+", "c"})
|
||||||
public void create(
|
public void create(
|
||||||
@ -70,6 +75,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 an incompatibility that may corrupt all worlds on the server if not handled properly.");
|
||||||
|
sender().sendMessage(C.RED + "it is strongly advised for you to take action. see log for full detail");
|
||||||
|
Iris.safeguard(C.RED + "----------------------------------------------------------------");
|
||||||
|
Iris.safeguard(C.RED + "Command ran: /iris create");
|
||||||
|
ServerBoot.printincompatiblepluginWarnings();
|
||||||
|
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?");
|
||||||
@ -99,37 +112,6 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
sender().sendMessage(C.GREEN + "Successfully created your world!");
|
sender().sendMessage(C.GREEN + "Successfully created your world!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Decree(description = "Remove an Iris world", aliases = {"del", "rm"}, sync = true)
|
|
||||||
public void remove(
|
|
||||||
@Param(description = "The world to remove")
|
|
||||||
World world,
|
|
||||||
@Param(description = "Whether to also remove the folder (if set to false, just does not load the world)", defaultValue = "true")
|
|
||||||
boolean delete
|
|
||||||
) {
|
|
||||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
|
||||||
sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", Bukkit.getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sender().sendMessage(C.GREEN + "Removing world: " + world.getName());
|
|
||||||
try {
|
|
||||||
if (IrisToolbelt.removeWorld(world)) {
|
|
||||||
sender().sendMessage(C.GREEN + "Successfully removed " + world.getName() + " from bukkit.yml");
|
|
||||||
} else {
|
|
||||||
sender().sendMessage(C.YELLOW + "Looks like the world was already removed from bukkit.yml");
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
sender().sendMessage(C.RED + "Failed to save bukkit.yml because of " + e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
IrisToolbelt.evacuate(world, "Deleting world");
|
|
||||||
Bukkit.unloadWorld(world, false);
|
|
||||||
if (delete && world.getWorldFolder().delete()) {
|
|
||||||
sender().sendMessage(C.GREEN + "Successfully removed world folder");
|
|
||||||
} else {
|
|
||||||
sender().sendMessage(C.RED + "Failed to remove world folder");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Decree(description = "Teleport to another world", aliases = {"tp"}, sync = true)
|
@Decree(description = "Teleport to another world", aliases = {"tp"}, sync = true)
|
||||||
public void teleport(
|
public void teleport(
|
||||||
@Param(description = "World to teleport to")
|
@Param(description = "World to teleport to")
|
||||||
@ -159,6 +141,14 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
public void version() {
|
public void version() {
|
||||||
sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
|
sender().sendMessage(C.GREEN + "Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
|
||||||
}
|
}
|
||||||
|
@Decree(description = "Benchmark your server", origin = DecreeOrigin.CONSOLE)
|
||||||
|
public void benchmark() throws InterruptedException {
|
||||||
|
if(!inProgress) {
|
||||||
|
IrisBenchmarking.runBenchmark();
|
||||||
|
} else {
|
||||||
|
Iris.info(C.RED + "Benchmark already is in progress.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Decree(description = "Print world height information", origin = DecreeOrigin.PLAYER)
|
@Decree(description = "Print world height information", origin = DecreeOrigin.PLAYER)
|
||||||
public void height() {
|
public void height() {
|
||||||
|
@ -0,0 +1,295 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2022 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.core.commands;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisSettings;
|
||||||
|
import com.volmit.iris.core.loader.IrisData;
|
||||||
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
|
import com.volmit.iris.engine.object.IrisWorld;
|
||||||
|
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
||||||
|
import com.volmit.iris.engine.platform.DummyChunkGenerator;
|
||||||
|
import com.volmit.iris.util.decree.DecreeExecutor;
|
||||||
|
import com.volmit.iris.util.decree.DecreeOrigin;
|
||||||
|
import com.volmit.iris.util.decree.annotations.Decree;
|
||||||
|
import com.volmit.iris.util.decree.annotations.Param;
|
||||||
|
import com.volmit.iris.util.format.C;
|
||||||
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Difficulty;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.volmit.iris.Iris.service;
|
||||||
|
|
||||||
|
// Not done yet but works
|
||||||
|
@Decree(name = "worldmanager", origin = DecreeOrigin.PLAYER, description = "Iris World Manager", aliases = {"manager"})
|
||||||
|
public class CommandWorldManager implements DecreeExecutor {
|
||||||
|
public Difficulty difficulty = Difficulty.NORMAL;
|
||||||
|
String WorldToLoad;
|
||||||
|
String WorldEngine;
|
||||||
|
String worldNameToCheck = "YourWorldName";
|
||||||
|
VolmitSender sender = Iris.getSender();
|
||||||
|
@Decree(description = "Unload an Iris World", origin = DecreeOrigin.PLAYER, sync = true)
|
||||||
|
public void unloadWorld(
|
||||||
|
@Param(description = "The world to unload")
|
||||||
|
World world
|
||||||
|
) {
|
||||||
|
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||||
|
sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", Bukkit.getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sender().sendMessage(C.GREEN + "Unloading world: " + world.getName());
|
||||||
|
try {
|
||||||
|
IrisToolbelt.evacuate(world);
|
||||||
|
Bukkit.unloadWorld(world, false);
|
||||||
|
sender().sendMessage(C.GREEN + "World unloaded successfully.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender().sendMessage(C.RED + "Failed to unload the world: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Decree(description = "Load an Iris World", origin = DecreeOrigin.PLAYER, sync = true, aliases = {"import"})
|
||||||
|
public void loadWorld(
|
||||||
|
@Param(description = "The name of the world to load")
|
||||||
|
String world
|
||||||
|
) {
|
||||||
|
World worldloaded = Bukkit.getWorld(world);
|
||||||
|
worldNameToCheck = world;
|
||||||
|
boolean worldExists = doesWorldExist(worldNameToCheck);
|
||||||
|
WorldEngine = world;
|
||||||
|
|
||||||
|
if (!worldExists) {
|
||||||
|
sender().sendMessage(C.YELLOW + world + " Doesnt exist on the server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WorldToLoad = world;
|
||||||
|
File BUKKIT_YML = new File("bukkit.yml");
|
||||||
|
String pathtodim = world + "\\iris\\pack\\dimensions\\";
|
||||||
|
File directory = new File(Bukkit.getWorldContainer(), pathtodim);
|
||||||
|
|
||||||
|
String dimension = null;
|
||||||
|
if (directory.exists() && directory.isDirectory()) {
|
||||||
|
File[] files = directory.listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
for (File file : files) {
|
||||||
|
if (file.isFile()) {
|
||||||
|
String fileName = file.getName();
|
||||||
|
if (fileName.endsWith(".json")) {
|
||||||
|
dimension = fileName.substring(0, fileName.length() - 5);
|
||||||
|
sender().sendMessage(C.BLUE + "Generator: " + dimension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender().sendMessage(C.GOLD + world + " is not an iris world.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sender().sendMessage(C.GREEN + "Loading world: " + world);
|
||||||
|
|
||||||
|
YamlConfiguration yml = YamlConfiguration.loadConfiguration(BUKKIT_YML);
|
||||||
|
String gen = "Iris:" + dimension;
|
||||||
|
ConfigurationSection section = yml.contains("worlds") ? yml.getConfigurationSection("worlds") : yml.createSection("worlds");
|
||||||
|
if (!section.contains(world)) {
|
||||||
|
section.createSection(world).set("generator", gen);
|
||||||
|
try {
|
||||||
|
yml.save(BUKKIT_YML);
|
||||||
|
Iris.info("Registered \"" + world + "\" in bukkit.yml");
|
||||||
|
} catch (IOException e) {
|
||||||
|
Iris.error("Failed to update bukkit.yml!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkForBukkitWorlds();
|
||||||
|
sender().sendMessage(C.GREEN + world + " loaded successfully.");
|
||||||
|
}
|
||||||
|
@Decree(description = "Evacuate an iris world", origin = DecreeOrigin.PLAYER, sync = true)
|
||||||
|
public void evacuate(
|
||||||
|
@Param(description = "Evacuate the world")
|
||||||
|
World world
|
||||||
|
) {
|
||||||
|
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||||
|
sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", Bukkit.getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sender().sendMessage(C.GREEN + "Evacuating world" + world.getName());
|
||||||
|
IrisToolbelt.evacuate(world);
|
||||||
|
}
|
||||||
|
@Decree(description = "Remove an Iris world", aliases = {"del", "rm", "delete"}, sync = true)
|
||||||
|
public void remove(
|
||||||
|
@Param(description = "The world to remove")
|
||||||
|
World world,
|
||||||
|
@Param(description = "Whether to also remove the folder (if set to false, just does not load the world)", defaultValue = "true")
|
||||||
|
boolean delete
|
||||||
|
) {
|
||||||
|
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||||
|
sender().sendMessage(C.RED + "This is not an Iris world. Iris worlds: " + String.join(", ", Bukkit.getServer().getWorlds().stream().filter(IrisToolbelt::isIrisWorld).map(World::getName).toList()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sender().sendMessage(C.GREEN + "Removing world: " + world.getName());
|
||||||
|
try {
|
||||||
|
if (IrisToolbelt.removeWorld(world)) {
|
||||||
|
sender().sendMessage(C.GREEN + "Successfully removed " + world.getName() + " from bukkit.yml");
|
||||||
|
} else {
|
||||||
|
sender().sendMessage(C.YELLOW + "Looks like the world was already removed from bukkit.yml");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
sender().sendMessage(C.RED + "Failed to save bukkit.yml because of " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
IrisToolbelt.evacuate(world, "Deleting world");
|
||||||
|
Bukkit.unloadWorld(world, false);
|
||||||
|
if (delete) {
|
||||||
|
if (deleteDirectory(world.getWorldFolder())) {
|
||||||
|
sender().sendMessage(C.GREEN + "Successfully removed world folder");
|
||||||
|
} else {
|
||||||
|
sender().sendMessage(C.RED + "Failed to remove world folder");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public static boolean deleteDirectory(File dir) {
|
||||||
|
if (dir.isDirectory()) {
|
||||||
|
File[] children = dir.listFiles();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
boolean success = deleteDirectory(children[i]);
|
||||||
|
if (!success) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dir.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean doesWorldExist(String worldName) {
|
||||||
|
File worldContainer = Bukkit.getWorldContainer();
|
||||||
|
File worldDirectory = new File(worldContainer, worldName);
|
||||||
|
return worldDirectory.exists() && worldDirectory.isDirectory();
|
||||||
|
}
|
||||||
|
private void checkForBukkitWorlds() {
|
||||||
|
FileConfiguration fc = new YamlConfiguration();
|
||||||
|
try {
|
||||||
|
fc.load(new File("bukkit.yml"));
|
||||||
|
ConfigurationSection section = fc.getConfigurationSection("worlds");
|
||||||
|
if (section == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> worldsToLoad = Collections.singletonList(WorldToLoad);
|
||||||
|
|
||||||
|
for (String s : section.getKeys(false)) {
|
||||||
|
if (!worldsToLoad.contains(s)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ConfigurationSection entry = section.getConfigurationSection(s);
|
||||||
|
if (!entry.contains("generator", true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String generator = entry.getString("generator");
|
||||||
|
if (generator.startsWith("Iris:")) {
|
||||||
|
generator = generator.split("\\Q:\\E")[1];
|
||||||
|
} else if (generator.equalsIgnoreCase("Iris")) {
|
||||||
|
generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Iris.info("2 World: %s | Generator: %s", s, generator);
|
||||||
|
if (Bukkit.getWorlds().stream().anyMatch(w -> w.getName().equals(s))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Iris.info(C.LIGHT_PURPLE + "Preparing Spawn for " + s + "' using Iris:" + generator + "...");
|
||||||
|
new WorldCreator(s)
|
||||||
|
.generator(getDefaultWorldGenerator(s, generator))
|
||||||
|
.environment(IrisData.loadAnyDimension(generator).getEnvironment())
|
||||||
|
.createWorld();
|
||||||
|
Iris.info(C.LIGHT_PURPLE + "Loaded " + s + "!");
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||||
|
Iris.debug("Default World Generator Called for " + worldName + " using ID: " + id);
|
||||||
|
if (worldName.equals("test")) {
|
||||||
|
try {
|
||||||
|
throw new RuntimeException();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Iris.info(e.getStackTrace()[1].getClassName());
|
||||||
|
if (e.getStackTrace()[1].getClassName().contains("com.onarandombox.MultiverseCore")) {
|
||||||
|
Iris.debug("MVC Test detected, Quick! Send them the dummy!");
|
||||||
|
return new DummyChunkGenerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IrisDimension dim;
|
||||||
|
if (id == null || id.isEmpty()) {
|
||||||
|
dim = IrisData.loadAnyDimension(IrisSettings.get().getGenerator().getDefaultWorldType());
|
||||||
|
} else {
|
||||||
|
dim = IrisData.loadAnyDimension(id);
|
||||||
|
}
|
||||||
|
Iris.debug("Generator ID: " + id + " requested by bukkit/plugin");
|
||||||
|
|
||||||
|
if (dim == null) {
|
||||||
|
Iris.warn("Unable to find dimension type " + id + " Looking for online packs...");
|
||||||
|
|
||||||
|
service(StudioSVC.class).downloadSearch(new VolmitSender(Bukkit.getConsoleSender()), id, true);
|
||||||
|
dim = IrisData.loadAnyDimension(id);
|
||||||
|
|
||||||
|
if (dim == null) {
|
||||||
|
throw new RuntimeException("Can't find dimension " + id + "!");
|
||||||
|
} else {
|
||||||
|
Iris.info("Resolved missing dimension, proceeding with generation.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Iris.debug("Assuming IrisDimension: " + dim.getName());
|
||||||
|
IrisWorld w = IrisWorld.builder()
|
||||||
|
.name(worldName)
|
||||||
|
.seed(1337)
|
||||||
|
.environment(dim.getEnvironment())
|
||||||
|
.worldFolder(new File(Bukkit.getWorldContainer(), worldName))
|
||||||
|
.minHeight(dim.getMinHeight())
|
||||||
|
.maxHeight(dim.getMaxHeight())
|
||||||
|
.build();
|
||||||
|
Iris.debug("Generator Config: " + w.toString());
|
||||||
|
File ff = new File(w.worldFolder(), "iris/pack");
|
||||||
|
if (!ff.exists() || ff.listFiles().length == 0) {
|
||||||
|
ff.mkdirs();
|
||||||
|
service(StudioSVC.class).installIntoWorld(sender, dim.getLoadKey(), ff.getParentFile());
|
||||||
|
}
|
||||||
|
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
650
src/main/java/com/volmit/iris/core/tools/IrisBenchmarking.java
Normal file
650
src/main/java/com/volmit/iris/core/tools/IrisBenchmarking.java
Normal file
@ -0,0 +1,650 @@
|
|||||||
|
package com.volmit.iris.core.tools;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.util.format.C;
|
||||||
|
import oshi.SystemInfo;
|
||||||
|
import oshi.hardware.CentralProcessor;
|
||||||
|
import oshi.hardware.GlobalMemory;
|
||||||
|
import oshi.hardware.HWDiskStore;
|
||||||
|
import oshi.software.os.OperatingSystem;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.lang.management.MemoryMXBean;
|
||||||
|
import java.lang.management.MemoryUsage;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
import java.util.zip.Deflater;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import static com.google.common.math.LongMath.isPrime;
|
||||||
|
|
||||||
|
public class IrisBenchmarking {
|
||||||
|
static String ServerOS;
|
||||||
|
static String filePath = "benchmark.dat";
|
||||||
|
private static long startTime;
|
||||||
|
static double avgWriteSpeedMBps;
|
||||||
|
static double avgReadSpeedMBps;
|
||||||
|
static double highestWriteSpeedMBps;
|
||||||
|
static double highestReadSpeedMBps;
|
||||||
|
static double lowestWriteSpeedMBps;
|
||||||
|
static double lowestReadSpeedMBps;
|
||||||
|
static double calculateIntegerMath;
|
||||||
|
static double calculateFloatingPoint;
|
||||||
|
static double calculatePrimeNumbers;
|
||||||
|
static double calculateStringSorting;
|
||||||
|
static double calculateDataEncryption;
|
||||||
|
static double calculateDataCompression;
|
||||||
|
static String currentRunning = "None";
|
||||||
|
static int BenchmarksCompleted = 0;
|
||||||
|
static int BenchmarksTotal = 7;
|
||||||
|
static int totalTasks = 10;
|
||||||
|
static int currentTasks = 0;
|
||||||
|
static double WindowsCPUCompression;
|
||||||
|
static double WindowsCPUEncryption;
|
||||||
|
static double WindowsCPUCSHA1;
|
||||||
|
static double elapsedTimeNs;
|
||||||
|
static boolean Winsat = false;
|
||||||
|
static boolean WindowsDiskSpeed = false;
|
||||||
|
public static boolean inProgress = false;
|
||||||
|
// Good enough for now. . .
|
||||||
|
|
||||||
|
public static void runBenchmark() throws InterruptedException {
|
||||||
|
inProgress = true;
|
||||||
|
getServerOS();
|
||||||
|
deleteTestFile(filePath);
|
||||||
|
AtomicReference<Double> doneCalculateDiskSpeed = new AtomicReference<>((double) 0);
|
||||||
|
startBenchmarkTimer();
|
||||||
|
Iris.info("Benchmark Started!");
|
||||||
|
Iris.warn("Although it may seem momentarily paused, it's actively processing.");
|
||||||
|
BenchmarksCompleted = 0;
|
||||||
|
|
||||||
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||||
|
currentRunning = "calculateDiskSpeed";
|
||||||
|
progressBar();
|
||||||
|
if (ServerOS.contains("Windows") && isRunningAsAdmin()) {
|
||||||
|
WindowsDiskSpeed = true;
|
||||||
|
WindowsDiskSpeedTest();
|
||||||
|
} else {
|
||||||
|
warningFallback();
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
doneCalculateDiskSpeed.set(roundToTwoDecimalPlaces(calculateDiskSpeed()));
|
||||||
|
BenchmarksCompleted++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}).thenRun(() -> {
|
||||||
|
currentRunning = "WindowsCpuSpeedTest";
|
||||||
|
progressBar();
|
||||||
|
if (ServerOS.contains("Windows") && isRunningAsAdmin()) {
|
||||||
|
Winsat = true;
|
||||||
|
WindowsCpuSpeedTest();
|
||||||
|
} else {
|
||||||
|
Iris.info("Skipping:" + C.BLUE + " Windows System Assessment Tool Benchmarks");
|
||||||
|
if (!ServerOS.contains("Windows")) {
|
||||||
|
Iris.info("Required Software:" + C.BLUE + " Windows");
|
||||||
|
BenchmarksTotal = 6;
|
||||||
|
}
|
||||||
|
if (!isRunningAsAdmin()) {
|
||||||
|
Iris.info(C.RED + "ERROR: " + C.DARK_RED + "Elevated privileges missing");
|
||||||
|
BenchmarksTotal = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}).thenRun(() -> {
|
||||||
|
currentRunning = "calculateIntegerMath";
|
||||||
|
progressBar();
|
||||||
|
calculateIntegerMath = roundToTwoDecimalPlaces(calculateIntegerMath());
|
||||||
|
BenchmarksCompleted++;
|
||||||
|
}).thenRun(() -> {
|
||||||
|
currentRunning = "calculateFloatingPoint";
|
||||||
|
progressBar();
|
||||||
|
calculateFloatingPoint = roundToTwoDecimalPlaces(calculateFloatingPoint());
|
||||||
|
BenchmarksCompleted++;
|
||||||
|
}).thenRun(() -> {
|
||||||
|
currentRunning = "calculateStringSorting";
|
||||||
|
progressBar();
|
||||||
|
calculateStringSorting = roundToTwoDecimalPlaces(calculateStringSorting());
|
||||||
|
BenchmarksCompleted++;
|
||||||
|
}).thenRun(() -> {
|
||||||
|
currentRunning = "calculatePrimeNumbers";
|
||||||
|
progressBar();
|
||||||
|
calculatePrimeNumbers = roundToTwoDecimalPlaces(calculatePrimeNumbers());
|
||||||
|
BenchmarksCompleted++;
|
||||||
|
}).thenRun(() -> {
|
||||||
|
currentRunning = "calculateDataEncryption";
|
||||||
|
progressBar();
|
||||||
|
calculateDataEncryption = roundToTwoDecimalPlaces(calculateDataEncryption());
|
||||||
|
BenchmarksCompleted++;
|
||||||
|
}).thenRun(() -> {
|
||||||
|
currentRunning = "calculateDataCompression";
|
||||||
|
progressBar();
|
||||||
|
calculateDataCompression = roundToTwoDecimalPlaces(calculateDataCompression());
|
||||||
|
BenchmarksCompleted++;
|
||||||
|
}).thenRun(() -> {
|
||||||
|
elapsedTimeNs = stopBenchmarkTimer();
|
||||||
|
results();
|
||||||
|
inProgress = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
future.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void progressBar() {
|
||||||
|
Iris.info("-----------------------------------------------------");
|
||||||
|
Iris.info("Currently Running: " + C.BLUE + currentRunning);
|
||||||
|
// Iris.info("Tasks: " + "Current Tasks: " + C.BLUE + currentTasks + C.WHITE + " / " + "Total Tasks: " + C.BLUE + totalTasks);
|
||||||
|
Iris.info("Benchmarks Completed: " + C.BLUE + BenchmarksCompleted + C.WHITE + " / " + "Total: " + C.BLUE + BenchmarksTotal);
|
||||||
|
Iris.info("-----------------------------------------------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void results() {
|
||||||
|
|
||||||
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
GlobalMemory globalMemory = systemInfo.getHardware().getMemory();
|
||||||
|
long totalMemoryMB = globalMemory.getTotal() / (1024 * 1024);
|
||||||
|
long availableMemoryMB = globalMemory.getAvailable() / (1024 * 1024);
|
||||||
|
long totalPageSize = globalMemory.getPageSize() / (1024 * 1024);
|
||||||
|
long usedMemoryMB = totalMemoryMB - availableMemoryMB;
|
||||||
|
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
|
||||||
|
|
||||||
|
Iris.info("OS: " + ServerOS);
|
||||||
|
if (!isRunningAsAdmin() || !ServerOS.contains("Windows")) {
|
||||||
|
Iris.info(C.GOLD + "For the full results use Windows + Admin Rights..");
|
||||||
|
}
|
||||||
|
Iris.info("CPU Model: " + getCPUModel());
|
||||||
|
Iris.info("CPU Score: " + "WIP");
|
||||||
|
Iris.info("- Integer Math: " + calculateIntegerMath + " MOps/Sec");
|
||||||
|
Iris.info("- Floating Point Math: " + calculateFloatingPoint + " MOps/Sec");
|
||||||
|
Iris.info("- Find Prime Numbers: " + calculatePrimeNumbers + " Primes/Sec");
|
||||||
|
Iris.info("- Random String Sorting: " + calculateStringSorting + " Thousand Strings/Sec");
|
||||||
|
Iris.info("- Data Encryption: " + formatDouble(calculateDataEncryption) + " MBytes/Sec");
|
||||||
|
Iris.info("- Data Compression: " + formatDouble(calculateDataCompression) + " MBytes/Sec");
|
||||||
|
|
||||||
|
if (WindowsDiskSpeed) {
|
||||||
|
Iris.info("Disk Model: " + getDiskModel());
|
||||||
|
Iris.info(C.BLUE + "- Running with Windows System Assessment Tool");
|
||||||
|
Iris.info("- Sequential 64.0 Write: " + C.BLUE + formatDouble(avgWriteSpeedMBps) + " Mbps");
|
||||||
|
Iris.info("- Sequential 64.0 Read: " + C.BLUE + formatDouble(avgReadSpeedMBps) + " Mbps");
|
||||||
|
} else {
|
||||||
|
Iris.info("Disk Model: " + getDiskModel());
|
||||||
|
Iris.info(C.GREEN + "- Running in Native Mode");
|
||||||
|
Iris.info("- Average Write Speed: " + C.GREEN + formatDouble(avgWriteSpeedMBps) + " Mbps");
|
||||||
|
Iris.info("- Average Read Speed: " + C.GREEN + formatDouble(avgReadSpeedMBps) + " Mbps");
|
||||||
|
Iris.info("- Highest Write Speed: " + formatDouble(highestWriteSpeedMBps) + " Mbps");
|
||||||
|
Iris.info("- Highest Read Speed: " + formatDouble(highestReadSpeedMBps) + " Mbps");
|
||||||
|
Iris.info("- Lowest Write Speed: " + formatDouble(lowestWriteSpeedMBps) + " Mbps");
|
||||||
|
Iris.info("- Lowest Read Speed: " + formatDouble(lowestReadSpeedMBps) + " Mbps");
|
||||||
|
}
|
||||||
|
Iris.info("Ram Usage: ");
|
||||||
|
Iris.info("- Total Ram: " + totalMemoryMB + " MB");
|
||||||
|
Iris.info("- Used Ram: " + usedMemoryMB + " MB");
|
||||||
|
Iris.info("- Total Process Ram: " + C.BLUE + getMaxMemoryUsage() + " MB");
|
||||||
|
Iris.info("- Total Paging Size: " + totalPageSize + " MB");
|
||||||
|
if (Winsat) {
|
||||||
|
Iris.info(C.BLUE + "Windows System Assessment Tool: ");
|
||||||
|
Iris.info("- CPU LZW Compression:" + C.BLUE + formatDouble(WindowsCPUCompression) + " MB/s");
|
||||||
|
Iris.info("- CPU AES256 Encryption: " + C.BLUE + formatDouble(WindowsCPUEncryption) + " MB/s");
|
||||||
|
Iris.info("- CPU SHA1 Hash: " + C.BLUE + formatDouble(WindowsCPUCSHA1) + " MB/s");
|
||||||
|
Iris.info("Duration: " + roundToTwoDecimalPlaces(elapsedTimeNs) + " Seconds");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getMaxMemoryUsage() {
|
||||||
|
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
|
||||||
|
MemoryUsage heapMemoryUsage = memoryMXBean.getHeapMemoryUsage();
|
||||||
|
MemoryUsage nonHeapMemoryUsage = memoryMXBean.getNonHeapMemoryUsage();
|
||||||
|
long maxHeapMemory = heapMemoryUsage.getMax();
|
||||||
|
long maxNonHeapMemory = nonHeapMemoryUsage.getMax();
|
||||||
|
long maxMemoryUsageMB = (maxHeapMemory + maxNonHeapMemory) / (1024 * 1024);
|
||||||
|
return maxMemoryUsageMB;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getServerOS() {
|
||||||
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
OperatingSystem os = systemInfo.getOperatingSystem();
|
||||||
|
ServerOS = os.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isRunningAsAdmin() {
|
||||||
|
if (ServerOS.contains("Windows")) {
|
||||||
|
try {
|
||||||
|
Process process = Runtime.getRuntime().exec("winsat disk");
|
||||||
|
process.waitFor();
|
||||||
|
return process.exitValue() == 0;
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
// Hmm
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCPUModel() {
|
||||||
|
try {
|
||||||
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
CentralProcessor processor = systemInfo.getHardware().getProcessor();
|
||||||
|
String cpuModel = processor.getProcessorIdentifier().getName();
|
||||||
|
return cpuModel.isEmpty() ? "Unknown CPU Model" : cpuModel;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "Unknown CPU Model";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDiskModel() {
|
||||||
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
List<HWDiskStore> diskStores = systemInfo.getHardware().getDiskStores();
|
||||||
|
if (!diskStores.isEmpty()) {
|
||||||
|
HWDiskStore firstDisk = diskStores.get(0);
|
||||||
|
return firstDisk.getModel();
|
||||||
|
} else {
|
||||||
|
return "Unknown Disk Model";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warningFallback() {
|
||||||
|
Iris.info(C.RED + "Using the " + C.DARK_RED + "FALLBACK" + C.RED + " method due to compatibility issues. ");
|
||||||
|
Iris.info(C.RED + "Please note that this may result in less accurate results.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatDouble(double value) {
|
||||||
|
return String.format("%.2f", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void startBenchmarkTimer() {
|
||||||
|
startTime = System.nanoTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double stopBenchmarkTimer() {
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
return (endTime - startTime) / 1_000_000_000.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateIntegerMath() {
|
||||||
|
final int numIterations = 1_000_000_000;
|
||||||
|
final int numRuns = 30;
|
||||||
|
double totalMopsPerSec = 0;
|
||||||
|
|
||||||
|
for (int run = 0; run < numRuns; run++) {
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < numIterations; i++) {
|
||||||
|
result += i * 2;
|
||||||
|
result -= i / 2;
|
||||||
|
result ^= i;
|
||||||
|
result <<= 1;
|
||||||
|
result >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
double elapsedSeconds = (endTime - startTime) / 1_000_000_000.0;
|
||||||
|
double mopsPerSec = (numIterations / elapsedSeconds) / 1_000_000.0;
|
||||||
|
|
||||||
|
totalMopsPerSec += mopsPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
double averageMopsPerSec = totalMopsPerSec / numRuns;
|
||||||
|
return averageMopsPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateFloatingPoint() {
|
||||||
|
long numIterations = 85_000_000;
|
||||||
|
int numRuns = 30;
|
||||||
|
double totalMopsPerSec = 0;
|
||||||
|
for (int run = 0; run < numRuns; run++) {
|
||||||
|
double result = 0;
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
|
||||||
|
for (int i = 0; i < numIterations; i++) {
|
||||||
|
result += Math.sqrt(i) * Math.sin(i) / (i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
double elapsedSeconds = (endTime - startTime) / 1_000_000_000.0;
|
||||||
|
double mopsPerSec = (numIterations / elapsedSeconds) / 1_000_000.0;
|
||||||
|
|
||||||
|
totalMopsPerSec += mopsPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
double averageMopsPerSec = totalMopsPerSec / numRuns;
|
||||||
|
return averageMopsPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculatePrimeNumbers() {
|
||||||
|
int primeCount;
|
||||||
|
long numIterations = 1_000_000;
|
||||||
|
int numRuns = 30;
|
||||||
|
double totalMopsPerSec = 0;
|
||||||
|
|
||||||
|
for (int run = 0; run < numRuns; run++) {
|
||||||
|
primeCount = 0;
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
|
||||||
|
for (int num = 2; primeCount < numIterations; num++) {
|
||||||
|
if (isPrime(num)) {
|
||||||
|
primeCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
double elapsedSeconds = (endTime - startTime) / 1_000_000_000.0;
|
||||||
|
double mopsPerSec = (primeCount / elapsedSeconds) / 1_000_000.0;
|
||||||
|
|
||||||
|
totalMopsPerSec += mopsPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
double averageMopsPerSec = totalMopsPerSec / numRuns;
|
||||||
|
return averageMopsPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateStringSorting() {
|
||||||
|
int stringCount = 1_000_000;
|
||||||
|
int stringLength = 100;
|
||||||
|
int numRuns = 30;
|
||||||
|
double totalMopsPerSec = 0;
|
||||||
|
|
||||||
|
for (int run = 0; run < numRuns; run++) {
|
||||||
|
List<String> randomStrings = generateRandomStrings(stringCount, stringLength);
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
randomStrings.sort(String::compareTo);
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
|
||||||
|
double elapsedSeconds = (endTime - startTime) / 1_000_000_000.0;
|
||||||
|
double mopsPerSec = (stringCount / elapsedSeconds) / 1_000.0;
|
||||||
|
|
||||||
|
totalMopsPerSec += mopsPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
double averageMopsPerSec = totalMopsPerSec / numRuns;
|
||||||
|
return averageMopsPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double calculateDataEncryption() {
|
||||||
|
int dataSizeMB = 100;
|
||||||
|
byte[] dataToEncrypt = generateRandomData(dataSizeMB * 1024 * 1024);
|
||||||
|
int numRuns = 20;
|
||||||
|
double totalMBytesPerSec = 0;
|
||||||
|
|
||||||
|
for (int run = 0; run < numRuns; run++) {
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
byte[] encryptedData = performEncryption(dataToEncrypt, 1);
|
||||||
|
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
double elapsedSeconds = (endTime - startTime) / 1_000_000_000.0;
|
||||||
|
double mbytesPerSec = (dataToEncrypt.length / (1024 * 1024.0)) / elapsedSeconds;
|
||||||
|
|
||||||
|
totalMBytesPerSec += mbytesPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
double averageMBytesPerSec = totalMBytesPerSec / numRuns;
|
||||||
|
return averageMBytesPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] performEncryption(byte[] data, int numRuns) {
|
||||||
|
byte[] key = "MyEncryptionKey".getBytes();
|
||||||
|
byte[] result = Arrays.copyOf(data, data.length);
|
||||||
|
for (int run = 0; run < numRuns; run++) {
|
||||||
|
for (int i = 0; i < result.length; i++) {
|
||||||
|
result[i] ^= key[i % key.length];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double calculateDataCompression() {
|
||||||
|
int dataSizeMB = 500;
|
||||||
|
byte[] dataToCompress = generateRandomData(dataSizeMB * 1024 * 1024);
|
||||||
|
long startTime = System.nanoTime();
|
||||||
|
byte[] compressedData = performCompression(dataToCompress);
|
||||||
|
long endTime = System.nanoTime();
|
||||||
|
|
||||||
|
double elapsedSeconds = (endTime - startTime) / 1e9;
|
||||||
|
double mbytesPerSec = (compressedData.length / (1024.0 * 1024.0)) / elapsedSeconds;
|
||||||
|
|
||||||
|
return mbytesPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] performCompression(byte[] data) {
|
||||||
|
Deflater deflater = new Deflater();
|
||||||
|
deflater.setInput(data);
|
||||||
|
deflater.finish();
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
|
||||||
|
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
while (!deflater.finished()) {
|
||||||
|
int count = deflater.deflate(buffer);
|
||||||
|
outputStream.write(buffer, 0, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
deflater.end();
|
||||||
|
return outputStream.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> generateRandomStrings(int count, int length) {
|
||||||
|
SecureRandom random = new SecureRandom();
|
||||||
|
List<String> randomStrings = new ArrayList<>();
|
||||||
|
|
||||||
|
IntStream.range(0, count).forEach(i -> {
|
||||||
|
byte[] bytes = new byte[length];
|
||||||
|
random.nextBytes(bytes);
|
||||||
|
randomStrings.add(Base64.getEncoder().encodeToString(bytes));
|
||||||
|
});
|
||||||
|
return randomStrings;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] generateRandomData(int size) {
|
||||||
|
SecureRandom random = new SecureRandom();
|
||||||
|
byte[] data = new byte[size];
|
||||||
|
random.nextBytes(data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double roundToTwoDecimalPlaces(double value) {
|
||||||
|
return Double.parseDouble(String.format("%.2f", value));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double calculateCPUScore(long elapsedTimeNs) {
|
||||||
|
return 1.0 / (elapsedTimeNs / 1_000_000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double calculateDiskSpeed() {
|
||||||
|
int numRuns = 10;
|
||||||
|
int fileSizeMB = 1000;
|
||||||
|
|
||||||
|
double[] writeSpeeds = new double[numRuns];
|
||||||
|
double[] readSpeeds = new double[numRuns];
|
||||||
|
|
||||||
|
for (int run = 0; run < numRuns; run++) {
|
||||||
|
long writeStartTime = System.nanoTime();
|
||||||
|
deleteTestFile(filePath);
|
||||||
|
createTestFile(filePath, fileSizeMB);
|
||||||
|
long writeEndTime = System.nanoTime();
|
||||||
|
|
||||||
|
long readStartTime = System.nanoTime();
|
||||||
|
readTestFile(filePath);
|
||||||
|
long readEndTime = System.nanoTime();
|
||||||
|
|
||||||
|
double writeSpeed = calculateDiskSpeedMBps(fileSizeMB, writeStartTime, writeEndTime);
|
||||||
|
double readSpeed = calculateDiskSpeedMBps(fileSizeMB, readStartTime, readEndTime);
|
||||||
|
|
||||||
|
writeSpeeds[run] = writeSpeed;
|
||||||
|
readSpeeds[run] = readSpeed;
|
||||||
|
|
||||||
|
if (run == 0) {
|
||||||
|
lowestWriteSpeedMBps = writeSpeed;
|
||||||
|
highestWriteSpeedMBps = writeSpeed;
|
||||||
|
lowestReadSpeedMBps = readSpeed;
|
||||||
|
highestReadSpeedMBps = readSpeed;
|
||||||
|
} else {
|
||||||
|
if (writeSpeed < lowestWriteSpeedMBps) {
|
||||||
|
lowestWriteSpeedMBps = writeSpeed;
|
||||||
|
}
|
||||||
|
if (writeSpeed > highestWriteSpeedMBps) {
|
||||||
|
highestWriteSpeedMBps = writeSpeed;
|
||||||
|
}
|
||||||
|
if (readSpeed < lowestReadSpeedMBps) {
|
||||||
|
lowestReadSpeedMBps = readSpeed;
|
||||||
|
}
|
||||||
|
if (readSpeed > highestReadSpeedMBps) {
|
||||||
|
highestReadSpeedMBps = readSpeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
avgWriteSpeedMBps = calculateAverage(writeSpeeds);
|
||||||
|
avgReadSpeedMBps = calculateAverage(readSpeeds);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createTestFile(String filePath, int fileSizeMB) {
|
||||||
|
try {
|
||||||
|
File file = new File(filePath);
|
||||||
|
byte[] data = new byte[1024 * 1024];
|
||||||
|
Arrays.fill(data, (byte) 0);
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
for (int i = 0; i < fileSizeMB; i++) {
|
||||||
|
fos.write(data);
|
||||||
|
}
|
||||||
|
fos.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void readTestFile(String filePath) {
|
||||||
|
try {
|
||||||
|
File file = new File(filePath);
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
while (fis.read(buffer) != -1) {
|
||||||
|
}
|
||||||
|
fis.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void deleteTestFile(String filePath) {
|
||||||
|
File file = new File(filePath);
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double calculateDiskSpeedMBps(int fileSizeMB, long startTime, long endTime) {
|
||||||
|
double elapsedSeconds = (endTime - startTime) / 1_000_000_000.0;
|
||||||
|
double writeSpeed = (fileSizeMB / elapsedSeconds);
|
||||||
|
return writeSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double calculateAverage(double[] values) {
|
||||||
|
double sum = 0;
|
||||||
|
for (double value : values) {
|
||||||
|
sum += value;
|
||||||
|
}
|
||||||
|
return sum / values.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WindowsDiskSpeedTest() {
|
||||||
|
try {
|
||||||
|
String command = "winsat disk";
|
||||||
|
Process process = Runtime.getRuntime().exec(command);
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
Iris.debug(line);
|
||||||
|
|
||||||
|
if (line.contains("Disk Sequential 64.0 Read")) {
|
||||||
|
avgReadSpeedMBps = extractSpeed(line);
|
||||||
|
} else if (line.contains("Disk Sequential 64.0 Write")) {
|
||||||
|
avgWriteSpeedMBps = extractSpeed(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
process.waitFor();
|
||||||
|
process.destroy();
|
||||||
|
|
||||||
|
Iris.debug("Sequential Read Speed: " + avgReadSpeedMBps + " MB/s");
|
||||||
|
Iris.debug("Sequential Write Speed: " + avgWriteSpeedMBps + " MB/s");
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double extractSpeed(String line) {
|
||||||
|
String[] tokens = line.split("\\s+");
|
||||||
|
for (int i = 0; i < tokens.length; i++) {
|
||||||
|
if (tokens[i].endsWith("MB/s") && i > 0) {
|
||||||
|
try {
|
||||||
|
return Double.parseDouble(tokens[i - 1]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WindowsCpuSpeedTest() {
|
||||||
|
try {
|
||||||
|
String command = "winsat cpuformal";
|
||||||
|
Process process = Runtime.getRuntime().exec(command);
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
Iris.debug(line);
|
||||||
|
|
||||||
|
if (line.contains("CPU AES256 Encryption")) {
|
||||||
|
WindowsCPUEncryption = extractCpuInfo(line);
|
||||||
|
}
|
||||||
|
if (line.contains("CPU LZW Compression")) {
|
||||||
|
WindowsCPUCompression = extractCpuInfo(line);
|
||||||
|
}
|
||||||
|
if (line.contains("CPU SHA1 Hash")) {
|
||||||
|
WindowsCPUCSHA1 = extractCpuInfo(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
process.waitFor();
|
||||||
|
process.destroy();
|
||||||
|
|
||||||
|
Iris.debug("Winsat Encryption: " + WindowsCPUEncryption + " MB/s");
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double extractCpuInfo(String line) {
|
||||||
|
String[] tokens = line.split("\\s+");
|
||||||
|
for (int i = 0; i < tokens.length; i++) {
|
||||||
|
if (tokens[i].endsWith("MB/s") && i > 0) {
|
||||||
|
try {
|
||||||
|
return Double.parseDouble(tokens[i - 1]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo JMH BENCHMARKS
|
||||||
|
|
||||||
|
}
|
@ -525,7 +525,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
double newRotation = config.getRotation().getYAxis().getMin() + slopeRotationY;
|
double newRotation = config.getRotation().getYAxis().getMin() + slopeRotationY;
|
||||||
config.getRotation().setYAxis(new IrisAxisRotationClamp(true, false, newRotation, newRotation, 360));
|
config.getRotation().setYAxis(new IrisAxisRotationClamp(true, false, newRotation, newRotation, 90));
|
||||||
config.getRotation().setEnabled(true);
|
config.getRotation().setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,6 @@
|
|||||||
|
package com.volmit.iris.engine.safeguard;
|
||||||
|
public class SafeguardUtils {
|
||||||
|
public static void resetdatapacks(){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
114
src/main/java/com/volmit/iris/engine/safeguard/ServerBoot.java
Normal file
114
src/main/java/com/volmit/iris/engine/safeguard/ServerBoot.java
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
package com.volmit.iris.engine.safeguard;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.nms.v20.NMSBinding1_20_1;
|
||||||
|
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;
|
||||||
|
public static boolean correctversion = true;
|
||||||
|
|
||||||
|
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();
|
||||||
|
if (!instance.getServer().getBukkitVersion().contains(NMSBinding1_20_1.NMS_VERSION)) {
|
||||||
|
unstablemode = true;
|
||||||
|
correctversion = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 printincompatiblepluginWarnings(){
|
||||||
|
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user