Solved problem with RAM not showing numbers correctly

This commit is contained in:
Carlos 2019-08-25 11:29:06 +02:00
parent cb9027c42a
commit f3aad57148
6 changed files with 145 additions and 142 deletions

View File

@ -1,5 +1,8 @@
# WebConsole # WebConsole
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/mesacarlos/WebConsole)](https://github.com/mesacarlos/WebConsole/releases/latest)
![GitHub All Releases](https://img.shields.io/github/downloads/mesacarlos/WebConsole/total?label=total%20downloads)
WebConsole is a Spigot plugin for Minecraft 1.8-1.14 that enables you to view your server console and manage your server from anywhere. It creates a WebSocket server in the background used by the web interface to send commands, receive your console log and manage your server. WebConsole is a Spigot plugin for Minecraft 1.8-1.14 that enables you to view your server console and manage your server from anywhere. It creates a WebSocket server in the background used by the web interface to send commands, receive your console log and manage your server.
Dont worry about privacy or security: all data is stored in your browser offline and your PC will connect directly to your minecraft server. No intermediary web servers, just you and your MC server. Dont worry about privacy or security: all data is stored in your browser offline and your PC will connect directly to your minecraft server. No intermediary web servers, just you and your MC server.

View File

@ -34,7 +34,7 @@ function setLanguage(locale){
"disconnectionModalCloseButton": "Close", "disconnectionModalCloseButton": "Close",
"players_online": "Players Online", "players_online": "Players Online",
"cpu_title": "CPU", "cpu_title": "CPU",
"ram_title": "RAM", "ram_title": "RAM usage",
"deleteServerButton": "Delete server", "deleteServerButton": "Delete server",
"sendCommandButton": "Send" "sendCommandButton": "Send"
} }
@ -64,7 +64,7 @@ function setLanguage(locale){
"disconnectionModalCloseButton": "Cerrar", "disconnectionModalCloseButton": "Cerrar",
"players_online": "Jugadores en línea", "players_online": "Jugadores en línea",
"cpu_title": "CPU", "cpu_title": "CPU",
"ram_title": "RAM", "ram_title": "RAM en uso",
"deleteServerButton": "Borrar servidor", "deleteServerButton": "Borrar servidor",
"sendCommandButton": "Enviar" "sendCommandButton": "Enviar"
} }

View File

@ -1,6 +1,6 @@
name: WebConsole name: WebConsole
main: com.mesacarlos.webconsole.WebConsole main: com.mesacarlos.webconsole.WebConsole
version: 1.1 version: 1.2
description: WebSockets-based web console description: WebSockets-based web console
author: Carlos Mesa author: Carlos Mesa
commands: commands:

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>WebConsole</groupId> <groupId>WebConsole</groupId>
<artifactId>WebConsole</artifactId> <artifactId>WebConsole</artifactId>
<version>1.1</version> <version>1.2</version>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<plugins> <plugins>

View File

@ -11,9 +11,9 @@ public class RamUsageCommand implements WSCommand {
public void execute(WSServer wsServer, WebSocket conn, String params) { public void execute(WSServer wsServer, WebSocket conn, String params) {
Runtime r = Runtime.getRuntime(); Runtime r = Runtime.getRuntime();
int free = (int) r.freeMemory() / 1024 / 1024; long free = r.freeMemory() / 1024 / 1024;
int max = (int) r.maxMemory() / 1024 / 1024; long max = r.maxMemory() / 1024 / 1024;
int used = max - free; long used = max - free;
wsServer.sendToClient(conn, wsServer.sendToClient(conn,
new RamUsage(free + " free, " + used + " used, " + max + " maximum memory", free, used, max)); new RamUsage(free + " free, " + used + " used, " + max + " maximum memory", free, used, max));

View File

@ -4,11 +4,11 @@ import com.google.gson.JsonObject;
public class RamUsage implements JSONOutput { public class RamUsage implements JSONOutput {
private String message; private String message;
private int free; private long free;
private int used; private long used;
private int max; private long max;
public RamUsage(String message, int free, int used, int max) { public RamUsage(String message, long free, long used, long max) {
this.message = message; this.message = message;
this.free = free; this.free = free;
this.used = used; this.used = used;
@ -29,7 +29,7 @@ public class RamUsage implements JSONOutput {
* Free amount of RAM, in MB * Free amount of RAM, in MB
* @return * @return
*/ */
public int getFree() { public long getFree() {
return free; return free;
} }
@ -37,7 +37,7 @@ public class RamUsage implements JSONOutput {
* Used amount of RAM, in MB * Used amount of RAM, in MB
* @return * @return
*/ */
public int getUsed() { public long getUsed() {
return used; return used;
} }
@ -45,7 +45,7 @@ public class RamUsage implements JSONOutput {
* Max amount of RAM, in MB * Max amount of RAM, in MB
* @return * @return
*/ */
public int getMax() { public long getMax() {
return max; return max;
} }