Better RamUsage show meter
Dieser Commit ist enthalten in:
Ursprung
28fb3b7301
Commit
f25fa86db9
@ -26,17 +26,15 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.boss.BarColor;
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.boss.BarStyle;
|
import org.bukkit.boss.BarStyle;
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@Linked(LinkageType.LISTENER)
|
@Linked(LinkageType.PLAIN)
|
||||||
public class RamUsage implements Listener {
|
public class RamUsage implements Listener {
|
||||||
|
|
||||||
|
private boolean mode = false;
|
||||||
private BossBar bossBar;
|
private BossBar bossBar;
|
||||||
|
|
||||||
public RamUsage() {
|
public RamUsage() {
|
||||||
@ -46,17 +44,17 @@ public class RamUsage implements Listener {
|
|||||||
long presumableFreeMemory = Runtime.getRuntime().maxMemory() - allocatedMemory;
|
long presumableFreeMemory = Runtime.getRuntime().maxMemory() - allocatedMemory;
|
||||||
double percentageFree = presumableFreeMemory / (double) Runtime.getRuntime().maxMemory();
|
double percentageFree = presumableFreeMemory / (double) Runtime.getRuntime().maxMemory();
|
||||||
bossBar.setProgress(1 - percentageFree);
|
bossBar.setProgress(1 - percentageFree);
|
||||||
}, 20, 20);
|
if (mode && percentageFree > 0.7) {
|
||||||
}
|
mode = false;
|
||||||
|
} else if (!mode && percentageFree < 0.5) {
|
||||||
@EventHandler
|
mode = true;
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
}
|
||||||
bossBar.addPlayer(event.getPlayer());
|
if (mode) {
|
||||||
}
|
Bukkit.getOnlinePlayers().forEach(bossBar::addPlayer);
|
||||||
|
} else {
|
||||||
@EventHandler
|
bossBar.removeAll();
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
}
|
||||||
bossBar.removePlayer(event.getPlayer());
|
}, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getUsage() {
|
public static double getUsage() {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren