Minor fix

This commit is contained in:
Carlos 2020-03-14 12:03:36 +01:00
parent 39b4ea5592
commit d1e1909e49
2 changed files with 47 additions and 42 deletions

View File

@ -37,7 +37,7 @@ function setLanguage(locale){
"disconnectionModalWelcomeScreenButton": "Back to welcome page",
"settingsLink": "Settings",
"settingsModalLongTitle": "WebConsole Settings",
"showDateSettingsSwitchLabel": "Show date and time on each console line",
"showDateSettingsSwitchLabel": "Show time on each console line",
"readLogFileSwitchLabel": "Retrieve full log file from server after login",
"settingsModalCloseButton": "Done",
"players_online": "Players Online",
@ -75,7 +75,7 @@ function setLanguage(locale){
"disconnectionModalWelcomeScreenButton": "Volver a pagina de inicio",
"settingsLink": "Configuración",
"settingsModalLongTitle": "Configuración de WebConsole",
"showDateSettingsSwitchLabel": "Mostrar fecha y hora en cada linea de consola",
"showDateSettingsSwitchLabel": "Mostrar hora en cada linea de consola",
"readLogFileSwitchLabel": "Leer log completo al iniciar sesión",
"settingsModalCloseButton": "Hecho",
"players_online": "Jugadores en línea",
@ -113,7 +113,7 @@ function setLanguage(locale){
"disconnectionModalWelcomeScreenButton": "Вернуться на страницу приветствия",
"settingsLink": "настройки",
"settingsModalLongTitle": "настройки WebConsole",
"showDateSettingsSwitchLabel": "Показать дату и время в каждой строке консоли",
"showDateSettingsSwitchLabel": "Показать время в каждой строке консоли",
"readLogFileSwitchLabel": "Получить полный файл журнала с сервера после входа в систему",
"settingsModalCloseButton": "Выполнено",
"players_online": "Игроки",
@ -151,7 +151,7 @@ function setLanguage(locale){
"disconnectionModalWelcomeScreenButton": "Voltar à página de boas-vindas",
"settingsLink": "Configurações",
"settingsModalLongTitle": "Configurações do WebConsole",
"showDateSettingsSwitchLabel": "Mostrar data e hora em cada linha do console",
"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",
@ -189,7 +189,7 @@ function setLanguage(locale){
"disconnectionModalWelcomeScreenButton": "返回欢迎页面",
"settingsLink": "设定值",
"settingsModalLongTitle": "WebConsole 设定值",
"showDateSettingsSwitchLabel": "在每个控制台行上显示日期和时间",
"showDateSettingsSwitchLabel": "在每个控制台行上显示时间",
"readLogFileSwitchLabel": "登录后从服务器检索完整的日志文件",
"settingsModalCloseButton": "完成",
"players_online": "在线人数",
@ -227,7 +227,7 @@ function setLanguage(locale){
"disconnectionModalWelcomeScreenButton": "Retour à la page d'accueil",
"settingsLink": "Réglages",
"settingsModalLongTitle": "Réglages de WebConsole",
"showDateSettingsSwitchLabel": "Afficher la date et l'heure sur chaque ligne de console",
"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",
@ -265,7 +265,7 @@ function setLanguage(locale){
"disconnectionModalWelcomeScreenButton": "Zpět na úvodní stránku",
"settingsLink": "Nastavení",
"settingsModalLongTitle": "Nastavení WebConsole",
"showDateSettingsSwitchLabel": "Zobrazit datum a čas na každé řádce konzoly",
"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",

View File

@ -1,36 +1,41 @@
package com.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 com.mesacarlos.webconsole.util.Internationalization;
import com.mesacarlos.webconsole.websocket.WSServer;
import com.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) {
e.printStackTrace();
}
if(lines == null) {
Bukkit.getLogger().info(Internationalization.getPhrase("log-read-error"));
return;
}
for(String line : lines)
wsServer.sendToClient(conn, new ConsoleOutput(line));
}
package com.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 com.mesacarlos.webconsole.util.Internationalization;
import com.mesacarlos.webconsole.websocket.WSServer;
import com.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));
}
}