From 3ce4a9b4d3f1561bd034e320432bf8f34a5936ac Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 2 May 2021 21:01:00 +0200 Subject: [PATCH] Remove RamUsage.bossBar --- .../bausystem/features/world/RamUsage.java | 35 ++----------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/RamUsage.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/RamUsage.java index 6a525271..4996b0aa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/RamUsage.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/RamUsage.java @@ -19,43 +19,14 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; -import org.bukkit.boss.BarColor; -import org.bukkit.boss.BarStyle; -import org.bukkit.boss.BossBar; -import org.bukkit.event.Listener; import java.lang.management.ManagementFactory; import java.util.logging.Level; -@Linked(LinkageType.PLAIN) -public class RamUsage implements Listener { - - private boolean mode = false; - private BossBar bossBar; - - public RamUsage() { - bossBar = Bukkit.createBossBar("§eRAM", BarColor.YELLOW, BarStyle.SEGMENTED_10); - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { - long allocatedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); - long presumableFreeMemory = Runtime.getRuntime().maxMemory() - allocatedMemory; - double percentageFree = presumableFreeMemory / (double) Runtime.getRuntime().maxMemory(); - bossBar.setProgress(1 - percentageFree); - if (mode && percentageFree > 0.5) { - mode = false; - } else if (!mode && percentageFree < 0.3) { - mode = true; - } - if (mode) { - Bukkit.getOnlinePlayers().forEach(bossBar::addPlayer); - } else { - bossBar.removeAll(); - } - }, 1, 1); - } +@UtilityClass +public class RamUsage { public static double getUsage() { try {