Merge branch 'master' of github.com:runelite/runelite
This commit is contained in:
@@ -24,10 +24,12 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.http.api;
|
package net.runelite.http.api;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -35,6 +37,9 @@ public class RuneliteAPI
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RuneliteAPI.class);
|
private static final Logger logger = LoggerFactory.getLogger(RuneliteAPI.class);
|
||||||
|
|
||||||
|
public static final OkHttpClient CLIENT = new OkHttpClient();
|
||||||
|
public static final Gson GSON = new Gson();
|
||||||
|
|
||||||
private static final String BASE = "https://api.runelite.net/runelite-";
|
private static final String BASE = "https://api.runelite.net/runelite-";
|
||||||
private static final String WSBASE = "wss://api.runelite.net/runelite-";
|
private static final String WSBASE = "wss://api.runelite.net/runelite-";
|
||||||
private static final Properties properties = new Properties();
|
private static final Properties properties = new Properties();
|
||||||
|
|||||||
@@ -24,13 +24,11 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.http.api.account;
|
package net.runelite.http.api.account;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import net.runelite.http.api.RuneliteAPI;
|
import net.runelite.http.api.RuneliteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
@@ -41,9 +39,6 @@ public class LoginClient
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(LoginClient.class);
|
private static final Logger logger = LoggerFactory.getLogger(LoginClient.class);
|
||||||
|
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
|
||||||
private final Gson gson = new Gson();
|
|
||||||
|
|
||||||
public OAuthResponse login() throws IOException
|
public OAuthResponse login() throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl.Builder builder = RuneliteAPI.getApiBase().newBuilder()
|
HttpUrl.Builder builder = RuneliteAPI.getApiBase().newBuilder()
|
||||||
@@ -58,12 +53,12 @@ public class LoginClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Response response = client.newCall(request).execute();
|
Response response = RuneliteAPI.CLIENT.newCall(request).execute();
|
||||||
|
|
||||||
try (ResponseBody body = response.body())
|
try (ResponseBody body = response.body())
|
||||||
{
|
{
|
||||||
InputStream in = body.byteStream();
|
InputStream in = body.byteStream();
|
||||||
return gson.fromJson(new InputStreamReader(in), OAuthResponse.class);
|
return RuneliteAPI.GSON.fromJson(new InputStreamReader(in), OAuthResponse.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,11 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.http.api.hiscore;
|
package net.runelite.http.api.hiscore;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import net.runelite.http.api.RuneliteAPI;
|
import net.runelite.http.api.RuneliteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
@@ -41,9 +39,6 @@ public class HiscoreClient
|
|||||||
{
|
{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(HiscoreClient.class);
|
private static final Logger logger = LoggerFactory.getLogger(HiscoreClient.class);
|
||||||
|
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
|
||||||
private final Gson gson = new Gson();
|
|
||||||
|
|
||||||
public HiscoreResult lookup(String username) throws IOException
|
public HiscoreResult lookup(String username) throws IOException
|
||||||
{
|
{
|
||||||
HttpUrl.Builder builder = RuneliteAPI.getApiBase().newBuilder()
|
HttpUrl.Builder builder = RuneliteAPI.getApiBase().newBuilder()
|
||||||
@@ -58,12 +53,12 @@ public class HiscoreClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Response response = client.newCall(request).execute();
|
Response response = RuneliteAPI.CLIENT.newCall(request).execute();
|
||||||
|
|
||||||
try (ResponseBody body = response.body())
|
try (ResponseBody body = response.body())
|
||||||
{
|
{
|
||||||
InputStream in = body.byteStream();
|
InputStream in = body.byteStream();
|
||||||
return gson.fromJson(new InputStreamReader(in), HiscoreResult.class);
|
return RuneliteAPI.GSON.fromJson(new InputStreamReader(in), HiscoreResult.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,10 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.http.api.xtea;
|
package net.runelite.http.api.xtea;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import net.runelite.http.api.RuneliteAPI;
|
import net.runelite.http.api.RuneliteAPI;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
@@ -42,9 +40,6 @@ public class XteaClient
|
|||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(XteaClient.class);
|
private static final Logger logger = LoggerFactory.getLogger(XteaClient.class);
|
||||||
|
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
|
||||||
private final Gson gson = new Gson();
|
|
||||||
|
|
||||||
public Response submit(int revision, int region, int[] keys) throws IOException
|
public Response submit(int revision, int region, int[] keys) throws IOException
|
||||||
{
|
{
|
||||||
XteaRequest xteaRequest = new XteaRequest();
|
XteaRequest xteaRequest = new XteaRequest();
|
||||||
@@ -56,7 +51,7 @@ public class XteaClient
|
|||||||
|
|
||||||
xteaRequest.addKey(xteaKey);
|
xteaRequest.addKey(xteaKey);
|
||||||
|
|
||||||
String json = gson.toJson(xteaRequest);
|
String json = RuneliteAPI.GSON.toJson(xteaRequest);
|
||||||
|
|
||||||
HttpUrl.Builder builder = RuneliteAPI.getApiBase().newBuilder()
|
HttpUrl.Builder builder = RuneliteAPI.getApiBase().newBuilder()
|
||||||
.addPathSegment("xtea");
|
.addPathSegment("xtea");
|
||||||
@@ -70,6 +65,6 @@ public class XteaClient
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return client.newCall(request).execute();
|
return RuneliteAPI.CLIENT.newCall(request).execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public class AccountService
|
|||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
try (Connection con = sql2o.beginTransaction())
|
try (Connection con = sql2o.open())
|
||||||
{
|
{
|
||||||
con.createQuery(CREATE_SESSIONS)
|
con.createQuery(CREATE_SESSIONS)
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ package net.runelite.http.service.hiscore;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import net.runelite.http.api.RuneliteAPI;
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
import net.runelite.http.api.hiscore.HiscoreResult;
|
||||||
import net.runelite.http.api.hiscore.Skill;
|
import net.runelite.http.api.hiscore.Skill;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
@@ -41,7 +41,6 @@ public class HiscoreService
|
|||||||
{
|
{
|
||||||
private static final HttpUrl RUNESCAPE_HISCORE_SERVICE = HttpUrl.parse("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws");
|
private static final HttpUrl RUNESCAPE_HISCORE_SERVICE = HttpUrl.parse("http://services.runescape.com/m=hiscore_oldschool/index_lite.ws");
|
||||||
|
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
|
||||||
private HttpUrl url = RUNESCAPE_HISCORE_SERVICE;
|
private HttpUrl url = RUNESCAPE_HISCORE_SERVICE;
|
||||||
|
|
||||||
public HiscoreResult lookup(String username) throws IOException, URISyntaxException
|
public HiscoreResult lookup(String username) throws IOException, URISyntaxException
|
||||||
@@ -53,7 +52,7 @@ public class HiscoreService
|
|||||||
.url(builder.build())
|
.url(builder.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Response response = client.newCall(request).execute();
|
Response response = RuneliteAPI.CLIENT.newCall(request).execute();
|
||||||
String responseStr;
|
String responseStr;
|
||||||
|
|
||||||
try (ResponseBody body = response.body())
|
try (ResponseBody body = response.body())
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ import java.net.URISyntaxException;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.runelite.http.api.RuneliteAPI;
|
||||||
import net.runelite.http.api.worlds.World;
|
import net.runelite.http.api.worlds.World;
|
||||||
import net.runelite.http.api.worlds.WorldResult;
|
import net.runelite.http.api.worlds.WorldResult;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
@@ -41,7 +41,6 @@ public class WorldsService
|
|||||||
{
|
{
|
||||||
private static final HttpUrl WORLD_URL = HttpUrl.parse("http://www.runescape.com/g=oldscape/slr.ws?order=LPWM");
|
private static final HttpUrl WORLD_URL = HttpUrl.parse("http://www.runescape.com/g=oldscape/slr.ws?order=LPWM");
|
||||||
|
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
|
||||||
private HttpUrl url = WORLD_URL;
|
private HttpUrl url = WORLD_URL;
|
||||||
|
|
||||||
public WorldResult listWorlds() throws IOException, URISyntaxException
|
public WorldResult listWorlds() throws IOException, URISyntaxException
|
||||||
@@ -50,7 +49,7 @@ public class WorldsService
|
|||||||
.url(url)
|
.url(url)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Response response = client.newCall(request).execute();
|
Response response = RuneliteAPI.CLIENT.newCall(request).execute();
|
||||||
byte[] b;
|
byte[] b;
|
||||||
|
|
||||||
try (ResponseBody body = response.body())
|
try (ResponseBody body = response.body())
|
||||||
|
|||||||
@@ -43,4 +43,9 @@
|
|||||||
<listener>
|
<listener>
|
||||||
<listener-class>com.commongroundpublishing.slf4j.impl.ServletContextLoggerSCL</listener-class>
|
<listener-class>com.commongroundpublishing.slf4j.impl.ServletContextLoggerSCL</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
||||||
|
<context-param>
|
||||||
|
<param-name>ServletContextLogger.LEVEL</param-name>
|
||||||
|
<param-value>INFO</param-value>
|
||||||
|
</context-param>
|
||||||
</web-app>
|
</web-app>
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import spark.Spark;
|
|
||||||
|
|
||||||
public class ServiceRunner
|
|
||||||
{
|
|
||||||
// not a real test, runs standalone spark
|
|
||||||
//@Test
|
|
||||||
public void run() throws InterruptedException
|
|
||||||
{
|
|
||||||
Service service = new Service();
|
|
||||||
service.init();
|
|
||||||
|
|
||||||
Spark.awaitInitialization();
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
Thread.sleep(1000L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -49,7 +49,8 @@ public enum Skill
|
|||||||
FARMING("Farming"),
|
FARMING("Farming"),
|
||||||
RUNECRAFT("Runecraft"),
|
RUNECRAFT("Runecraft"),
|
||||||
HUNTER("Hunter"),
|
HUNTER("Hunter"),
|
||||||
CONSTRUCTION("Construction");
|
CONSTRUCTION("Construction"),
|
||||||
|
OVERALL("Overall");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ public class HiscorePanel extends PluginPanel
|
|||||||
private final JLabel farmingLabel = new JLabel("--");
|
private final JLabel farmingLabel = new JLabel("--");
|
||||||
private final JLabel constructionLabel = new JLabel("--");
|
private final JLabel constructionLabel = new JLabel("--");
|
||||||
private final JLabel hunterLabel = new JLabel("--");
|
private final JLabel hunterLabel = new JLabel("--");
|
||||||
|
private final JLabel overallLabel = new JLabel("--");
|
||||||
|
|
||||||
private GridLayout stats;
|
private GridLayout stats;
|
||||||
|
|
||||||
@@ -135,6 +136,7 @@ public class HiscorePanel extends PluginPanel
|
|||||||
statsPanel.add(makeSkillPanel(Skill.FARMING, farmingLabel));
|
statsPanel.add(makeSkillPanel(Skill.FARMING, farmingLabel));
|
||||||
statsPanel.add(makeSkillPanel(Skill.CONSTRUCTION, constructionLabel));
|
statsPanel.add(makeSkillPanel(Skill.CONSTRUCTION, constructionLabel));
|
||||||
statsPanel.add(makeSkillPanel(Skill.HUNTER, hunterLabel));
|
statsPanel.add(makeSkillPanel(Skill.HUNTER, hunterLabel));
|
||||||
|
statsPanel.add(makeSkillPanel(Skill.OVERALL, overallLabel));
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
@@ -210,6 +212,7 @@ public class HiscorePanel extends PluginPanel
|
|||||||
setLabel(runecraftLabel, result.getRunecraft());
|
setLabel(runecraftLabel, result.getRunecraft());
|
||||||
setLabel(hunterLabel, result.getHunter());
|
setLabel(hunterLabel, result.getHunter());
|
||||||
setLabel(constructionLabel, result.getConstruction());
|
setLabel(constructionLabel, result.getConstruction());
|
||||||
|
setLabel(overallLabel, result.getOverall());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLabel(JLabel label, net.runelite.http.api.hiscore.Skill skill)
|
private void setLabel(JLabel label, net.runelite.http.api.hiscore.Skill skill)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ PROJECT_VERSION=`mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}
|
|||||||
# Don't deploy pull requests (there are no secrets, anyway)
|
# Don't deploy pull requests (there are no secrets, anyway)
|
||||||
# And don't deploy releases, they are already deployed by the updater before this,
|
# And don't deploy releases, they are already deployed by the updater before this,
|
||||||
# and are signed.
|
# and are signed.
|
||||||
if [[ "${TRAVIS_PULL_REQUEST}" = "false" && $PROJECT_VERSION == *"-SNAPSHOT" ]]; then
|
if [[ "${TRAVIS_PULL_REQUEST}" == "false" && $PROJECT_VERSION == *"-SNAPSHOT" && "$TRAVIS_BRANCH" == "master" ]]; then
|
||||||
mvn clean deploy --settings travis/settings.xml
|
mvn clean deploy --settings travis/settings.xml
|
||||||
else
|
else
|
||||||
mvn clean verify --settings travis/settings.xml
|
mvn clean verify --settings travis/settings.xml
|
||||||
|
|||||||
Reference in New Issue
Block a user