Remove RamUsage.bossBar
Dieser Commit ist enthalten in:
Ursprung
fadc8bd3da
Commit
3ce4a9b4d3
@ -19,43 +19,14 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.world;
|
package de.steamwar.bausystem.features.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import lombok.experimental.UtilityClass;
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
|
||||||
import de.steamwar.bausystem.linkage.Linked;
|
|
||||||
import org.bukkit.Bukkit;
|
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.lang.management.ManagementFactory;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@Linked(LinkageType.PLAIN)
|
@UtilityClass
|
||||||
public class RamUsage implements Listener {
|
public class RamUsage {
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getUsage() {
|
public static double getUsage() {
|
||||||
try {
|
try {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren