Skip to content

Commit 1b34433

Browse files
committed
Last fix of console
1 parent 171a630 commit 1b34433

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/main/java/dev/le_app/mcss_api_java/Server.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ public String[] getConsole(int lines) throws APIUnauthorizedException, IOExcepti
719719
}
720720

721721
//get the JSON array from the object
722-
JSONArray consoleJsonArray = new JSONArray(conn.getInputStream());
722+
InputStreamReader reader = new InputStreamReader(conn.getInputStream());
723+
JSONArray consoleJsonArray = new JSONArray(new JSONTokener(reader));
723724

724725
//Create a string array to store the console
725726
String[] console = new String[consoleJsonArray.length()];
@@ -781,7 +782,8 @@ public String[] getConsoleFromBeginning(int lines, boolean takeFromBeginning) th
781782
}
782783

783784
//get the JSON array from the object
784-
JSONArray consoleJsonArray = new JSONArray(conn.getInputStream());
785+
InputStreamReader reader = new InputStreamReader(conn.getInputStream());
786+
JSONArray consoleJsonArray = new JSONArray(new JSONTokener(reader));
785787

786788
//Create a string array to store the console
787789
String[] console = new String[consoleJsonArray.length()];
@@ -843,7 +845,8 @@ public String[] getConsoleReversed(int lines, boolean reversed) throws APIUnauth
843845
}
844846

845847
//get the JSON array from the object
846-
JSONArray consoleJsonArray = new JSONArray(conn.getInputStream());
848+
InputStreamReader reader = new InputStreamReader(conn.getInputStream());
849+
JSONArray consoleJsonArray = new JSONArray(new JSONTokener(reader));
847850

848851
//Create a string array to store the console
849852
String[] console = new String[consoleJsonArray.length()];
@@ -908,7 +911,8 @@ public String[] getConsole(int lines, boolean takeFromBeginning, boolean reverse
908911
}
909912

910913
//get the JSON array from the object
911-
JSONArray consoleJsonArray = new JSONArray(conn.getInputStream());
914+
InputStreamReader reader = new InputStreamReader(conn.getInputStream());
915+
JSONArray consoleJsonArray = new JSONArray(new JSONTokener(reader));
912916

913917
//Create a string array to store the console
914918
String[] console = new String[consoleJsonArray.length()];

src/test/java/TestMCSSApi.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ void testGetServers() {
119119
name = server.getName();
120120
server.setName("API Test");
121121
assert(server.getName().equals("API Test"));
122+
for (String s : server.getConsole(5)) {
123+
System.out.println(s);
124+
}
122125
server.setName(name);
123126
}
124127
} catch (APIUnauthorizedException e) {

0 commit comments

Comments
 (0)