mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-01-06 15:51:30 +00:00
Merge branch '3.2.5' of https://github.com/RePixelatedMC/Iris into PixelatedDev
# Conflicts: # core/src/main/java/com/volmit/iris/core/commands/CommandIris.java
This commit is contained in:
@@ -25,7 +25,7 @@ plugins {
|
|||||||
id "de.undercouch.download" version "5.0.1"
|
id "de.undercouch.download" version "5.0.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
version '3.2.3-1.19.2-1.20.4'
|
version '3.2.4-1.19.2-1.20.4'
|
||||||
def specialSourceVersion = '1.11.0' //[NMS]
|
def specialSourceVersion = '1.11.0' //[NMS]
|
||||||
|
|
||||||
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
|
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
|
||||||
|
|||||||
@@ -806,9 +806,6 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
splash = splashstable;
|
splash = splashstable;
|
||||||
}
|
}
|
||||||
OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
|
|
||||||
String osArch = osBean.getArch();
|
|
||||||
String osName = osBean.getName();
|
|
||||||
|
|
||||||
if (!passedserversoftware) {
|
if (!passedserversoftware) {
|
||||||
Iris.info("Server type & version: " + C.RED + Bukkit.getVersion());
|
Iris.info("Server type & version: " + C.RED + Bukkit.getVersion());
|
||||||
@@ -821,35 +818,9 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
Iris.info(C.YELLOW + "Purpur is recommended to use with iris.");
|
Iris.info(C.YELLOW + "Purpur is recommended to use with iris.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Iris.info("Server OS: " + osName + " (" + osArch + ")");
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (warningmode){
|
|
||||||
Iris.info("Server Cpu: " + C.GOLD + getCPUModel());
|
|
||||||
} else {
|
|
||||||
if(unstablemode){
|
|
||||||
Iris.info("Server Cpu: " + C.DARK_RED + getCPUModel());
|
|
||||||
} else {
|
|
||||||
if (getCPUModel().contains("Intel")) {
|
|
||||||
Iris.info("Server Cpu: " + C.BLUE + getCPUModel());
|
|
||||||
}
|
|
||||||
if (getCPUModel().contains("Ryzen")) {
|
|
||||||
Iris.info("Server Cpu: " + C.RED + getCPUModel());
|
|
||||||
}
|
|
||||||
if (!getCPUModel().contains("Ryzen") && !getCPUModel().contains("Intel")) {
|
|
||||||
Iris.info("Server Cpu: " + C.GRAY + getCPUModel());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e){
|
|
||||||
Iris.info("Server Cpu: " + C.DARK_RED + "Failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
Iris.info("Process Threads: " + Runtime.getRuntime().availableProcessors());
|
|
||||||
Iris.info("Process Memory: " + getHardware.getProcessMemory() + " MB");
|
|
||||||
Iris.info("Free DiskSpace: " + Form.ofSize(freeSpace.getFreeSpace(), 1024));
|
|
||||||
if (getHardware.getProcessMemory() < 5999) {
|
if (getHardware.getProcessMemory() < 5999) {
|
||||||
Iris.warn("6GB+ Ram is recommended");
|
Iris.warn("6GB+ Ram is recommended");
|
||||||
|
Iris.warn("Process Memory: " + getHardware.getProcessMemory() + " MB");
|
||||||
}
|
}
|
||||||
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
|
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
|
||||||
Iris.info("Custom Biomes: " + INMS.get().countCustomBiomes());
|
Iris.info("Custom Biomes: " + INMS.get().countCustomBiomes());
|
||||||
|
|||||||
@@ -78,7 +78,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 CommandUpdater updater;
|
private CommandSupport support;
|
||||||
private CommandDeveloper developer;
|
private CommandDeveloper developer;
|
||||||
public static boolean worldCreation = false;
|
public static boolean worldCreation = false;
|
||||||
String WorldEngine;
|
String WorldEngine;
|
||||||
@@ -320,6 +320,24 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
return dir.delete();
|
return dir.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Decree(description = "Updates all chunk in the specified world")
|
||||||
|
public void updater(
|
||||||
|
@Param(description = "World to update chunks at")
|
||||||
|
World world
|
||||||
|
) {
|
||||||
|
if (!IrisToolbelt.isIrisWorld(world)) {
|
||||||
|
sender().sendMessage(C.GOLD + "This is not an Iris world");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChunkUpdater updater = new ChunkUpdater(world);
|
||||||
|
if (sender().isPlayer()) {
|
||||||
|
sender().sendMessage(C.GREEN + "Updating " + world.getName() + " Total chunks: " + Form.f(updater.getChunks()));
|
||||||
|
} else {
|
||||||
|
Iris.info(C.GREEN + "Updating " + world.getName() + " Total chunks: " + Form.f(updater.getChunks()));
|
||||||
|
}
|
||||||
|
updater.start();
|
||||||
|
}
|
||||||
|
|
||||||
@Decree(description = "Set aura spins")
|
@Decree(description = "Set aura spins")
|
||||||
public void aura(
|
public void aura(
|
||||||
@Param(description = "The h color value", defaultValue = "-20")
|
@Param(description = "The h color value", defaultValue = "-20")
|
||||||
@@ -515,6 +533,7 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Iris.error("Failed to update bukkit.yml!");
|
Iris.error("Failed to update bukkit.yml!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkForBukkitWorlds(world);
|
checkForBukkitWorlds(world);
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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.loader.IrisData;
|
||||||
|
import com.volmit.iris.core.pregenerator.ChunkUpdater;
|
||||||
|
import com.volmit.iris.core.service.IrisEngineSVC;
|
||||||
|
import com.volmit.iris.core.tools.IrisPackBenchmarking;
|
||||||
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
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.format.Form;
|
||||||
|
import com.volmit.iris.util.io.IO;
|
||||||
|
import com.volmit.iris.util.mantle.TectonicPlate;
|
||||||
|
import com.volmit.iris.util.misc.Hastebin;
|
||||||
|
import com.volmit.iris.util.misc.Platform;
|
||||||
|
import com.volmit.iris.util.misc.getHardware;
|
||||||
|
import com.volmit.iris.util.nbt.mca.MCAFile;
|
||||||
|
import com.volmit.iris.util.nbt.mca.MCAUtil;
|
||||||
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||||
|
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||||
|
import net.jpountz.lz4.LZ4FrameInputStream;
|
||||||
|
import net.jpountz.lz4.LZ4FrameOutputStream;
|
||||||
|
import org.apache.commons.lang.RandomStringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import oshi.SystemInfo;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
|
@Decree(name = "Support", origin = DecreeOrigin.BOTH, description = "Iris World Manager", aliases = {"support"})
|
||||||
|
public class CommandSupport implements DecreeExecutor {
|
||||||
|
|
||||||
|
@Decree(description = "report")
|
||||||
|
public void report() {
|
||||||
|
try {
|
||||||
|
if (sender().isPlayer()) sender().sendMessage(C.GOLD + "Creating report..");
|
||||||
|
if (!sender().isPlayer()) Iris.info(C.GOLD + "Creating report..");
|
||||||
|
Hastebin.enviornment(sender());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Iris.info(C.RED + "Something went wrong: ");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -28,7 +28,6 @@ import java.io.InputStreamReader;
|
|||||||
|
|
||||||
import static com.google.common.math.LongMath.isPrime;
|
import static com.google.common.math.LongMath.isPrime;
|
||||||
import static com.volmit.iris.util.misc.getHardware.getCPUModel;
|
import static com.volmit.iris.util.misc.getHardware.getCPUModel;
|
||||||
import static com.volmit.iris.util.misc.getHardware.getDiskModel;
|
|
||||||
public class IrisBenchmarking {
|
public class IrisBenchmarking {
|
||||||
static String ServerOS;
|
static String ServerOS;
|
||||||
static String filePath = "benchmark.dat";
|
static String filePath = "benchmark.dat";
|
||||||
@@ -180,12 +179,12 @@ public class IrisBenchmarking {
|
|||||||
Iris.info("- Data Compression: " + formatDouble(calculateDataCompression) + " MBytes/Sec");
|
Iris.info("- Data Compression: " + formatDouble(calculateDataCompression) + " MBytes/Sec");
|
||||||
|
|
||||||
if (WindowsDiskSpeed) {
|
if (WindowsDiskSpeed) {
|
||||||
Iris.info("Disk Model: " + getDiskModel());
|
//Iris.info("Disk Model: " + getDiskModel());
|
||||||
Iris.info(C.BLUE + "- Running with Windows System Assessment Tool");
|
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 Write: " + C.BLUE + formatDouble(avgWriteSpeedMBps) + " Mbps");
|
||||||
Iris.info("- Sequential 64.0 Read: " + C.BLUE + formatDouble(avgReadSpeedMBps) + " Mbps");
|
Iris.info("- Sequential 64.0 Read: " + C.BLUE + formatDouble(avgReadSpeedMBps) + " Mbps");
|
||||||
} else {
|
} else {
|
||||||
Iris.info("Disk Model: " + getDiskModel());
|
// Iris.info("Disk Model: " + getDiskModel());
|
||||||
Iris.info(C.GREEN + "- Running in Native Mode");
|
Iris.info(C.GREEN + "- Running in Native Mode");
|
||||||
Iris.info("- Average Write Speed: " + C.GREEN + formatDouble(avgWriteSpeedMBps) + " Mbps");
|
Iris.info("- Average Write Speed: " + C.GREEN + formatDouble(avgWriteSpeedMBps) + " Mbps");
|
||||||
Iris.info("- Average Read Speed: " + C.GREEN + formatDouble(avgReadSpeedMBps) + " Mbps");
|
Iris.info("- Average Read Speed: " + C.GREEN + formatDouble(avgReadSpeedMBps) + " Mbps");
|
||||||
|
|||||||
135
core/src/main/java/com/volmit/iris/util/misc/Hastebin.java
Normal file
135
core/src/main/java/com/volmit/iris/util/misc/Hastebin.java
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
package com.volmit.iris.util.misc;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.format.C;
|
||||||
|
import com.volmit.iris.util.format.Form;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import oshi.SystemInfo;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Hastebin {
|
||||||
|
|
||||||
|
public static void enviornment(CommandSender sender) {
|
||||||
|
// Construct the server information
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
KList<String> disks = new KList<>(getHardware.getDisk());
|
||||||
|
KList<String> interfaces = new KList<>(getHardware.getInterfaces());
|
||||||
|
KList<String> displays = new KList<>(getHardware.getEDID());
|
||||||
|
KList<String> sensors = new KList<>(getHardware.getSensors());
|
||||||
|
KList<String> gpus = new KList<>(getHardware.getGraphicsCards());
|
||||||
|
KList<String> powersources = new KList<>(getHardware.getPowerSources());
|
||||||
|
|
||||||
|
KList<World> IrisWorlds = new KList<>();
|
||||||
|
KList<World> BukkitWorlds = new KList<>();
|
||||||
|
|
||||||
|
for (World w : Bukkit.getServer().getWorlds()) {
|
||||||
|
try {
|
||||||
|
Engine engine = IrisToolbelt.access(w).getEngine();
|
||||||
|
if (engine != null) {
|
||||||
|
IrisWorlds.add(w);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
BukkitWorlds.add(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append(" -- == Iris Info == -- \n");
|
||||||
|
sb.append("Iris Version Version: ").append(Iris.instance.getDescription().getVersion()).append("\n");
|
||||||
|
sb.append("- Iris Worlds");
|
||||||
|
for (World w : IrisWorlds.copy()) {
|
||||||
|
sb.append(" - ").append(w.getName());
|
||||||
|
}
|
||||||
|
sb.append("- Bukkit Worlds");
|
||||||
|
for (World w : BukkitWorlds.copy()) {
|
||||||
|
sb.append(" - ").append(w.getName());
|
||||||
|
}
|
||||||
|
sb.append(" -- == Platform Overview == -- " + "\n");
|
||||||
|
sb.append("Server Type: ").append(Bukkit.getVersion()).append("\n");
|
||||||
|
sb.append("Server Uptime: ").append(Form.stampTime(systemInfo.getOperatingSystem().getSystemUptime())).append("\n");
|
||||||
|
sb.append("Version: ").append(Platform.getVersion()).append(" - Platform: ").append(Platform.getName()).append("\n");
|
||||||
|
sb.append("Java Vendor: ").append(Platform.ENVIRONMENT.getJavaVendor()).append(" - Java Version: ").append(Platform.ENVIRONMENT.getJavaVersion()).append("\n");
|
||||||
|
sb.append(" -- == Processor Overview == -- " + "\n");
|
||||||
|
sb.append("CPU Model: ").append(getHardware.getCPUModel());
|
||||||
|
sb.append("CPU Architecture: ").append(Platform.CPU.getArchitecture()).append(" Available Processors: ").append(Platform.CPU.getAvailableProcessors()).append("\n");
|
||||||
|
sb.append("CPU Load: ").append(Form.pc(Platform.CPU.getCPULoad())).append(" CPU Live Process Load: ").append(Form.pc(Platform.CPU.getLiveProcessCPULoad())).append("\n");
|
||||||
|
sb.append("-=" + " Graphics " + "=- " + "\n");
|
||||||
|
for (String gpu : gpus) {
|
||||||
|
sb.append(" ").append(gpu).append("\n");
|
||||||
|
}
|
||||||
|
sb.append(" -- == Memory Information == -- " + "\n");
|
||||||
|
sb.append("Physical Memory - Total: ").append(Form.memSize(Platform.MEMORY.PHYSICAL.getTotalMemory())).append(" Free: ").append(Form.memSize(Platform.MEMORY.PHYSICAL.getFreeMemory())).append(" Used: ").append(Form.memSize(Platform.MEMORY.PHYSICAL.getUsedMemory())).append("\n");
|
||||||
|
sb.append("Virtual Memory - Total: ").append(Form.memSize(Platform.MEMORY.VIRTUAL.getTotalMemory())).append(" Free: ").append(Form.memSize(Platform.MEMORY.VIRTUAL.getFreeMemory())).append(" Used: ").append(Form.memSize(Platform.MEMORY.VIRTUAL.getUsedMemory())).append("\n");
|
||||||
|
sb.append(" -- == Storage Information == -- " + "\n");
|
||||||
|
for (String disk : disks) {
|
||||||
|
sb.append(" ").append(sb.append(disk)).append("\n");
|
||||||
|
}
|
||||||
|
sb.append(" -- == Interface Information == -- "+ "\n" );
|
||||||
|
for (String inter : interfaces) {
|
||||||
|
sb.append(" ").append(inter).append("\n");
|
||||||
|
}
|
||||||
|
sb.append(" -- == Display Information == -- "+ "\n" );
|
||||||
|
for (String display : displays) {
|
||||||
|
sb.append(display).append("\n");
|
||||||
|
}
|
||||||
|
sb.append(" -- == Sensor Information == -- " + "\n");
|
||||||
|
for (String sensor : sensors) {
|
||||||
|
sb.append(" ").append(sensor).append("\n");
|
||||||
|
}
|
||||||
|
sb.append(" -- == Power Information == -- " + "\n");
|
||||||
|
for (String power : powersources) {
|
||||||
|
sb.append(" ").append(power).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
String hastebinUrl = uploadToHastebin(sb.toString());
|
||||||
|
|
||||||
|
// Create the clickable message
|
||||||
|
TextComponent message = new TextComponent("[Link]");
|
||||||
|
TextComponent link = new TextComponent(hastebinUrl);
|
||||||
|
link.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, hastebinUrl));
|
||||||
|
message.addExtra(link);
|
||||||
|
|
||||||
|
// Send the clickable message to the player
|
||||||
|
sender.spigot().sendMessage(message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.sendMessage(C.DARK_RED + "Failed to upload server information to Hastebin.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String uploadToHastebin(String content) throws Exception {
|
||||||
|
URL url = new URL("https://paste.bytecode.ninja/documents");
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setRequestProperty("Content-Type", "text/plain");
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
|
||||||
|
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
|
||||||
|
wr.writeBytes(content);
|
||||||
|
wr.flush();
|
||||||
|
wr.close();
|
||||||
|
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||||
|
String response = br.readLine();
|
||||||
|
br.close();
|
||||||
|
|
||||||
|
return "https://paste.bytecode.ninja/" + response.split("\"")[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
145
core/src/main/java/com/volmit/iris/util/misc/Platform.java
Normal file
145
core/src/main/java/com/volmit/iris/util/misc/Platform.java
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
package com.volmit.iris.util.misc;
|
||||||
|
|
||||||
|
import com.sun.management.OperatingSystemMXBean;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
|
||||||
|
@SuppressWarnings("restriction")
|
||||||
|
public class Platform {
|
||||||
|
public static String getVersion() {
|
||||||
|
return getSystem().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getName() {
|
||||||
|
return getSystem().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OperatingSystemMXBean getSystem() {
|
||||||
|
return (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ENVIRONMENT {
|
||||||
|
public static boolean canRunBatch() {
|
||||||
|
return getSystem().getName().toLowerCase().contains("windows");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getJavaHome() {
|
||||||
|
return System.getProperty("java.home");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getJavaVendor() {
|
||||||
|
return System.getProperty("java.vendor");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getJavaVersion() {
|
||||||
|
return System.getProperty("java.version");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class STORAGE {
|
||||||
|
public static long getAbsoluteTotalSpace() {
|
||||||
|
long t = 0;
|
||||||
|
|
||||||
|
for (File i : getRoots()) {
|
||||||
|
t += getTotalSpace(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getTotalSpace() {
|
||||||
|
return getTotalSpace(new File("."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getTotalSpace(File root) {
|
||||||
|
return root.getTotalSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getAbsoluteFreeSpace() {
|
||||||
|
long t = 0;
|
||||||
|
|
||||||
|
for (File i : getRoots()) {
|
||||||
|
t += getFreeSpace(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getFreeSpace() {
|
||||||
|
return getFreeSpace(new File("."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getFreeSpace(File root) {
|
||||||
|
return root.getFreeSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getUsedSpace() {
|
||||||
|
return getTotalSpace() - getFreeSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getUsedSpace(File root) {
|
||||||
|
return getTotalSpace(root) - getFreeSpace(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getAbsoluteUsedSpace() {
|
||||||
|
return getAbsoluteTotalSpace() - getAbsoluteFreeSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File[] getRoots() {
|
||||||
|
return File.listRoots();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MEMORY {
|
||||||
|
public static class PHYSICAL {
|
||||||
|
public static long getTotalMemory() {
|
||||||
|
return getSystem().getTotalPhysicalMemorySize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getFreeMemory() {
|
||||||
|
return getSystem().getFreePhysicalMemorySize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getUsedMemory() {
|
||||||
|
return getTotalMemory() - getFreeMemory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class VIRTUAL {
|
||||||
|
public static long getTotalMemory() {
|
||||||
|
return getSystem().getTotalSwapSpaceSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getFreeMemory() {
|
||||||
|
return getSystem().getFreeSwapSpaceSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getUsedMemory() {
|
||||||
|
return getTotalMemory() - getFreeMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getCommittedVirtualMemory() {
|
||||||
|
return getSystem().getCommittedVirtualMemorySize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CPU {
|
||||||
|
public static int getAvailableProcessors() {
|
||||||
|
return getSystem().getAvailableProcessors();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getCPULoad() {
|
||||||
|
return getSystem().getSystemCpuLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getLiveProcessCPULoad() {
|
||||||
|
return getSystem().getProcessCpuLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getArchitecture() {
|
||||||
|
return getSystem().getArch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,24 @@
|
|||||||
package com.volmit.iris.util.misc;
|
package com.volmit.iris.util.misc;
|
||||||
|
|
||||||
import oshi.SystemInfo;
|
|
||||||
import oshi.hardware.CentralProcessor;
|
|
||||||
import oshi.hardware.HWDiskStore;
|
|
||||||
import oshi.software.os.OperatingSystem;
|
|
||||||
|
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.format.C;
|
||||||
|
import com.volmit.iris.util.format.Form;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import oshi.SystemInfo;
|
||||||
|
import oshi.hardware.*;
|
||||||
|
import oshi.software.os.FileSystem;
|
||||||
|
import oshi.software.os.OSFileStore;
|
||||||
|
import oshi.software.os.OperatingSystem;
|
||||||
|
import oshi.util.EdidUtil;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class getHardware {
|
public class getHardware {
|
||||||
public static String getServerOS() {
|
public static String getServerOS() {
|
||||||
@@ -44,14 +57,127 @@ public class getHardware {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDiskModel() {
|
public static KList<String> getSensors() {
|
||||||
SystemInfo systemInfo = new SystemInfo();
|
try {
|
||||||
List<HWDiskStore> diskStores = systemInfo.getHardware().getDiskStores();
|
KList<String> temps = new KList<>();
|
||||||
if (!diskStores.isEmpty()) {
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
HWDiskStore firstDisk = diskStores.get(0);
|
temps.add("CPU Temperature: " + systemInfo.getHardware().getSensors().getCpuTemperature());
|
||||||
return firstDisk.getModel();
|
temps.add("CPU Voltage: " + systemInfo.getHardware().getSensors().getCpuTemperature());
|
||||||
} else {
|
temps.add("Fan Speeds: " + Arrays.toString(systemInfo.getHardware().getSensors().getFanSpeeds()));
|
||||||
return "Unknown Disk Model";
|
return temps.copy();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static KList<String> getGraphicsCards() {
|
||||||
|
try {
|
||||||
|
KList<String> gpus = new KList<>();
|
||||||
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
for (GraphicsCard gpu : systemInfo.getHardware().getGraphicsCards()) {
|
||||||
|
gpus.add(C.BLUE + "Gpu Model: " + C.GRAY + gpu.getName());
|
||||||
|
gpus.add("- vRam Size: " + C.GRAY + Form.memSize(gpu.getVRam()));
|
||||||
|
gpus.add("- Vendor: " + C.GRAY + gpu.getVendor());
|
||||||
|
}
|
||||||
|
return gpus.copy();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KList<String> getDisk() {
|
||||||
|
try {
|
||||||
|
KList<String> systemDisks = new KList<>();
|
||||||
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
List<HWDiskStore> diskStores = systemInfo.getHardware().getDiskStores();
|
||||||
|
OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
|
||||||
|
List<OSFileStore> fileStores = operatingSystem.getFileSystem().getFileStores();
|
||||||
|
|
||||||
|
for (HWDiskStore disk : diskStores) {
|
||||||
|
systemDisks.add(C.BLUE + "Disk: " + disk.getName());
|
||||||
|
systemDisks.add("- Model: " + disk.getModel());
|
||||||
|
systemDisks.add("Partitions: " + disk.getPartitions());
|
||||||
|
for (OSFileStore partition : fileStores) {
|
||||||
|
systemDisks.add(C.BLUE + "- Name: " + partition.getName());
|
||||||
|
systemDisks.add(" - Description: " + partition.getDescription());
|
||||||
|
systemDisks.add(" - Total Space: " + Form.memSize(partition.getTotalSpace()));
|
||||||
|
systemDisks.add(" - Free Space: " + Form.memSize(partition.getFreeSpace()));
|
||||||
|
systemDisks.add(" - Mount: " + partition.getMount());
|
||||||
|
systemDisks.add(" - Label: " + partition.getLabel());
|
||||||
|
}
|
||||||
|
systemDisks.add(C.DARK_GRAY + "-=" + C.BLUE +" Since Boot " + C.DARK_GRAY + "=- ");
|
||||||
|
systemDisks.add("- Total Reads: " + Form.memSize(disk.getReadBytes()));
|
||||||
|
systemDisks.add("- Total Writes: " + Form.memSize(disk.getWriteBytes()));
|
||||||
|
}
|
||||||
|
if (systemDisks.isEmpty()) {
|
||||||
|
systemDisks.add("Failed to get disks.");
|
||||||
|
}
|
||||||
|
return systemDisks.copy();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KList<String> getPowerSources() {
|
||||||
|
try {
|
||||||
|
KList<String> systemPowerSources = new KList<>();
|
||||||
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
List<PowerSource> powerSources = systemInfo.getHardware().getPowerSources();
|
||||||
|
for (PowerSource powersource : powerSources) {
|
||||||
|
systemPowerSources.add(C.BLUE + "- Name: " + powersource.getName());
|
||||||
|
systemPowerSources.add("- RemainingCapacityPercent: " + powersource.getRemainingCapacityPercent());
|
||||||
|
systemPowerSources.add("- Power Usage Rate: " + powersource.getPowerUsageRate());
|
||||||
|
systemPowerSources.add("- Power OnLine: " + powersource.isPowerOnLine());
|
||||||
|
systemPowerSources.add("- Capacity Units: " + powersource.getCapacityUnits());
|
||||||
|
systemPowerSources.add("- Cycle Count: " + powersource.getCycleCount());
|
||||||
|
}
|
||||||
|
if (systemPowerSources.isEmpty()) {
|
||||||
|
systemPowerSources.add("No PowerSources.");
|
||||||
|
}
|
||||||
|
return systemPowerSources.copy();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KList<String> getEDID() {
|
||||||
|
try {
|
||||||
|
KList<String> systemEDID = new KList<>();
|
||||||
|
SystemInfo systemInfo = new SystemInfo();
|
||||||
|
HardwareAbstractionLayer hardware = systemInfo.getHardware();
|
||||||
|
List<Display> displays = hardware.getDisplays();
|
||||||
|
for (Display display : displays) {
|
||||||
|
systemEDID.add("Display: " + display.getEdid());
|
||||||
|
}
|
||||||
|
if (!systemEDID.isEmpty()) {
|
||||||
|
systemEDID.add("No displays");
|
||||||
|
}
|
||||||
|
return systemEDID.copy();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KList<String> getInterfaces() {
|
||||||
|
try {
|
||||||
|
KList<String> interfaces = new KList<>();
|
||||||
|
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||||
|
for (NetworkInterface ni : Collections.list(networkInterfaces)) {
|
||||||
|
interfaces.add(C.BLUE + "Display Name: %s", ni.getDisplayName());
|
||||||
|
Enumeration<InetAddress> inetAddresses = ni.getInetAddresses();
|
||||||
|
for (InetAddress ia : Collections.list(inetAddresses)) {
|
||||||
|
interfaces.add("IP: %s", ia.getHostAddress());
|
||||||
|
}
|
||||||
|
return interfaces.copy();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user