Solved bug with text encoding and changed default host to 0.0.0.0
This commit is contained in:
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user