Name history error

Discussion in 'BungeeCord Plugin Development' started by IHasSwag, May 20, 2015.

  1. So I made a command /names <username> to fetch a players previous names, but I get this error

    Code (Text):
    20.05 14:36:08 [Server] SEVERE Task BungeeTask([email protected], id=9, [email protected], [email protected], delay=0, period=0, running=true) encountered an exception
    20.05 14:36:08 [Server] INFO org.tgnetwork.proxy.JSON.JSONException: Missing value at 18 [character 19 line 1]
    20.05 14:36:08 [Server] INFO at org.tgnetwork.proxy.JSON.JSONTokener.syntaxError(JSONTokener.java:430)
    20.05 14:36:08 [Server] INFO at org.tgnetwork.proxy.JSON.JSONTokener.nextValue(JSONTokener.java:385)
    20.05 14:36:08 [Server] INFO at org.tgnetwork.proxy.JSON.JSONObject.<init>(JSONObject.java:78)
    20.05 14:36:08 [Server] INFO at org.tgnetwork.proxy.JSON.JSONTokener.nextValue(JSONTokener.java:361)
    20.05 14:36:08 [Server] INFO at org.tgnetwork.proxy.JSON.JSONArray.<init>(JSONArray.java:116)
    20.05 14:36:08 [Server] INFO at org.tgnetwork.proxy.JSON.JSONArray.<init>(JSONArray.java:145)
    20.05 14:36:08 [Server] INFO at org.tgnetwork.proxy.utils.NameFetcher.readJsonFromUrl(NameFetcher.java:95)
    20.05 14:36:08 [Server] INFO at org.tgnetwork.proxy.utils.NameFetcher.access$0(NameFetcher.java:91)
    20.05 14:36:08 [Server] INFO at org.tgnetwork.proxy.utils.NameFetcher$1.run(NameFetcher.java:64)
    20.05 14:36:08 [Server] INFO at net.md_5.bungee.scheduler.BungeeTask.run(BungeeTask.java:63)
    20.05 14:36:08 [Server] INFO at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    20.05 14:36:08 [Server] INFO at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    20.05 14:36:08 [Server] INFO at java.lang.Thread.run(Thread.java:745)
    Anyone know how to fix it?

    Also the errors comes from this medtod:

    Code (Text):
    private JSONArray readJsonFromUrl(String url) throws IOException, JSONException {
            try (InputStream is = new URL(url).openStream()) {
                BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
                String jsonText = readAll(rd);
                return new JSONArray(jsonText);
            }
        }
     
  2. The json seems to be malformed. Can you post an example?
     
  3. I just took the json code from bukkits api, since my plugin is a bungeecord one and bungee doesnt have json