Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
544720331b | ||
![]() |
0b8bea51b9 | ||
![]() |
d2e5bcb293 | ||
![]() |
dc1ad6d418 | ||
![]() |
c5799af7dc | ||
![]() |
25ce2f6864 | ||
![]() |
d59fe2c467 | ||
![]() |
f0f263ebe0 | ||
![]() |
b284b00a9b | ||
![]() |
a2c595ccb3 | ||
![]() |
045c154f6c | ||
![]() |
b1847debbb | ||
![]() |
542448ad0b | ||
![]() |
10edee6226 | ||
![]() |
d5394144a3 | ||
![]() |
7d093b4800 | ||
![]() |
dc3208004f | ||
![]() |
c5b959b306 | ||
![]() |
8c65a31f1b | ||
![]() |
b60528b824 | ||
![]() |
f5a11bd7f4 | ||
![]() |
820baaca67 | ||
![]() |
be88747631 | ||
![]() |
832c801a60 | ||
![]() |
4dd842286a | ||
![]() |
b26deceeeb | ||
![]() |
01c4c18ef2 | ||
![]() |
6faf5c3892 | ||
![]() |
441c8851eb | ||
![]() |
65b3582427 | ||
![]() |
6503efb74d | ||
![]() |
cc245b8629 | ||
![]() |
f4e6b79733 | ||
![]() |
b7ca43284a | ||
![]() |
8efd97ba75 | ||
![]() |
211152a70d |
5
.gitignore
vendored
5
.gitignore
vendored
@ -68,4 +68,7 @@ local.properties
|
||||
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||
.cache-main
|
||||
.scala_dependencies
|
||||
.worksheet
|
||||
.worksheet
|
||||
|
||||
#idea
|
||||
.idea
|
11
README.md
11
README.md
@ -4,7 +4,7 @@
|
||||
[](https://github.com/mesacarlos/WebConsole/releases/latest)
|
||||

|
||||
|
||||
WebConsole is a Spigot plugin for Minecraft 1.8-1.16+ that allows 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.18+ that allows 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.
|
||||
|
||||
Don't worry about privacy or security: all data is stored in your browser locally and your PC will connect directly to your minecraft server. No intermediary web servers, just you and your MC server.
|
||||
|
||||
@ -14,7 +14,7 @@ Don't worry about privacy or security: all data is stored in your browser locall
|
||||
* Colors supported, for both Windows and Linux hosts. (Colors are represented different in each platform).
|
||||
* Real-time connected players, machine CPU and server RAM usage information.
|
||||
* Capable of keeping active connections to more than one server to keep retrieving console log in the background for them all.
|
||||
* English, Spanish, Chinese (thanks to Neubulae and OPhantomO), Czech (thanks to Tada), Deutsch (thanks to NoNamePro0), Dutch (thanks to Twockx), French (thanks to pickatchou999), Italian (thanks to AlexZap), Korean (thanks to XxPKBxX), Portuguese (thanks to AlexandreMuassab and Connect500BR), Russian (thanks to Stashenko) and Turkish (thanks to acarnd03) supported.
|
||||
* English, Spanish, Chinese (thanks to Neubulae and OPhantomO), Czech (thanks to Tada), Deutsch (thanks to NoNamePro0), Dutch (thanks to Twockx), French (thanks to pickatchou999), Italian (thanks to AlexZap), Japanese (thanks to kuroneko6423), Korean (thanks to XxPKBxX), Portuguese (thanks to AlexandreMuassab and Connect500BR), Russian (thanks to Stashenko) and Turkish (thanks to acarnd03) supported.
|
||||
* Free!
|
||||
|
||||

|
||||
@ -53,13 +53,12 @@ A explanation of the `host`, `port`, `language` and `passwords` fields follows:
|
||||
|
||||
`port`: A port where to run this plugin (cannot be the port you are using for Minecraft).
|
||||
|
||||
You can modify `language` to view console and command messages in your preferred language. Valid languages are English (`en`), Spanish (`es`), Chinese (`zh`), Czech (`cs`), Deutsch (`de`), Dutch (`nl`), French (`fr`), Italian (`it`), Korean (`ko`), Portuguese (`pt`), Russian (`ru`) and Turkish (`tr`). **IMPORTANT: There is a known issue with Microsoft Windows cmd that shows weird characters when using a language different than English. If you are using Windows to host your server, check [this wiki page](https://github.com/mesacarlos/WebConsole/wiki/Show-local-characters-in-Windows-Console) to solve the problem**.
|
||||
You can modify `language` to view console and command messages in your preferred language. Valid languages are English (`en`), Spanish (`es`), Chinese (`zh`), Czech (`cs`), Deutsch (`de`), Dutch (`nl`), French (`fr`), Italian (`it`), Japanese (`ja`) Korean (`ko`), Polskie (`pl`), Portuguese (`pt`), Russian (`ru`) and Turkish (`tr`). **IMPORTANT: There is a known issue with Microsoft Windows cmd that shows weird characters when using a language different than English. If you are using Windows to host your server, check [this wiki page](https://github.com/mesacarlos/WebConsole/wiki/Show-local-characters-in-Windows-Console) to solve the problem**.
|
||||
|
||||
From version 2.0 you can now create more than one user and set them as admin (Permission for both reading console and executing commands) or viewer (Permission for only reading console and CPU and RAM usage). This is configured using the `passwords` section:
|
||||
- By default, a user called user1 with password mySecurePassword is created, please replace or remove it as it is only served as an example.
|
||||
- If you want to create a admin user, type below `admin:` a row like `user: password` replacing user with your desired username and password with your password.
|
||||
- You can create as many admins as you want repeating this step.
|
||||
- If you want to create a view-only user, remove the `{}` after `viewer: ` and do the same process as for admin users below `viewer: `. You can also create as many viewers as needed.
|
||||
- If you want to create a view-only user, remove the `{}` after `viewer: ` and type below a row like `user: password` replacing user with your desired username and password with your password.
|
||||
- You can create as many admins or viewers as needed.
|
||||
- For all your admin users, you can enable a whitelist of commands under the commandWhitelist section of your user.
|
||||
|
||||
The rest of the fields are used for SSL configuration. You can learn how to activate SSL [here](https://github.com/mesacarlos/WebConsole/wiki/SSL-Configuration). SSL **is not** required for WebConsole to work, you can still use it without encription, unless you are hosting your client in a HTTPS server, in this case is mandatory to enable SSL in all your servers due to web browsers restrictions.
|
||||
|
@ -54,8 +54,10 @@
|
||||
<a class="dropdown-item" href="#" onclick="setLanguage('fr_FR')">Français</a>
|
||||
<a class="dropdown-item" href="#" onclick="setLanguage('it_IT')">Italiano</a>
|
||||
<a class="dropdown-item" href="#" onclick="setLanguage('pt_BR')">Português</a>
|
||||
<a class="dropdown-item" href="#" onclick="setLanguage('pl_PL')">Polskie</a>
|
||||
<a class="dropdown-item" href="#" onclick="setLanguage('ru_RU')">русский</a>
|
||||
<a class="dropdown-item" href="#" onclick="setLanguage('tr_TR')">Türk</a>
|
||||
<a class="dropdown-item" href="#" onclick="setLanguage('ja_JA')">日本語</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
@ -78,8 +80,8 @@
|
||||
<div class="container" id="serverContainer" style="display: none;">
|
||||
<h1 class="mt-4" id="serverTitle"></h1>
|
||||
|
||||
<div class="row p-3">
|
||||
<div class="col-sm-3 mb-2">
|
||||
<div class="row p-2">
|
||||
<div class="col-sm-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title" id="players_online">Players Online</h5>
|
||||
@ -90,7 +92,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3 mb-2">
|
||||
<div class="col-sm-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title" id="cpu_title">CPU</h5>
|
||||
@ -101,7 +103,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3 mb-2">
|
||||
<div class="col-sm-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title" id="ram_title">RAM</h5>
|
||||
@ -112,19 +114,32 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3 mb-2">
|
||||
<div class="col-sm-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p class="card-text">
|
||||
<span id="user_title">Logged as</span>
|
||||
<span id="loggedUsernameLabel">Unknown</span>
|
||||
(<span id="loggedUserTypeLabel">Unknown</span>)
|
||||
</p>
|
||||
<button type="button" class="btn btn-danger btn-sm" id="deleteServerButton">Delete server</button>
|
||||
<h5 class="card-title" id="tps_title">TPS</h5>
|
||||
<p class="card-text"><span id="tps">0</span> Ticks / <span id="maxTps">0</span> Ticks</p>
|
||||
<div class="progress flat-progressbar">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" id="TpsProgressBar"></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-body overflow-auto text-light bg-dark console" id="consoleTextArea"></div>
|
||||
@ -264,7 +279,7 @@
|
||||
<!-- Webpage footer -->
|
||||
<footer class="footer mt-auto py-3">
|
||||
<div class="container">
|
||||
<span class="text-muted">WebConsole v2.2 - <a href="https://github.com/mesacarlos/WebConsole">GitHub</a></span>
|
||||
<span class="text-muted">WebConsole v2.4 - <a href="https://github.com/mesacarlos/WebConsole">GitHub</a></span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@ -274,15 +289,15 @@
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- WebConsole JS Objects -->
|
||||
<script src="scripts/object/Setting.js?v=2.2.0"></script>
|
||||
<script src="scripts/object/WSServer.js?v=2.2.0"></script>
|
||||
<script src="scripts/object/Setting.js?v=2.4.0"></script>
|
||||
<script src="scripts/object/WSServer.js?v=2.4.0"></script>
|
||||
|
||||
<!-- WebConsole JS Scripts -->
|
||||
<script src="scripts/WebConsoleLanguage.js?v=2.2.0"></script>
|
||||
<script src="scripts/WebConsoleConnector.js?v=2.2.0"></script>
|
||||
<script src="scripts/WebConsoleManager.js?v=2.2.0"></script>
|
||||
<script src="scripts/WebConsolePersistenceManager.js?v=2.2.0"></script>
|
||||
<script src="scripts/WebConsole.js?v=2.2.0"></script>
|
||||
<script src="scripts/WebConsoleJqueryHandler.js?v=2.2.0"></script>
|
||||
<script src="scripts/WebConsoleLanguage.js?v=2.4.0"></script>
|
||||
<script src="scripts/WebConsoleConnector.js?v=2.4.0"></script>
|
||||
<script src="scripts/WebConsoleManager.js?v=2.4.0"></script>
|
||||
<script src="scripts/WebConsolePersistenceManager.js?v=2.4.0"></script>
|
||||
<script src="scripts/WebConsole.js?v=2.4.0"></script>
|
||||
<script src="scripts/WebConsoleJqueryHandler.js?v=2.4.0"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -5,14 +5,39 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Global variables
|
||||
*/
|
||||
var persistenceManager = new WebConsolePersistenceManager();
|
||||
var connectionManager = new WebConsoleManager();
|
||||
var lang;
|
||||
var autoPasswordCompleted = false; //When true, saved password was used. If a 401 is received, then saved password is not correct
|
||||
var statusCommandsInterval = -1;
|
||||
var commandHistoryIndex = -1; //Saves current command history index. -1 when not browsing history.
|
||||
* Global variables
|
||||
*/
|
||||
const persistenceManager = new WebConsolePersistenceManager();
|
||||
const connectionManager = new WebConsoleManager();
|
||||
let lang;
|
||||
let autoPasswordCompleted = false; //When true, saved password was used. If a 401 is received, then saved password is not correct
|
||||
let statusCommandsInterval = -1;
|
||||
let commandHistoryIndex = -1; //Saves current command history index. -1 when not browsing history.
|
||||
|
||||
/**
|
||||
* Load list of servers in file servers.json
|
||||
* and auto update in next request when file is changed
|
||||
*/
|
||||
function readServerList() {
|
||||
let hash = persistenceManager.getSetting('server:hash')
|
||||
|
||||
/**
|
||||
* Hash code function used for compare version of file servers.json
|
||||
* https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript
|
||||
*/
|
||||
const hashCode = s => s.split('').reduce((a,b)=>{a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
|
||||
|
||||
fetch('servers.json')
|
||||
.then(res => res.text())
|
||||
.then(json => {
|
||||
if (hash !== hashCode(json)) {
|
||||
persistenceManager.setSetting('server:hash', hashCode(json))
|
||||
JSON.parse(json).forEach(server => persistenceManager.saveServer(server))
|
||||
}
|
||||
})
|
||||
.then(updateServerList)
|
||||
.catch(() => console.info('Ignore load new list in file servers.json.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and show server to user
|
||||
@ -36,10 +61,10 @@ function openServer(serverName){
|
||||
connectionManager.loadConnection(serverName);
|
||||
|
||||
//Load saved messages
|
||||
var i;
|
||||
var messages = connectionManager.activeConnection.messages;
|
||||
let i;
|
||||
const messages = connectionManager.activeConnection.messages;
|
||||
for(i = 0; i < messages.length; i++){
|
||||
if(messages[i].status != 401){
|
||||
if(messages[i].status !== 401){
|
||||
onWebSocketsMessage(messages[i]);
|
||||
}
|
||||
}
|
||||
@ -63,7 +88,7 @@ function onWebSocketsMessage(message){
|
||||
$("#loggedUserTypeLabel").text(message.as);
|
||||
|
||||
//Disable command bar if user is viewer
|
||||
if(message.as.toLowerCase() == "viewer"){
|
||||
if(message.as.toLowerCase() === "viewer"){
|
||||
$("#commandInput").prop("disabled", true);
|
||||
$("#sendCommandButton").prop("disabled", true);
|
||||
}
|
||||
@ -81,7 +106,7 @@ function onWebSocketsMessage(message){
|
||||
break;
|
||||
case 401:
|
||||
//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){
|
||||
connectionManager.sendPassword(savedPwd);
|
||||
autoPasswordCompleted = true;
|
||||
@ -102,13 +127,17 @@ function onWebSocketsMessage(message){
|
||||
//RAM Usage
|
||||
writeRamInfo(message.free, message.used, message.max);
|
||||
break;
|
||||
case 1003:
|
||||
//Server TPS
|
||||
writeTpsInfo(message.tps, 20);
|
||||
break;
|
||||
default:
|
||||
console.log('Unknown server response:');
|
||||
}
|
||||
console.log(message);
|
||||
|
||||
//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(){
|
||||
connectionManager.askForInfo();
|
||||
}, 2500);
|
||||
@ -119,8 +148,8 @@ function onWebSocketsMessage(message){
|
||||
* Write to console
|
||||
*/
|
||||
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.
|
||||
msg = msg.replace(/</g, "<");
|
||||
msg = msg.replace(/(?:\r\n|\r|\n)/g, "<br>");
|
||||
@ -170,6 +199,32 @@ function writeToWebConsole(msg, time){
|
||||
|
||||
msg = msg.replace(/§r/g, "</span>"); //&r
|
||||
|
||||
//Color filter for MC 1.18 (Also easy :D)
|
||||
//span may not be closed every time but browsers will do for ourselves
|
||||
msg = msg.replace(/0/g, "<span style='color: #000000;'>"); //&0
|
||||
msg = msg.replace(/1/g, "<span style='color: #0000AA;'>"); //&1
|
||||
msg = msg.replace(/2/g, "<span style='color: #00AA00;'>"); //&2
|
||||
msg = msg.replace(/3/g, "<span style='color: #00AAAA;'>"); //&3
|
||||
msg = msg.replace(/4/g, "<span style='color: #AA0000;'>"); //&4
|
||||
msg = msg.replace(/5/g, "<span style='color: #AA00AA;'>"); //&5
|
||||
msg = msg.replace(/6/g, "<span style='color: #FFAA00;'>"); //&6
|
||||
msg = msg.replace(/7/g, "<span style='color: #AAAAAA;'>"); //&7
|
||||
msg = msg.replace(/8/g, "<span style='color: #555555;'>"); //&8
|
||||
msg = msg.replace(/9/g, "<span style='color: #5555FF;'>"); //&9
|
||||
msg = msg.replace(/a/g, "<span style='color: #55FF55;'>"); //&a
|
||||
msg = msg.replace(/b/g, "<span style='color: #55FFFF;'>"); //&b
|
||||
msg = msg.replace(/c/g, "<span style='color: #FF5555;'>"); //&c
|
||||
msg = msg.replace(/d/g, "<span style='color: #FF55FF;'>"); //&d
|
||||
msg = msg.replace(/e/g, "<span style='color: #FFFF55;'>"); //&e
|
||||
msg = msg.replace(/f/g, "<span style='color: #FFFFFF;'>"); //&f
|
||||
|
||||
msg = msg.replace(/l/g, "<span style='font-weight:bold;'>"); //&l
|
||||
msg = msg.replace(/m/g, "<span style='text-decoration: line-through;'>"); //&m
|
||||
msg = msg.replace(/n/g, "<span style='text-decoration: underline;'>"); //&n
|
||||
msg = msg.replace(/o/g, "<span style='font-style: italic;'>"); //&o
|
||||
|
||||
msg = msg.replace(/r/g, "</span>"); //&r
|
||||
|
||||
//Append datetime if enabled
|
||||
if(persistenceManager.getSetting("dateTimePrefix")){
|
||||
if(typeof time !== 'undefined' && time !== null) //if time is present and not null
|
||||
@ -184,7 +239,7 @@ function writeToWebConsole(msg, time){
|
||||
$("#consoleTextArea").append(msg + "<br>");
|
||||
|
||||
if(isScrolledDown){
|
||||
var textarea = document.getElementById('consoleTextArea');
|
||||
const textarea = document.getElementById('consoleTextArea');
|
||||
textarea.scrollTop = textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
@ -195,8 +250,8 @@ function writeToWebConsole(msg, time){
|
||||
function writePlayerInfo(connected, maximum){
|
||||
$("#connectedPlayers").text(connected);
|
||||
$("#maxPlayers").text(maximum);
|
||||
|
||||
var percent = (connected/maximum)*100;
|
||||
|
||||
const percent = (connected / maximum) * 100;
|
||||
$("#playerProgressBar").width(percent + "%");
|
||||
}
|
||||
|
||||
@ -215,16 +270,30 @@ function writeCpuInfo(usage){
|
||||
function writeRamInfo(free, used, total){
|
||||
$("#usedRam").text(used);
|
||||
$("#totalRam").text(total);
|
||||
|
||||
var percent = (used/total)*100;
|
||||
|
||||
const percent = (used / total) * 100;
|
||||
$("#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.
|
||||
*/
|
||||
function closedConnection(serverName){
|
||||
if(connectionManager.activeConnection.serverName == serverName){
|
||||
if(connectionManager.activeConnection.serverName === serverName){
|
||||
//Disable command input and button
|
||||
$("#commandInput").prop("disabled", true);
|
||||
$("#sendCommandButton").prop("disabled", true);
|
||||
@ -263,13 +332,13 @@ function updateServerList(){
|
||||
$('.servermenuitem').remove();
|
||||
|
||||
//Add all servers
|
||||
var servers = persistenceManager.getAllServers();
|
||||
for(var i = 0; i < servers.length; i++){
|
||||
const servers = persistenceManager.getAllServers();
|
||||
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>');
|
||||
}
|
||||
|
||||
//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>');
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ $(document).ready(function() {
|
||||
$("#serverContainer").hide();
|
||||
persistenceManager.initializeSettings();
|
||||
setLanguage(persistenceManager.getLanguage());
|
||||
readServerList();
|
||||
updateServerList();
|
||||
|
||||
//Check SSL host
|
||||
@ -223,4 +224,4 @@ $("#showDateSettingsSwitch").click(function() {
|
||||
$("#readLogFileSwitch").click(function() {
|
||||
//Update modal switches and boxes with saved settings
|
||||
persistenceManager.setSetting("retrieveLogFile", $("#readLogFileSwitch").is(":checked"));
|
||||
});
|
||||
});
|
||||
|
@ -501,6 +501,88 @@ function setLanguage(locale){
|
||||
"sendCommandButton": "Gönder"
|
||||
}
|
||||
break;
|
||||
case "ja_JA": //Credit to kuroneko6423 | https://kuroneko6423.com
|
||||
lang = {
|
||||
"navbarHomeLink": "ホーム",
|
||||
"home_header": "メニューからサーバーを選択",
|
||||
"home_description": "ナビゲーションバーを使って、新しいMinecraftサーバーを追加したり、以前に追加したサーバーに接続したりします。",
|
||||
"serversDropdown": "あなたのサーバー",
|
||||
"add_server": "サーバー追加",
|
||||
"noServersAdded": "追加されたサーバーはありません",
|
||||
"lang_dropdown": "言語",
|
||||
"addServerModalLongTitle": "新規サーバーの追加",
|
||||
"addServerModalSvName": "サーバー名:",
|
||||
"addServerModalSvIp": "サーバーIP:",
|
||||
"addServerModalSvPort": "WebConsoleポート:",
|
||||
"addServerModalSvSsl": "サーバーでSSLが有効になっている",
|
||||
"addServerModalSslAdvice": "HTTPSウェブサイトからの接続にはSSLが必要です。",
|
||||
"addServerModalClose": "閉じる",
|
||||
"saveAndConnectServerButton": "保存と接続",
|
||||
"passwordModalLongTitle": "パスワードが必要です",
|
||||
"passwordModalLabel": "パスワード:",
|
||||
"passwordModalRememberLabel": "パスワードの記憶",
|
||||
"passwordModalCloseButton": "閉じる",
|
||||
"passwordSendButton": "ログイン",
|
||||
"disconnectionModalLongTitle": "切断",
|
||||
"disconnectionModalDescription": "サーバーとの接続が切断されました:",
|
||||
"disconnectionModalsub1": "サーバーが意図的に閉じられました。",
|
||||
"disconnectionModalsub2": "ポートがホスト上で開かれていません。この場合、ポートチェッカーを使ってトラブルシューティングを行い、ファイアウォールやルーターを再確認してください。",
|
||||
"disconnectionModalCloseButton": "閉じる",
|
||||
"disconnectionModalWelcomeScreenButton": "ホームに戻る",
|
||||
"settingsLink": "設定",
|
||||
"settingsModalLongTitle": "WebConsole 設定",
|
||||
"showDateSettingsSwitchLabel": "各コンソールラインに時間を表示",
|
||||
"readLogFileSwitchLabel": "ログイン後にサーバーからフルログファイルを取得する",
|
||||
"settingsModalCloseButton": "了承",
|
||||
"players_online": "プレイヤーオンライン",
|
||||
"cpu_title": "CPU",
|
||||
"ram_title": "RAM",
|
||||
"user_title": "ログインします。",
|
||||
"deleteServerButton": "サーバーを削除",
|
||||
"sendCommandButton": "送信"
|
||||
}
|
||||
break;
|
||||
case "pl_PL": //Credit to gpewojan1
|
||||
lang = {
|
||||
"navbarHomeLink": "Strona główna",
|
||||
"home_header": "Wybierz serwer z menu",
|
||||
"home_description": "Użyj zakładki \"Twoje serwery\", aby dodać nowy serwer Minecraft lub połączyć się do serwera dodanego wcześniej",
|
||||
"serversDropdown": "Twoje serwery",
|
||||
"add_server": "Dodaj Serwer",
|
||||
"noServersAdded": "Nie dodano żadnych serwerów",
|
||||
"lang_dropdown": "Język",
|
||||
"addServerModalLongTitle": "Dodaj nowy serwer",
|
||||
"addServerModalSvName": "Nazwa serwera:",
|
||||
"addServerModalSvIp": "IP Serwera:",
|
||||
"addServerModalSvPort": "Port WebConsole:",
|
||||
"addServerModalSvSsl": "SSL jest włączony na tym serwerze",
|
||||
"addServerModalSslAdvice": "SSL jest wymagany do połączeń ze stronami HTTPS",
|
||||
"addServerModalClose": "Zamknij",
|
||||
"saveAndConnectServerButton": "Zapisz i połącz",
|
||||
"passwordModalLongTitle": "Hasło jest wymagane",
|
||||
"passwordModalLabel": "Hasło:",
|
||||
"passwordModalRememberLabel": "Zapamiętaj hasło",
|
||||
"passwordModalCloseButton": "Zamknij",
|
||||
"passwordSendButton": "Zaloguj się",
|
||||
"disconnectionModalLongTitle": "Rozłączono",
|
||||
"disconnectionModalDescription": "Połączenie z serwerem zostało zerwane. Możliwe powody:",
|
||||
"disconnectionModalsub1": "Serwer został wyłączony intencjonalnie.",
|
||||
"disconnectionModalsub2": "Port nie jest otworzony przez host. W tym przypadku sprawdź, czy port jest otwarty używając port checkera i sprawdź twój firewall oraz router.",
|
||||
"disconnectionModalCloseButton": "Zamknij",
|
||||
"disconnectionModalWelcomeScreenButton": "Strona główna",
|
||||
"settingsLink": "Ustawienia",
|
||||
"settingsModalLongTitle": "Ustawienia WebConsole",
|
||||
"showDateSettingsSwitchLabel": "Pokaż czas na każdej linijce w konsoli",
|
||||
"readLogFileSwitchLabel": "Pokaż pełny log z serwera po zalogowaniu się",
|
||||
"settingsModalCloseButton": "Ok",
|
||||
"players_online": "Gracze Online",
|
||||
"cpu_title": "Zużycie CPU",
|
||||
"ram_title": "Zużycie RAM",
|
||||
"user_title": "Zalogowano jako",
|
||||
"deleteServerButton": "Usuń serwer",
|
||||
"sendCommandButton": "Wyślij"
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console.error("No language set");
|
||||
}
|
||||
|
@ -97,6 +97,11 @@ class WebConsoleManager {
|
||||
command: "RAMUSAGE",
|
||||
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
|
||||
ram-usage-message = {0} free, {1} used, {2} maximum memory
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole version {0}.
|
||||
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
|
||||
ram-usage-message = {0} volné, {1} použité, {2} maximální paměti
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole verze {0}.
|
||||
webconsole-no-connections = Nejsou žádné WebConsole připojení.
|
||||
|
@ -34,6 +34,9 @@ players-message = {0} von {1} Spieler sind verbunden.
|
||||
# RamUsageCommand.java
|
||||
ram-usage-message = {0} frei, {1} benutzt, {2} maximal
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks von {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = Die WebConsole Version ist {0}.
|
||||
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
|
||||
ram-usage-message = {0} free, {1} used, {2} maximum memory
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole version {0}.
|
||||
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
|
||||
ram-usage-message = Memoria: {0} libre, {1} usada, {2} maxima
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole version {0}.
|
||||
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
|
||||
ram-usage-message = {0} gratuit, {1} utilisé, {2} mémoire maximale
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = version WebConsole {0}.
|
||||
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
|
||||
ram-usage-message = {0} Libera, {1} Usata, {2} Memoria massima
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = Versione WebConsole {0}.
|
||||
webconsole-no-connections = Non è stata effettuata ancora nessuna connessione tramite WebConsole.
|
||||
|
49
phrases_ja.properties
Normal file
49
phrases_ja.properties
Normal file
@ -0,0 +1,49 @@
|
||||
# WebConsole.java
|
||||
boot-error = WebSocket Serverの起動時にエラーが発生しました。
|
||||
|
||||
# WSServer.java
|
||||
connection-resumed-message = 接続されています。既にログイン、接続している方を切断してもう一度接続してみてください。
|
||||
connection-resumed-console = [WebConsole] から接続し、セッションを再開しました。 {0}
|
||||
connection-login-message = 接続開始、ログイン待ち...
|
||||
connection-login-console = [WebConsole] 接続され、ログインを待っています... {0}
|
||||
unknown-command-message = 不明、または存在しないコマンドです
|
||||
unknown-command-console = [WebConsole] シグナル "{0}" は有効ではないので処理されませんでした。プラグインやウェブインターフェイスは最新のものを使用していますか?
|
||||
forbidden-message = Forbidden
|
||||
forbidden-console = [WebConsole] {0} は、ログインしていない状態で "{1}" を実行しようとしました!
|
||||
closed-connection = [WebConsole] 接続を閉じて、からログアウトしました。 {0}
|
||||
error-on-connection = [WebConsole] 接続時にエラーが発生しました。 {0}: {1}
|
||||
started-websocket = [WebConsole] WebSocketサーバが正常に起動しました。
|
||||
error-disconnected-client = [WebConsole] 切断された WebSocket クライアントにメッセージを送信しようとしました。
|
||||
|
||||
# CpuUsageCommand.java
|
||||
cpu-usage-message = Usage is {0}%
|
||||
|
||||
# ExecCommand.java
|
||||
no-send-permission-console = [WebConsole] {0} は勝手に {1} を実行しようとしましたが権限がないためはじかれました。
|
||||
cmd-executed-console = [WebConsole] {0} 実行 "{1}".
|
||||
|
||||
# LogInCommand.java
|
||||
login-sucessful-message = ログイン
|
||||
login-sucessful-console = [WebConsole] {0} ログインに成功しました。
|
||||
login-failed-message = パスワードが正しくありません、もう一度お試しください。
|
||||
login-failed-console = [WebConsole] ログイン時にパスワードが正しくないです。 {0}
|
||||
|
||||
# PlayersCommand.java
|
||||
players-message = 接続数 | {0} ,最大接続数 | {1}
|
||||
|
||||
# RamUsageCommand.java
|
||||
ram-usage-message = {0} 空き, {1} 使用済み, {2} 最大メモリ
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsoleのバージョン {0}.
|
||||
webconsole-no-connections = 現在、WebConsoleのログイン接続はありません。
|
||||
webconsole-active-connections = WebConsoleに接続しました。:
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = latest.logファイルの読み込みエラーが発生しました
|
||||
|
||||
# User.java
|
||||
user-tostring = User {0} from {1} as {2}
|
@ -34,6 +34,9 @@ players-message = {0}/{1}명의 플레이어를 연결하였습니다
|
||||
# RamUsageCommand.java
|
||||
ram-usage-message = {0} 여유, {1} 사용, {2} 최대
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole 버전 {0}.
|
||||
webconsole-no-connections = 현재 로그인된 사람이 없습니다.
|
||||
|
@ -34,6 +34,9 @@ players-message = {0} spelers verbonden voor een maximum van {1}
|
||||
# RamUsageCommand.java
|
||||
ram-usage-message = {0} ongebruikt, {1} gebruikt, {2} maximaal geheugen
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole versie {0}.
|
||||
webconsole-no-connections = Er zijn nu geen ingelogde Web Console-verbindingen.
|
||||
|
46
phrases_pl.properties
Normal file
46
phrases_pl.properties
Normal file
@ -0,0 +1,46 @@
|
||||
# WebConsole.java
|
||||
boot-error = Wystąpił błąd podczas włączanie serwera WebSocket.
|
||||
|
||||
# WSServer.java
|
||||
connection-resumed-message = Połączono i zalogowano! Witaj z powrotem!
|
||||
connection-resumed-console = [WebConsole] Połączono i wznowiono sesję z {0}
|
||||
connection-login-message = Połączenie rozpoczęte, oczekiwanie na zalogowanie
|
||||
connection-login-console = [WebConsole] Połączenie rozpoczęte, oczekiwanie na zalogowanie z {0}
|
||||
unknown-command-message = Nieznana komenda
|
||||
unknown-command-console = [WebConsole] Sygnał "{0}" nie został przetworzony, ponieważ jest nie poprawny. Czy twój plugin oraz klient są w najnowszej wersji?
|
||||
forbidden-message = Brak dostępu
|
||||
forbidden-console = [WebConsole] {0} spróbował uruchomić komendę "{1}" bez zalogowania się!
|
||||
closed-connection = [WebConsole] Zamknięto połączenie i wylogowano z {0}
|
||||
error-on-connection = [WebConsole] Wystąpił błąd na połączeniu {0}: {1}
|
||||
started-websocket = [WebConsole] Serwer WebSocket został uruchomiony pomyślnie.
|
||||
error-disconnected-client = [WebConsole] Podjęto próbę wysłania wiadomości do rozłączonego klienta WebSocket.
|
||||
|
||||
# CpuUsageCommand.java
|
||||
cpu-usage-message = Zużycie: {0}%
|
||||
|
||||
# ExecCommand.java
|
||||
no-send-permission-console = [WebConsole] {0} podjął próbę uruchominia komendy {1} bez poprawnych uprawnień.
|
||||
cmd-executed-console = [WebConsole] {0} uruchomił komendę "{1}".
|
||||
|
||||
# LogInCommand.java
|
||||
login-sucessful-message = Zalogowano
|
||||
login-sucessful-console = [WebConsole] {0} pomyślnie się zalogował.
|
||||
login-failed-message = Niepoprawne hasło, spróbuj ponownie.
|
||||
login-failed-console = [WebConsole] Niepoprawne hasło podczas logowania z {0}
|
||||
|
||||
# PlayersCommand.java
|
||||
players-message = Połączono {0}/{1} graczy
|
||||
|
||||
# RamUsageCommand.java
|
||||
ram-usage-message = {0} wolne, {1} w użyciu. Maksymalne zużycie: {2}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = Wersja WebConsole: {0}.
|
||||
webconsole-no-connections = W tej chwili nikt nie jest połączony do WebConsole.
|
||||
webconsole-active-connections = Połączono do WebConsole z:
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = Wystąpił błąd podczas próby przeczytania pliku latest.log
|
||||
|
||||
# User.java
|
||||
user-tostring = Użytkownik {0} z {1} jako {2}
|
@ -34,6 +34,9 @@ players-message = Atualmente tem {0} jogador(es) de um total de {1}
|
||||
# RamUsageCommand.java
|
||||
ram-usage-message = Disponível: {0}, Consumo de RAM: {1} / {2}
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole versão {0}.
|
||||
webconsole-no-connections = Atualmente não tem nenhum usuário conectado.
|
||||
|
@ -34,6 +34,9 @@ players-message = Подключено {0} игроков из максимум
|
||||
# RamUsageCommand.java
|
||||
ram-usage-message = {0} свободно, {1} используется, {2} макс. памяти
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = Версия WebConsole {0}.
|
||||
webconsole-no-connections = В настоящее время нет подключений к WebConsole.
|
||||
|
@ -34,6 +34,9 @@ players-message = {0} oyuncu bağlandı, toplam {1} oyuncu bağlanabilir.
|
||||
# RamUsageCommand.java
|
||||
ram-usage-message = {0} boş, {1} kullanılıyor, {2} maksimum bellek
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole sürümü {0}.
|
||||
webconsole-no-connections = Şuanda oturum açılmış WebSocket bağlantısı yok.
|
||||
|
@ -34,6 +34,9 @@ players-message = {0}玩家連接,最多{1}
|
||||
# RamUsageCommand.java
|
||||
ram-usage-message = 空閒{0} , 已使用{1} , 最大內存{2}
|
||||
|
||||
# TpsCommand.java
|
||||
tps-message = {0} ticks from {1}
|
||||
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = 網站控制台版本 {0}.
|
||||
webconsole-no-connections = 現在沒有連接登錄網站控制台。
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: WebConsole
|
||||
main: es.mesacarlos.webconsole.WebConsole
|
||||
api-version: 1.13
|
||||
version: 2.2
|
||||
version: 2.4
|
||||
description: WebSocket-based web console
|
||||
author: Carlos Mesa
|
||||
commands:
|
||||
|
8
pom.xml
8
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>WebConsole</groupId>
|
||||
<artifactId>WebConsole</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>2.4</version>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
@ -73,12 +73,12 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.12.1</version>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.13.2</version>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
|
||||
<dependency>
|
||||
@ -90,7 +90,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -23,7 +23,8 @@ import es.mesacarlos.webconsole.websocket.response.LoggedIn;
|
||||
import es.mesacarlos.webconsole.websocket.response.UnknownCommand;
|
||||
|
||||
public class WSServer extends WebSocketServer {
|
||||
private HashMap<String, WSCommand> commands = WSCommandFactory.getCommandsHashMap();
|
||||
|
||||
private final HashMap<String, WSCommand> commands = WSCommandFactory.getCommandsHashMap();
|
||||
|
||||
public WSServer(InetSocketAddress address) {
|
||||
super(address);
|
||||
|
@ -0,0 +1,54 @@
|
||||
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 org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class TpsCommand implements WSCommand {
|
||||
private static final String mcVer = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
|
||||
@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 {
|
||||
try {
|
||||
Class<?> minecraftServerClass = Class.forName("net.minecraft.server." + mcVer + ".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;
|
||||
} catch (Exception e) {
|
||||
//If an uncaught exception is thrown, maybe it is because this method of getting TPS does not work in the MV version currently running..
|
||||
return new double[] { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -11,6 +11,7 @@ public class WSCommandFactory {
|
||||
commands.put("PLAYERS", new PlayersCommand());
|
||||
commands.put("CPUUSAGE", new CpuUsageCommand());
|
||||
commands.put("RAMUSAGE", new RamUsageCommand());
|
||||
commands.put("TPS", new TpsCommand());
|
||||
commands.put("READLOGFILE", new ReadLogFileCommand());
|
||||
return commands;
|
||||
}
|
||||
|
@ -2,9 +2,10 @@ package es.mesacarlos.webconsole.websocket.response;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class ConsoleOutput implements JSONOutput{
|
||||
private String message;
|
||||
private String time;
|
||||
public class ConsoleOutput implements JSONOutput {
|
||||
|
||||
private final String message;
|
||||
private final String time;
|
||||
|
||||
public ConsoleOutput(String message, String time) {
|
||||
this.message = message;
|
||||
|
@ -2,9 +2,10 @@ package es.mesacarlos.webconsole.websocket.response;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class CpuUsage implements JSONOutput{
|
||||
private String message;
|
||||
private double usage;
|
||||
public class CpuUsage implements JSONOutput {
|
||||
|
||||
private final String message;
|
||||
private final double usage;
|
||||
|
||||
public CpuUsage(String message, double usage) {
|
||||
this.message = message;
|
||||
|
@ -4,8 +4,9 @@ import com.google.gson.JsonObject;
|
||||
|
||||
import es.mesacarlos.webconsole.config.UserType;
|
||||
|
||||
public class LoggedIn implements JSONOutput{
|
||||
private String message;
|
||||
public class LoggedIn implements JSONOutput {
|
||||
|
||||
private final String message;
|
||||
private String respondsTo;
|
||||
private String username;
|
||||
private UserType as;
|
||||
|
@ -2,8 +2,9 @@ package es.mesacarlos.webconsole.websocket.response;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class LoginRequired implements JSONOutput{
|
||||
private String message;
|
||||
public class LoginRequired implements JSONOutput {
|
||||
|
||||
private final String message;
|
||||
|
||||
public LoginRequired(String message) {
|
||||
this.message = message;
|
||||
|
@ -5,11 +5,12 @@ import java.util.List;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class Players implements JSONOutput{
|
||||
private String message;
|
||||
private int connectedPlayers;
|
||||
private int maxPlayers;
|
||||
private List<String> connectedPlayersList;
|
||||
public class Players implements JSONOutput {
|
||||
|
||||
private final String message;
|
||||
private final int connectedPlayers;
|
||||
private final int maxPlayers;
|
||||
private final List<String> connectedPlayersList;
|
||||
|
||||
public Players(String message, int connectedPlayers, int maxPlayers, List<String> connectedPlayersList) {
|
||||
this.message = message;
|
||||
|
@ -3,10 +3,11 @@ package es.mesacarlos.webconsole.websocket.response;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class RamUsage implements JSONOutput {
|
||||
private String message;
|
||||
private long free;
|
||||
private long used;
|
||||
private long max;
|
||||
|
||||
private final String message;
|
||||
private final long free;
|
||||
private final long used;
|
||||
private final long max;
|
||||
|
||||
public RamUsage(String message, long free, long used, long max) {
|
||||
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;
|
||||
|
||||
public class UnknownCommand implements JSONOutput{
|
||||
private String message;
|
||||
private String respondsTo;
|
||||
public class UnknownCommand implements JSONOutput {
|
||||
|
||||
private final String message;
|
||||
private final String respondsTo;
|
||||
|
||||
public UnknownCommand(String message, String respondsTo) {
|
||||
this.message = message;
|
||||
|
Loading…
x
Reference in New Issue
Block a user