commit
b284b00a9b
5
.gitignore
vendored
5
.gitignore
vendored
@ -68,4 +68,7 @@ local.properties
|
|||||||
# Scala IDE specific (Scala & Java development for Eclipse)
|
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||||
.cache-main
|
.cache-main
|
||||||
.scala_dependencies
|
.scala_dependencies
|
||||||
.worksheet
|
.worksheet
|
||||||
|
|
||||||
|
#idea
|
||||||
|
.idea
|
@ -79,8 +79,8 @@
|
|||||||
<div class="container" id="serverContainer" style="display: none;">
|
<div class="container" id="serverContainer" style="display: none;">
|
||||||
<h1 class="mt-4" id="serverTitle"></h1>
|
<h1 class="mt-4" id="serverTitle"></h1>
|
||||||
|
|
||||||
<div class="row p-3">
|
<div class="row p-2">
|
||||||
<div class="col-sm-3 mb-2">
|
<div class="col-sm-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title" id="players_online">Players Online</h5>
|
<h5 class="card-title" id="players_online">Players Online</h5>
|
||||||
@ -91,7 +91,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 mb-2">
|
<div class="col-sm-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title" id="cpu_title">CPU</h5>
|
<h5 class="card-title" id="cpu_title">CPU</h5>
|
||||||
@ -102,7 +102,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 mb-2">
|
<div class="col-sm-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title" id="ram_title">RAM</h5>
|
<h5 class="card-title" id="ram_title">RAM</h5>
|
||||||
@ -113,19 +113,32 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 mb-2">
|
<div class="col-sm-3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">
|
<h5 class="card-title" id="tps_title">TPS</h5>
|
||||||
<span id="user_title">Logged as</span>
|
<p class="card-text"><span id="tps">0</span> Ticks / <span id="maxTps">0</span> Ticks</p>
|
||||||
<span id="loggedUsernameLabel">Unknown</span>
|
<div class="progress flat-progressbar">
|
||||||
(<span id="loggedUserTypeLabel">Unknown</span>)
|
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" id="TpsProgressBar"></div>
|
||||||
</p>
|
</div>
|
||||||
<button type="button" class="btn btn-danger btn-sm" id="deleteServerButton">Delete server</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row p-2 mb-2">
|
||||||
|
<div class="col-sm-9">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<span id="user_title">Logged as</span> <span id="loggedUsernameLabel">Unknown</span> (<span id="loggedUserTypeLabel">Unknown</span>)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<div class="card">
|
||||||
|
<button type="button" class="btn btn-danger btn-sm" id="deleteServerButton">Delete server</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="card mb-2">
|
<div class="card mb-2">
|
||||||
<div class="card-body overflow-auto text-light bg-dark console" id="consoleTextArea"></div>
|
<div class="card-body overflow-auto text-light bg-dark console" id="consoleTextArea"></div>
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global variables
|
* Global variables
|
||||||
*/
|
*/
|
||||||
var persistenceManager = new WebConsolePersistenceManager();
|
const persistenceManager = new WebConsolePersistenceManager();
|
||||||
var connectionManager = new WebConsoleManager();
|
const connectionManager = new WebConsoleManager();
|
||||||
var lang;
|
let lang;
|
||||||
var autoPasswordCompleted = false; //When true, saved password was used. If a 401 is received, then saved password is not correct
|
let autoPasswordCompleted = false; //When true, saved password was used. If a 401 is received, then saved password is not correct
|
||||||
var statusCommandsInterval = -1;
|
let statusCommandsInterval = -1;
|
||||||
var commandHistoryIndex = -1; //Saves current command history index. -1 when not browsing history.
|
let commandHistoryIndex = -1; //Saves current command history index. -1 when not browsing history.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load list of servers in file servers.json
|
* Load list of servers in file servers.json
|
||||||
@ -61,10 +61,10 @@ function openServer(serverName){
|
|||||||
connectionManager.loadConnection(serverName);
|
connectionManager.loadConnection(serverName);
|
||||||
|
|
||||||
//Load saved messages
|
//Load saved messages
|
||||||
var i;
|
let i;
|
||||||
var messages = connectionManager.activeConnection.messages;
|
const messages = connectionManager.activeConnection.messages;
|
||||||
for(i = 0; i < messages.length; i++){
|
for(i = 0; i < messages.length; i++){
|
||||||
if(messages[i].status != 401){
|
if(messages[i].status !== 401){
|
||||||
onWebSocketsMessage(messages[i]);
|
onWebSocketsMessage(messages[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ function onWebSocketsMessage(message){
|
|||||||
$("#loggedUserTypeLabel").text(message.as);
|
$("#loggedUserTypeLabel").text(message.as);
|
||||||
|
|
||||||
//Disable command bar if user is viewer
|
//Disable command bar if user is viewer
|
||||||
if(message.as.toLowerCase() == "viewer"){
|
if(message.as.toLowerCase() === "viewer"){
|
||||||
$("#commandInput").prop("disabled", true);
|
$("#commandInput").prop("disabled", true);
|
||||||
$("#sendCommandButton").prop("disabled", true);
|
$("#sendCommandButton").prop("disabled", true);
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ function onWebSocketsMessage(message){
|
|||||||
break;
|
break;
|
||||||
case 401:
|
case 401:
|
||||||
//Waiting for login. Show password modal or retrieve password
|
//Waiting for login. Show password modal or retrieve password
|
||||||
var savedPwd = persistenceManager.getServer(connectionManager.activeConnection.serverName).serverPassword;
|
const savedPwd = persistenceManager.getServer(connectionManager.activeConnection.serverName).serverPassword;
|
||||||
if(typeof savedPwd !== "undefined" && !autoPasswordCompleted){
|
if(typeof savedPwd !== "undefined" && !autoPasswordCompleted){
|
||||||
connectionManager.sendPassword(savedPwd);
|
connectionManager.sendPassword(savedPwd);
|
||||||
autoPasswordCompleted = true;
|
autoPasswordCompleted = true;
|
||||||
@ -127,13 +127,17 @@ function onWebSocketsMessage(message){
|
|||||||
//RAM Usage
|
//RAM Usage
|
||||||
writeRamInfo(message.free, message.used, message.max);
|
writeRamInfo(message.free, message.used, message.max);
|
||||||
break;
|
break;
|
||||||
|
case 1003:
|
||||||
|
//Server TPS
|
||||||
|
writeTpsInfo(message.tps, 20);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('Unknown server response:');
|
console.log('Unknown server response:');
|
||||||
}
|
}
|
||||||
console.log(message);
|
console.log(message);
|
||||||
|
|
||||||
//Add interval for Players, CPU and RAM info, if not set
|
//Add interval for Players, CPU and RAM info, if not set
|
||||||
if(statusCommandsInterval == -1 && message.status !== 401){
|
if(statusCommandsInterval === -1 && message.status !== 401){
|
||||||
statusCommandsInterval = setInterval(function(){
|
statusCommandsInterval = setInterval(function(){
|
||||||
connectionManager.askForInfo();
|
connectionManager.askForInfo();
|
||||||
}, 2500);
|
}, 2500);
|
||||||
@ -144,8 +148,8 @@ function onWebSocketsMessage(message){
|
|||||||
* Write to console
|
* Write to console
|
||||||
*/
|
*/
|
||||||
function writeToWebConsole(msg, time){
|
function writeToWebConsole(msg, time){
|
||||||
var isScrolledDown = document.getElementById("consoleTextArea").scrollHeight - document.getElementById("consoleTextArea").scrollTop - 40 == $("#consoleTextArea").height();
|
const isScrolledDown = document.getElementById("consoleTextArea").scrollHeight - document.getElementById("consoleTextArea").scrollTop - 40 === $("#consoleTextArea").height();
|
||||||
|
|
||||||
//Write to div, replacing < to < (to avoid XSS) and replacing new line to br.
|
//Write to div, replacing < to < (to avoid XSS) and replacing new line to br.
|
||||||
msg = msg.replace(/</g, "<");
|
msg = msg.replace(/</g, "<");
|
||||||
msg = msg.replace(/(?:\r\n|\r|\n)/g, "<br>");
|
msg = msg.replace(/(?:\r\n|\r|\n)/g, "<br>");
|
||||||
@ -209,7 +213,7 @@ function writeToWebConsole(msg, time){
|
|||||||
$("#consoleTextArea").append(msg + "<br>");
|
$("#consoleTextArea").append(msg + "<br>");
|
||||||
|
|
||||||
if(isScrolledDown){
|
if(isScrolledDown){
|
||||||
var textarea = document.getElementById('consoleTextArea');
|
const textarea = document.getElementById('consoleTextArea');
|
||||||
textarea.scrollTop = textarea.scrollHeight;
|
textarea.scrollTop = textarea.scrollHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,8 +224,8 @@ function writeToWebConsole(msg, time){
|
|||||||
function writePlayerInfo(connected, maximum){
|
function writePlayerInfo(connected, maximum){
|
||||||
$("#connectedPlayers").text(connected);
|
$("#connectedPlayers").text(connected);
|
||||||
$("#maxPlayers").text(maximum);
|
$("#maxPlayers").text(maximum);
|
||||||
|
|
||||||
var percent = (connected/maximum)*100;
|
const percent = (connected / maximum) * 100;
|
||||||
$("#playerProgressBar").width(percent + "%");
|
$("#playerProgressBar").width(percent + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,16 +244,30 @@ function writeCpuInfo(usage){
|
|||||||
function writeRamInfo(free, used, total){
|
function writeRamInfo(free, used, total){
|
||||||
$("#usedRam").text(used);
|
$("#usedRam").text(used);
|
||||||
$("#totalRam").text(total);
|
$("#totalRam").text(total);
|
||||||
|
|
||||||
var percent = (used/total)*100;
|
const percent = (used / total) * 100;
|
||||||
$("#RamProgressBar").width(percent + "%");
|
$("#RamProgressBar").width(percent + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill TPS info card
|
||||||
|
*/
|
||||||
|
function writeTpsInfo(tps, max){
|
||||||
|
if(tps > 20) {
|
||||||
|
tps = 20;
|
||||||
|
}
|
||||||
|
$("#tps").text(tps);
|
||||||
|
$("#maxTps").text(max);
|
||||||
|
|
||||||
|
const percent = (tps / max) * 100;
|
||||||
|
$("#TpsProgressBar").width(percent + "%");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from WebConsoleConnector only.
|
* Called from WebConsoleConnector only.
|
||||||
*/
|
*/
|
||||||
function closedConnection(serverName){
|
function closedConnection(serverName){
|
||||||
if(connectionManager.activeConnection.serverName == serverName){
|
if(connectionManager.activeConnection.serverName === serverName){
|
||||||
//Disable command input and button
|
//Disable command input and button
|
||||||
$("#commandInput").prop("disabled", true);
|
$("#commandInput").prop("disabled", true);
|
||||||
$("#sendCommandButton").prop("disabled", true);
|
$("#sendCommandButton").prop("disabled", true);
|
||||||
@ -288,13 +306,13 @@ function updateServerList(){
|
|||||||
$('.servermenuitem').remove();
|
$('.servermenuitem').remove();
|
||||||
|
|
||||||
//Add all servers
|
//Add all servers
|
||||||
var servers = persistenceManager.getAllServers();
|
const servers = persistenceManager.getAllServers();
|
||||||
for(var i = 0; i < servers.length; i++){
|
for(let i = 0; i < servers.length; i++){
|
||||||
$('#ServerListDropDown').append('<a class="dropdown-item servermenuitem" href="#" onclick="openServer(\'' + servers[i].serverName + '\')">' + servers[i].serverName.replace(/</g,"<").replace(/>/g,">").replace(/'/g,"").replace(/"/g,"") + '</a>');
|
$('#ServerListDropDown').append('<a class="dropdown-item servermenuitem" href="#" onclick="openServer(\'' + servers[i].serverName + '\')">' + servers[i].serverName.replace(/</g,"<").replace(/>/g,">").replace(/'/g,"").replace(/"/g,"") + '</a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Show a "no servers" message when no servers are added
|
//Show a "no servers" message when no servers are added
|
||||||
if(servers.length == 0){
|
if(servers.length === 0){
|
||||||
$('#ServerListDropDown').append('<a class="dropdown-item servermenuitem disabled" href="#" id="noServersAdded">No servers added</a>');
|
$('#ServerListDropDown').append('<a class="dropdown-item servermenuitem disabled" href="#" id="noServersAdded">No servers added</a>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,11 @@ class WebConsoleManager {
|
|||||||
command: "RAMUSAGE",
|
command: "RAMUSAGE",
|
||||||
token: this.activeConnection.token,
|
token: this.activeConnection.token,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "TPS",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +34,9 @@ players-message = Connected {0} players for a maximum of {1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} free, {1} used, {2} maximum memory
|
ram-usage-message = {0} free, {1} used, {2} maximum memory
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = WebConsole version {0}.
|
webconsole-version = WebConsole version {0}.
|
||||||
webconsole-no-connections = There are no logged in WebConsole connections now.
|
webconsole-no-connections = There are no logged in WebConsole connections now.
|
||||||
|
@ -34,6 +34,9 @@ players-message = Je připojeno {0} hráčů z maxima {1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} volné, {1} použité, {2} maximální paměti
|
ram-usage-message = {0} volné, {1} použité, {2} maximální paměti
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = WebConsole verze {0}.
|
webconsole-version = WebConsole verze {0}.
|
||||||
webconsole-no-connections = Nejsou žádné WebConsole připojení.
|
webconsole-no-connections = Nejsou žádné WebConsole připojení.
|
||||||
|
@ -34,6 +34,9 @@ players-message = {0} von {1} Spieler sind verbunden.
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} frei, {1} benutzt, {2} maximal
|
ram-usage-message = {0} frei, {1} benutzt, {2} maximal
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks von {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = Die WebConsole Version ist {0}.
|
webconsole-version = Die WebConsole Version ist {0}.
|
||||||
webconsole-no-connections = Aktuell ist niemand mit der WebConsole verbunden
|
webconsole-no-connections = Aktuell ist niemand mit der WebConsole verbunden
|
||||||
|
@ -34,6 +34,9 @@ players-message = Connected {0} players for a maximum of {1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} free, {1} used, {2} maximum memory
|
ram-usage-message = {0} free, {1} used, {2} maximum memory
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = WebConsole version {0}.
|
webconsole-version = WebConsole version {0}.
|
||||||
webconsole-no-connections = There are no logged in WebConsole connections now.
|
webconsole-no-connections = There are no logged in WebConsole connections now.
|
||||||
|
@ -34,6 +34,9 @@ players-message = Actualmente conectados {0} jugadores de un máximo de {1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = Memoria: {0} libre, {1} usada, {2} maxima
|
ram-usage-message = Memoria: {0} libre, {1} usada, {2} maxima
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = WebConsole version {0}.
|
webconsole-version = WebConsole version {0}.
|
||||||
webconsole-no-connections = No hay ninguna conexión activa a WebConsole en este momento.
|
webconsole-no-connections = No hay ninguna conexión activa a WebConsole en este momento.
|
||||||
|
@ -34,6 +34,9 @@ players-message = Joueurs {0} connectés pour un maximum de {1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} gratuit, {1} utilisé, {2} mémoire maximale
|
ram-usage-message = {0} gratuit, {1} utilisé, {2} mémoire maximale
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = version WebConsole {0}.
|
webconsole-version = version WebConsole {0}.
|
||||||
webconsole-no-connections = Aucune connexion WebConsole n'est connectée maintenant.
|
webconsole-no-connections = Aucune connexion WebConsole n'est connectée maintenant.
|
||||||
|
@ -34,6 +34,9 @@ players-message = Connessi {0} players su un massimo di {1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} Libera, {1} Usata, {2} Memoria massima
|
ram-usage-message = {0} Libera, {1} Usata, {2} Memoria massima
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = Versione WebConsole {0}.
|
webconsole-version = Versione WebConsole {0}.
|
||||||
webconsole-no-connections = Non è stata effettuata ancora nessuna connessione tramite WebConsole.
|
webconsole-no-connections = Non è stata effettuata ancora nessuna connessione tramite WebConsole.
|
||||||
|
@ -34,6 +34,9 @@ players-message = 接続数 | {0} ,最大接続数 | {1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} 空き, {1} 使用済み, {2} 最大メモリ
|
ram-usage-message = {0} 空き, {1} 使用済み, {2} 最大メモリ
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = WebConsoleのバージョン {0}.
|
webconsole-version = WebConsoleのバージョン {0}.
|
||||||
webconsole-no-connections = 現在、WebConsoleのログイン接続はありません。
|
webconsole-no-connections = 現在、WebConsoleのログイン接続はありません。
|
||||||
|
@ -34,6 +34,9 @@ players-message = {0}/{1}명의 플레이어를 연결하였습니다
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} 여유, {1} 사용, {2} 최대
|
ram-usage-message = {0} 여유, {1} 사용, {2} 최대
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = WebConsole 버전 {0}.
|
webconsole-version = WebConsole 버전 {0}.
|
||||||
webconsole-no-connections = 현재 로그인된 사람이 없습니다.
|
webconsole-no-connections = 현재 로그인된 사람이 없습니다.
|
||||||
|
@ -34,6 +34,9 @@ players-message = {0} spelers verbonden voor een maximum van {1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} ongebruikt, {1} gebruikt, {2} maximaal geheugen
|
ram-usage-message = {0} ongebruikt, {1} gebruikt, {2} maximaal geheugen
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = WebConsole versie {0}.
|
webconsole-version = WebConsole versie {0}.
|
||||||
webconsole-no-connections = Er zijn nu geen ingelogde Web Console-verbindingen.
|
webconsole-no-connections = Er zijn nu geen ingelogde Web Console-verbindingen.
|
||||||
|
@ -34,6 +34,9 @@ players-message = Atualmente tem {0} jogador(es) de um total de {1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = Disponível: {0}, Consumo de RAM: {1} / {2}
|
ram-usage-message = Disponível: {0}, Consumo de RAM: {1} / {2}
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = WebConsole versão {0}.
|
webconsole-version = WebConsole versão {0}.
|
||||||
webconsole-no-connections = Atualmente não tem nenhum usuário conectado.
|
webconsole-no-connections = Atualmente não tem nenhum usuário conectado.
|
||||||
|
@ -34,6 +34,9 @@ players-message = Подключено {0} игроков из максимум
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} свободно, {1} используется, {2} макс. памяти
|
ram-usage-message = {0} свободно, {1} используется, {2} макс. памяти
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = Версия WebConsole {0}.
|
webconsole-version = Версия WebConsole {0}.
|
||||||
webconsole-no-connections = В настоящее время нет подключений к WebConsole.
|
webconsole-no-connections = В настоящее время нет подключений к WebConsole.
|
||||||
|
@ -34,6 +34,9 @@ players-message = {0} oyuncu bağlandı, toplam {1} oyuncu bağlanabilir.
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = {0} boş, {1} kullanılıyor, {2} maksimum bellek
|
ram-usage-message = {0} boş, {1} kullanılıyor, {2} maksimum bellek
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = WebConsole sürümü {0}.
|
webconsole-version = WebConsole sürümü {0}.
|
||||||
webconsole-no-connections = Şuanda oturum açılmış WebSocket bağlantısı yok.
|
webconsole-no-connections = Şuanda oturum açılmış WebSocket bağlantısı yok.
|
||||||
|
@ -34,6 +34,9 @@ players-message = {0}玩家連接,最多{1}
|
|||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = 空閒{0} , 已使用{1} , 最大內存{2}
|
ram-usage-message = 空閒{0} , 已使用{1} , 最大內存{2}
|
||||||
|
|
||||||
|
# TpsCommand.java
|
||||||
|
tps-message = {0} ticks from {1}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = 網站控制台版本 {0}.
|
webconsole-version = 網站控制台版本 {0}.
|
||||||
webconsole-no-connections = 現在沒有連接登錄網站控制台。
|
webconsole-no-connections = 現在沒有連接登錄網站控制台。
|
||||||
|
@ -23,7 +23,8 @@ import es.mesacarlos.webconsole.websocket.response.LoggedIn;
|
|||||||
import es.mesacarlos.webconsole.websocket.response.UnknownCommand;
|
import es.mesacarlos.webconsole.websocket.response.UnknownCommand;
|
||||||
|
|
||||||
public class WSServer extends WebSocketServer {
|
public class WSServer extends WebSocketServer {
|
||||||
private HashMap<String, WSCommand> commands = WSCommandFactory.getCommandsHashMap();
|
|
||||||
|
private final HashMap<String, WSCommand> commands = WSCommandFactory.getCommandsHashMap();
|
||||||
|
|
||||||
public WSServer(InetSocketAddress address) {
|
public WSServer(InetSocketAddress address) {
|
||||||
super(address);
|
super(address);
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package es.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
|
//------------------------------
|
||||||
|
//
|
||||||
|
// This class was developed by Rafael K.
|
||||||
|
// On 1/8/2022 at 10:22 PM
|
||||||
|
// In the project WebConsole
|
||||||
|
//
|
||||||
|
//------------------------------
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.Tps;
|
||||||
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
public class TpsCommand implements WSCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(WSServer wsServer, WebSocket conn, String params) {
|
||||||
|
try {
|
||||||
|
double tps = getTps()[0];
|
||||||
|
wsServer.sendToClient(conn, new Tps(Internationalization.getPhrase("tps-message", tps), tps));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Current server Tps
|
||||||
|
*/
|
||||||
|
public double[] getTps() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException {
|
||||||
|
Class<?> minecraftServerClass = Class.forName("net.minecraft.server.MinecraftServer");
|
||||||
|
Method getServerMethod = minecraftServerClass.getDeclaredMethod("getServer");
|
||||||
|
Object serverInstance = getServerMethod.invoke(null);
|
||||||
|
Field recentTpsField = serverInstance.getClass().getField("recentTps");
|
||||||
|
double[] recentTps = (double[]) recentTpsField.get(serverInstance);
|
||||||
|
for (int i = 0; i < recentTps.length; i++) {
|
||||||
|
recentTps[i] = Math.round(recentTps[i]);
|
||||||
|
}
|
||||||
|
return recentTps;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,6 +11,7 @@ public class WSCommandFactory {
|
|||||||
commands.put("PLAYERS", new PlayersCommand());
|
commands.put("PLAYERS", new PlayersCommand());
|
||||||
commands.put("CPUUSAGE", new CpuUsageCommand());
|
commands.put("CPUUSAGE", new CpuUsageCommand());
|
||||||
commands.put("RAMUSAGE", new RamUsageCommand());
|
commands.put("RAMUSAGE", new RamUsageCommand());
|
||||||
|
commands.put("TPS", new TpsCommand());
|
||||||
commands.put("READLOGFILE", new ReadLogFileCommand());
|
commands.put("READLOGFILE", new ReadLogFileCommand());
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@ package es.mesacarlos.webconsole.websocket.response;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
public class ConsoleOutput implements JSONOutput{
|
public class ConsoleOutput implements JSONOutput {
|
||||||
private String message;
|
|
||||||
private String time;
|
private final String message;
|
||||||
|
private final String time;
|
||||||
|
|
||||||
public ConsoleOutput(String message, String time) {
|
public ConsoleOutput(String message, String time) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
@ -2,9 +2,10 @@ package es.mesacarlos.webconsole.websocket.response;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
public class CpuUsage implements JSONOutput{
|
public class CpuUsage implements JSONOutput {
|
||||||
private String message;
|
|
||||||
private double usage;
|
private final String message;
|
||||||
|
private final double usage;
|
||||||
|
|
||||||
public CpuUsage(String message, double usage) {
|
public CpuUsage(String message, double usage) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
@ -4,8 +4,9 @@ import com.google.gson.JsonObject;
|
|||||||
|
|
||||||
import es.mesacarlos.webconsole.config.UserType;
|
import es.mesacarlos.webconsole.config.UserType;
|
||||||
|
|
||||||
public class LoggedIn implements JSONOutput{
|
public class LoggedIn implements JSONOutput {
|
||||||
private String message;
|
|
||||||
|
private final String message;
|
||||||
private String respondsTo;
|
private String respondsTo;
|
||||||
private String username;
|
private String username;
|
||||||
private UserType as;
|
private UserType as;
|
||||||
|
@ -2,8 +2,9 @@ package es.mesacarlos.webconsole.websocket.response;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
public class LoginRequired implements JSONOutput{
|
public class LoginRequired implements JSONOutput {
|
||||||
private String message;
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
public LoginRequired(String message) {
|
public LoginRequired(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
@ -5,11 +5,12 @@ import java.util.List;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
public class Players implements JSONOutput{
|
public class Players implements JSONOutput {
|
||||||
private String message;
|
|
||||||
private int connectedPlayers;
|
private final String message;
|
||||||
private int maxPlayers;
|
private final int connectedPlayers;
|
||||||
private List<String> connectedPlayersList;
|
private final int maxPlayers;
|
||||||
|
private final List<String> connectedPlayersList;
|
||||||
|
|
||||||
public Players(String message, int connectedPlayers, int maxPlayers, List<String> connectedPlayersList) {
|
public Players(String message, int connectedPlayers, int maxPlayers, List<String> connectedPlayersList) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
@ -3,10 +3,11 @@ package es.mesacarlos.webconsole.websocket.response;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
public class RamUsage implements JSONOutput {
|
public class RamUsage implements JSONOutput {
|
||||||
private String message;
|
|
||||||
private long free;
|
private final String message;
|
||||||
private long used;
|
private final long free;
|
||||||
private long max;
|
private final long used;
|
||||||
|
private final long max;
|
||||||
|
|
||||||
public RamUsage(String message, long free, long used, long max) {
|
public RamUsage(String message, long free, long used, long max) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
51
src/es/mesacarlos/webconsole/websocket/response/Tps.java
Normal file
51
src/es/mesacarlos/webconsole/websocket/response/Tps.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package es.mesacarlos.webconsole.websocket.response;
|
||||||
|
|
||||||
|
//------------------------------
|
||||||
|
//
|
||||||
|
// This class was developed by Rafael K.
|
||||||
|
// On 1/8/2022 at 10:23 PM
|
||||||
|
// In the project WebConsole
|
||||||
|
//
|
||||||
|
//------------------------------
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
public class Tps implements JSONOutput {
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
private final double tps;
|
||||||
|
|
||||||
|
public Tps(String message, double tps) {
|
||||||
|
this.message = message;
|
||||||
|
this.tps = tps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatusCode() {
|
||||||
|
return 1003;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets current server TPS
|
||||||
|
* @return Global Server TPS
|
||||||
|
*/
|
||||||
|
public double getTps() {
|
||||||
|
return tps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toJSON() {
|
||||||
|
JsonObject object = new JsonObject();
|
||||||
|
object.addProperty("status", getStatusCode());
|
||||||
|
object.addProperty("statusDescription", "TPS Usage");
|
||||||
|
object.addProperty("tps", getTps());
|
||||||
|
object.addProperty("message", getMessage());
|
||||||
|
return object.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,9 +2,10 @@ package es.mesacarlos.webconsole.websocket.response;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
public class UnknownCommand implements JSONOutput{
|
public class UnknownCommand implements JSONOutput {
|
||||||
private String message;
|
|
||||||
private String respondsTo;
|
private final String message;
|
||||||
|
private final String respondsTo;
|
||||||
|
|
||||||
public UnknownCommand(String message, String respondsTo) {
|
public UnknownCommand(String message, String respondsTo) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user