Solved bug with text encoding and changed default host to 0.0.0.0

This commit is contained in:
Carlos
2020-05-30 13:49:13 +02:00
parent 2643999e8d
commit d1b158a0fe
18 changed files with 240 additions and 214 deletions

View File

@ -74,7 +74,7 @@ public class WebConsole extends JavaPlugin {
config.addDefault("KeyPassword", "keypassword");
// Connection config variables
config.addDefault("host", "localhost");
config.addDefault("host", "0.0.0.0");
config.addDefault("port", 8080);
config.addDefault("password", 1234);

View File

@ -49,4 +49,19 @@ public class Internationalization {
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;
}
}

View File

@ -111,7 +111,7 @@ public class WSServer extends WebSocketServer {
try {
conn.send(content.toJSON());
}catch(WebsocketNotConnectedException e) {
Bukkit.getLogger().warning("Tried to send message to a disconnected client.");
Bukkit.getLogger().warning(Internationalization.getPhrase("error-disconnected-client"));
}
}

View File

@ -14,7 +14,7 @@ public class ExecCommand implements WSCommand {
@Override
public void execute(WSServer wsServer, WebSocket conn, String command) {
Bukkit.getLogger().info(Internationalization.getPhrase("cmd-executed-console", conn.getRemoteSocketAddress(), command));
Bukkit.getLogger().info(Internationalization.getPhrase("cmd-executed-console", conn.getRemoteSocketAddress(), Internationalization.utf8ToIso(command)));
ConsoleCommandSender sender = Bukkit.getServer().getConsoleSender();
try {