Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 57 lines 1.7 kB view raw
1package net.minecraft.server; 2 3import javax.swing.*; 4import java.awt.*; 5 6public class GuiStatsComponent extends JComponent { 7 8 private int[] a = new int[256]; 9 private int b = 0; 10 private String[] c = new String[10]; 11 12 public GuiStatsComponent() { 13 this.setPreferredSize(new Dimension(256, 196)); 14 this.setMinimumSize(new Dimension(256, 196)); 15 this.setMaximumSize(new Dimension(256, 196)); 16 (new Timer(500, new GuiStatsListener(this))).start(); 17 this.setBackground(Color.BLACK); 18 } 19 20 private void a() { 21 long i = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); 22 23 System.gc(); 24 this.c[0] = "Memory use: " + i / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)"; 25 this.c[1] = "Threads: " + NetworkManager.b + " + " + NetworkManager.c; 26 this.a[this.b++ & 255] = (int) (i * 100L / Runtime.getRuntime().maxMemory()); 27 this.repaint(); 28 } 29 30 public void paint(Graphics graphics) { 31 graphics.setColor(new Color(16777215)); 32 graphics.fillRect(0, 0, 256, 192); 33 34 int i; 35 36 for (i = 0; i < 256; ++i) { 37 int j = this.a[i + this.b & 255]; 38 39 graphics.setColor(new Color(j + 28 << 16)); 40 graphics.fillRect(i, 100 - j, 1, j); 41 } 42 43 graphics.setColor(Color.BLACK); 44 45 for (i = 0; i < this.c.length; ++i) { 46 String s = this.c[i]; 47 48 if (s != null) { 49 graphics.drawString(s, 32, 116 + i * 16); 50 } 51 } 52 } 53 54 static void a(GuiStatsComponent guistatscomponent) { 55 guistatscomponent.a(); 56 } 57}