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
[![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.
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",
"players_online": "Players Online",
"cpu_title": "CPU",
"ram_title": "RAM",
"ram_title": "RAM usage",
"deleteServerButton": "Delete server",
"sendCommandButton": "Send"
}
@ -64,7 +64,7 @@ function setLanguage(locale){
"disconnectionModalCloseButton": "Cerrar",
"players_online": "Jugadores en línea",
"cpu_title": "CPU",
"ram_title": "RAM",
"ram_title": "RAM en uso",
"deleteServerButton": "Borrar servidor",
"sendCommandButton": "Enviar"
}

View File

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

View File

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

View File

@ -11,9 +11,9 @@ public class RamUsageCommand implements WSCommand {
public void execute(WSServer wsServer, WebSocket conn, String params) {
Runtime r = Runtime.getRuntime();
int free = (int) r.freeMemory() / 1024 / 1024;
int max = (int) r.maxMemory() / 1024 / 1024;
int used = max - free;
long free = r.freeMemory() / 1024 / 1024;
long max = r.maxMemory() / 1024 / 1024;
long used = max - free;
wsServer.sendToClient(conn,
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 {
private String message;
private int free;
private int used;
private int max;
private long free;
private long used;
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.free = free;
this.used = used;
@ -29,7 +29,7 @@ public class RamUsage implements JSONOutput {
* Free amount of RAM, in MB
* @return
*/
public int getFree() {
public long getFree() {
return free;
}
@ -37,7 +37,7 @@ public class RamUsage implements JSONOutput {
* Used amount of RAM, in MB
* @return
*/
public int getUsed() {
public long getUsed() {
return used;
}
@ -45,7 +45,7 @@ public class RamUsage implements JSONOutput {
* Max amount of RAM, in MB
* @return
*/
public int getMax() {
public long getMax() {
return max;
}