From 6c426644f65a59d505822c64d2cd23dc276c88fa Mon Sep 17 00:00:00 2001 From: Allink Date: Wed, 25 May 2022 18:49:53 +0100 Subject: [PATCH] Add uptime & memory related functions to FUtil --- .../totalfreedommod/util/FUtil.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index 45364d10..2775decd 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -1,5 +1,6 @@ package me.totalfreedom.totalfreedommod.util; +import com.earth2me.essentials.utils.DateUtil; import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import org.apache.commons.io.FileUtils; @@ -16,6 +17,7 @@ import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; import java.io.*; +import java.lang.management.ManagementFactory; import java.net.HttpURLConnection; import java.net.URL; import java.text.ParseException; @@ -829,6 +831,26 @@ public class FUtil return total / longs.length; } + public static String getUptime() + { + return DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime()); + } + + public static double getMaxMem() + { + return Runtime.getRuntime().maxMemory() / 1024f / 1024f; + } + + public static double getTotalMem() + { + return Runtime.getRuntime().totalMemory() / 1024f / 1024f; + } + + public static double getFreeMem() + { + return Runtime.getRuntime().freeMemory() / 1024f / 1024f; + } + public static class PaginationList extends ArrayList {