Compare commits
156 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 | ||
![]() |
7ef71ebdd1 | ||
![]() |
d0929adddd | ||
![]() |
b055b9b248 | ||
![]() |
e6d230c2d8 | ||
![]() |
896e659e93 | ||
![]() |
05e2706fa9 | ||
![]() |
0cb3156186 | ||
![]() |
e846ad6441 | ||
![]() |
378d96c504 | ||
![]() |
2cda25e281 | ||
![]() |
a6087d13c8 | ||
![]() |
d593cf379e | ||
![]() |
75a505c63f | ||
![]() |
55dd139746 | ||
![]() |
60666d8433 | ||
![]() |
7609179e24 | ||
![]() |
383b0e3420 | ||
![]() |
dd9003190a | ||
![]() |
d2696df7bc | ||
![]() |
27f769f6ac | ||
![]() |
7c4286f7df | ||
![]() |
ffe238e977 | ||
![]() |
05e225d507 | ||
![]() |
4dadd550a4 | ||
![]() |
613bfa7d6f | ||
![]() |
60e483c3c3 | ||
![]() |
06e75e274d | ||
![]() |
6fca4669e4 | ||
![]() |
7a1e5475bb | ||
![]() |
c00ef4a0f5 | ||
![]() |
deac072d54 | ||
![]() |
3316d0e450 | ||
![]() |
5703b8aa04 | ||
![]() |
db61ea7e80 | ||
![]() |
4865db233d | ||
![]() |
9add265d34 | ||
![]() |
dfe9851af4 | ||
![]() |
2c180a4bbf | ||
![]() |
c3451fb6a2 | ||
![]() |
5de27fe76e | ||
![]() |
cc65b123ab | ||
![]() |
fc4235074b | ||
![]() |
f177d1fe2d | ||
![]() |
45c3584061 | ||
![]() |
9680776275 | ||
![]() |
84e170dce2 | ||
![]() |
209244bd22 | ||
![]() |
d8c71045d2 | ||
![]() |
d1b158a0fe | ||
![]() |
2643999e8d | ||
![]() |
a5335b1e6e | ||
![]() |
8664fee1eb | ||
![]() |
71d5a698e5 | ||
![]() |
20910e8364 | ||
![]() |
f193be7ef2 | ||
![]() |
b0f362fd0b | ||
![]() |
bee430447a | ||
![]() |
ca9d85a757 | ||
![]() |
e92bfe2d38 | ||
![]() |
218422376d | ||
![]() |
ffe6181369 | ||
![]() |
0573c0b1e8 | ||
![]() |
d526206056 | ||
![]() |
d1e1909e49 | ||
![]() |
39b4ea5592 | ||
![]() |
67f282743e | ||
![]() |
66ef3badfd | ||
![]() |
b7e1478991 | ||
![]() |
8ebac6a33d | ||
![]() |
a54230b035 | ||
![]() |
8aaa0f9efb | ||
![]() |
caff280350 | ||
![]() |
d6c0ad99da | ||
![]() |
ed2cd71a61 | ||
![]() |
1e23c1df29 | ||
![]() |
6af86a45e8 | ||
![]() |
5c833246d8 | ||
![]() |
14844dd95d | ||
![]() |
5d3b414dba | ||
![]() |
c989947369 | ||
![]() |
50956e8be7 | ||
![]() |
2d124942be | ||
![]() |
3db4689f80 | ||
![]() |
6d4c601a3e | ||
![]() |
9dd62bd0c5 | ||
![]() |
d6874e44e9 | ||
![]() |
1aeb8ea1e7 | ||
![]() |
188ea53481 | ||
![]() |
6dbf2a87fc | ||
![]() |
b4a2c63ab4 | ||
![]() |
7d35f04d61 | ||
![]() |
2ac1f0f40d | ||
![]() |
bfbb411d7c | ||
![]() |
a04fa7cbf6 | ||
![]() |
3716a31b2c | ||
![]() |
01ceb62047 | ||
![]() |
15265c50c2 | ||
![]() |
4fc298c4c5 | ||
![]() |
0f64720f12 | ||
![]() |
5605763d8f | ||
![]() |
d3e2d08b8b | ||
![]() |
1ee25b2035 | ||
![]() |
c66faf1021 | ||
![]() |
ca33489af1 | ||
![]() |
aa6edfd0f0 | ||
![]() |
69b10a8514 | ||
![]() |
81b5389b30 | ||
![]() |
206f62f81f | ||
![]() |
02c4fd9a63 | ||
![]() |
227a3a8df3 | ||
![]() |
94a8831495 | ||
![]() |
2e238027bb | ||
![]() |
17acf70e04 | ||
![]() |
16ac86b5dd | ||
![]() |
f3aad57148 | ||
![]() |
cb9027c42a | ||
![]() |
f3ec1c5149 | ||
![]() |
c5e51af034 | ||
![]() |
5a3e5a3a84 | ||
![]() |
475b9951c1 |
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [master]
|
||||||
|
schedule:
|
||||||
|
- cron: '0 6 * * 6'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
# Override automatic language detection by changing the below list
|
||||||
|
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||||
|
language: ['javascript', 'java']
|
||||||
|
# Learn more...
|
||||||
|
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# We must fetch at least the immediate parents so that if this is
|
||||||
|
# a pull request then we can checkout the head.
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
# If this run was triggered by a pull request event, then checkout
|
||||||
|
# the head of the pull request instead of the merge commit.
|
||||||
|
- run: git checkout HEAD^2
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -69,3 +69,6 @@ local.properties
|
|||||||
.cache-main
|
.cache-main
|
||||||
.scala_dependencies
|
.scala_dependencies
|
||||||
.worksheet
|
.worksheet
|
||||||
|
|
||||||
|
#idea
|
||||||
|
.idea
|
103
API_js/WebConsoleAPI.js
Normal file
103
API_js/WebConsoleAPI.js
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/**
|
||||||
|
WebConsole API for WebConsole
|
||||||
|
Used to manage active connections
|
||||||
|
https://github.com/mesacarlos
|
||||||
|
2019-2020 Carlos Mesa under MIT License.
|
||||||
|
*/
|
||||||
|
class WebConsoleAPI {
|
||||||
|
constructor(serverURI){
|
||||||
|
this.activeConnection = new WebConsoleConnector(serverURI);
|
||||||
|
this.activeConnection.subscribe(this.onMsg);
|
||||||
|
this.activeConnection.connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send password to server
|
||||||
|
*/
|
||||||
|
login(pwd){
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "LOGIN",
|
||||||
|
params: pwd
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send console command to server
|
||||||
|
*/
|
||||||
|
sendConsoleCmd(cmd){
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "EXEC",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
params: cmd
|
||||||
|
});
|
||||||
|
|
||||||
|
this.activeConnection.commands.push(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asks server for CPU, RAM and players info
|
||||||
|
*/
|
||||||
|
askForInfo(){
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "PLAYERS",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "CPUUSAGE",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "RAMUSAGE",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asks server for full latest.log
|
||||||
|
*/
|
||||||
|
askForLogs(){
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "READLOGFILE",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is executed when a message is received from the server
|
||||||
|
*/
|
||||||
|
onMsg(message){
|
||||||
|
//Print JSON to console. You may remove this line:
|
||||||
|
console.log(message);
|
||||||
|
|
||||||
|
//Type your code inside the switch cases:
|
||||||
|
switch (message.status) {
|
||||||
|
case 10:
|
||||||
|
//Console Output
|
||||||
|
//Info: The weird characters you probably get are the color indicators. Check the link below to learn how the official client parses them
|
||||||
|
//https://github.com/mesacarlos/WebConsole/blob/383b0e3420a948a61c7935ff84f40ff159fbd466/client/scripts/WebConsole.js#L128
|
||||||
|
break;
|
||||||
|
case 200:
|
||||||
|
//LoggedIn
|
||||||
|
break;
|
||||||
|
case 400:
|
||||||
|
//Unknown Command
|
||||||
|
break;
|
||||||
|
case 401:
|
||||||
|
//Waiting for login...
|
||||||
|
break;
|
||||||
|
case 1000:
|
||||||
|
//Connected players info
|
||||||
|
break;
|
||||||
|
case 1001:
|
||||||
|
//Cpu Usage info
|
||||||
|
break;
|
||||||
|
case 1002:
|
||||||
|
//RAM Usage info
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log('Unknown server response:');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
API_js/WebConsoleConnector.js
Normal file
96
API_js/WebConsoleConnector.js
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/**
|
||||||
|
WebConsole Connector for WebConsole
|
||||||
|
Used to connect to WebSocketsServer
|
||||||
|
https://github.com/mesacarlos
|
||||||
|
2019-2020 Carlos Mesa under MIT License.
|
||||||
|
*/
|
||||||
|
class WebConsoleConnector {
|
||||||
|
|
||||||
|
constructor(serverURI) {
|
||||||
|
this.serverURI = serverURI;
|
||||||
|
this.token;
|
||||||
|
this.subscribers = []; //List of functions called when a new message arrive
|
||||||
|
this.messages = []; //All messages retrieved since connection start
|
||||||
|
this.commands = []; //EXEC Commands sent by user to this server
|
||||||
|
this.isLogged = false; //Is logged in with valid pasword or not
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to WebSocket
|
||||||
|
*/
|
||||||
|
connect(){
|
||||||
|
var connector = this;
|
||||||
|
this.websocket = new WebSocket(this.serverURI);
|
||||||
|
this.websocket.onopen = function(evt) { connector.onOpen(evt) };
|
||||||
|
this.websocket.onclose = function(evt) { connector.onClose(evt) };
|
||||||
|
this.websocket.onmessage = function(evt) { connector.onMessage(evt) };
|
||||||
|
this.websocket.onerror = function(evt) { connector.onError(evt) };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal function
|
||||||
|
*/
|
||||||
|
onOpen(evt){
|
||||||
|
//Event: Connection opened
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal function
|
||||||
|
*/
|
||||||
|
onClose(evt){
|
||||||
|
console.log("Closed reason: " + evt.reason); //No reason provided (using chrome at least)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal function
|
||||||
|
*/
|
||||||
|
onMessage(evt){
|
||||||
|
var obj = JSON.parse(evt.data);
|
||||||
|
|
||||||
|
//Sucessfully connected? Save token
|
||||||
|
if(obj.status === 200){
|
||||||
|
this.token = obj.token;
|
||||||
|
this.isLogged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.notify(obj); //Notify all subscribers
|
||||||
|
this.messages.push(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal function
|
||||||
|
*/
|
||||||
|
onError(evt){
|
||||||
|
//Error occurred on the connection
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies a new message to all subscribers
|
||||||
|
*/
|
||||||
|
notify(obj){
|
||||||
|
this.subscribers.forEach(function(fun) {
|
||||||
|
fun(obj); //Calls function with this object
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a WebSocket command to Server
|
||||||
|
*/
|
||||||
|
sendToServer(message){
|
||||||
|
this.websocket.send(JSON.stringify(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a function to subscriber list
|
||||||
|
*/
|
||||||
|
subscribe(func){
|
||||||
|
this.subscribers.push(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unsubscribe all subscribers
|
||||||
|
*/
|
||||||
|
removeSubscribers(){
|
||||||
|
this.subscribers = [];
|
||||||
|
}
|
||||||
|
}
|
13
API_js/demo.html
Normal file
13
API_js/demo.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="WebConsoleAPI.js"></script>
|
||||||
|
<script src="WebConsoleConnector.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>API demo</h1>
|
||||||
|
<p>Open your console (F12) and type: var webconsoleapi = new WebConsoleAPI("ws://localhost:8080");</p>
|
||||||
|
<p>Replace ws:// with wss:// if your server have SSL enabled, localhost with your server IP and 8080 with your port.</p>
|
||||||
|
<p>Then call login(pwd) to login, sendConsoleCmd(cmd) to execute a command, etc...</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2019 Carlos Mesa
|
Copyright (c) 2019-2020 Carlos Mesa
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
95
README.md
95
README.md
@ -1,71 +1,82 @@
|
|||||||
# WebConsole
|
# WebConsole
|
||||||
|
|
||||||
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.
|
[](https://jenkins.mesacarlos.es/job/WebConsole/)
|
||||||
|
[](https://github.com/mesacarlos/WebConsole/releases/latest)
|
||||||
|

|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
#### Additional features:
|
||||||
|
* Multiuser system and View-only user mode: You can create multiple users and set their role to "Admin" or "Viewer". Users with the role "Viewer" can only read console, CPU and RAM usage. Users with role "Admin" can also run commands on the server. Useful if you want your friends to watch the server console but deny them from typing commands and ruining your server. Also, you can whitelist or blacklist some commands.
|
||||||
|
* Command history: Use up/down arrow keys to browse the command history, like in the real console.
|
||||||
|
* 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), 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!
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
## Plugin installation
|
## Plugin installation
|
||||||
|
|
||||||
1. Download plugin from [Releases](https://github.com/mesacarlos/WebConsole/releases)
|
1. Download plugin from [Releases](https://github.com/mesacarlos/WebConsole/releases).
|
||||||
2. Open and close your server to generate the config.yml file and open it. You will see something like the following:
|
2. Open and close your server to generate the config.yml file and open it. You will see something like the following:
|
||||||
|
|
||||||
> useSSL: false
|
useSSL: false
|
||||||
> StoreType: JKS
|
StoreType: JKS
|
||||||
> KeyStore: plugins/WebConsole/keystore.jks
|
KeyStore: plugins/WebConsole/keystore.jks
|
||||||
> StorePassword: storepassword
|
StorePassword: storepassword
|
||||||
> KeyPassword: keypassword
|
KeyPassword: keypassword
|
||||||
> host: localhost
|
host: 0.0.0.0
|
||||||
> port: 8080
|
port: 8080
|
||||||
> password: yourPasswordGoesHere
|
language: en
|
||||||
|
passwords:
|
||||||
Fill `host`, `port` and `password` values. They are, respectively, your server IP, a port where to run this plugin (cannot be the port you are using for Minecraft) and the login password. Password will be asked every time you connect to WebConsole.
|
admin:
|
||||||
|
user1:
|
||||||
|
password: mySecurePassword
|
||||||
|
commandWhitelist:
|
||||||
|
enabled: true
|
||||||
|
commandWhitelistActsAsBlacklist: false
|
||||||
|
whitelist:
|
||||||
|
- whisper
|
||||||
|
- gamemode survival
|
||||||
|
viewer: {}
|
||||||
|
|
||||||
|
|
||||||
#### SSL Configuration
|
|
||||||
|
|
||||||
If you want to use WebSockets Secure (An encrypted connection between Client and Server instead of sending plaintext) you need to enable it replacing `useSSL: false` to `useSSL: true` in your config.yml and generating your keystore.jks. You can achieve this by generating a selfsigned certificate or using a valid one, like a Let's Encrypt certificate.
|
A explanation of the `host`, `port`, `language` and `passwords` fields follows:
|
||||||
|
|
||||||
|
`host`: Leaving it as 0.0.0.0 will do the trick. If you experience issues , you can change this value to your device IP. If you are in a VPS or dedicated server (or you have a full public IP allocated for your device) type your public IP. If you are at your home (and you don't have a public IP assigned to your device) type your private IP, it is probably something like 192.168.xx.xx.
|
||||||
|
|
||||||
##### Selfsigned certificate
|
`port`: A port where to run this plugin (cannot be the port you are using for Minecraft).
|
||||||
|
|
||||||
The fast way, but only reccomended for testing purposes. Generate your certificate by running this command on your machine
|
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**.
|
||||||
|
|
||||||
> keytool -genkey -keyalg RSA -validity 3650 -keystore "keystore.jks" -storepass "**storepassword**" -keypass "**keypassword**" -alias "default" -dname "CN=127.0.0.1, OU=**MyOrgUnit**, O=**MyOrg**, L=**MyCity**, S=**MyRegion**, C=**MyCountry**"
|
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 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.
|
||||||
|
|
||||||
Remember to replace required values (the bold ones), so final command looks like this:
|
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.
|
||||||
|
|
||||||
> keytool -genkey -keyalg RSA -validity 3650 -keystore "keystore.jks" -storepass "myVerySecurePaSSword" -keypass "aVerySecurePaSSw0rdAgain" -alias "default" -dname "CN=127.0.0.1, OU=WebConsoleDevelopers, O=WebConsole, L=Madrid, S=Madrid, C=Spain"
|
|
||||||
|
|
||||||
Then, to enable connections from your browser remember to first navigate to https://localhost:8080/ (change port if you changed it before at config.yml) and skip the security warning (Click on connect anyway). This is required in order to allow your browser to connect to servers using your own selfsigned certificate. If you don´t follow this step, your browser will block connections to your WebSockets Server.
|
|
||||||
|
|
||||||
|
|
||||||
##### Let's Encrypt certificate (or any PEM certificates)
|
|
||||||
|
|
||||||
WebConsole does not support PEM certificates, so you will need to convert it to create your keystore.jks file. Follow the steps mentioned in [this guide](https://gist.github.com/xkr47/920ffe94f6a4c171ee59), also explained here:
|
|
||||||
|
|
||||||
1. Convert certificate chain + private key to the PKCS#12 file format. You will be asked for a password: Remember it as it will be the StorePassword required in your config.yml
|
|
||||||
> openssl pkcs12 -export -out keystore.pkcs12 -in fullchain.pem -inkey privkey.pem
|
|
||||||
|
|
||||||
2. convert PKCS#12 file into Java keystore format. You will be asked for another password. This time you are typing the KeyPassword, also required in config.yml
|
|
||||||
> keytool -importkeystore -srckeystore keystore.pkcs12 -srcstoretype PKCS12 -destkeystore keystore.jks
|
|
||||||
|
|
||||||
3. PKCS#12 file can be deleted
|
|
||||||
> rm keystore.pkcs12
|
|
||||||
|
|
||||||
4. Copy keystore.jks to your plugin folder (plugins/WebConsole/keystore.jks)
|
|
||||||
|
|
||||||
|
|
||||||
## Using web interface
|
## Using web interface
|
||||||
|
|
||||||
1. Download web interface (client.zip) from [Releases](https://github.com/mesacarlos/WebConsole/releases)
|
1. You can download web interface (client.zip) from [Releases](https://github.com/mesacarlos/WebConsole/releases) or, if you prefer, you can use my [WebConsole Hosted Clients](https://mesacarlos.es/webconsole/) webpage. You can host the client in a web server, or use it offline. That's up to you.
|
||||||
2. If you want, you can host it in a web server, or use it offline. That's up to you.
|
2. Open index.html if you downloaded the client or click on the latest version if you are using my Hosted Clients website.
|
||||||
3. To start adding servers, click on `Your servers`, and then `Add server`. Fill Server name, IP and WebConsole port (the one you placed into config.yml before), and you are ready to go. You will be prompted for password when connecting.
|
3. To start adding servers, click on `Your servers`, and then `Add server`. Fill Server name, IP and WebConsole port (the one you placed into config.yml before), and you are ready to go. You will be prompted for password when connecting.
|
||||||
|
|
||||||
|
## Check connected WebConsole clients
|
||||||
|
Since v1.3, you can use /WebConsole command to view how many clients are connected and their IP address. This is the only Minecraft command provided by this plugin. This command requires you to have `webconsole.webconsole` permission to execute it.
|
||||||
|
|
||||||
|
|
||||||
## Technical information
|
## Technical information
|
||||||
|
|
||||||
You can find how client and server comunicate [here](https://github.com/mesacarlos/WebConsole/wiki/WebSocket-commands-and-responses)
|
You can find how client and server comunicate [here](https://github.com/mesacarlos/WebConsole/wiki/WebSocket-commands-and-responses).
|
||||||
|
|
||||||
|
## Bugs, suggestions or problems configuring WebConsole?
|
||||||
|
You can open an issue on [GitHub](https://github.com/mesacarlos/WebConsole/issues) or ask me at [Spigot forums](https://www.spigotmc.org/threads/webconsole.390291/).
|
BIN
client/favicon.png
Normal file
BIN
client/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -4,6 +4,8 @@
|
|||||||
<!-- Required meta tags -->
|
<!-- Required meta tags -->
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<link rel="shortcut icon" href="favicon.png">
|
||||||
|
|
||||||
|
|
||||||
<!-- Bootstrap CSS -->
|
<!-- Bootstrap CSS -->
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||||
@ -44,8 +46,23 @@
|
|||||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="langDropdown">
|
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="langDropdown">
|
||||||
<a class="dropdown-item" href="#" onclick="setLanguage('en_US')">English</a>
|
<a class="dropdown-item" href="#" onclick="setLanguage('en_US')">English</a>
|
||||||
<a class="dropdown-item" href="#" onclick="setLanguage('es_ES')">Español</a>
|
<a class="dropdown-item" href="#" onclick="setLanguage('es_ES')">Español</a>
|
||||||
|
<a class="dropdown-item" href="#" onclick="setLanguage('zh_CN')">中文</a>
|
||||||
|
<a class="dropdown-item" href="#" onclick="setLanguage('ko_KR')">한국어</a>
|
||||||
|
<a class="dropdown-item" href="#" onclick="setLanguage('cs_CZ')">Czech</a>
|
||||||
|
<a class="dropdown-item" href="#" onclick="setLanguage('de_DE')">Deutsche</a>
|
||||||
|
<a class="dropdown-item" href="#" onclick="setLanguage('nl_NL')">Dutch</a>
|
||||||
|
<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>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href data-toggle="modal" data-target="#settingsModal" id="settingsLink">Settings</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@ -63,8 +80,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>
|
||||||
@ -75,10 +92,10 @@
|
|||||||
</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">CPU</h5>
|
<h5 class="card-title" id="cpu_title">CPU</h5>
|
||||||
<p class="card-text" id="cpuInfo">0%</p>
|
<p class="card-text" id="cpuInfo">0%</p>
|
||||||
<div class="progress flat-progressbar">
|
<div class="progress flat-progressbar">
|
||||||
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" id="CpuProgressBar"></div>
|
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" id="CpuProgressBar"></div>
|
||||||
@ -86,10 +103,10 @@
|
|||||||
</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">RAM</h5>
|
<h5 class="card-title" id="ram_title">RAM</h5>
|
||||||
<p class="card-text"><span id="usedRam">0</span> MB / <span id="totalRam">0</span> MB</p>
|
<p class="card-text"><span id="usedRam">0</span> MB / <span id="totalRam">0</span> MB</p>
|
||||||
<div class="progress flat-progressbar">
|
<div class="progress flat-progressbar">
|
||||||
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" id="RamProgressBar"></div>
|
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;" id="RamProgressBar"></div>
|
||||||
@ -97,10 +114,33 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 mb-2">
|
<div class="col-sm-3">
|
||||||
<button type="button" class="btn btn-danger" id="deleteServerButton">Delete server</button>
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<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>
|
||||||
|
</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>
|
||||||
</div>
|
</div>
|
||||||
@ -124,28 +164,29 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form>
|
<form id="addServerForm">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="server-name" class="col-form-label" id="addServerModalSvName">Server name:</label>
|
<label for="server-name" class="col-form-label" id="addServerModalSvName">Server name:</label>
|
||||||
<input type="text" class="form-control" id="server-name">
|
<input type="text" class="form-control" id="server-name" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="server-ip" class="col-form-label" id="addServerModalSvIp">Server IP:</label>
|
<label for="server-ip" class="col-form-label" id="addServerModalSvIp">Server IP:</label>
|
||||||
<input type="text" class="form-control" id="server-ip" placeholder="localhost">
|
<input type="text" class="form-control" id="server-ip" placeholder="localhost" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="server-port" class="col-form-label" id="addServerModalSvPort">Server port:</label>
|
<label for="server-port" class="col-form-label" id="addServerModalSvPort">Server port:</label>
|
||||||
<input type="number" class="form-control" id="server-port" placeholder="8080">
|
<input type="number" class="form-control" id="server-port" placeholder="8080" min="1" max="65535" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="checkbox" id="server-ssl">
|
<input class="form-check-input" type="checkbox" id="server-ssl">
|
||||||
<label class="form-check-label" for="server-ssl" id="addServerModalSvSsl">Server is SSL enabled</label>
|
<label class="form-check-label" for="server-ssl" id="addServerModalSvSsl">Server is SSL enabled</label>
|
||||||
|
<div class="text-danger" id="addServerModalSslAdvice"></div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="addServerModalClose">Close</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="addServerModalClose">Close</button>
|
||||||
<button type="button" class="btn btn-primary" data-dismiss="modal" id="saveAndConnectServerButton">Save and connect</button>
|
<button type="button" class="btn btn-primary" id="saveAndConnectServerButton">Save and connect</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -193,11 +234,43 @@
|
|||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body" id="disconnectionModalDescription">
|
<div class="modal-body">
|
||||||
Connection was lost with the server you were connected to. Moved back to welcome screen.
|
<span id="disconnectionModalDescription">Connection was lost with the server. This can be caused by:</span>
|
||||||
|
<ul>
|
||||||
|
<li id="disconnectionModalsub1">Server was closed intentionally.</li>
|
||||||
|
<li id="disconnectionModalsub2">Port is not opened on your host. In this case, troubleshoot using <a href="https://www.yougetsignal.com/tools/open-ports/">this tool</a> and recheck your firewall or router.</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-primary" data-dismiss="modal" id="disconnectionModalCloseButton">Close</button>
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="disconnectionModalWelcomeScreenButton">Welcome screen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Settings Modal -->
|
||||||
|
<div class="modal fade" id="settingsModal" tabindex="-1" role="dialog" aria-labelledby="settingsModalCenterTitle" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="settingsModalLongTitle">WebConsole Settings</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="settingsModalDescription">
|
||||||
|
<div class="custom-control custom-switch">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="showDateSettingsSwitch">
|
||||||
|
<label class="custom-control-label" for="showDateSettingsSwitch" id="showDateSettingsSwitchLabel">Show date and time on each console line</label>
|
||||||
|
</div>
|
||||||
|
<div class="custom-control custom-switch">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="readLogFileSwitch">
|
||||||
|
<label class="custom-control-label" for="readLogFileSwitch" id="readLogFileSwitchLabel">Retrieve full log file from server after login</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="settingsModalCloseButton">Done</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -206,7 +279,7 @@
|
|||||||
<!-- Webpage footer -->
|
<!-- Webpage footer -->
|
||||||
<footer class="footer mt-auto py-3">
|
<footer class="footer mt-auto py-3">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<span class="text-muted">WebConsole v1.1 (rev. 3) - <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>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
@ -215,12 +288,16 @@
|
|||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
<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.4.0"></script>
|
||||||
|
<script src="scripts/object/WSServer.js?v=2.4.0"></script>
|
||||||
|
|
||||||
<!-- WebConsole JS Scripts -->
|
<!-- WebConsole JS Scripts -->
|
||||||
<script src="scripts/WebConsoleLanguage.js"></script>
|
<script src="scripts/WebConsoleLanguage.js?v=2.4.0"></script>
|
||||||
<script src="scripts/WebConsoleConnector.js"></script>
|
<script src="scripts/WebConsoleConnector.js?v=2.4.0"></script>
|
||||||
<script src="scripts/WebConsoleManager.js"></script>
|
<script src="scripts/WebConsoleManager.js?v=2.4.0"></script>
|
||||||
<script src="scripts/WebConsolePersistenceManager.js"></script>
|
<script src="scripts/WebConsolePersistenceManager.js?v=2.4.0"></script>
|
||||||
<script src="scripts/WebConsole.js"></script>
|
<script src="scripts/WebConsole.js?v=2.4.0"></script>
|
||||||
<script src="scripts/WebConsoleJqueryHandler.js"></script>
|
<script src="scripts/WebConsoleJqueryHandler.js?v=2.4.0"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -1,30 +1,57 @@
|
|||||||
/**
|
/**
|
||||||
Main JS file for WebConsole.
|
Main JS file for WebConsole.
|
||||||
https://github.com/mesacarlos
|
https://github.com/mesacarlos
|
||||||
2019 Carlos Mesa under MIT License.
|
2019-2020 Carlos Mesa under MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
* 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
|
* Prepare and show server to user
|
||||||
*/
|
*/
|
||||||
function openServer(serverName){
|
function openServer(serverName){
|
||||||
//Hide welcome div if user is in welcome page
|
//Hide welcome div if user is not in welcome page
|
||||||
$("#welcomeContainer").hide();
|
$("#welcomeContainer").hide();
|
||||||
$("#serverContainer").show();
|
$("#serverContainer").show();
|
||||||
|
|
||||||
//Change server name and related info
|
//Change server name and related info
|
||||||
$("#serverTitle").text(serverName);
|
$("#serverTitle").text(serverName);
|
||||||
$("#consoleTextArea").text("");
|
$("#consoleTextArea").text("");
|
||||||
|
$("#commandInput").prop("disabled", false);
|
||||||
|
$("#sendCommandButton").prop("disabled", false);
|
||||||
|
|
||||||
//New server, new variables:
|
//New server, new variables:
|
||||||
autoPasswordCompleted = false;
|
autoPasswordCompleted = false;
|
||||||
@ -34,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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,11 +77,28 @@ function onWebSocketsMessage(message){
|
|||||||
switch (message.status) {
|
switch (message.status) {
|
||||||
case 10:
|
case 10:
|
||||||
//Console Output
|
//Console Output
|
||||||
writeToWebConsole(message.message);
|
writeToWebConsole(message.message, message.time);
|
||||||
break;
|
break;
|
||||||
case 200:
|
case 200:
|
||||||
//Processed
|
//LoggedIn
|
||||||
writeToWebConsole(message.message);
|
writeToWebConsole(message.message);
|
||||||
|
|
||||||
|
//Show user and permissions
|
||||||
|
$("#loggedUsernameLabel").text(message.username);
|
||||||
|
$("#loggedUserTypeLabel").text(message.as);
|
||||||
|
|
||||||
|
//Disable command bar if user is viewer
|
||||||
|
if(message.as.toLowerCase() === "viewer"){
|
||||||
|
$("#commandInput").prop("disabled", true);
|
||||||
|
$("#sendCommandButton").prop("disabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Read log file if enabled
|
||||||
|
if(connectionManager.activeConnection.isLogged === false){
|
||||||
|
connectionManager.activeConnection.isLogged = true;
|
||||||
|
if(persistenceManager.getSetting("retrieveLogFile") === true)
|
||||||
|
connectionManager.askForLogs();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 400:
|
case 400:
|
||||||
//Unknown Command
|
//Unknown Command
|
||||||
@ -62,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;
|
||||||
@ -73,6 +117,7 @@ function onWebSocketsMessage(message){
|
|||||||
case 1000:
|
case 1000:
|
||||||
//Players
|
//Players
|
||||||
writePlayerInfo(message.connectedPlayers, message.maxPlayers);
|
writePlayerInfo(message.connectedPlayers, message.maxPlayers);
|
||||||
|
connectionManager.activeConnection.players = JSON.parse(message.players);
|
||||||
break;
|
break;
|
||||||
case 1001:
|
case 1001:
|
||||||
//Cpu Usage
|
//Cpu Usage
|
||||||
@ -82,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);
|
||||||
@ -98,11 +147,11 @@ function onWebSocketsMessage(message){
|
|||||||
/**
|
/**
|
||||||
* Write to console
|
* Write to console
|
||||||
*/
|
*/
|
||||||
function writeToWebConsole(msg){
|
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>");
|
||||||
|
|
||||||
//Color filter for Windows (thanks to SuperPykkon)
|
//Color filter for Windows (thanks to SuperPykkon)
|
||||||
@ -150,10 +199,47 @@ function writeToWebConsole(msg){
|
|||||||
|
|
||||||
msg = msg.replace(/§r/g, "</span>"); //&r
|
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
|
||||||
|
msg = "[" + time + "] " + msg;
|
||||||
|
else if(typeof time !== 'undefined' && time === null) //if time is present and null
|
||||||
|
; //no time (is already printed)
|
||||||
|
else
|
||||||
|
msg = "[" + new Date().toLocaleTimeString() + "] " + msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$("#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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,7 +251,7 @@ 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 + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,21 +271,37 @@ 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){
|
||||||
backToHomepage();
|
//Disable command input and button
|
||||||
|
$("#commandInput").prop("disabled", true);
|
||||||
|
$("#sendCommandButton").prop("disabled", true);
|
||||||
|
|
||||||
//Inform user
|
//Inform user
|
||||||
$('#disconnectionModal').modal('show');
|
$('#disconnectionModal').modal('show');
|
||||||
}
|
}
|
||||||
connectionManager.deleteConnection(serverName);
|
connectionManager.deleteConnection(serverName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,13 +332,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 + '</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="#">No Servers added</a>');
|
$('#ServerListDropDown').append('<a class="dropdown-item servermenuitem disabled" href="#" id="noServersAdded">No servers added</a>');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,16 +2,19 @@
|
|||||||
WebConsole Connector for WebConsole
|
WebConsole Connector for WebConsole
|
||||||
Used to connect to WebSocketsServer
|
Used to connect to WebSocketsServer
|
||||||
https://github.com/mesacarlos
|
https://github.com/mesacarlos
|
||||||
2019 Carlos Mesa under MIT License.
|
2019-2020 Carlos Mesa under MIT License.
|
||||||
*/
|
*/
|
||||||
class WebConsoleConnector {
|
class WebConsoleConnector {
|
||||||
|
|
||||||
constructor(serverName, serverURI) {
|
constructor(serverName, serverURI) {
|
||||||
this.serverName = serverName;
|
this.serverName = serverName;
|
||||||
this.serverURI = serverURI;
|
this.serverURI = serverURI;
|
||||||
|
this.token;
|
||||||
this.subscribers = []; //List of functions called when a new message arrive
|
this.subscribers = []; //List of functions called when a new message arrive
|
||||||
this.messages = []; //All messages retrieved since connection start
|
this.messages = []; //All messages retrieved since connection start
|
||||||
this.commands = []; //EXEC Commands sent by user to this server
|
this.commands = []; //EXEC Commands sent by user to this server
|
||||||
|
this.players = []; //Connected users.
|
||||||
|
this.isLogged = false; //Is logged in with valid pasword or not
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,8 +33,7 @@ class WebConsoleConnector {
|
|||||||
* Internal function
|
* Internal function
|
||||||
*/
|
*/
|
||||||
onOpen(evt){
|
onOpen(evt){
|
||||||
//TODO Check que la version es correcta, y que es un WebSocket del plugin y no de otra cosa
|
//TODO Check version is correct, and this websocket server is a WebConsole WebSocket
|
||||||
//No es necesario notificar al usuario porque ya se recibe un console output de ello
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,6 +41,7 @@ class WebConsoleConnector {
|
|||||||
*/
|
*/
|
||||||
onClose(evt){
|
onClose(evt){
|
||||||
closedConnection(this.serverName);
|
closedConnection(this.serverName);
|
||||||
|
console.log("Closed reason: " + evt.reason); //No reason provided (using chrome at least)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,6 +49,11 @@ class WebConsoleConnector {
|
|||||||
*/
|
*/
|
||||||
onMessage(evt){
|
onMessage(evt){
|
||||||
var obj = JSON.parse(evt.data);
|
var obj = JSON.parse(evt.data);
|
||||||
|
|
||||||
|
|
||||||
|
if(obj.status === 200) //If is a LoggedIn response, save our token
|
||||||
|
this.token = obj.token;
|
||||||
|
|
||||||
this.notify(obj); //Notify all subscribers
|
this.notify(obj); //Notify all subscribers
|
||||||
this.messages.push(obj);
|
this.messages.push(obj);
|
||||||
}
|
}
|
||||||
@ -61,7 +69,7 @@ class WebConsoleConnector {
|
|||||||
* Sends a WebSocket command to Server
|
* Sends a WebSocket command to Server
|
||||||
*/
|
*/
|
||||||
sendToServer(message){
|
sendToServer(message){
|
||||||
this.websocket.send(message);
|
this.websocket.send(JSON.stringify(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
JS File containing all JQuery-related handlers
|
JS File containing all JQuery-related handlers
|
||||||
https://github.com/mesacarlos
|
https://github.com/mesacarlos
|
||||||
2019 Carlos Mesa under MIT License.
|
2019-2020 Carlos Mesa under MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9,16 +9,41 @@
|
|||||||
*/
|
*/
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#serverContainer").hide();
|
$("#serverContainer").hide();
|
||||||
updateServerList();
|
persistenceManager.initializeSettings();
|
||||||
setLanguage(persistenceManager.getLanguage());
|
setLanguage(persistenceManager.getLanguage());
|
||||||
|
readServerList();
|
||||||
|
updateServerList();
|
||||||
|
|
||||||
|
//Check SSL host
|
||||||
|
if (location.protocol != 'https:'){
|
||||||
|
$("#addServerModalSslAdvice").hide();
|
||||||
|
}else{
|
||||||
|
$("#server-ssl").prop('checked', true);
|
||||||
|
$("#server-ssl").prop("disabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Remove servers from persistence with invalid names. See v1.4-rev2 for details
|
||||||
|
var servers = persistenceManager.getAllServers();
|
||||||
|
for(var i = 0; i < servers.length; i++){
|
||||||
|
if(servers[i].serverName.includes("\'") || servers[i].serverName.includes("\"") || servers[i].serverName.includes("<") || servers[i].serverName.includes(">")){
|
||||||
|
persistenceManager.deleteServer(servers[i].serverName);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add server modal button click
|
* Add server modal button click
|
||||||
*/
|
*/
|
||||||
$("#saveAndConnectServerButton").click(function() {
|
$("#saveAndConnectServerButton").click(function() {
|
||||||
|
//Validate form data
|
||||||
|
var addServerForm = document.getElementById("addServerForm");
|
||||||
|
if(!addServerForm.checkValidity()){
|
||||||
|
addServerForm.classList.add('was-validated');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Save server
|
//Save server
|
||||||
var name = $("#server-name").val();
|
var name = $("#server-name").val().replace(/</g,"<").replace(/>/g,">").replace(/'/g,"").replace(/"/g,"");
|
||||||
var wcIp = $("#server-ip").val();
|
var wcIp = $("#server-ip").val();
|
||||||
var wcPort = $("#server-port").val();
|
var wcPort = $("#server-port").val();
|
||||||
var wcSsl = $("#server-ssl").prop('checked');
|
var wcSsl = $("#server-ssl").prop('checked');
|
||||||
@ -30,6 +55,10 @@ $("#saveAndConnectServerButton").click(function() {
|
|||||||
}
|
}
|
||||||
persistenceManager.saveServer(new WSServer(name, uri));
|
persistenceManager.saveServer(new WSServer(name, uri));
|
||||||
|
|
||||||
|
//Close modal
|
||||||
|
addServerForm.classList.remove('was-validated');
|
||||||
|
$("#addServerModal").modal('hide');
|
||||||
|
|
||||||
//Empty all modal values
|
//Empty all modal values
|
||||||
$("#server-name").val("");
|
$("#server-name").val("");
|
||||||
$("#server-ip").val("");
|
$("#server-ip").val("");
|
||||||
@ -95,7 +124,7 @@ $("#sendCommandButton").click(function() {
|
|||||||
/**
|
/**
|
||||||
* Enter or arrow down/up key on command input
|
* Enter or arrow down/up key on command input
|
||||||
*/
|
*/
|
||||||
$("#commandInput").on('keydown', function (e) {
|
$("#commandInput").on('keyup', function (e) {
|
||||||
if(e.which === 13){ //Detect enter key
|
if(e.which === 13){ //Detect enter key
|
||||||
//Disable textbox to prevent multiple submit
|
//Disable textbox to prevent multiple submit
|
||||||
$(this).attr("disabled", "disabled");
|
$(this).attr("disabled", "disabled");
|
||||||
@ -123,7 +152,10 @@ $("#commandInput").on('keydown', function (e) {
|
|||||||
$("#commandInput").val(connectionManager.activeConnection.commands[commandHistoryIndex + 1]);
|
$("#commandInput").val(connectionManager.activeConnection.commands[commandHistoryIndex + 1]);
|
||||||
commandHistoryIndex = commandHistoryIndex + 1;
|
commandHistoryIndex = commandHistoryIndex + 1;
|
||||||
}
|
}
|
||||||
|
}else if(e.which == 9){ //Detect tab key
|
||||||
|
//TODO Suggest user from connectionManager.activeConnection.players;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,3 +194,34 @@ $("#navbarHomeLink").click(function() {
|
|||||||
backToHomepage();
|
backToHomepage();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On DisconnectedModal, back to welcome screen clicked
|
||||||
|
*/
|
||||||
|
$("#disconnectionModalWelcomeScreenButton").click(function() {
|
||||||
|
backToHomepage();
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On Settings link clicked
|
||||||
|
*/
|
||||||
|
$("#settingsLink").click(function() {
|
||||||
|
//Update modal switches and boxes with saved settings
|
||||||
|
$("#showDateSettingsSwitch").prop("checked", persistenceManager.getSetting("dateTimePrefix"));
|
||||||
|
$("#readLogFileSwitch").prop("checked", persistenceManager.getSetting("retrieveLogFile"));
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On showDateSettingsSwitch switched
|
||||||
|
*/
|
||||||
|
$("#showDateSettingsSwitch").click(function() {
|
||||||
|
//Update modal switches and boxes with saved settings
|
||||||
|
persistenceManager.setSetting("dateTimePrefix", $("#showDateSettingsSwitch").is(":checked"));
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On readLogFileSwitch switched
|
||||||
|
*/
|
||||||
|
$("#readLogFileSwitch").click(function() {
|
||||||
|
//Update modal switches and boxes with saved settings
|
||||||
|
persistenceManager.setSetting("retrieveLogFile", $("#readLogFileSwitch").is(":checked"));
|
||||||
|
});
|
||||||
|
@ -2,26 +2,28 @@
|
|||||||
WebConsole Language Manager for WebConsole
|
WebConsole Language Manager for WebConsole
|
||||||
Used to save your preferred language into your browser
|
Used to save your preferred language into your browser
|
||||||
https://github.com/mesacarlos
|
https://github.com/mesacarlos
|
||||||
2019 Carlos Mesa under MIT License.
|
2019-2020 Carlos Mesa under MIT License.
|
||||||
*/
|
*/
|
||||||
function setLanguage(locale){
|
function setLanguage(locale){
|
||||||
//Save to persistence
|
//Save to persistence
|
||||||
persistenceManager.setLanguage(locale);
|
persistenceManager.setLanguage(locale);
|
||||||
//Set dialog phrases
|
//Set locale phrases
|
||||||
switch(locale){
|
switch(locale){
|
||||||
case "en_US":
|
case "en_US":
|
||||||
lang = {
|
lang = {
|
||||||
"home_link": "Home",
|
"navbarHomeLink": "Home",
|
||||||
"home_header": "Select a server from the menu",
|
"home_header": "Select a server from the menu",
|
||||||
"home_description": "Use the navigation bar to add a new Minecraft Server or connect to a previously added one.",
|
"home_description": "Use the navigation bar to add a new Minecraft Server or connect to a previously added one.",
|
||||||
"server_dropdown": "Your servers",
|
"serversDropdown": "Your servers",
|
||||||
"add_server": "Add Server",
|
"add_server": "Add Server",
|
||||||
|
"noServersAdded": "No servers added",
|
||||||
"lang_dropdown": "Language",
|
"lang_dropdown": "Language",
|
||||||
"addServerModalLongTitle": "Add a new server",
|
"addServerModalLongTitle": "Add a new server",
|
||||||
"addServerModalSvName": "Server name:",
|
"addServerModalSvName": "Server name:",
|
||||||
"addServerModalSvIp": "Server IP:",
|
"addServerModalSvIp": "Server IP:",
|
||||||
"addServerModalSvPort": "WebConsole port:",
|
"addServerModalSvPort": "WebConsole port:",
|
||||||
"addServerModalSvSsl": "Server is SSL enabled",
|
"addServerModalSvSsl": "SSL is enabled on the server",
|
||||||
|
"addServerModalSslAdvice": "SSL is required for connections made from HTTPS websites",
|
||||||
"addServerModalClose": "Close",
|
"addServerModalClose": "Close",
|
||||||
"saveAndConnectServerButton": "Save and connect",
|
"saveAndConnectServerButton": "Save and connect",
|
||||||
"passwordModalLongTitle": "Password required",
|
"passwordModalLongTitle": "Password required",
|
||||||
@ -30,25 +32,39 @@ function setLanguage(locale){
|
|||||||
"passwordModalCloseButton": "Close",
|
"passwordModalCloseButton": "Close",
|
||||||
"passwordSendButton": "Login",
|
"passwordSendButton": "Login",
|
||||||
"disconnectionModalLongTitle": "Disconnected",
|
"disconnectionModalLongTitle": "Disconnected",
|
||||||
"disconnectionModalDescription": "Connection was lost with the server you were connected to, probably caused by a server stop. Moved back to welcome screen.",
|
"disconnectionModalDescription": "Connection was lost with the server. This can be caused by:",
|
||||||
|
"disconnectionModalsub1": "Server was closed intentionally.",
|
||||||
|
"disconnectionModalsub2": "Port is not opened on your host. In this case, troubleshoot using a port checker and recheck your firewall or router.",
|
||||||
|
"disconnectionModalCloseButton": "Close",
|
||||||
|
"disconnectionModalWelcomeScreenButton": "Back to welcome page",
|
||||||
|
"settingsLink": "Settings",
|
||||||
|
"settingsModalLongTitle": "WebConsole Settings",
|
||||||
|
"showDateSettingsSwitchLabel": "Show time on each console line",
|
||||||
|
"readLogFileSwitchLabel": "Retrieve full log file from server after login",
|
||||||
|
"settingsModalCloseButton": "Done",
|
||||||
"players_online": "Players Online",
|
"players_online": "Players Online",
|
||||||
|
"cpu_title": "CPU",
|
||||||
|
"ram_title": "RAM usage",
|
||||||
|
"user_title": "Logged as",
|
||||||
"deleteServerButton": "Delete server",
|
"deleteServerButton": "Delete server",
|
||||||
"sendCommandButton": "Send"
|
"sendCommandButton": "Send"
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "es_ES":
|
case "es_ES":
|
||||||
lang = {
|
lang = {
|
||||||
"home_link": "Inicio",
|
"navbarHomeLink": "Inicio",
|
||||||
"home_header": "Selecciona un servidor del menú",
|
"home_header": "Selecciona un servidor del menú",
|
||||||
"home_description": "Usa la barra superior para añadir un nuevo servidor de Minecraft o para conectarte a un servidor añadido previamente.",
|
"home_description": "Usa la barra superior para añadir un nuevo servidor de Minecraft o para conectarte a un servidor añadido previamente.",
|
||||||
"server_dropdown": "Tus servidores",
|
"serversDropdown": "Tus servidores",
|
||||||
"add_server": "Añadir Server",
|
"add_server": "Añadir Server",
|
||||||
|
"noServersAdded": "Ningun servidor guardado",
|
||||||
"lang_dropdown": "Idioma",
|
"lang_dropdown": "Idioma",
|
||||||
"addServerModalLongTitle": "Añadir un nuevo servidor",
|
"addServerModalLongTitle": "Añadir un nuevo servidor",
|
||||||
"addServerModalSvName": "Nombre del servidor:",
|
"addServerModalSvName": "Nombre del servidor:",
|
||||||
"addServerModalSvIp": "IP del servidor:",
|
"addServerModalSvIp": "IP del servidor:",
|
||||||
"addServerModalSvPort": "Puerto WebConsole:",
|
"addServerModalSvPort": "Puerto WebConsole:",
|
||||||
"addServerModalSvSsl": "SSL está activado",
|
"addServerModalSvSsl": "SSL está activado",
|
||||||
|
"addServerModalSslAdvice": "Te estás conectando al cliente por HTTPS, por tanto SSL es obligatorio",
|
||||||
"addServerModalClose": "Cerrar",
|
"addServerModalClose": "Cerrar",
|
||||||
"saveAndConnectServerButton": "Guardar y conectar",
|
"saveAndConnectServerButton": "Guardar y conectar",
|
||||||
"passwordModalLongTitle": "Se necesita contraseña",
|
"passwordModalLongTitle": "Se necesita contraseña",
|
||||||
@ -57,37 +73,527 @@ function setLanguage(locale){
|
|||||||
"passwordModalCloseButton": "Cerrar",
|
"passwordModalCloseButton": "Cerrar",
|
||||||
"passwordSendButton": "Iniciar sesión",
|
"passwordSendButton": "Iniciar sesión",
|
||||||
"disconnectionModalLongTitle": "Desconectado",
|
"disconnectionModalLongTitle": "Desconectado",
|
||||||
"disconnectionModalDescription": "Se ha perdido la conexión con el servidor al que estabas conectado. Esto puede ser debido a que el servidor se ha cerrado. Se ha vuelto a la ventana principal.",
|
"disconnectionModalDescription": "Se perdió la conexión con el servidor. Esto puede deberse a:",
|
||||||
|
"disconnectionModalsub1": "El servidor se cerró intencionadamente.",
|
||||||
|
"disconnectionModalsub2": "El puerto no está abierto en el host. Utiliza un port checker para verificar que el puerto está abierto y comprueba tu firewall o router.",
|
||||||
|
"disconnectionModalCloseButton": "Cerrar",
|
||||||
|
"disconnectionModalWelcomeScreenButton": "Volver a pagina de inicio",
|
||||||
|
"settingsLink": "Configuración",
|
||||||
|
"settingsModalLongTitle": "Configuración de WebConsole",
|
||||||
|
"showDateSettingsSwitchLabel": "Mostrar hora en cada linea de consola",
|
||||||
|
"readLogFileSwitchLabel": "Leer log completo al iniciar sesión",
|
||||||
|
"settingsModalCloseButton": "Hecho",
|
||||||
"players_online": "Jugadores en línea",
|
"players_online": "Jugadores en línea",
|
||||||
|
"cpu_title": "CPU",
|
||||||
|
"ram_title": "RAM en uso",
|
||||||
|
"user_title": "Iniciado sesion como",
|
||||||
"deleteServerButton": "Borrar servidor",
|
"deleteServerButton": "Borrar servidor",
|
||||||
"sendCommandButton": "Enviar"
|
"sendCommandButton": "Enviar"
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "ru_RU": //Credit to Stashenko
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "Главная",
|
||||||
|
"home_header": "Выберите сервер из меню",
|
||||||
|
"home_description": "Используйте панель навигации, чтобы добавить новый сервер Minecraft или подключиться к ранее добавленному.",
|
||||||
|
"serversDropdown": "Ваши серверы",
|
||||||
|
"add_server": "Добавить сервер",
|
||||||
|
"noServersAdded": "Серверы не добавлены",
|
||||||
|
"lang_dropdown": "Язык",
|
||||||
|
"addServerModalLongTitle": "Добавить новый сервер",
|
||||||
|
"addServerModalSvName": "Название сервера:",
|
||||||
|
"addServerModalSvIp": "IP сервера:",
|
||||||
|
"addServerModalSvPort": "Порт WebConsole:",
|
||||||
|
"addServerModalSvSsl": "Сервер с поддержкой SSL",
|
||||||
|
"addServerModalSslAdvice": "SSL требуется для клиентских подключений HTTPS",
|
||||||
|
"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 "pt_BR": //Credit to AlexandreMuassab
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "Principal",
|
||||||
|
"home_header": "Selecione o seu servidor na aba acima.",
|
||||||
|
"home_description": "Use a barra de navegação para adicionar ou conectar-se entre os servidores.",
|
||||||
|
"serversDropdown": "Servidores",
|
||||||
|
"add_server": "Adicionar um servidor",
|
||||||
|
"noServersAdded": "Nenhum servidor adicionado",
|
||||||
|
"lang_dropdown": "Idioma",
|
||||||
|
"addServerModalLongTitle": "Adicionar um novo servidor",
|
||||||
|
"addServerModalSvName": "Nome:",
|
||||||
|
"addServerModalSvIp": "IP:",
|
||||||
|
"addServerModalSvPort": "Porta(config.yml):",
|
||||||
|
"addServerModalSvSsl": "SSL do servidor está habilitado ?",
|
||||||
|
"addServerModalSslAdvice": "É necessário SSL para conexões do cliente HTTPS",
|
||||||
|
"addServerModalClose": "Fechar",
|
||||||
|
"saveAndConnectServerButton": "Salvar e conectar",
|
||||||
|
"passwordModalLongTitle": "Necessário uma senha",
|
||||||
|
"passwordModalLabel": "Senha:",
|
||||||
|
"passwordModalRememberLabel": "Deseja salvar esta senha ?",
|
||||||
|
"passwordModalCloseButton": "Fechar",
|
||||||
|
"passwordSendButton": "Logar",
|
||||||
|
"disconnectionModalLongTitle": "desconectado",
|
||||||
|
"disconnectionModalDescription": "A conexão com o servidor foi perdida. Isso pode ser causado por:",
|
||||||
|
"disconnectionModalsub1": "O servidor foi fechado intencionalmente.",
|
||||||
|
"disconnectionModalsub2": "A porta não está aberta em seu host. Se for esse o caso, solucione o problema com um testador de porta e verifique seu firewall ou router novamente.",
|
||||||
|
"disconnectionModalCloseButton": "Fechar",
|
||||||
|
"disconnectionModalWelcomeScreenButton": "Voltar à página de boas-vindas",
|
||||||
|
"settingsLink": "Configurações",
|
||||||
|
"settingsModalLongTitle": "Configurações do WebConsole",
|
||||||
|
"showDateSettingsSwitchLabel": "Mostrar hora em cada linha do console",
|
||||||
|
"readLogFileSwitchLabel": "Recuperar arquivo de log completo do servidor após o login",
|
||||||
|
"settingsModalCloseButton": "Feito",
|
||||||
|
"players_online": "Jogadores online",
|
||||||
|
"cpu_title": "Consumo de CPU",
|
||||||
|
"ram_title": "Consumo de RAM",
|
||||||
|
"user_title": "Logado como",
|
||||||
|
"deleteServerButton": "Remover este servidor",
|
||||||
|
"sendCommandButton": "Enviar"
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "zh_CN": //Credit to Neubulae
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "首页",
|
||||||
|
"home_header": "请从菜单中选择一个服务器",
|
||||||
|
"home_description": "请使用导航栏以添加新服务器, 或连接至已设定服务器.",
|
||||||
|
"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": "内存使用量",
|
||||||
|
"user_title": "登录为",
|
||||||
|
"deleteServerButton": "关闭服务器",
|
||||||
|
"sendCommandButton": "发送"
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "ko_KR":
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "메인",
|
||||||
|
"home_header": "메뉴에서 서버를 선택해 주세요",
|
||||||
|
"home_description": "새 서버를 추가하거나 전에 추가한 서버에 연결하려면 네비게이션 바를 사용하세요.",
|
||||||
|
"serversDropdown": "서버 목록",
|
||||||
|
"add_server": "서버 추가하기",
|
||||||
|
"noServersAdded": "서버 없음",
|
||||||
|
"lang_dropdown": "언어",
|
||||||
|
"addServerModalLongTitle": "서버 추가",
|
||||||
|
"addServerModalSvName": "서버 이름:",
|
||||||
|
"addServerModalSvIp": "서버 주소:",
|
||||||
|
"addServerModalSvPort": "WebConsole 포트:",
|
||||||
|
"addServerModalSvSsl": "서버가 SSL을 사용합니다",
|
||||||
|
"addServerModalSslAdvice": "SSL은 HTTPS 연결을 위해 필요합니다",
|
||||||
|
"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 "fr_FR":
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "Page d'accueil",
|
||||||
|
"home_header": "Sélectionnez un serveur dans le menu",
|
||||||
|
"home_description": "Utilisez la barre de navigation pour ajouter un nouveau serveur ou connectez-vous à un autre précédemment ajouté.",
|
||||||
|
"serversDropdown": "Vos serveurs",
|
||||||
|
"add_server": "Ajouter un serveur",
|
||||||
|
"noServersAdded": "Aucun serveur ajouté",
|
||||||
|
"lang_dropdown": "Langue",
|
||||||
|
"addServerModalLongTitle": "Ajouter un nouveau serveur",
|
||||||
|
"addServerModalSvName": "Nom du serveur:",
|
||||||
|
"addServerModalSvIp": "Serveur IP:",
|
||||||
|
"addServerModalSvPort": "WebConsole port:",
|
||||||
|
"addServerModalSvSsl": "SSL est activé",
|
||||||
|
"addServerModalSslAdvice": "SSL est requis si vous vous connectez à partir d'un client HTTPS",
|
||||||
|
"addServerModalClose": "Fermer",
|
||||||
|
"saveAndConnectServerButton": "Enregistrez et connectez",
|
||||||
|
"passwordModalLongTitle": "Mot de passe requis",
|
||||||
|
"passwordModalLabel": "Mot de passe:",
|
||||||
|
"passwordModalRememberLabel": "Se souvenir du mot de passe",
|
||||||
|
"passwordModalCloseButton": "Fermer",
|
||||||
|
"passwordSendButton": "S'identifier",
|
||||||
|
"disconnectionModalLongTitle": "Débranché",
|
||||||
|
"disconnectionModalDescription": "La connexion avec le serveur a été perdue. Cela peut être causé par:",
|
||||||
|
"disconnectionModalsub1": "Le serveur a été fermé intentionnellement.",
|
||||||
|
"disconnectionModalsub2": "Le port n'est pas ouvert sur votre hôte. Si tel est le cas, dépannez avec un testeur de port et vérifiez à nouveau votre firewall ou votre router.",
|
||||||
|
"disconnectionModalCloseButton": "Fermer",
|
||||||
|
"disconnectionModalWelcomeScreenButton": "Retour à la page d'accueil",
|
||||||
|
"settingsLink": "Réglages",
|
||||||
|
"settingsModalLongTitle": "Réglages de WebConsole",
|
||||||
|
"showDateSettingsSwitchLabel": "Afficher l'heure sur chaque ligne de console",
|
||||||
|
"readLogFileSwitchLabel": "Récupérer le fichier journal complet du serveur après la connexion",
|
||||||
|
"settingsModalCloseButton": "Terminé",
|
||||||
|
"players_online": "Joueurs en ligne",
|
||||||
|
"cpu_title": "Utilisation de la CPU",
|
||||||
|
"ram_title": "Utilisation de la RAM",
|
||||||
|
"user_title": "Connecté en tant que",
|
||||||
|
"deleteServerButton": "Supprimer le serveur",
|
||||||
|
"sendCommandButton": "Envoyer"
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "cs_CZ":
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "Domů",
|
||||||
|
"home_header": "Vyberte server z nabídky",
|
||||||
|
"home_description": "Použijte navigační lištu pro přidání nového minecraftového serveru, nebo pro připojení k existujícímu.",
|
||||||
|
"serversDropdown": "Vaše servery",
|
||||||
|
"add_server": "Přidat server",
|
||||||
|
"noServersAdded": "Nebyly přidány žádné servery",
|
||||||
|
"lang_dropdown": "Jazyk",
|
||||||
|
"addServerModalLongTitle": "Přidat nový server",
|
||||||
|
"addServerModalSvName": "Jméno serveru:",
|
||||||
|
"addServerModalSvIp": "IP adresa serveru:",
|
||||||
|
"addServerModalSvPort": "Port WebConsole:",
|
||||||
|
"addServerModalSvSsl": "SSL je zapnuté na tomto serveru",
|
||||||
|
"addServerModalSslAdvice": "SSL je vyžadováno pro připojení klientů pomocí HTTPS",
|
||||||
|
"addServerModalClose": "Zavřít",
|
||||||
|
"saveAndConnectServerButton": "Uložit a připojit",
|
||||||
|
"passwordModalLongTitle": "Vyžadováno heslo",
|
||||||
|
"passwordModalLabel": "Heslo:",
|
||||||
|
"passwordModalRememberLabel": "Pamatovat si heslo",
|
||||||
|
"passwordModalCloseButton": "Zavřít",
|
||||||
|
"passwordSendButton": "Přihlásit se",
|
||||||
|
"disconnectionModalLongTitle": "Odpojeno",
|
||||||
|
"disconnectionModalDescription": "Připojení bylo ztraceno se serverem. To může být způsobeno:",
|
||||||
|
"disconnectionModalsub1": "Server byl úmyslně uzavřen.",
|
||||||
|
"disconnectionModalsub2": "Port není na hostiteli otevřený. Pokud tomu tak je, odstraňte problém s testerem portů a znovu zkontrolujte firewall nebo router.",
|
||||||
|
"disconnectionModalCloseButton": "Zavřít",
|
||||||
|
"disconnectionModalWelcomeScreenButton": "Zpět na úvodní stránku",
|
||||||
|
"settingsLink": "Nastavení",
|
||||||
|
"settingsModalLongTitle": "Nastavení WebConsole",
|
||||||
|
"showDateSettingsSwitchLabel": "Zobrazit čas v každém řádku konzoly",
|
||||||
|
"readLogFileSwitchLabel": "Po přihlášení načtěte úplný soubor protokolu ze serveru",
|
||||||
|
"settingsModalCloseButton": "Hotovo",
|
||||||
|
"players_online": "Počet hráčů online",
|
||||||
|
"cpu_title": "CPU",
|
||||||
|
"ram_title": "Využití RAM",
|
||||||
|
"user_title": "Přihlášen jako",
|
||||||
|
"deleteServerButton": "Odstranit server",
|
||||||
|
"sendCommandButton": "Odeslat"
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "it_IT": //Credit to AlexZap
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "Home",
|
||||||
|
"home_header": "Seleziona un server dal menù",
|
||||||
|
"home_description": "Usa la barra di navigazione per connetterti al server o clicca sul menù a tendina sovrastante.",
|
||||||
|
"serversDropdown": "I tuoi server",
|
||||||
|
"add_server": "Aggiungi un Server",
|
||||||
|
"noServersAdded": "Nessun server aggiunto",
|
||||||
|
"lang_dropdown": "Lingua",
|
||||||
|
"addServerModalLongTitle": "Aaggiungi un nuovo server",
|
||||||
|
"addServerModalSvName": "Nome server:",
|
||||||
|
"addServerModalSvIp": "IP server:",
|
||||||
|
"addServerModalSvPort": "Porta WebConsole:",
|
||||||
|
"addServerModalSvSsl": "Il server è abilitato a SSL",
|
||||||
|
"addServerModalSslAdvice": "L'SSL e richiesto in caso di connessioni HTTPS",
|
||||||
|
"addServerModalClose": "Chiudi",
|
||||||
|
"saveAndConnectServerButton": "Salva e connettiti",
|
||||||
|
"passwordModalLongTitle": "Password richiesta",
|
||||||
|
"passwordModalLabel": "Password:",
|
||||||
|
"passwordModalRememberLabel": "Ricorda la mia password",
|
||||||
|
"passwordModalCloseButton": "Chiudi",
|
||||||
|
"passwordSendButton": "Login",
|
||||||
|
"disconnectionModalLongTitle": "Disconnesso",
|
||||||
|
"disconnectionModalDescription": "La connessione con il server è stata persa. Ciò può essere causato da:",
|
||||||
|
"disconnectionModalsub1": "Il server è stato chiuso intenzionalmente.",
|
||||||
|
"disconnectionModalsub2": "La porta non è aperta sul tuo host. In tal caso, risolvere i problemi con un tester della porta e controllare nuovamente il firewall o il router.",
|
||||||
|
"disconnectionModalCloseButton": "Chiudi",
|
||||||
|
"disconnectionModalWelcomeScreenButton": "Torna alla Home",
|
||||||
|
"settingsLink": "Impostazioni",
|
||||||
|
"settingsModalLongTitle": "Impostazioni WebConsole",
|
||||||
|
"showDateSettingsSwitchLabel": "Mostra la data e l'ora per ogni linea della console",
|
||||||
|
"readLogFileSwitchLabel": "Mostra l'intero file log dopo il login",
|
||||||
|
"settingsModalCloseButton": "Conferma",
|
||||||
|
"players_online": "Giocatori online",
|
||||||
|
"cpu_title": "Utilizzo CPU",
|
||||||
|
"ram_title": "Utilizzo RAM",
|
||||||
|
"user_title": "Collegato come",
|
||||||
|
"deleteServerButton": "Cancella il server",
|
||||||
|
"sendCommandButton": "Invio"
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "nl_NL": //Credit to Twockx
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "Homepagina",
|
||||||
|
"home_header": "Selecteer een server van het menu",
|
||||||
|
"home_description": "Gebruik de navigatiebalk om een nieuwe Minecraft-server toe te voegen of maak verbinding met een eerder toegevoegde server.",
|
||||||
|
"serversDropdown": "Uw servers",
|
||||||
|
"add_server": "Voeg server toe",
|
||||||
|
"noServersAdded": "Geen servers toegevoegd",
|
||||||
|
"lang_dropdown": "Taal",
|
||||||
|
"addServerModalLongTitle": "Voeg een nieuwe server toe",
|
||||||
|
"addServerModalSvName": "Server naam:",
|
||||||
|
"addServerModalSvIp": "Server IP:",
|
||||||
|
"addServerModalSvPort": "WebConsole poort:",
|
||||||
|
"addServerModalSvSsl": "Server SSL is ingeschakeld",
|
||||||
|
"addServerModalSslAdvice": "SSL is vereist voor HTTPS-clientverbindingen",
|
||||||
|
"addServerModalClose": "Sluiten",
|
||||||
|
"saveAndConnectServerButton": "Opslaan en verbinden",
|
||||||
|
"passwordModalLongTitle": "Wachtwoord vereist",
|
||||||
|
"passwordModalLabel": "Wachtwoord:",
|
||||||
|
"passwordModalRememberLabel": "Onthoud wachtwoord",
|
||||||
|
"passwordModalCloseButton": "Sluiten",
|
||||||
|
"passwordSendButton": "Log in",
|
||||||
|
"disconnectionModalLongTitle": "Verbinding verbroken",
|
||||||
|
"disconnectionModalDescription": "De verbinding met de server is verbroken. Dit kan worden veroorzaakt door:",
|
||||||
|
"disconnectionModalsub1": "De server is opzettelijk gesloten.",
|
||||||
|
"disconnectionModalsub2": "De poort is niet open op uw host. Als dit het geval is, lost u het probleem op met een poorttester en controleert u uw firewall of router opnieuw.",
|
||||||
|
"disconnectionModalCloseButton": "Sluiten",
|
||||||
|
"disconnectionModalWelcomeScreenButton": "Terug naar homepagina",
|
||||||
|
"settingsLink": "Instellingen",
|
||||||
|
"settingsModalLongTitle": "WebConsole Instellingen",
|
||||||
|
"showDateSettingsSwitchLabel": "Toon tijd op elke consolelijn",
|
||||||
|
"readLogFileSwitchLabel": "Haal het volledige logbestand op van de server na inloggen",
|
||||||
|
"settingsModalCloseButton": "Klaar",
|
||||||
|
"players_online": "Spelers online",
|
||||||
|
"cpu_title": "CPU",
|
||||||
|
"ram_title": "RAM gebruik",
|
||||||
|
"user_title": "Aangemeld als",
|
||||||
|
"deleteServerButton": "Verwijder server",
|
||||||
|
"sendCommandButton": "Stuur"
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "de_DE": //Credit to NoNamePro0
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "Startseite",
|
||||||
|
"home_header": "Willkommen bei der WebConsole",
|
||||||
|
"home_description": "Nutze die Menübar um einen Server beizutreten",
|
||||||
|
"serversDropdown": "Deine Server",
|
||||||
|
"add_server": "Neuen Server hinzufügen",
|
||||||
|
"noServersAdded": "Keine Server hinzugefügt",
|
||||||
|
"lang_dropdown": "Sprache",
|
||||||
|
"addServerModalLongTitle": "Hinzufüge deinen Server",
|
||||||
|
"addServerModalSvName": "Server-Name:",
|
||||||
|
"addServerModalSvIp": "Server-IP:",
|
||||||
|
"addServerModalSvPort": "WebConsole Port:",
|
||||||
|
"addServerModalSvSsl": "Server ist SSL verschlüsselt",
|
||||||
|
"addServerModalSslAdvice": "SSL ist erforderlich für HTTPS Verbindungen",
|
||||||
|
"addServerModalClose": "Schließen",
|
||||||
|
"saveAndConnectServerButton": "Speichern und verbinden",
|
||||||
|
"passwordModalLongTitle": "Passwort benötigt",
|
||||||
|
"passwordModalLabel": "Passwort:",
|
||||||
|
"passwordModalRememberLabel": "Passwort merken",
|
||||||
|
"passwordModalCloseButton": "Schließen",
|
||||||
|
"passwordSendButton": "Login",
|
||||||
|
"disconnectionModalLongTitle": "Verbindung getrennt",
|
||||||
|
"disconnectionModalDescription": "Die Verbindung zum Server wurde unterbrochen. Dies kann verursacht werden durch:",
|
||||||
|
"disconnectionModalsub1": "Server wurde absichtlich geschlossen.",
|
||||||
|
"disconnectionModalsub2": "Der Port ist auf Ihrem Host nicht geöffnet. Wenn dies der Fall ist, beheben Sie die Fehlerbehebung mit einem Port-Tester und überprüfen Sie Ihre Firewall oder Ihren Router erneut.",
|
||||||
|
"disconnectionModalCloseButton": "Schließen",
|
||||||
|
"disconnectionModalWelcomeScreenButton": "Zurück zur Startseite",
|
||||||
|
"settingsLink": "Einstellungen",
|
||||||
|
"settingsModalLongTitle": "WebConsole Einstellungen",
|
||||||
|
"showDateSettingsSwitchLabel": "Zeig die Uhrzeit vor jeder Linie in der Console",
|
||||||
|
"readLogFileSwitchLabel": "Zeige die komplette Log nach dem Login",
|
||||||
|
"settingsModalCloseButton": "Fertig!",
|
||||||
|
"players_online": "Spieler Online",
|
||||||
|
"cpu_title": "CPU",
|
||||||
|
"ram_title": "RAM",
|
||||||
|
"user_title": "Angemeldet als",
|
||||||
|
"deleteServerButton": "Server entfernen",
|
||||||
|
"sendCommandButton": "Senden"
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "tr_TR": //Credit to acarnd03
|
||||||
|
lang = {
|
||||||
|
"navbarHomeLink": "Ev",
|
||||||
|
"home_header": "Menüden bir sunucu seçin",
|
||||||
|
"home_description": "Yeni bir Minecraft Sunucusu eklemek veya önceden eklenmiş bir sunucuya bağlanmak için gezinme çubuğunu kullanın.",
|
||||||
|
"serversDropdown": "Sunucularınız",
|
||||||
|
"add_server": "Sunucu ekle",
|
||||||
|
"noServersAdded": "Sunucu eklenmedi",
|
||||||
|
"lang_dropdown": "Dil",
|
||||||
|
"addServerModalLongTitle": "Yeni bir sunucu ekleyin",
|
||||||
|
"addServerModalSvName": "Sunucu adı:",
|
||||||
|
"addServerModalSvIp": "Sunucu IP'si:",
|
||||||
|
"addServerModalSvPort": "WebConsole bağlantı noktası:",
|
||||||
|
"addServerModalSvSsl": "Sunucu SSL etkin",
|
||||||
|
"addServerModalSslAdvice": "HTTPS istemci bağlantıları için SSL gereklidir",
|
||||||
|
"addServerModalClose": "Kapat",
|
||||||
|
"saveAndConnectServerButton": "Kaydet ve bağlan",
|
||||||
|
"passwordModalLongTitle": "Şifre gereklidir",
|
||||||
|
"passwordModalLabel": "Parola:",
|
||||||
|
"passwordModalRememberLabel": "Şifremi hatırla",
|
||||||
|
"passwordModalCloseButton": "Kapat",
|
||||||
|
"passwordSendButton": "Oturum aç",
|
||||||
|
"disconnectionModalLongTitle": "Bağlantı kesildi",
|
||||||
|
"disconnectionModalDescription": "Sunucuyla bağlantı kesildi. Bunun nedeni şunlar olabilir:",
|
||||||
|
"disconnectionModalsub1": "Sunucu kasıtlı olarak kapatıldı.",
|
||||||
|
"disconnectionModalsub2": "Ana makinenizde bağlantı noktası açılmadı. Bu durumda, bir bağlantı noktası denetleyicisi kullanarak sorunu giderin ve güvenlik duvarınızı veya yönlendiricinizi yeniden kontrol edin.",
|
||||||
|
"disconnectionModalCloseButton": "Kapat",
|
||||||
|
"disconnectionModalWelcomeScreenButton": "Karşılama sayfasına geri dön",
|
||||||
|
"settingsLink": "Ayarlar",
|
||||||
|
"settingsModalLongTitle": "WebConsole Ayarları",
|
||||||
|
"showDateSettingsSwitchLabel": "Her konsol satırında zamanı göster",
|
||||||
|
"readLogFileSwitchLabel": "Giriş yaptıktan sonra tam günlük dosyasını sunucudan alın",
|
||||||
|
"settingsModalCloseButton": "Bitti",
|
||||||
|
"players_online": "Çevrimiçi Oyuncular",
|
||||||
|
"cpu_title": "CPU",
|
||||||
|
"ram_title": "RAM kullanımı",
|
||||||
|
"user_title": "olarak giriş yapıldı",
|
||||||
|
"deleteServerButton": "Sunucuyu silin",
|
||||||
|
"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:
|
default:
|
||||||
console.error("No language set");
|
console.error("No language set");
|
||||||
}
|
}
|
||||||
//Set navbar phrases
|
|
||||||
document.getElementById("navbarHomeLink").textContent = lang.home_link;
|
//Set phrases
|
||||||
document.getElementById("home_header").textContent = lang.home_header;
|
jQuery.each(lang, (key, value) =>{
|
||||||
document.getElementById("home_description").textContent = lang.home_description;
|
try{
|
||||||
document.getElementById("serversDropdown").textContent = lang.server_dropdown;
|
document.getElementById(key).textContent = value;
|
||||||
document.getElementById("add_server").textContent = lang.add_server;
|
}catch(err){
|
||||||
document.getElementById("lang_dropdown").textContent = lang.lang_dropdown;
|
console.error("Cannot translate " + key + " (" + value + ")")
|
||||||
document.getElementById("addServerModalLongTitle").textContent = lang.addServerModalLongTitle;
|
}
|
||||||
document.getElementById("addServerModalSvName").textContent = lang.addServerModalSvName;
|
});
|
||||||
document.getElementById("addServerModalSvIp").textContent = lang.addServerModalSvIp;
|
|
||||||
document.getElementById("addServerModalSvPort").textContent = lang.addServerModalSvPort;
|
|
||||||
document.getElementById("addServerModalSvSsl").textContent = lang.addServerModalSvSsl;
|
|
||||||
document.getElementById("addServerModalClose").textContent = lang.addServerModalClose;
|
|
||||||
document.getElementById("saveAndConnectServerButton").textContent = lang.saveAndConnectServerButton;
|
|
||||||
document.getElementById("passwordModalLongTitle").textContent = lang.passwordModalLongTitle;
|
|
||||||
document.getElementById("passwordModalLabel").textContent = lang.passwordModalLabel;
|
|
||||||
document.getElementById("passwordModalRememberLabel").textContent = lang.passwordModalRememberLabel;
|
|
||||||
document.getElementById("passwordModalCloseButton").textContent = lang.passwordModalCloseButton;
|
|
||||||
document.getElementById("passwordSendButton").textContent = lang.passwordSendButton;
|
|
||||||
document.getElementById("disconnectionModalLongTitle").textContent = lang.disconnectionModalLongTitle;
|
|
||||||
document.getElementById("disconnectionModalDescription").textContent = lang.disconnectionModalDescription;
|
|
||||||
document.getElementById("players_online").textContent = lang.players_online;
|
|
||||||
document.getElementById("deleteServerButton").textContent = lang.deleteServerButton;
|
|
||||||
document.getElementById("sendCommandButton").textContent = lang.sendCommandButton;
|
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
WebConsole Manager for WebConsole
|
WebConsole Manager for WebConsole
|
||||||
Used to manage active connections
|
Used to manage active connections
|
||||||
https://github.com/mesacarlos
|
https://github.com/mesacarlos
|
||||||
2019 Carlos Mesa under MIT License.
|
2019-2020 Carlos Mesa under MIT License.
|
||||||
*/
|
*/
|
||||||
class WebConsoleManager {
|
class WebConsoleManager {
|
||||||
constructor(){
|
constructor(){
|
||||||
@ -41,9 +41,9 @@ class WebConsoleManager {
|
|||||||
* Deletes connection (for example, if a connection was closed by server).
|
* Deletes connection (for example, if a connection was closed by server).
|
||||||
* Called by WebConsole.js
|
* Called by WebConsole.js
|
||||||
*/
|
*/
|
||||||
deleteConnection(serverName){
|
deleteConnection(serverName, deleteFromArrayOnly){
|
||||||
//Delete from active connection (if it is the active one)
|
//Delete from active connection (if it is the active one)
|
||||||
if(this.activeConnection.serverName == serverName){
|
if(!deleteFromArrayOnly && this.activeConnection.serverName == serverName){
|
||||||
this.activeConnection = null;
|
this.activeConnection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,14 +60,22 @@ class WebConsoleManager {
|
|||||||
* Send password to server
|
* Send password to server
|
||||||
*/
|
*/
|
||||||
sendPassword(pwd){
|
sendPassword(pwd){
|
||||||
this.activeConnection.sendToServer("LOGIN " + pwd);
|
this.activeConnection.sendToServer({
|
||||||
|
command: "LOGIN",
|
||||||
|
params: pwd
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send console command to server
|
* Send console command to server
|
||||||
*/
|
*/
|
||||||
sendConsoleCmd(cmd){
|
sendConsoleCmd(cmd){
|
||||||
this.activeConnection.sendToServer("EXEC " + cmd);
|
this.activeConnection.sendToServer({
|
||||||
|
command: "EXEC",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
params: cmd
|
||||||
|
});
|
||||||
|
|
||||||
this.activeConnection.commands.push(cmd);
|
this.activeConnection.commands.push(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,9 +83,35 @@ class WebConsoleManager {
|
|||||||
* Asks server for CPU, RAM and players info
|
* Asks server for CPU, RAM and players info
|
||||||
*/
|
*/
|
||||||
askForInfo(){
|
askForInfo(){
|
||||||
this.activeConnection.sendToServer("PLAYERS");
|
this.activeConnection.sendToServer({
|
||||||
this.activeConnection.sendToServer("CPUUSAGE");
|
command: "PLAYERS",
|
||||||
this.activeConnection.sendToServer("RAMUSAGE");
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "CPUUSAGE",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "RAMUSAGE",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "TPS",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asks server for full latest.log
|
||||||
|
*/
|
||||||
|
askForLogs(){
|
||||||
|
this.activeConnection.sendToServer({
|
||||||
|
command: "READLOGFILE",
|
||||||
|
token: this.activeConnection.token,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
WebConsole Persistence Manager for WebConsole
|
WebConsole Persistence Manager for WebConsole
|
||||||
Used to save your servers into your browser
|
Used to save your servers and config into your browser
|
||||||
https://github.com/mesacarlos
|
https://github.com/mesacarlos
|
||||||
2019 Carlos Mesa under MIT License.
|
2019-2020 Carlos Mesa under MIT License.
|
||||||
*/
|
*/
|
||||||
class WebConsolePersistenceManager{
|
class WebConsolePersistenceManager{
|
||||||
|
|
||||||
@ -10,8 +10,6 @@ class WebConsolePersistenceManager{
|
|||||||
* Saves or updates server into WebStorage
|
* Saves or updates server into WebStorage
|
||||||
*/
|
*/
|
||||||
saveServer(serverObject){
|
saveServer(serverObject){
|
||||||
this.initializeLocalStorage();
|
|
||||||
|
|
||||||
//Check if server exists
|
//Check if server exists
|
||||||
var i;
|
var i;
|
||||||
var found = false;
|
var found = false;
|
||||||
@ -36,8 +34,6 @@ class WebConsolePersistenceManager{
|
|||||||
* Delete server from saved servers
|
* Delete server from saved servers
|
||||||
*/
|
*/
|
||||||
deleteServer(serverName){
|
deleteServer(serverName){
|
||||||
this.initializeLocalStorage();
|
|
||||||
|
|
||||||
//Find server
|
//Find server
|
||||||
var i;
|
var i;
|
||||||
var index = -1;
|
var index = -1;
|
||||||
@ -61,8 +57,6 @@ class WebConsolePersistenceManager{
|
|||||||
* Get server details as object
|
* Get server details as object
|
||||||
*/
|
*/
|
||||||
getServer(serverName){
|
getServer(serverName){
|
||||||
this.initializeLocalStorage();
|
|
||||||
|
|
||||||
var i;
|
var i;
|
||||||
var servers = this.getAllServers();
|
var servers = this.getAllServers();
|
||||||
for (i = 0; i < servers.length; i++) {
|
for (i = 0; i < servers.length; i++) {
|
||||||
@ -76,8 +70,6 @@ class WebConsolePersistenceManager{
|
|||||||
* Get all servers
|
* Get all servers
|
||||||
*/
|
*/
|
||||||
getAllServers(){
|
getAllServers(){
|
||||||
this.initializeLocalStorage();
|
|
||||||
|
|
||||||
var storageObj = JSON.parse(window.localStorage.WebConsole);
|
var storageObj = JSON.parse(window.localStorage.WebConsole);
|
||||||
return storageObj.servers;
|
return storageObj.servers;
|
||||||
}
|
}
|
||||||
@ -86,8 +78,6 @@ class WebConsolePersistenceManager{
|
|||||||
* Save language for this client
|
* Save language for this client
|
||||||
*/
|
*/
|
||||||
setLanguage(lang){
|
setLanguage(lang){
|
||||||
this.initializeLocalStorage();
|
|
||||||
|
|
||||||
//Retrieve saved data
|
//Retrieve saved data
|
||||||
var storageObj = JSON.parse(window.localStorage.WebConsole);
|
var storageObj = JSON.parse(window.localStorage.WebConsole);
|
||||||
storageObj.language = lang;
|
storageObj.language = lang;
|
||||||
@ -100,8 +90,6 @@ class WebConsolePersistenceManager{
|
|||||||
* Get saved language for this client
|
* Get saved language for this client
|
||||||
*/
|
*/
|
||||||
getLanguage(){
|
getLanguage(){
|
||||||
this.initializeLocalStorage();
|
|
||||||
|
|
||||||
var storageObj = JSON.parse(window.localStorage.WebConsole);
|
var storageObj = JSON.parse(window.localStorage.WebConsole);
|
||||||
if(!storageObj.language)
|
if(!storageObj.language)
|
||||||
return "en_US";
|
return "en_US";
|
||||||
@ -135,15 +123,54 @@ class WebConsolePersistenceManager{
|
|||||||
window.localStorage.WebConsole = JSON.stringify(storageObj);
|
window.localStorage.WebConsole = JSON.stringify(storageObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create settings object if not defined or populate with new options if updating
|
||||||
|
*/
|
||||||
|
initializeSettings(){
|
||||||
|
this.initializeLocalStorage();
|
||||||
|
|
||||||
|
//Create settings object
|
||||||
|
var currentSettings = JSON.parse(window.localStorage.WebConsole).settings;
|
||||||
|
if (typeof currentSettings === 'undefined') {
|
||||||
|
currentSettings = new Object();
|
||||||
}
|
}
|
||||||
|
|
||||||
class WSServer{
|
//Setting array initialization. If you need to add more settings, add them here. Any object is valid as a value (not only bool)
|
||||||
constructor(serverName, serverURI){
|
var settings = {
|
||||||
this.serverName = serverName;
|
dateTimePrefix : new Setting("dateTimePrefix", true),
|
||||||
this.serverURI = serverURI;
|
retrieveLogFile : new Setting("retrieveLogFile", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
setPassword(pwd){
|
//Set settings
|
||||||
this.serverPassword = pwd;
|
jQuery.each(settings, (key, settingObj) =>{
|
||||||
|
if(!currentSettings.hasOwnProperty(settingObj.name))
|
||||||
|
currentSettings[settingObj.name] = settingObj.defaultValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
//Save all
|
||||||
|
var storageObj = JSON.parse(window.localStorage.WebConsole);
|
||||||
|
storageObj.settings = currentSettings;
|
||||||
|
window.localStorage.WebConsole = JSON.stringify(storageObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update setting value
|
||||||
|
*/
|
||||||
|
setSetting(name, value){
|
||||||
|
var currentSettings = JSON.parse(window.localStorage.WebConsole).settings;
|
||||||
|
currentSettings[name] = value;
|
||||||
|
|
||||||
|
//Save all
|
||||||
|
var storageObj = JSON.parse(window.localStorage.WebConsole);
|
||||||
|
storageObj.settings = currentSettings;
|
||||||
|
window.localStorage.WebConsole = JSON.stringify(storageObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get setting value
|
||||||
|
*/
|
||||||
|
getSetting(name){
|
||||||
|
return JSON.parse(window.localStorage.WebConsole).settings[name];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
6
client/scripts/object/Setting.js
Normal file
6
client/scripts/object/Setting.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class Setting{
|
||||||
|
constructor(name, defaultValue){
|
||||||
|
this.name = name;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
}
|
10
client/scripts/object/WSServer.js
Normal file
10
client/scripts/object/WSServer.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
class WSServer{
|
||||||
|
constructor(serverName, serverURI){
|
||||||
|
this.serverName = serverName;
|
||||||
|
this.serverURI = serverURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPassword(pwd){
|
||||||
|
this.serverPassword = pwd;
|
||||||
|
}
|
||||||
|
}
|
@ -5,3 +5,9 @@
|
|||||||
.console{
|
.console{
|
||||||
height: 480px;
|
height: 480px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-control::-webkit-input-placeholder { opacity: 0.4; } /* WebKit, Blink, Edge */
|
||||||
|
.form-control:-moz-placeholder { opacity: 0.4; } /* Mozilla Firefox 4 to 18 */
|
||||||
|
.form-control::-moz-placeholder { opacity: 0.4; } /* Mozilla Firefox 19+ */
|
||||||
|
.form-control:-ms-input-placeholder { opacity: 0.4; } /* Internet Explorer 10-11 */
|
||||||
|
.form-control::-ms-input-placeholder { opacity: 0.4; } /* Microsoft Edge */
|
49
phrases.properties
Normal file
49
phrases.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = Error occured while starting WebSocket Server.
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Connected. Already logged in, welcome back!
|
||||||
|
connection-resumed-console = [WebConsole] Connected and resumed session from {0}
|
||||||
|
connection-login-message = Connection started, waiting login
|
||||||
|
connection-login-console = [WebConsole] Connected and waiting login from {0}
|
||||||
|
unknown-command-message = Unknown command
|
||||||
|
unknown-command-console = [WebConsole] Signal "{0}" was not processed since is not valid. Is your plugin/web interface up to date?
|
||||||
|
forbidden-message = Forbidden
|
||||||
|
forbidden-console = [WebConsole] {0} tried to run "{1}" while not logged in!
|
||||||
|
closed-connection = [WebConsole] Closed connection and logged out from {0}
|
||||||
|
error-on-connection = [WebConsole] Error occurred on connection {0}: {1}
|
||||||
|
started-websocket = [WebConsole] WebSocket Server started successfully.
|
||||||
|
error-disconnected-client = [WebConsole] Attempted to send a message to a disconnected WebSocket client.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = Usage is {0}%
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0} tried to run {1} without permission.
|
||||||
|
cmd-executed-console = [WebConsole] {0} executed "{1}".
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Logged in
|
||||||
|
login-sucessful-console = [WebConsole] {0} successfully logged in.
|
||||||
|
login-failed-message = Incorrect password, try again
|
||||||
|
login-failed-console = [WebConsole] Password incorrect while login from {0}
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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.
|
||||||
|
webconsole-active-connections = Connected to WebConsole from:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Error trying to read latest.log file
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = User {0} from {1} as {2}
|
49
phrases_cs.properties
Normal file
49
phrases_cs.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = Stala se chyba při spouštění WebSocketového serveru.
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Připojeno. Jste již přihlášeni, vítejte zpět!
|
||||||
|
connection-resumed-console = [WebConsole] Připojeno a obnoveno spojení z {0}.
|
||||||
|
connection-login-message = Připojení zahájeno, očekávám přihlášení.
|
||||||
|
connection-login-console = [WebConsole] Připojení z {0}, očekávám přihlášení .
|
||||||
|
unknown-command-message = Neznámý příkaz!
|
||||||
|
unknown-command-console = [WebConsole] Signál "{0}" nebyl zpracován, protože není platný. Je váš plugin/webová interface aktuálný?
|
||||||
|
forbidden-message = Nepovoleno
|
||||||
|
forbidden-console = [WebConsole] {0} se pokusil spustit "{1}" nepřihlášený!
|
||||||
|
closed-connection = [WebConsole] Ukončeno připojení a odhlášeno z {0}!
|
||||||
|
error-on-connection = [WebConsole] Nastala chyba u připojení {0}: {1}
|
||||||
|
started-websocket = [WebConsole] Websocketový server se úspěšně spustil.
|
||||||
|
error-disconnected-client = [WebConsole] Pokus o odeslání zprávy odpojenému klientovi.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = Využití je {0}%
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0} se pokusil spustit {1} bez povolení.
|
||||||
|
cmd-executed-console = [WebConsole] {0} spustil "{1}".
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Jste přihlášeni.
|
||||||
|
login-sucessful-console = [WebConsole] {0} úspěšně přihlášeni.
|
||||||
|
login-failed-message = Špatné heslo, zkuste prosím znovu.
|
||||||
|
login-failed-console = [WebConsole] {0} se pokusil připojit se špatným heslem.
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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í.
|
||||||
|
webconsole-active-connections = Připojeno k WebConsole z:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Chyba při čtení souboru latest.log
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = Uživatel {0} z {1} tak jako {2}
|
49
phrases_de.properties
Normal file
49
phrases_de.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = Ein Fehler ist aufgekommen beim Starten des WebSocket Server.
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Verbunden. Bereits eingeloggt, willkommen zurück!
|
||||||
|
connection-resumed-console = [WebConsole] {0} hat sich Verbunden und ist bereits eingeloggt.
|
||||||
|
connection-login-message = Verbunden, warten auf den Login.
|
||||||
|
connection-login-console = [WebConsole] {0} hat sich verbunden, auf den Login wird gewartet.
|
||||||
|
unknown-command-message = Unbekannter Befehl.
|
||||||
|
unknown-command-console = [WebConsole] Der Command '{0}' existiert nicht. Ist dein Plugin/Webinterface auf dem aktuellsten Stand?
|
||||||
|
forbidden-message = Nicht erlaubt! Versuche erneut dich zu verbinden mit deinem Passwort!
|
||||||
|
forbidden-console = [WebConsole] {0} hat versucht "{1}" auszuführen, ohne eingeloggt zu sein.
|
||||||
|
closed-connection = [WebConsole] {0} hat seine Verbindung geschlossen und hat sich ausgeloggt.
|
||||||
|
error-on-connection = [WebConsole] Fehler beim verbinden von {0}: {1}.
|
||||||
|
started-websocket = [WebConsole] WebSocket Server wurde erfolgreich gestartet.
|
||||||
|
error-disconnected-client = [WebConsole] Es wurde versucht, eine Nachricht an einen nicht verbundenen Client zu senden.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = Die CPU Auslastung liegt bei {0}%.
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0} hat versucht, {1} ohne Erlaubnis auszuführen.
|
||||||
|
cmd-executed-console = [WebConsole] {0} hat "{1}" ausgeführt.
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Eingeloggt.
|
||||||
|
login-sucessful-console = [WebConsole] {0} hat sich erfolgreich eingeloggt.
|
||||||
|
login-failed-message = Falsches Passwort, versuch es nochmal!
|
||||||
|
login-failed-console = [WebConsole] {0} hat das Passwort falsch eingegeben
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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
|
||||||
|
webconsole-active-connections = Aktive Verbindugen von:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Fehler beim lesen der 'latest.log'-Logdatei
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = Benutzer {0} von {1} wie {2}
|
49
phrases_en.properties
Normal file
49
phrases_en.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = Error occured while starting WebSocket Server.
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Connected. Already logged in, welcome back!
|
||||||
|
connection-resumed-console = [WebConsole] Connected and resumed session from {0}
|
||||||
|
connection-login-message = Connection started, waiting login
|
||||||
|
connection-login-console = [WebConsole] Connected and waiting login from {0}
|
||||||
|
unknown-command-message = Unknown command
|
||||||
|
unknown-command-console = [WebConsole] Signal "{0}" was not processed since is not valid. Is your plugin/web interface up to date?
|
||||||
|
forbidden-message = Forbidden
|
||||||
|
forbidden-console = [WebConsole] {0} tried to run "{1}" while not logged in!
|
||||||
|
closed-connection = [WebConsole] Closed connection and logged out from {0}
|
||||||
|
error-on-connection = [WebConsole] Error occurred on connection {0}: {1}
|
||||||
|
started-websocket = [WebConsole] WebSocket Server started successfully.
|
||||||
|
error-disconnected-client = [WebConsole] Attempted to send a message to a disconnected WebSocket client.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = Usage is {0}%
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0} tried to run {1} without permission.
|
||||||
|
cmd-executed-console = [WebConsole] {0} executed "{1}".
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Logged in
|
||||||
|
login-sucessful-console = [WebConsole] {0} successfully logged in.
|
||||||
|
login-failed-message = Incorrect password, try again
|
||||||
|
login-failed-console = [WebConsole] Password incorrect while login from {0}
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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.
|
||||||
|
webconsole-active-connections = Connected to WebConsole from:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Error trying to read latest.log file
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = User {0} from {1} as {2}
|
49
phrases_es.properties
Normal file
49
phrases_es.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = Ocurrió un error al intentar iniciar el servidor WebSocket
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Conectado. Ya habías iniciado sesión, bienvenido de vuelta!
|
||||||
|
connection-resumed-console = [WebConsole] Conectado y resumiendo sesión desde {0}
|
||||||
|
connection-login-message = Conexión iniciada, esperando login.
|
||||||
|
connection-login-console = [WebConsole] Conectado y esperando login desde {0}
|
||||||
|
unknown-command-message = Comando desconocido
|
||||||
|
unknown-command-console = [WebConsole] La señal "{0}" no se ha procesado porque no es válida. ¿Tienes la ultima versión del plugin y de la interfaz web?
|
||||||
|
forbidden-message = Prohibido
|
||||||
|
forbidden-console = [WebConsole] {0} intento ejecutar "{1}" sin tener una sesión iniciada!
|
||||||
|
closed-connection = [WebConsole] Sesión cerrada y desconectado desde {0}
|
||||||
|
error-on-connection = [WebConsole] Ocurrió un error en la conexión con {0}: {1}
|
||||||
|
started-websocket = [WebConsole] Servidor WebSocket iniciado con éxito.
|
||||||
|
error-disconnected-client = [WebConsole] Se intentó enviar un mensaje a un cliente WebSocket que estaba desconectado.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = En uso {0}%
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0} intentó ejecutar {1} sin permiso.
|
||||||
|
cmd-executed-console = [WebConsole] {0} ejecutó "{1}".
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Sesión iniciada
|
||||||
|
login-sucessful-console = [WebConsole] {0} inició sesión con exito.
|
||||||
|
login-failed-message = Contraña incorrecta, inténtalo de nuevo
|
||||||
|
login-failed-console = [WebConsole] Contraseña incorrecta al intentar iniciar sesión desde {0}
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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.
|
||||||
|
webconsole-active-connections = Conectado a WebConsole desde:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Error leyendo el fichero latest.log
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = Usuario {0} desde {1} como {2}
|
49
phrases_fr.properties
Normal file
49
phrases_fr.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = Une erreur s'est produite lors du démarrage de WebSocket Server.
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Connecté. Déjà connecté, bienvenue à nouveau!
|
||||||
|
connection-resumed-console = [WebConsole] Session connectée et reprise à partir de {0}
|
||||||
|
connection-login-message = Connexion démarrée, connexion en attente
|
||||||
|
connection-login-console = [WebConsole] Connexion connectée et en attente depuis {0}
|
||||||
|
unknown-command-message = Commande inconnue
|
||||||
|
unknown-command-console = [WebConsole] Le signal "{0}" n'a pas été traité car il n'est pas valide. Votre plugin / interface web est-il à jour?
|
||||||
|
forbidden-message = Interdit
|
||||||
|
forbidden-console = [WebConsole] {0} a tenté d'exécuter "{1}" alors qu'il n'était pas connecté!
|
||||||
|
closed-connection = [WebConsole] Connexion fermée et déconnecté de {0}
|
||||||
|
error-on-connection = [WebConsole] Une erreur s'est produite lors de la connexion {0}: {1}
|
||||||
|
started-websocket = [WebConsole] WebSocket Server a démarré avec succès.
|
||||||
|
error-disconnected-client = [WebConsole] Vous avez tenté d'envoyer un message à un client WebSocket déconnecté.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = L'utilisation est {0}%
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0} a tenté d'exécuter {1} sans autorisation.
|
||||||
|
cmd-executed-console = [WebConsole] {0} a exécuté "{1}".
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Connecté
|
||||||
|
login-sucessful-console = [WebConsole] {0} session démarrée avec succès.
|
||||||
|
login-failed-message = Mot de passe incorrect, réessayez
|
||||||
|
login-failed-console = [WebConsole] Mot de passe incorrect lors de la connexion depuis {0}
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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.
|
||||||
|
webconsole-active-connections = Connecté à WebConsole depuis:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Erreur lors de la lecture du fichier latest.log
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = Utilisateur {0} depuis {1} comme {2}
|
49
phrases_it.properties
Normal file
49
phrases_it.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = C''è stato un errore mentre avviavo WebConsole server.
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Connesso. Login già fatto, Bentornato!
|
||||||
|
connection-resumed-console = [WebConsole] Connesso e sessione ripresa da {0}
|
||||||
|
connection-login-message = Connessione stabilita, attendo il login
|
||||||
|
connection-login-console = [WebConsole] Connesso e attendo login da {0}
|
||||||
|
unknown-command-message = Comando sconosciuto
|
||||||
|
unknown-command-console = [WebConsole] Il segnale "{0}" non è stato processato siccome non è valido. Il tuo plugin/web interface è aggiornato?
|
||||||
|
forbidden-message = Proibito
|
||||||
|
forbidden-console = [WebConsole] {0} ha tentato di avviare "{1}" mentre non aveva ancora effettuato il login!
|
||||||
|
closed-connection = [WebConsole] Connessione chiusa e disconnessione da {0}
|
||||||
|
error-on-connection = [WebConsole] Si è verificato un errore sulla connessione {0}: {1}
|
||||||
|
started-websocket = [WebConsole] WebSocket Server avviato correttamente.
|
||||||
|
error-disconnected-client = [WebConsole] Tentativo di inviare un messaggio a un client WebSocket disconnesso.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = L''uso è {0}%
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0} ha provato a eseguire {1} senza autorizzazione.
|
||||||
|
cmd-executed-console = [WebConsole] {0} eseguito "{1}".
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Accesso eseguito
|
||||||
|
login-sucessful-console = [WebConsole] {0} ha effettuato l'accesso correttamente.
|
||||||
|
login-failed-message = Password scorretta, riprova
|
||||||
|
login-failed-console = [WebConsole] Password scorretta inserita da {0}
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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.
|
||||||
|
webconsole-active-connections = Connesso a WebConsole da:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Errore metre tentavo di leggere latest.log
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = Utente {0} a partire dal {1} come {2}
|
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}
|
49
phrases_ko.properties
Normal file
49
phrases_ko.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = WebSocket 서버를 시작하는 도중 오류가 발생하였습니다.
|
||||||
|
|
||||||
|
# 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}" 신호는 알맞지 않기 때문에 처리되지 않았습니다. 플러그인 또는 웹 UI가 최신입니까?
|
||||||
|
forbidden-message = 제한되었습니다
|
||||||
|
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 = 사용량은 {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-active-connections = WebConsole에 연결하였습니다:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = latest.log 파일을 불러오는 데 오류가 발생하였습니다
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = 유저 {0}, {1}로부터, {2}로서
|
49
phrases_nl.properties
Normal file
49
phrases_nl.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = Er is een fout opgetreden bij het starten van WebSocket Server.
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Verbonden. Al ingelogd, welkom terug!
|
||||||
|
connection-resumed-console = [WebConsole] Verbonden en hervatte sessie van {0}
|
||||||
|
connection-login-message = Verbinding gestart, wachtend op inloggen
|
||||||
|
connection-login-console = [WebConsole] Verbonden en wachtend op inloggen vanaf {0}
|
||||||
|
unknown-command-message = Onbekend commando
|
||||||
|
unknown-command-console = [WebConsole] Signaal "{0}" is niet verwerkt omdat het niet geldig is. Is uw plugin/web interface up-to-date?
|
||||||
|
forbidden-message = Verboden
|
||||||
|
forbidden-console = [WebConsole] {0} probeerde "{1}" uit te voeren zonder ingelogd te zijn!
|
||||||
|
closed-connection = [WebConsole] Verbinding verbroken en uitgelogd van {0}
|
||||||
|
error-on-connection = [WebConsole] Er is een fout opgetreden bij het verbinden van {0}: {1}
|
||||||
|
started-websocket = [WebConsole] De WebSocket Server is succesvol gestart.
|
||||||
|
error-disconnected-client = [WebConsole] Poging om een bericht te sturen naar een niet-verbonden WebSocket-client.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = Verbruik is {0}%
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0} heeft geprobeerd {1} uit te voeren zonder toestemming.
|
||||||
|
cmd-executed-console = [WebConsole] {0} voerde "{1}" uit.
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Ingelogd
|
||||||
|
login-sucessful-console = [WebConsole] {0} succesvol ingelogd.
|
||||||
|
login-failed-message = Incorrect wachtwoord, probeer het opnieuw
|
||||||
|
login-failed-console = [WebConsole] Wachtwoord onjuist bij inloggen vanaf {0}
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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.
|
||||||
|
webconsole-active-connections = Verbonden aan WebConsole vanaf:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Er is een fout opgetreden bij het lezen van het bestand latest.log
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = Gebruiker {0} uit {1} als {2}
|
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}
|
49
phrases_pt.properties
Normal file
49
phrases_pt.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = Não foi possível conectar-se ao WebSocket.
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Você foi conectado, seja bem-vindo!
|
||||||
|
connection-resumed-console = [WebConsole] {0} foi reconectado.
|
||||||
|
connection-login-message = Você foi conectado, esperando autênticação
|
||||||
|
connection-login-console = [WebConsole] {0} foi conectado, aguardando autênticação.
|
||||||
|
unknown-command-message = Comando desconhecido.
|
||||||
|
unknown-command-console = [WebConsole] "{0}" não pode ser executado poís não é um comando válido. Provavel que o plugin ou client esteja desatualizado.
|
||||||
|
forbidden-message = Acesso Negado
|
||||||
|
forbidden-console = [WebConsole] {0} tentou executar "{1}" mas não está autênticado!
|
||||||
|
closed-connection = [WebConsole] {0} foi desconectado.
|
||||||
|
error-on-connection = [WebConsole] Houve um erro na conexão de {0}: {1}
|
||||||
|
started-websocket = [WebConsole] WebSocket Server foi iniciado com sucesso.
|
||||||
|
error-disconnected-client = [WebConsole] Tentativa de enviar uma mensagem para um cliente WebSocket desconectado..
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = Consumindo {0}%
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0} tentou executar o {1} sem permissão.
|
||||||
|
cmd-executed-console = [WebConsole] {0} executou "{1}".
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Você foi autênticado.
|
||||||
|
login-sucessful-console = [WebConsole] {0} acabou de se conectar.
|
||||||
|
login-failed-message = Senha incorreta, porfavor, contate algum responsável.
|
||||||
|
login-failed-console = [WebConsole] {0} tentou conectar-se, mas falhou ao digitar a senha.
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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.
|
||||||
|
webconsole-active-connections = Atualmente temos:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = Erro ao ler o arquivo latest.log
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = Usuário {0} da {1} como {2}
|
49
phrases_ru.properties
Normal file
49
phrases_ru.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-console = [WebConsole] {0} попытался запустить "{1}", пока не вошел в систему!
|
||||||
|
closed-connection = [WebConsole] Соединение закрытое и выход из {0}
|
||||||
|
error-on-connection = [WebConsole] Произошла ошибка при подключении к {0}: {1}
|
||||||
|
started-websocket = [WebConsole] WebSocket Server успешно запущен.
|
||||||
|
error-disconnected-client = [WebConsole] Попытка отправить сообщение отключенному клиенту WebSocket.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = Использование {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 = Подключен к веб-консоли из :
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = ошибка чтения последнего latest.log
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = пользователь {0} из {1} так как {2}
|
49
phrases_tr.properties
Normal file
49
phrases_tr.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = WebSocket sunucusunu başlatırken hata oluştu.
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = Bağlandı. Zaten giriş yaptın, tekrar hoş geldin!
|
||||||
|
connection-resumed-console = [WebConsole] Bağlandı ve {0} konumundan gelen oturum devam ettirildi
|
||||||
|
connection-login-message = Bağlantı başladı, giriş bekleniyor
|
||||||
|
connection-login-console = [WebConsole] Bağlandı ve {0} konumundan giriş bekleniyor
|
||||||
|
unknown-command-message = Bilinmeyen komut
|
||||||
|
unknown-command-console = [WebConsole] "{0}" sinyali geçerli olmadığından işlenilemedi. Eklentin/web arayüzün güncellenmiş mi?
|
||||||
|
forbidden-message = Forbidden
|
||||||
|
forbidden-console = [WebConsole] {0}, "{1}" giriş yapmamış olmasına rağmen çalıştırmayı denedi!
|
||||||
|
closed-connection = [WebConsole] Bağlantı kapatıldı ve {0} konumundan çıkış yapıldı
|
||||||
|
error-on-connection = [WebConsole] Bağlantıda hata oluştu {0}: {1}
|
||||||
|
started-websocket = [WebConsole] WebSocket sunucusu başarıyla başlatıldı.
|
||||||
|
error-disconnected-client = [WebConsole] Bağlantısı kesilmiş bir WebSocket'a bir mesaj gönderilmeye çalışıldı.
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = Şuanki kullanım %{0}
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0}, {1}'ı yetkisiz olarak çalıştırmayı denedi.
|
||||||
|
cmd-executed-console = [WebConsole] {0}, "{1}" çalıştırdı.
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = Giriş yapıldı
|
||||||
|
login-sucessful-console = [WebConsole] {0} başarıyla giriş yaptı.
|
||||||
|
login-failed-message = Yanlış şifre, tekrar deneyin
|
||||||
|
login-failed-console = [WebConsole] {0} konumundan giriş yapılırken şifre yanlış girildi.
|
||||||
|
|
||||||
|
# PlayersCommand.java
|
||||||
|
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.
|
||||||
|
webconsole-active-connections = WebConsole'a buradan bağlanıldı:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = latest.log dosyasını okumayı denerken hata oluştu
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = {0} isimli kullanıcı {1} konumundan, ayrıca bir {2}
|
49
phrases_zh.properties
Normal file
49
phrases_zh.properties
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# WebConsole.java
|
||||||
|
boot-error = 啟動WebSocket服務器時出錯。
|
||||||
|
|
||||||
|
# WSServer.java
|
||||||
|
connection-resumed-message = 已經登錄,歡迎回來!
|
||||||
|
connection-resumed-console = [網站控制台] 重新恢復連接 {0}
|
||||||
|
connection-login-message = 連接開始,等待登錄
|
||||||
|
connection-login-console = [網站控制台] 已連接並等待登錄 {0}
|
||||||
|
unknown-command-message = 未知的命令
|
||||||
|
unknown-command-console = [網站控制台] 信號 '{0}' 未被處理,因為是無效的。 您的插件/網頁界面是最新的嗎?
|
||||||
|
forbidden-message = 被禁止
|
||||||
|
forbidden-console = [網站控制台] {0} 嘗試在未登錄的情況下運行 '{1}' !
|
||||||
|
closed-connection = [網站控制台] 關閉連接並註銷 {0}
|
||||||
|
error-on-connection = [網站控制台] 連接時出錯 {0}: {1}
|
||||||
|
started-websocket = [網站控制台] 網站控制台 伺服器成功啟動。
|
||||||
|
error-disconnected-client = [WebConsole] 尝试向断开连接的WebSocket客户端发送消息。
|
||||||
|
|
||||||
|
# CpuUsageCommand.java
|
||||||
|
cpu-usage-message = 已使用 {0}%
|
||||||
|
|
||||||
|
# ExecCommand.java
|
||||||
|
no-send-permission-console = [WebConsole] {0}试图未经许可而运行{1}。
|
||||||
|
cmd-executed-console = [網站控制台] {0} 執行 '{1}'.
|
||||||
|
|
||||||
|
# LogInCommand.java
|
||||||
|
login-sucessful-message = 登錄
|
||||||
|
login-sucessful-console = [網站控制台] {0}已成功登录。
|
||||||
|
login-failed-message = 密碼不正確,請重試
|
||||||
|
login-failed-console = [網站控制台] 登錄時密碼不正確 {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 = 網站控制台版本 {0}.
|
||||||
|
webconsole-no-connections = 現在沒有連接登錄網站控制台。
|
||||||
|
webconsole-active-connections = 從以下位置連接到網站控制台:
|
||||||
|
|
||||||
|
# ReadLogFileCommand.java
|
||||||
|
log-read-error = 读取Latest.log文件时出错
|
||||||
|
|
||||||
|
# User.java
|
||||||
|
user-tostring = 用户 {0} 从 {1} 如 {2}
|
11
plugin.yml
11
plugin.yml
@ -1,6 +1,11 @@
|
|||||||
name: WebConsole
|
name: WebConsole
|
||||||
main: com.mesacarlos.webconsole.WebConsole
|
main: es.mesacarlos.webconsole.WebConsole
|
||||||
version: 1.1
|
api-version: 1.13
|
||||||
description: WebSockets-based web console
|
version: 2.4
|
||||||
|
description: WebSocket-based web console
|
||||||
author: Carlos Mesa
|
author: Carlos Mesa
|
||||||
commands:
|
commands:
|
||||||
|
WebConsole:
|
||||||
|
description: Shows version and active connections of WebConsole
|
||||||
|
permission: webconsole.webconsole
|
||||||
|
usage: /WebConsole
|
23
pom.xml
23
pom.xml
@ -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>2.4</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -38,6 +38,7 @@
|
|||||||
<directory>.</directory>
|
<directory>.</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*.yml</include>
|
<include>**/*.yml</include>
|
||||||
|
<include>**/*.properties</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
@ -59,25 +60,37 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
<version>1.8-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- WebSockets Server Dependency -->
|
<!-- WebSockets Server Dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.java-websocket</groupId>
|
<groupId>org.java-websocket</groupId>
|
||||||
<artifactId>Java-WebSocket</artifactId>
|
<artifactId>Java-WebSocket</artifactId>
|
||||||
<version>1.4.0</version>
|
<version>1.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Logger -->
|
<!-- Logger -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-api</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
<version>2.12.1</version>
|
<version>2.17.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-core</artifactId>
|
<artifactId>log4j-core</artifactId>
|
||||||
<version>2.12.1</version>
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
<version>1.7.25</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -1,29 +0,0 @@
|
|||||||
package com.mesacarlos.webconsole.command;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.java_websocket.WebSocket;
|
|
||||||
|
|
||||||
import com.mesacarlos.webconsole.websockets.WSServer;
|
|
||||||
|
|
||||||
public class ExecCommand implements WSCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(WSServer wsServer, WebSocket conn, String command) {
|
|
||||||
|
|
||||||
Bukkit.getLogger().info("[WebConsole] " + conn.getRemoteSocketAddress() + " executed '" + command + "'");
|
|
||||||
ConsoleCommandSender sender = Bukkit.getServer().getConsoleSender();
|
|
||||||
|
|
||||||
try {
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
boolean success = Bukkit.getScheduler()
|
|
||||||
.callSyncMethod(wsServer.getMainClass(), () -> Bukkit.dispatchCommand(sender, command)).get();
|
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.mesacarlos.webconsole.command;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.java_websocket.WebSocket;
|
|
||||||
|
|
||||||
import com.mesacarlos.webconsole.json.LoginRequired;
|
|
||||||
import com.mesacarlos.webconsole.json.Processed;
|
|
||||||
import com.mesacarlos.webconsole.util.LoginManager;
|
|
||||||
import com.mesacarlos.webconsole.websockets.WSServer;
|
|
||||||
|
|
||||||
public class LogInCommand implements WSCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(WSServer wsServer, WebSocket conn, String password) {
|
|
||||||
// If user is logged in, then return.
|
|
||||||
if (LoginManager.getInstance().isLoggedIn(conn.getRemoteSocketAddress()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Get password from config files
|
|
||||||
String receivedPassword = wsServer.getMainClass().getConfig().getString("password");
|
|
||||||
|
|
||||||
if (receivedPassword.equals(password)) {
|
|
||||||
// Password is correct, logging in
|
|
||||||
LoginManager.getInstance().logIn(conn.getRemoteSocketAddress());
|
|
||||||
wsServer.sendToClient(conn, new Processed("Logged In", "LOGIN ********"));
|
|
||||||
Bukkit.getLogger().info("[WebConsole] Successfully logged in from " + conn.getRemoteSocketAddress());
|
|
||||||
} else {
|
|
||||||
wsServer.sendToClient(conn, new LoginRequired("Incorrect password, try again"));
|
|
||||||
Bukkit.getLogger()
|
|
||||||
.info("[WebConsole] Password incorrect while login from " + conn.getRemoteSocketAddress());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package com.mesacarlos.webconsole.command;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.java_websocket.WebSocket;
|
|
||||||
|
|
||||||
import com.mesacarlos.webconsole.json.Players;
|
|
||||||
import com.mesacarlos.webconsole.websockets.WSServer;
|
|
||||||
|
|
||||||
public class PlayersCommand implements WSCommand{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(WSServer wsServer, WebSocket conn, String params) {
|
|
||||||
int connectedPlayers = Bukkit.getOnlinePlayers().size();
|
|
||||||
int maxPlayers = Bukkit.getMaxPlayers();
|
|
||||||
|
|
||||||
wsServer.sendToClient(conn, new Players("Currently " + connectedPlayers + " connected players for a maximum of " + maxPlayers, connectedPlayers, maxPlayers));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.mesacarlos.webconsole.command;
|
|
||||||
|
|
||||||
import org.java_websocket.WebSocket;
|
|
||||||
|
|
||||||
import com.mesacarlos.webconsole.json.RamUsage;
|
|
||||||
import com.mesacarlos.webconsole.websockets.WSServer;
|
|
||||||
|
|
||||||
public class RamUsageCommand implements WSCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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;
|
|
||||||
|
|
||||||
wsServer.sendToClient(conn,
|
|
||||||
new RamUsage(free + " free, " + used + " used, " + max + " maximum memory", free, used, max));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package com.mesacarlos.webconsole.json;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
public class Processed implements JSONOutput{
|
|
||||||
private String message;
|
|
||||||
private String respondsTo;
|
|
||||||
|
|
||||||
public Processed(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Processed(String message, String respondsTo) {
|
|
||||||
this.message = message;
|
|
||||||
this.respondsTo = respondsTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getStatusCode() {
|
|
||||||
return 200;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The command that originated this response
|
|
||||||
* @return WebSockets full command and parameters
|
|
||||||
*/
|
|
||||||
private String getRespondsTo() {
|
|
||||||
return respondsTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toJSON() {
|
|
||||||
JsonObject object = new JsonObject();
|
|
||||||
object.addProperty("status", getStatusCode());
|
|
||||||
object.addProperty("statusDescription", "Processed");
|
|
||||||
object.addProperty("respondsTo", getRespondsTo());
|
|
||||||
object.addProperty("message", getMessage());
|
|
||||||
return object.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package com.mesacarlos.webconsole.util;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class LoginManager {
|
|
||||||
private List<InetSocketAddress> loggedInUsers = new ArrayList<InetSocketAddress>();
|
|
||||||
private static LoginManager instance;
|
|
||||||
|
|
||||||
private LoginManager() {}
|
|
||||||
|
|
||||||
public static LoginManager getInstance() {
|
|
||||||
if(instance == null)
|
|
||||||
instance = new LoginManager();
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logIn(InetSocketAddress address) {
|
|
||||||
loggedInUsers.add(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void logOut(InetSocketAddress address) {
|
|
||||||
loggedInUsers.remove(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLoggedIn(InetSocketAddress address) {
|
|
||||||
return loggedInUsers.contains(address);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
package com.mesacarlos.webconsole.websockets;
|
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.java_websocket.WebSocket;
|
|
||||||
import org.java_websocket.handshake.ClientHandshake;
|
|
||||||
import org.java_websocket.server.WebSocketServer;
|
|
||||||
|
|
||||||
import com.mesacarlos.webconsole.WebConsole;
|
|
||||||
import com.mesacarlos.webconsole.command.CommandFactory;
|
|
||||||
import com.mesacarlos.webconsole.command.WSCommand;
|
|
||||||
import com.mesacarlos.webconsole.json.ConsoleOutput;
|
|
||||||
import com.mesacarlos.webconsole.json.JSONOutput;
|
|
||||||
import com.mesacarlos.webconsole.json.LoginRequired;
|
|
||||||
import com.mesacarlos.webconsole.json.Processed;
|
|
||||||
import com.mesacarlos.webconsole.json.UnknownCommand;
|
|
||||||
import com.mesacarlos.webconsole.util.LoginManager;
|
|
||||||
|
|
||||||
public class WSServer extends WebSocketServer {
|
|
||||||
private HashMap<String, WSCommand> commands = CommandFactory.getCommandsHashMap();
|
|
||||||
private WebConsole plugin;
|
|
||||||
|
|
||||||
public WSServer(WebConsole plugin, InetSocketAddress address) {
|
|
||||||
super(address);
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
|
||||||
if(LoginManager.getInstance().isLoggedIn(conn.getRemoteSocketAddress()))
|
|
||||||
sendToClient(conn, new Processed("Connected. Already logged in, welcome back!"));
|
|
||||||
else
|
|
||||||
sendToClient(conn, new LoginRequired("Connection started, waiting login"));
|
|
||||||
Bukkit.getLogger().info("[WebConsole] Connected and waiting login from " + conn.getRemoteSocketAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessage(WebSocket conn, String message) {
|
|
||||||
// Get command and params
|
|
||||||
String wsCommand = message.split(" ")[0];
|
|
||||||
String wsCommandParams = "";
|
|
||||||
if (message.contains(" "))
|
|
||||||
wsCommandParams = message.split(" ", 2)[1];
|
|
||||||
|
|
||||||
// Run command
|
|
||||||
WSCommand cmd = commands.get(wsCommand);
|
|
||||||
|
|
||||||
if (cmd == null) {
|
|
||||||
//Command does not exist
|
|
||||||
sendToClient(conn, new UnknownCommand("Unknown command", message));
|
|
||||||
Bukkit.getLogger().info(
|
|
||||||
"[WebConsole] Signal '" + message + "' was not processed since is not valid. Is your plugin/web interface up to date?");
|
|
||||||
} else if (!LoginManager.getInstance().isLoggedIn(conn.getRemoteSocketAddress())
|
|
||||||
&& !wsCommand.equals("LOGIN")) {
|
|
||||||
//User is not authorised. DO NOTHING, IMPORTANT!
|
|
||||||
sendToClient(conn, new LoginRequired("Forbidden"));
|
|
||||||
Bukkit.getLogger().warning("[WebConsole] " + conn.getRemoteSocketAddress()
|
|
||||||
+ " tried to run '" + message + "' while not logged in!");
|
|
||||||
} else {
|
|
||||||
cmd.execute(this, conn, wsCommandParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
|
||||||
LoginManager.getInstance().logOut(conn.getRemoteSocketAddress());
|
|
||||||
Bukkit.getLogger()
|
|
||||||
.info("[WebConsole] Closed WS connection " + conn.getRemoteSocketAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(WebSocket conn, Exception ex) {
|
|
||||||
Bukkit.getLogger()
|
|
||||||
.warning("[WebConsole] Error occured on connection " + conn.getRemoteSocketAddress() + ":" + ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
Bukkit.getLogger().info("[WebConsole] WebSocket Server started successfully");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns main class
|
|
||||||
* @return Main plugin class
|
|
||||||
*/
|
|
||||||
public WebConsole getMainClass() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the message to all connected AND logged-in users
|
|
||||||
*/
|
|
||||||
public void onNewConsoleLinePrinted(String line) {
|
|
||||||
Collection<WebSocket> connections = getConnections();
|
|
||||||
for (WebSocket connection : connections) {
|
|
||||||
if (LoginManager.getInstance().isLoggedIn(connection.getRemoteSocketAddress()))
|
|
||||||
sendToClient(connection, new ConsoleOutput(line));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends this JSONOutput to client
|
|
||||||
* @param conn Connection to client
|
|
||||||
* @param content JSONOutput object
|
|
||||||
*/
|
|
||||||
public void sendToClient(WebSocket conn, JSONOutput content) {
|
|
||||||
conn.send(content.toJSON());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +1,8 @@
|
|||||||
package com.mesacarlos.webconsole;
|
package es.mesacarlos.webconsole;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
|
|
||||||
import javax.net.ssl.KeyManagerFactory;
|
import javax.net.ssl.KeyManagerFactory;
|
||||||
@ -13,33 +12,39 @@ import javax.net.ssl.TrustManagerFactory;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.core.Filter;
|
import org.apache.logging.log4j.core.Filter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.java_websocket.server.DefaultSSLWebSocketServerFactory;
|
import org.java_websocket.server.DefaultSSLWebSocketServerFactory;
|
||||||
|
|
||||||
import com.mesacarlos.webconsole.util.LogFilter;
|
import es.mesacarlos.webconsole.config.ConfigManager;
|
||||||
import com.mesacarlos.webconsole.websockets.WSServer;
|
import es.mesacarlos.webconsole.minecraft.WebConsoleCommand;
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
import es.mesacarlos.webconsole.util.LogFilter;
|
||||||
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
|
||||||
public class WebConsole extends JavaPlugin {
|
public class WebConsole extends JavaPlugin {
|
||||||
FileConfiguration config = this.getConfig();
|
|
||||||
|
|
||||||
// Websocket server and thread
|
// Websocket server and thread
|
||||||
private WSServer server;
|
private WSServer server;
|
||||||
private Thread wsThread;
|
private Thread wsThread;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
createConfig();
|
//Change language to user-specified language.
|
||||||
|
Internationalization.setCurrentLocale(ConfigManager.getInstance().getLanguage());
|
||||||
|
|
||||||
|
//Start WebSocket Server
|
||||||
try {
|
try {
|
||||||
startWS();
|
startWS();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getLogger().warning("Error occured while starting WebSockets Server.");
|
Bukkit.getLogger().warning(Internationalization.getPhrase("boot-error"));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This filter is used to read the whole console.
|
||||||
Filter f = new LogFilter(getWSServer());
|
Filter f = new LogFilter(getWSServer());
|
||||||
((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).addFilter(f);
|
((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).addFilter(f);
|
||||||
|
|
||||||
|
//Register /WebConsole command
|
||||||
|
getCommand("WebConsole").setExecutor(new WebConsoleCommand(this.getDescription().getVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,44 +52,24 @@ public class WebConsole extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
server.stop();
|
server.stop();
|
||||||
wsThread = null;
|
wsThread = null;
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates configuration file
|
|
||||||
*/
|
|
||||||
private void createConfig() {
|
|
||||||
// SSL variables
|
|
||||||
config.addDefault("useSSL", false);
|
|
||||||
config.addDefault("StoreType", "JKS");
|
|
||||||
config.addDefault("KeyStore", "plugins/WebConsole/keystore.jks");
|
|
||||||
config.addDefault("StorePassword", "storepassword");
|
|
||||||
config.addDefault("KeyPassword", "keypassword");
|
|
||||||
|
|
||||||
// Connection config variables
|
|
||||||
config.addDefault("host", "localhost");
|
|
||||||
config.addDefault("port", 8080);
|
|
||||||
config.addDefault("password", 1234);
|
|
||||||
|
|
||||||
config.options().copyDefaults(true);
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start WebSocket server
|
* Start WebSocket server
|
||||||
*/
|
*/
|
||||||
private void startWS() throws Exception {
|
private void startWS() throws Exception {
|
||||||
// Create WebSocket server
|
// Create WebSocket server
|
||||||
server = new WSServer(this, new InetSocketAddress(config.getString("host"), config.getInt("port")));
|
server = new WSServer(ConfigManager.getInstance().getSocketAdress());
|
||||||
|
|
||||||
if(config.getBoolean("useSSL")) {
|
if(ConfigManager.getInstance().isSslEnabled()) {
|
||||||
// Configure SSL
|
// Configure SSL
|
||||||
String STORETYPE = config.getString("StoreType");
|
String STORETYPE = ConfigManager.getInstance().getStoreType();
|
||||||
String KEYSTORE = config.getString("KeyStore");
|
String KEYSTORE = ConfigManager.getInstance().getKeyStore();
|
||||||
String STOREPASSWORD = config.getString("StorePassword");
|
String STOREPASSWORD = ConfigManager.getInstance().getStorePassword();
|
||||||
String KEYPASSWORD = config.getString("KeyPassword");
|
String KEYPASSWORD = ConfigManager.getInstance().getKeyPassword();
|
||||||
|
|
||||||
KeyStore ks = KeyStore.getInstance(STORETYPE);
|
KeyStore ks = KeyStore.getInstance(STORETYPE);
|
||||||
File kf = new File(KEYSTORE);
|
File kf = new File(KEYSTORE);
|
||||||
@ -113,6 +98,6 @@ public class WebConsole extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WSServer getWSServer() {
|
public WSServer getWSServer() {
|
||||||
return (WSServer) server;
|
return server;
|
||||||
}
|
}
|
||||||
}
|
}
|
40
src/es/mesacarlos/webconsole/auth/ConnectedUser.java
Normal file
40
src/es/mesacarlos/webconsole/auth/ConnectedUser.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package es.mesacarlos.webconsole.auth;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.config.UserType;
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
|
||||||
|
public class ConnectedUser {
|
||||||
|
private String username;
|
||||||
|
private InetSocketAddress socketAddress;
|
||||||
|
private String token;
|
||||||
|
private UserType userType;
|
||||||
|
|
||||||
|
public ConnectedUser(InetSocketAddress socketAddress, String username, String token, UserType userType) {
|
||||||
|
this.socketAddress = socketAddress;
|
||||||
|
this.username = username;
|
||||||
|
this.token = token;
|
||||||
|
this.userType = userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InetSocketAddress getSocketAddress() {
|
||||||
|
return socketAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserType getUserType() {
|
||||||
|
return userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return Internationalization.getPhrase("user-tostring", username, socketAddress, userType);
|
||||||
|
}
|
||||||
|
}
|
80
src/es/mesacarlos/webconsole/auth/LoginManager.java
Normal file
80
src/es/mesacarlos/webconsole/auth/LoginManager.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package es.mesacarlos.webconsole.auth;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class LoginManager {
|
||||||
|
private ArrayList<ConnectedUser> loggedInUsers = new ArrayList<ConnectedUser>();
|
||||||
|
private static LoginManager instance;
|
||||||
|
|
||||||
|
private LoginManager() {}
|
||||||
|
|
||||||
|
public static LoginManager getInstance() {
|
||||||
|
if(instance == null)
|
||||||
|
instance = new LoginManager();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user in
|
||||||
|
* @param user User to login
|
||||||
|
*/
|
||||||
|
public void logIn(ConnectedUser user) {
|
||||||
|
loggedInUsers.add(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs user out
|
||||||
|
* @param address User to logout
|
||||||
|
*/
|
||||||
|
public void logOut(InetSocketAddress address) {
|
||||||
|
for(ConnectedUser user : loggedInUsers.toArray(new ConnectedUser[loggedInUsers.size()]))
|
||||||
|
if(user.getSocketAddress().equals(address))
|
||||||
|
loggedInUsers.remove(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user object by socket
|
||||||
|
* @param address socket of the user
|
||||||
|
* @return User object, null if no user logged in from that address
|
||||||
|
*/
|
||||||
|
public ConnectedUser getUser(InetSocketAddress address) {
|
||||||
|
for(ConnectedUser user : loggedInUsers)
|
||||||
|
if(user.getSocketAddress().equals(address))
|
||||||
|
return user;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if user is logged in. It checks that both the socket adress and the user token corresponds to a logged in user.
|
||||||
|
* @param address User to check
|
||||||
|
* @return true if user is logged in, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isLoggedIn(InetSocketAddress address, String token) {
|
||||||
|
for(ConnectedUser user : loggedInUsers)
|
||||||
|
if(user.getSocketAddress().equals(address) && user.getToken().equals(token))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an user is logged in from a given socket address
|
||||||
|
* @param address User to check
|
||||||
|
* @return true if user is logged in, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isSocketConnected(InetSocketAddress address) {
|
||||||
|
for(ConnectedUser user : loggedInUsers)
|
||||||
|
if(user.getSocketAddress().equals(address))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the full logged-in user list
|
||||||
|
* @return list of logged in users
|
||||||
|
*/
|
||||||
|
public ArrayList<ConnectedUser> getLoggedInUsers() {
|
||||||
|
return loggedInUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
171
src/es/mesacarlos/webconsole/config/ConfigManager.java
Normal file
171
src/es/mesacarlos/webconsole/config/ConfigManager.java
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
package es.mesacarlos.webconsole.config;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.WebConsole;
|
||||||
|
|
||||||
|
public class ConfigManager {
|
||||||
|
private static ConfigManager instance;
|
||||||
|
private WebConsole plugin = (WebConsole) Bukkit.getPluginManager().getPlugin("WebConsole");
|
||||||
|
private FileConfiguration config = plugin.getConfig();
|
||||||
|
|
||||||
|
private ConfigManager() {
|
||||||
|
loadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ConfigManager getInstance() {
|
||||||
|
if(instance == null)
|
||||||
|
instance = new ConfigManager();
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create configuration file or load it if already exist
|
||||||
|
*/
|
||||||
|
private void loadConfig() {
|
||||||
|
// SSL variables
|
||||||
|
config.addDefault("useSSL", false);
|
||||||
|
config.addDefault("StoreType", "JKS");
|
||||||
|
config.addDefault("KeyStore", "plugins/WebConsole/keystore.jks");
|
||||||
|
config.addDefault("StorePassword", "storepassword");
|
||||||
|
config.addDefault("KeyPassword", "keypassword");
|
||||||
|
|
||||||
|
// Connection config variables
|
||||||
|
config.addDefault("host", "0.0.0.0");
|
||||||
|
config.addDefault("port", 8080);
|
||||||
|
|
||||||
|
// Language config
|
||||||
|
config.addDefault("language", "en");
|
||||||
|
|
||||||
|
//Create passwords section if it does not exist
|
||||||
|
ConfigurationSection passwordsSection = config.getConfigurationSection("passwords");
|
||||||
|
if(passwordsSection == null) {
|
||||||
|
passwordsSection = config.createSection("passwords");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create passwords.admin section if it does not exist
|
||||||
|
ConfigurationSection adminPasswordSection = passwordsSection.getConfigurationSection("admin");
|
||||||
|
if(adminPasswordSection == null) {
|
||||||
|
adminPasswordSection = passwordsSection.createSection("admin");
|
||||||
|
adminPasswordSection.createSection("user1");
|
||||||
|
}
|
||||||
|
|
||||||
|
//For each admin user, create the password value and the commandWhitelist section if it does not exist
|
||||||
|
Set<String> adminUsersSections = adminPasswordSection.getKeys(false);
|
||||||
|
for (String adminUserSectionName : adminUsersSections) {
|
||||||
|
ConfigurationSection userSection = adminPasswordSection.getConfigurationSection(adminUserSectionName);
|
||||||
|
if(userSection == null) {
|
||||||
|
//If userSection is null, that means that the config file is prior to v2.2. We need to update the file to v2.2 by replacing the "user:password" value to a new section for each user.
|
||||||
|
String userPasswordFromOldConfig = adminPasswordSection.getString(adminUserSectionName);
|
||||||
|
userSection = adminPasswordSection.createSection(adminUserSectionName);
|
||||||
|
userSection.set("password", userPasswordFromOldConfig);
|
||||||
|
}
|
||||||
|
userSection.addDefault("password", "mySecurePassword");
|
||||||
|
|
||||||
|
ConfigurationSection commandWhitelist = userSection.getConfigurationSection("commandWhitelist");
|
||||||
|
if(commandWhitelist == null) {
|
||||||
|
commandWhitelist = userSection.createSection("commandWhitelist");
|
||||||
|
commandWhitelist.addDefault("enabled", false);
|
||||||
|
commandWhitelist.addDefault("commandWhitelistActsAsBlacklist", false);
|
||||||
|
commandWhitelist.addDefault("whitelist", Arrays.asList("whisper", "gamemode survival"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create passwords.viewer section if it does not exist
|
||||||
|
ConfigurationSection viewerPasswordSection = passwordsSection.getConfigurationSection("viewer");
|
||||||
|
if(viewerPasswordSection == null) {
|
||||||
|
viewerPasswordSection = passwordsSection.createSection("viewer");
|
||||||
|
}
|
||||||
|
|
||||||
|
config.options().copyDefaults(true);
|
||||||
|
plugin.saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSslEnabled() {
|
||||||
|
return config.getBoolean("useSSL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStoreType() {
|
||||||
|
return config.getString("StoreType");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKeyStore() {
|
||||||
|
return config.getString("KeyStore");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStorePassword() {
|
||||||
|
return config.getString("StorePassword");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKeyPassword() {
|
||||||
|
return config.getString("KeyPassword");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get host and port fields already as InetSocketAddress
|
||||||
|
* @return InetSocketAddress created from the fields host and port of config.yml
|
||||||
|
*/
|
||||||
|
public InetSocketAddress getSocketAdress() {
|
||||||
|
return new InetSocketAddress(config.getString("host"), config.getInt("port"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language code from config.yml
|
||||||
|
* @return language code
|
||||||
|
*/
|
||||||
|
public String getLanguage() {
|
||||||
|
return config.getString("language");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all admins as a UserData list
|
||||||
|
* @return list of admin users
|
||||||
|
*/
|
||||||
|
private List<UserData> getAdmins() {
|
||||||
|
Set<String> adminConfig = plugin.getConfig().getConfigurationSection("passwords").getConfigurationSection("admin").getKeys(false);
|
||||||
|
|
||||||
|
List<UserData> adminUsers = new ArrayList<>();
|
||||||
|
|
||||||
|
for(String username : adminConfig) {
|
||||||
|
adminUsers.add(new UserData(
|
||||||
|
username,
|
||||||
|
plugin.getConfig().getString("passwords.admin." + username + ".password"),
|
||||||
|
UserType.ADMIN,
|
||||||
|
plugin.getConfig().getBoolean("passwords.admin." + username + ".commandWhitelist.enabled"),
|
||||||
|
plugin.getConfig().getBoolean("passwords.admin." + username + ".commandWhitelist.commandWhitelistActsAsBlacklist"),
|
||||||
|
plugin.getConfig().getStringList("passwords.admin." + username + ".commandWhitelist.whitelist")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return adminUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all viewers as a UserData list
|
||||||
|
* @return list of viewer users
|
||||||
|
*/
|
||||||
|
private List<UserData> getViewers() {
|
||||||
|
Map<String, Object> passwords = plugin.getConfig().getConfigurationSection("passwords").getConfigurationSection("viewer").getValues(false);
|
||||||
|
List<UserData> viewerUsers = new ArrayList<>();
|
||||||
|
|
||||||
|
for(Map.Entry<String, Object> entry : passwords.entrySet())
|
||||||
|
viewerUsers.add(new UserData(entry.getKey(), entry.getValue().toString(), UserType.VIEWER, false, false, new ArrayList<>()));
|
||||||
|
|
||||||
|
return viewerUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all registered users
|
||||||
|
* @return All Admin and Viewer users inside config.yml
|
||||||
|
*/
|
||||||
|
public List<UserData> getAllUsers(){
|
||||||
|
List<UserData> users = getAdmins();
|
||||||
|
users.addAll(getViewers());
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
46
src/es/mesacarlos/webconsole/config/UserData.java
Normal file
46
src/es/mesacarlos/webconsole/config/UserData.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package es.mesacarlos.webconsole.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class UserData {
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private UserType userType;
|
||||||
|
private boolean isWhitelistEnabled;
|
||||||
|
private boolean isWhitelistActsAsBlacklist;
|
||||||
|
private List<String> whitelistedCommands;
|
||||||
|
|
||||||
|
public UserData(String username, String password, UserType userType,
|
||||||
|
boolean isWhitelistEnabled, boolean isWhitelistActsAsBlacklist, List<String> whitelistedCommands) {
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
this.userType = userType;
|
||||||
|
this.isWhitelistEnabled = isWhitelistEnabled;
|
||||||
|
this.isWhitelistActsAsBlacklist = isWhitelistActsAsBlacklist;
|
||||||
|
this.whitelistedCommands = whitelistedCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserType getUserType() {
|
||||||
|
return userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWhitelistEnabled() {
|
||||||
|
return isWhitelistEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWhitelistActsAsBlacklist() {
|
||||||
|
return isWhitelistActsAsBlacklist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getWhitelistedCommands() {
|
||||||
|
return whitelistedCommands;
|
||||||
|
}
|
||||||
|
}
|
6
src/es/mesacarlos/webconsole/config/UserType.java
Normal file
6
src/es/mesacarlos/webconsole/config/UserType.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package es.mesacarlos.webconsole.config;
|
||||||
|
|
||||||
|
public enum UserType {
|
||||||
|
ADMIN,
|
||||||
|
VIEWER
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package es.mesacarlos.webconsole.minecraft;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.auth.LoginManager;
|
||||||
|
import es.mesacarlos.webconsole.auth.ConnectedUser;
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
|
||||||
|
public class WebConsoleCommand implements CommandExecutor {
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
public WebConsoleCommand(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
StringBuilder msg = new StringBuilder();
|
||||||
|
|
||||||
|
msg.append(Internationalization.getPhrase("webconsole-version", version) + "\n");
|
||||||
|
ArrayList<ConnectedUser> users = LoginManager.getInstance().getLoggedInUsers();
|
||||||
|
|
||||||
|
if (users.isEmpty()) {
|
||||||
|
msg.append(Internationalization.getPhrase("webconsole-no-connections"));
|
||||||
|
} else {
|
||||||
|
msg.append(Internationalization.getPhrase("webconsole-active-connections") + "\n");
|
||||||
|
for (int i = 0; i < users.size(); i++) {
|
||||||
|
ConnectedUser user = users.get(i);
|
||||||
|
msg.append(user.toString());
|
||||||
|
if(i+1 < users.size())
|
||||||
|
msg.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(msg.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.mesacarlos.webconsole.util;
|
package es.mesacarlos.webconsole.util;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -7,4 +7,8 @@ public class DateTimeUtils {
|
|||||||
public static String getDateAsString() {
|
public static String getDateAsString() {
|
||||||
return new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date());
|
return new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getTimeAsString() {
|
||||||
|
return new SimpleDateFormat("HH:mm:ss").format(new Date());
|
||||||
|
}
|
||||||
}
|
}
|
67
src/es/mesacarlos/webconsole/util/Internationalization.java
Normal file
67
src/es/mesacarlos/webconsole/util/Internationalization.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package es.mesacarlos.webconsole.util;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class Internationalization {
|
||||||
|
private static ResourceBundle messages = ResourceBundle.getBundle("phrases", new Locale("en"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes locale of this application
|
||||||
|
* @param locale String representing language
|
||||||
|
*/
|
||||||
|
public static void setCurrentLocale(String locale) {
|
||||||
|
messages = ResourceBundle.getBundle("phrases", new Locale(locale));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current locale
|
||||||
|
* @return Current locale
|
||||||
|
*/
|
||||||
|
public static Locale getCurrentLocale() {
|
||||||
|
return messages.getLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets translated message
|
||||||
|
* @return The desired message in user's language
|
||||||
|
*/
|
||||||
|
public static String getPhrase(String phrase, Object... params) {
|
||||||
|
String msg = messages.getString(phrase);
|
||||||
|
msg = MessageFormat.format(msg, params);
|
||||||
|
msg = correctEncoding(msg);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Java i18n uses ISO-8859-1 internally, so we need to correct all characters to UTF-8
|
||||||
|
* @param msg Message to correct
|
||||||
|
* @return Message corrected
|
||||||
|
*/
|
||||||
|
private static String correctEncoding(String msg) {
|
||||||
|
try {
|
||||||
|
msg = new String(msg.getBytes("ISO-8859-1"), "UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getPhrase() method expects all params to be ISO-8859-1.
|
||||||
|
* This method will be used when a UTF-8 String is given and you need to use it as a parameter for the above mentioned function.
|
||||||
|
*
|
||||||
|
* @return The same String encoded ISO-8859-1
|
||||||
|
*/
|
||||||
|
public static String utf8ToIso(String msg) {
|
||||||
|
try {
|
||||||
|
msg = new String(msg.getBytes("UTF-8"), "ISO-8859-1");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
93
src/es/mesacarlos/webconsole/util/JsonUtils.java
Normal file
93
src/es/mesacarlos/webconsole/util/JsonUtils.java
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package es.mesacarlos.webconsole.util;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
public class JsonUtils {
|
||||||
|
/*{
|
||||||
|
"command": "LOGIN",
|
||||||
|
"token": "aosduhasiudgasuidgasdgaspid",
|
||||||
|
"params": ""
|
||||||
|
}*/
|
||||||
|
public final static String COMMAND_PROPERTY = "command";
|
||||||
|
public final static String TOKEN_PROPERTY = "token";
|
||||||
|
public final static String PARAMS_PROPERTY = "params";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that a given String is a valid JSON
|
||||||
|
* @param Json JSON to check
|
||||||
|
* @return true if it is a valid JSON, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isValidJson(String Json) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
try {
|
||||||
|
gson.fromJson(Json, Object.class);
|
||||||
|
Object jsonObjType = gson.fromJson(Json, Object.class).getClass();
|
||||||
|
if(jsonObjType.equals(String.class)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (com.google.gson.JsonSyntaxException ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that a given JSON contains some property
|
||||||
|
* @param JsonString JSON to check
|
||||||
|
* @param property property to check
|
||||||
|
* @return true if the JSON string contains that property, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean containsProperty(String JsonString, String property) {
|
||||||
|
if(!isValidJson(JsonString))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
JsonParser parser = new JsonParser();
|
||||||
|
JsonObject obj = parser.parse(JsonString).getAsJsonObject();
|
||||||
|
JsonElement elem = obj.get(property);
|
||||||
|
if(elem == null)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that a given JSON contains some property, and its type is a String
|
||||||
|
* @param JsonString JSON to check
|
||||||
|
* @param property property to check
|
||||||
|
* @returntrue if the JSON string contains that property and it is a String, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean containsStringProperty(String JsonString, String property) {
|
||||||
|
if(!isValidJson(JsonString))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
JsonParser parser = new JsonParser();
|
||||||
|
JsonObject obj = parser.parse(JsonString).getAsJsonObject();
|
||||||
|
JsonElement elem = obj.get(property);
|
||||||
|
if(elem == null)
|
||||||
|
return false;
|
||||||
|
try {
|
||||||
|
elem.getAsString();
|
||||||
|
return true;
|
||||||
|
}catch(Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a String property from a JSON
|
||||||
|
* @param JsonString JSON to check
|
||||||
|
* @param property property to extract from JSON string
|
||||||
|
* @return the value for that property. If the property is not set, an empty string will be returned
|
||||||
|
*/
|
||||||
|
public static String getStringProperty(String JsonString, String property) {
|
||||||
|
JsonParser parser = new JsonParser();
|
||||||
|
JsonObject obj = parser.parse(JsonString).getAsJsonObject();
|
||||||
|
JsonElement result = obj.get(property);
|
||||||
|
if(result != null)
|
||||||
|
return result.getAsString();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.mesacarlos.webconsole.util;
|
package es.mesacarlos.webconsole.util;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.Marker;
|
import org.apache.logging.log4j.Marker;
|
||||||
@ -7,7 +7,7 @@ import org.apache.logging.log4j.core.LogEvent;
|
|||||||
import org.apache.logging.log4j.core.Logger;
|
import org.apache.logging.log4j.core.Logger;
|
||||||
import org.apache.logging.log4j.message.Message;
|
import org.apache.logging.log4j.message.Message;
|
||||||
|
|
||||||
import com.mesacarlos.webconsole.websockets.WSServer;
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
|
||||||
public class LogFilter implements Filter{
|
public class LogFilter implements Filter{
|
||||||
private WSServer wsServer;
|
private WSServer wsServer;
|
116
src/es/mesacarlos/webconsole/websocket/WSServer.java
Normal file
116
src/es/mesacarlos/webconsole/websocket/WSServer.java
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package es.mesacarlos.webconsole.websocket;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.java_websocket.WebSocket;
|
||||||
|
import org.java_websocket.exceptions.WebsocketNotConnectedException;
|
||||||
|
import org.java_websocket.handshake.ClientHandshake;
|
||||||
|
import org.java_websocket.server.WebSocketServer;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.auth.LoginManager;
|
||||||
|
import es.mesacarlos.webconsole.util.DateTimeUtils;
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
import es.mesacarlos.webconsole.util.JsonUtils;
|
||||||
|
import es.mesacarlos.webconsole.websocket.command.WSCommandFactory;
|
||||||
|
import es.mesacarlos.webconsole.websocket.command.WSCommand;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.ConsoleOutput;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.JSONOutput;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.LoginRequired;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.LoggedIn;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.UnknownCommand;
|
||||||
|
|
||||||
|
public class WSServer extends WebSocketServer {
|
||||||
|
|
||||||
|
private final HashMap<String, WSCommand> commands = WSCommandFactory.getCommandsHashMap();
|
||||||
|
|
||||||
|
public WSServer(InetSocketAddress address) {
|
||||||
|
super(address);
|
||||||
|
setReuseAddr(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
||||||
|
if (LoginManager.getInstance().isSocketConnected(conn.getRemoteSocketAddress())) {
|
||||||
|
sendToClient(conn, new LoggedIn(Internationalization.getPhrase("connection-resumed-message")));
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("connection-resumed-console", conn.getRemoteSocketAddress()));
|
||||||
|
} else {
|
||||||
|
sendToClient(conn, new LoginRequired(Internationalization.getPhrase("connection-login-message")));
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("connection-login-console", conn.getRemoteSocketAddress()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMessage(WebSocket conn, String message) {
|
||||||
|
if(!JsonUtils.containsStringProperty(message, "command") //Contains a command
|
||||||
|
|| ( !JsonUtils.containsStringProperty(message, "token") && !JsonUtils.getStringProperty(message, JsonUtils.COMMAND_PROPERTY).equals("LOGIN")) //Contains a token or it is a login command
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Get command and params
|
||||||
|
String wsCommand = JsonUtils.getStringProperty(message, JsonUtils.COMMAND_PROPERTY);
|
||||||
|
String wsToken = JsonUtils.getStringProperty(message, JsonUtils.TOKEN_PROPERTY);
|
||||||
|
String wsCommandParams = JsonUtils.getStringProperty(message, JsonUtils.PARAMS_PROPERTY);
|
||||||
|
|
||||||
|
// Run command
|
||||||
|
WSCommand cmd = commands.get(wsCommand);
|
||||||
|
|
||||||
|
if (cmd == null) {
|
||||||
|
// Command does not exist
|
||||||
|
sendToClient(conn, new UnknownCommand(Internationalization.getPhrase("unknown-command-message"), message));
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("unknown-command-console", message));
|
||||||
|
} else if (!wsCommand.equals("LOGIN")
|
||||||
|
&& !LoginManager.getInstance().isLoggedIn(conn.getRemoteSocketAddress(), wsToken)) {
|
||||||
|
// User is not authorised. DO NOTHING, IMPORTANT!
|
||||||
|
sendToClient(conn, new LoginRequired(Internationalization.getPhrase("forbidden-message")));
|
||||||
|
Bukkit.getLogger().warning(Internationalization.getPhrase("forbidden-console", conn.getRemoteSocketAddress(), message));
|
||||||
|
} else {
|
||||||
|
cmd.execute(this, conn, wsCommandParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
||||||
|
LoginManager.getInstance().logOut(conn.getRemoteSocketAddress());
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("closed-connection", conn.getRemoteSocketAddress()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(WebSocket conn, Exception ex) {
|
||||||
|
Bukkit.getLogger().warning(Internationalization.getPhrase("error-on-connection", conn.getRemoteSocketAddress(), ex));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("started-websocket"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends the message to all connected AND logged-in users
|
||||||
|
*/
|
||||||
|
public void onNewConsoleLinePrinted(String line) {
|
||||||
|
Collection<WebSocket> connections = getConnections();
|
||||||
|
for (WebSocket connection : connections) {
|
||||||
|
if (LoginManager.getInstance().isSocketConnected(connection.getRemoteSocketAddress()))
|
||||||
|
sendToClient(connection, new ConsoleOutput(line, DateTimeUtils.getTimeAsString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends this JSONOutput to client
|
||||||
|
* @param conn Connection to client
|
||||||
|
* @param content JSONOutput object
|
||||||
|
*/
|
||||||
|
public void sendToClient(WebSocket conn, JSONOutput content) {
|
||||||
|
try {
|
||||||
|
conn.send(content.toJSON());
|
||||||
|
}catch(WebsocketNotConnectedException e) {
|
||||||
|
LoginManager.getInstance().logOut(conn.getRemoteSocketAddress());
|
||||||
|
Bukkit.getLogger().warning(Internationalization.getPhrase("error-disconnected-client"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.mesacarlos.webconsole.command;
|
package es.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
|
|
||||||
@ -9,8 +9,9 @@ import javax.management.ObjectName;
|
|||||||
|
|
||||||
import org.java_websocket.WebSocket;
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
import com.mesacarlos.webconsole.json.CpuUsage;
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
import com.mesacarlos.webconsole.websockets.WSServer;
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.CpuUsage;
|
||||||
|
|
||||||
public class CpuUsageCommand implements WSCommand {
|
public class CpuUsageCommand implements WSCommand {
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ public class CpuUsageCommand implements WSCommand {
|
|||||||
public void execute(WSServer wsServer, WebSocket conn, String params) {
|
public void execute(WSServer wsServer, WebSocket conn, String params) {
|
||||||
try {
|
try {
|
||||||
double usage = getProcessCpuLoad();
|
double usage = getProcessCpuLoad();
|
||||||
wsServer.sendToClient(conn, new CpuUsage("Usage is " + usage + "%", usage));
|
wsServer.sendToClient(conn, new CpuUsage(Internationalization.getPhrase("cpu-usage-message", usage), usage));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
package es.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.config.ConfigManager;
|
||||||
|
import es.mesacarlos.webconsole.config.UserData;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.WebConsole;
|
||||||
|
import es.mesacarlos.webconsole.auth.LoginManager;
|
||||||
|
import es.mesacarlos.webconsole.auth.ConnectedUser;
|
||||||
|
import es.mesacarlos.webconsole.config.UserType;
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
|
||||||
|
public class ExecCommand implements WSCommand {
|
||||||
|
LoginManager loginManager = LoginManager.getInstance();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(WSServer wsServer, WebSocket conn, String command) {
|
||||||
|
ConnectedUser u = LoginManager.getInstance().getUser(conn.getRemoteSocketAddress());
|
||||||
|
if(u == null || u.getUserType() != UserType.ADMIN) {
|
||||||
|
if(u != null)
|
||||||
|
Bukkit.getLogger().warning(Internationalization.getPhrase("no-send-permission-console", u, command));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean allowCommand = checkWhitelist(conn, command);
|
||||||
|
if (!allowCommand) {
|
||||||
|
Bukkit.getLogger().warning(Internationalization.getPhrase("no-send-permission-console", u, command));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("cmd-executed-console", conn.getRemoteSocketAddress(), Internationalization.utf8ToIso(command)));
|
||||||
|
ConsoleCommandSender sender = Bukkit.getServer().getConsoleSender();
|
||||||
|
WebConsole plugin = (WebConsole) Bukkit.getPluginManager().getPlugin("WebConsole");
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
boolean success = Bukkit.getScheduler()
|
||||||
|
.callSyncMethod(plugin, () -> Bukkit.dispatchCommand(sender, command)).get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkWhitelist(WebSocket conn, String command) {
|
||||||
|
for(UserData ud : ConfigManager.getInstance().getAllUsers()) {
|
||||||
|
if (ud.getUsername().equals(loginManager.getUser(conn.getRemoteSocketAddress()).getUsername())) {
|
||||||
|
|
||||||
|
if (!ud.isWhitelistEnabled()) { //Skip whitelist check.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] splitCommand = command.split(" ");
|
||||||
|
|
||||||
|
for (String whitelistedCommand : ud.getWhitelistedCommands()) {
|
||||||
|
String[] splitWhitelistedCommand = whitelistedCommand.split(" ");
|
||||||
|
|
||||||
|
if(equalsArray(splitCommand, splitWhitelistedCommand)) {
|
||||||
|
//Command matches the whitelist
|
||||||
|
if(ud.isWhitelistActsAsBlacklist())
|
||||||
|
return false; //If acts as blacklist, do not allow command
|
||||||
|
else
|
||||||
|
return true; //If acts as Whitelist, allow command
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//If execution reached this point, then the command is not in the blacklist.
|
||||||
|
if(ud.isWhitelistActsAsBlacklist())
|
||||||
|
return true; //If acts as blacklist, allow command
|
||||||
|
else
|
||||||
|
return false; //If acts as Whitelist, do not allow command
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("No user matched the whitelist check.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the user command matches the whitelisted command
|
||||||
|
*
|
||||||
|
* @param splitCommand Command sent by user
|
||||||
|
* @param splitWhitelistedCommand Command in the whitelist
|
||||||
|
* @return true if the user command matches the whitelist command
|
||||||
|
*/
|
||||||
|
private boolean equalsArray(String[] splitCommand, String[] splitWhitelistedCommand) {
|
||||||
|
for (int i = 0; i < splitWhitelistedCommand.length; i++)
|
||||||
|
if (!splitCommand[i].equalsIgnoreCase(splitWhitelistedCommand[i]))
|
||||||
|
return false; //Does not match so far
|
||||||
|
return true; //Matches the command
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package es.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.auth.LoginManager;
|
||||||
|
import es.mesacarlos.webconsole.auth.ConnectedUser;
|
||||||
|
import es.mesacarlos.webconsole.config.ConfigManager;
|
||||||
|
import es.mesacarlos.webconsole.config.UserData;
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.LoginRequired;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.LoggedIn;
|
||||||
|
|
||||||
|
public class LogInCommand implements WSCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(WSServer wsServer, WebSocket conn, String password) {
|
||||||
|
// If user is logged in, then return.
|
||||||
|
if (LoginManager.getInstance().isSocketConnected(conn.getRemoteSocketAddress()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Check if user exists
|
||||||
|
for(UserData ud : ConfigManager.getInstance().getAllUsers()) {
|
||||||
|
if(ud.getPassword().equals(password)) {
|
||||||
|
ConnectedUser user = new ConnectedUser(conn.getRemoteSocketAddress(), ud.getUsername(), UUID.randomUUID().toString(), ud.getUserType());
|
||||||
|
LoginManager.getInstance().logIn(user);
|
||||||
|
|
||||||
|
wsServer.sendToClient(conn, new LoggedIn(Internationalization.getPhrase("login-sucessful-message"), "LOGIN ********", user.getUsername(), user.getUserType(), user.getToken()));
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("login-sucessful-console", user.toString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wsServer.sendToClient(conn, new LoginRequired(Internationalization.getPhrase("login-failed-message")));
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("login-failed-console", conn.getRemoteSocketAddress()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package es.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.Players;
|
||||||
|
|
||||||
|
public class PlayersCommand implements WSCommand{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(WSServer wsServer, WebSocket conn, String params) {
|
||||||
|
List<String> connectedPlayersList = new ArrayList<String>();
|
||||||
|
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
connectedPlayersList.add(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
int connectedPlayers = connectedPlayersList.size();
|
||||||
|
int maxPlayers = Bukkit.getMaxPlayers();
|
||||||
|
|
||||||
|
wsServer.sendToClient(conn,
|
||||||
|
new Players(
|
||||||
|
Internationalization.getPhrase("players-message", connectedPlayers, maxPlayers),
|
||||||
|
connectedPlayers,
|
||||||
|
maxPlayers,
|
||||||
|
connectedPlayersList
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package es.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.RamUsage;
|
||||||
|
|
||||||
|
public class RamUsageCommand implements WSCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(WSServer wsServer, WebSocket conn, String params) {
|
||||||
|
Runtime r = Runtime.getRuntime();
|
||||||
|
|
||||||
|
long free = r.freeMemory() / 1024 / 1024;
|
||||||
|
long max = r.maxMemory() / 1024 / 1024;
|
||||||
|
long used = r.totalMemory() / 1024 / 1024 - free;
|
||||||
|
|
||||||
|
wsServer.sendToClient(conn,
|
||||||
|
new RamUsage(
|
||||||
|
Internationalization.getPhrase("ram-usage-message", free, used, max),
|
||||||
|
free,
|
||||||
|
used,
|
||||||
|
max
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package es.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.util.Internationalization;
|
||||||
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
import es.mesacarlos.webconsole.websocket.response.ConsoleOutput;
|
||||||
|
|
||||||
|
public class ReadLogFileCommand implements WSCommand{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(WSServer wsServer, WebSocket conn, String params) {
|
||||||
|
List<String> lines = null;
|
||||||
|
try {
|
||||||
|
lines = Files.readAllLines(Paths.get("logs/latest.log"), StandardCharsets.UTF_8);
|
||||||
|
} catch (IOException e) {
|
||||||
|
try {
|
||||||
|
lines = Files.readAllLines(Paths.get("logs/latest.log"), StandardCharsets.ISO_8859_1);
|
||||||
|
}catch(IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lines == null) {
|
||||||
|
Bukkit.getLogger().info(Internationalization.getPhrase("log-read-error"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String line : lines)
|
||||||
|
wsServer.sendToClient(conn, new ConsoleOutput(line, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package com.mesacarlos.webconsole.command;
|
package es.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
import org.java_websocket.WebSocket;
|
import org.java_websocket.WebSocket;
|
||||||
|
|
||||||
import com.mesacarlos.webconsole.websockets.WSServer;
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
|
||||||
public interface WSCommand {
|
public interface WSCommand {
|
||||||
void execute(WSServer wsServer, WebSocket conn, String params);
|
void execute(WSServer wsServer, WebSocket conn, String params);
|
@ -1,8 +1,8 @@
|
|||||||
package com.mesacarlos.webconsole.command;
|
package es.mesacarlos.webconsole.websocket.command;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class CommandFactory {
|
public class WSCommandFactory {
|
||||||
|
|
||||||
public static HashMap<String, WSCommand> getCommandsHashMap() {
|
public static HashMap<String, WSCommand> getCommandsHashMap() {
|
||||||
HashMap<String, WSCommand> commands = new HashMap<String, WSCommand>();
|
HashMap<String, WSCommand> commands = new HashMap<String, WSCommand>();
|
||||||
@ -11,6 +11,8 @@ public class CommandFactory {
|
|||||||
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());
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,15 @@
|
|||||||
package com.mesacarlos.webconsole.json;
|
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;
|
|
||||||
|
|
||||||
public ConsoleOutput(String message) {
|
private final String message;
|
||||||
|
private final String time;
|
||||||
|
|
||||||
|
public ConsoleOutput(String message, String time) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -19,11 +22,16 @@ public class ConsoleOutput implements JSONOutput{
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toJSON() {
|
public String toJSON() {
|
||||||
JsonObject object = new JsonObject();
|
JsonObject object = new JsonObject();
|
||||||
object.addProperty("status", getStatusCode());
|
object.addProperty("status", getStatusCode());
|
||||||
object.addProperty("statusDescription", "Console Output");
|
object.addProperty("statusDescription", "Console Output");
|
||||||
|
object.addProperty("time", getTime());
|
||||||
object.addProperty("message", getMessage());
|
object.addProperty("message", getMessage());
|
||||||
return object.toString();
|
return object.toString();
|
||||||
}
|
}
|
@ -1,10 +1,11 @@
|
|||||||
package com.mesacarlos.webconsole.json;
|
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;
|
@ -1,4 +1,4 @@
|
|||||||
package com.mesacarlos.webconsole.json;
|
package es.mesacarlos.webconsole.websocket.response;
|
||||||
|
|
||||||
public interface JSONOutput {
|
public interface JSONOutput {
|
||||||
/**
|
/**
|
@ -0,0 +1,76 @@
|
|||||||
|
package es.mesacarlos.webconsole.websocket.response;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.config.UserType;
|
||||||
|
|
||||||
|
public class LoggedIn implements JSONOutput {
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
private String respondsTo;
|
||||||
|
private String username;
|
||||||
|
private UserType as;
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
public LoggedIn(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoggedIn(String message, String respondsTo, String username, UserType as, String token) {
|
||||||
|
this.message = message;
|
||||||
|
this.respondsTo = respondsTo;
|
||||||
|
this.username = username;
|
||||||
|
this.as = as;
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStatusCode() {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The command that originated this response
|
||||||
|
* @return WebSockets full command and parameters
|
||||||
|
*/
|
||||||
|
private String getRespondsTo() {
|
||||||
|
return respondsTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAs() {
|
||||||
|
switch(as) {
|
||||||
|
case ADMIN:
|
||||||
|
return "ADMIN";
|
||||||
|
default:
|
||||||
|
return "VIEWER"; //This is not a security hole bc its just informative...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toJSON() {
|
||||||
|
JsonObject object = new JsonObject();
|
||||||
|
object.addProperty("status", getStatusCode());
|
||||||
|
object.addProperty("statusDescription", "LoggedIn");
|
||||||
|
object.addProperty("respondsTo", getRespondsTo());
|
||||||
|
object.addProperty("username", getUsername());
|
||||||
|
object.addProperty("as", getAs());
|
||||||
|
object.addProperty("token", getToken());
|
||||||
|
object.addProperty("message", getMessage());
|
||||||
|
return object.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,9 +1,10 @@
|
|||||||
package com.mesacarlos.webconsole.json;
|
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;
|
@ -1,16 +1,22 @@
|
|||||||
package com.mesacarlos.webconsole.json;
|
package es.mesacarlos.webconsole.websocket.response;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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 int maxPlayers;
|
|
||||||
|
|
||||||
public Players(String message, int connectedPlayers, int maxPlayers) {
|
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;
|
this.message = message;
|
||||||
this.connectedPlayers = connectedPlayers;
|
this.connectedPlayers = connectedPlayers;
|
||||||
this.maxPlayers = maxPlayers;
|
this.maxPlayers = maxPlayers;
|
||||||
|
this.connectedPlayersList = connectedPlayersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,6 +44,7 @@ public class Players implements JSONOutput{
|
|||||||
object.addProperty("statusDescription", "Players");
|
object.addProperty("statusDescription", "Players");
|
||||||
object.addProperty("connectedPlayers", getConnectedPlayers());
|
object.addProperty("connectedPlayers", getConnectedPlayers());
|
||||||
object.addProperty("maxPlayers", getMaxPlayers());
|
object.addProperty("maxPlayers", getMaxPlayers());
|
||||||
|
object.addProperty("players", new Gson().toJson(connectedPlayersList));
|
||||||
object.addProperty("message", getMessage());
|
object.addProperty("message", getMessage());
|
||||||
return object.toString();
|
return object.toString();
|
||||||
}
|
}
|
@ -1,14 +1,15 @@
|
|||||||
package com.mesacarlos.webconsole.json;
|
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 int free;
|
|
||||||
private int used;
|
|
||||||
private int max;
|
|
||||||
|
|
||||||
public RamUsage(String message, int free, int used, int 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;
|
this.message = message;
|
||||||
this.free = free;
|
this.free = free;
|
||||||
this.used = used;
|
this.used = used;
|
||||||
@ -29,7 +30,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 +38,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 +46,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;
|
||||||
}
|
}
|
||||||
|
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,11 @@
|
|||||||
package com.mesacarlos.webconsole.json;
|
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