From e54f9e4c8a97a640de53aaaad72712bd0e6d2291 Mon Sep 17 00:00:00 2001 From: noremac201 Date: Sat, 13 May 2017 10:27:21 -0500 Subject: [PATCH 1/7] added total level to highscores/skill enum --- runelite-api/src/main/java/net/runelite/api/Skill.java | 3 ++- .../java/net/runelite/client/plugins/hiscore/HiscorePanel.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/runelite-api/src/main/java/net/runelite/api/Skill.java b/runelite-api/src/main/java/net/runelite/api/Skill.java index 09ceec47b6..08425c4f3c 100644 --- a/runelite-api/src/main/java/net/runelite/api/Skill.java +++ b/runelite-api/src/main/java/net/runelite/api/Skill.java @@ -49,7 +49,8 @@ public enum Skill FARMING("Farming"), RUNECRAFT("Runecraft"), HUNTER("Hunter"), - CONSTRUCTION("Construction"); + CONSTRUCTION("Construction"), + OVERALL("Overall"); private final String name; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java index c118a05298..8a8c197ac1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java @@ -78,6 +78,7 @@ public class HiscorePanel extends PluginPanel private final JLabel farmingLabel = new JLabel("--"); private final JLabel constructionLabel = new JLabel("--"); private final JLabel hunterLabel = new JLabel("--"); + private final JLabel overallLabel = new JLabel("--"); private GridLayout stats; @@ -135,6 +136,7 @@ public class HiscorePanel extends PluginPanel statsPanel.add(makeSkillPanel(Skill.FARMING, farmingLabel)); statsPanel.add(makeSkillPanel(Skill.CONSTRUCTION, constructionLabel)); statsPanel.add(makeSkillPanel(Skill.HUNTER, hunterLabel)); + statsPanel.add(makeSkillPanel(Skill.OVERALL, overallLabel)); } catch (IOException ex) { @@ -210,6 +212,7 @@ public class HiscorePanel extends PluginPanel setLabel(runecraftLabel, result.getRunecraft()); setLabel(hunterLabel, result.getHunter()); setLabel(constructionLabel, result.getConstruction()); + setLabel(overallLabel, result.getOverall()); } private void setLabel(JLabel label, net.runelite.http.api.hiscore.Skill skill) From 566a785ebf811184976c0921aa92d5a78600ab62 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 15 May 2017 17:25:36 -0400 Subject: [PATCH 2/7] travis: only deploy commits on the master branch --- travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/build.sh b/travis/build.sh index 242f8e75f4..28eab54eaf 100755 --- a/travis/build.sh +++ b/travis/build.sh @@ -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) # And don't deploy releases, they are already deployed by the updater before this, # 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 else mvn clean verify --settings travis/settings.xml From 38823d1afae3cfc62aad0a82a9da0d88cd30d465 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 15 May 2017 19:07:41 -0400 Subject: [PATCH 3/7] http-api: share a common http client --- .../src/main/java/net/runelite/http/api/RuneliteAPI.java | 3 +++ .../main/java/net/runelite/http/api/account/LoginClient.java | 4 +--- .../java/net/runelite/http/api/hiscore/HiscoreClient.java | 4 +--- .../src/main/java/net/runelite/http/api/xtea/XteaClient.java | 4 +--- .../net/runelite/http/service/hiscore/HiscoreService.java | 5 ++--- .../java/net/runelite/http/service/worlds/WorldsService.java | 5 ++--- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/http-api/src/main/java/net/runelite/http/api/RuneliteAPI.java b/http-api/src/main/java/net/runelite/http/api/RuneliteAPI.java index 4f193d08a9..2a499fc937 100644 --- a/http-api/src/main/java/net/runelite/http/api/RuneliteAPI.java +++ b/http-api/src/main/java/net/runelite/http/api/RuneliteAPI.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Properties; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,6 +36,8 @@ public class RuneliteAPI { private static final Logger logger = LoggerFactory.getLogger(RuneliteAPI.class); + public static final OkHttpClient CLIENT = new OkHttpClient(); + private static final String BASE = "https://api.runelite.net/runelite-"; private static final String WSBASE = "wss://api.runelite.net/runelite-"; private static final Properties properties = new Properties(); diff --git a/http-api/src/main/java/net/runelite/http/api/account/LoginClient.java b/http-api/src/main/java/net/runelite/http/api/account/LoginClient.java index 60947380c2..ef03953340 100644 --- a/http-api/src/main/java/net/runelite/http/api/account/LoginClient.java +++ b/http-api/src/main/java/net/runelite/http/api/account/LoginClient.java @@ -30,7 +30,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import net.runelite.http.api.RuneliteAPI; import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; @@ -41,7 +40,6 @@ public class LoginClient { 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 @@ -58,7 +56,7 @@ public class LoginClient .url(url) .build(); - Response response = client.newCall(request).execute(); + Response response = RuneliteAPI.CLIENT.newCall(request).execute(); try (ResponseBody body = response.body()) { diff --git a/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java b/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java index 7832c6b42c..23581669f7 100644 --- a/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java +++ b/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java @@ -30,7 +30,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import net.runelite.http.api.RuneliteAPI; import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; @@ -41,7 +40,6 @@ public class HiscoreClient { 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 @@ -58,7 +56,7 @@ public class HiscoreClient .url(url) .build(); - Response response = client.newCall(request).execute(); + Response response = RuneliteAPI.CLIENT.newCall(request).execute(); try (ResponseBody body = response.body()) { diff --git a/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java b/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java index 1fe82a19fa..79cd7fbc9b 100644 --- a/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java +++ b/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java @@ -29,7 +29,6 @@ import java.io.IOException; import net.runelite.http.api.RuneliteAPI; import okhttp3.HttpUrl; import okhttp3.MediaType; -import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @@ -42,7 +41,6 @@ public class XteaClient 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 @@ -70,6 +68,6 @@ public class XteaClient .url(url) .build(); - return client.newCall(request).execute(); + return RuneliteAPI.CLIENT.newCall(request).execute(); } } diff --git a/http-service/src/main/java/net/runelite/http/service/hiscore/HiscoreService.java b/http-service/src/main/java/net/runelite/http/service/hiscore/HiscoreService.java index e88ff4144b..5f265343e8 100644 --- a/http-service/src/main/java/net/runelite/http/service/hiscore/HiscoreService.java +++ b/http-service/src/main/java/net/runelite/http/service/hiscore/HiscoreService.java @@ -26,10 +26,10 @@ package net.runelite.http.service.hiscore; import java.io.IOException; import java.net.URISyntaxException; +import net.runelite.http.api.RuneliteAPI; import net.runelite.http.api.hiscore.HiscoreResult; import net.runelite.http.api.hiscore.Skill; import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; 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 final OkHttpClient client = new OkHttpClient(); private HttpUrl url = RUNESCAPE_HISCORE_SERVICE; public HiscoreResult lookup(String username) throws IOException, URISyntaxException @@ -53,7 +52,7 @@ public class HiscoreService .url(builder.build()) .build(); - Response response = client.newCall(request).execute(); + Response response = RuneliteAPI.CLIENT.newCall(request).execute(); String responseStr; try (ResponseBody body = response.body()) diff --git a/http-service/src/main/java/net/runelite/http/service/worlds/WorldsService.java b/http-service/src/main/java/net/runelite/http/service/worlds/WorldsService.java index e27b381e56..f31c1b0cf1 100644 --- a/http-service/src/main/java/net/runelite/http/service/worlds/WorldsService.java +++ b/http-service/src/main/java/net/runelite/http/service/worlds/WorldsService.java @@ -29,10 +29,10 @@ import java.net.URISyntaxException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; +import net.runelite.http.api.RuneliteAPI; import net.runelite.http.api.worlds.World; import net.runelite.http.api.worlds.WorldResult; import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; 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 final OkHttpClient client = new OkHttpClient(); private HttpUrl url = WORLD_URL; public WorldResult listWorlds() throws IOException, URISyntaxException @@ -50,7 +49,7 @@ public class WorldsService .url(url) .build(); - Response response = client.newCall(request).execute(); + Response response = RuneliteAPI.CLIENT.newCall(request).execute(); byte[] b; try (ResponseBody body = response.body()) From 58292794f3e2011968f464932715c8f9256727c3 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 15 May 2017 19:36:57 -0400 Subject: [PATCH 4/7] http-api: share a common gson instance --- .../src/main/java/net/runelite/http/api/RuneliteAPI.java | 2 ++ .../main/java/net/runelite/http/api/account/LoginClient.java | 5 +---- .../java/net/runelite/http/api/hiscore/HiscoreClient.java | 5 +---- .../src/main/java/net/runelite/http/api/xtea/XteaClient.java | 5 +---- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/http-api/src/main/java/net/runelite/http/api/RuneliteAPI.java b/http-api/src/main/java/net/runelite/http/api/RuneliteAPI.java index 2a499fc937..f3f0cbbeaa 100644 --- a/http-api/src/main/java/net/runelite/http/api/RuneliteAPI.java +++ b/http-api/src/main/java/net/runelite/http/api/RuneliteAPI.java @@ -24,6 +24,7 @@ */ package net.runelite.http.api; +import com.google.gson.Gson; import java.io.IOException; import java.io.InputStream; import java.util.Properties; @@ -37,6 +38,7 @@ public class RuneliteAPI 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 WSBASE = "wss://api.runelite.net/runelite-"; diff --git a/http-api/src/main/java/net/runelite/http/api/account/LoginClient.java b/http-api/src/main/java/net/runelite/http/api/account/LoginClient.java index ef03953340..4e8209d3d9 100644 --- a/http-api/src/main/java/net/runelite/http/api/account/LoginClient.java +++ b/http-api/src/main/java/net/runelite/http/api/account/LoginClient.java @@ -24,7 +24,6 @@ */ package net.runelite.http.api.account; -import com.google.gson.Gson; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -40,8 +39,6 @@ public class LoginClient { private static final Logger logger = LoggerFactory.getLogger(LoginClient.class); - private final Gson gson = new Gson(); - public OAuthResponse login() throws IOException { HttpUrl.Builder builder = RuneliteAPI.getApiBase().newBuilder() @@ -61,7 +58,7 @@ public class LoginClient try (ResponseBody body = response.body()) { InputStream in = body.byteStream(); - return gson.fromJson(new InputStreamReader(in), OAuthResponse.class); + return RuneliteAPI.GSON.fromJson(new InputStreamReader(in), OAuthResponse.class); } } } diff --git a/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java b/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java index 23581669f7..5ac42e4779 100644 --- a/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java +++ b/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java @@ -24,7 +24,6 @@ */ package net.runelite.http.api.hiscore; -import com.google.gson.Gson; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -40,8 +39,6 @@ public class HiscoreClient { private static final Logger logger = LoggerFactory.getLogger(HiscoreClient.class); - private final Gson gson = new Gson(); - public HiscoreResult lookup(String username) throws IOException { HttpUrl.Builder builder = RuneliteAPI.getApiBase().newBuilder() @@ -61,7 +58,7 @@ public class HiscoreClient try (ResponseBody body = response.body()) { InputStream in = body.byteStream(); - return gson.fromJson(new InputStreamReader(in), HiscoreResult.class); + return RuneliteAPI.GSON.fromJson(new InputStreamReader(in), HiscoreResult.class); } } } diff --git a/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java b/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java index 79cd7fbc9b..c32630fa65 100644 --- a/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java +++ b/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java @@ -24,7 +24,6 @@ */ package net.runelite.http.api.xtea; -import com.google.gson.Gson; import java.io.IOException; import net.runelite.http.api.RuneliteAPI; import okhttp3.HttpUrl; @@ -41,8 +40,6 @@ public class XteaClient private static final Logger logger = LoggerFactory.getLogger(XteaClient.class); - private final Gson gson = new Gson(); - public Response submit(int revision, int region, int[] keys) throws IOException { XteaRequest xteaRequest = new XteaRequest(); @@ -54,7 +51,7 @@ public class XteaClient xteaRequest.addKey(xteaKey); - String json = gson.toJson(xteaRequest); + String json = RuneliteAPI.GSON.toJson(xteaRequest); HttpUrl.Builder builder = RuneliteAPI.getApiBase().newBuilder() .addPathSegment("xtea"); From 1171aed33120c0b6af36e4e62c0ac5c6718c75d6 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 15 May 2017 20:45:16 -0400 Subject: [PATCH 5/7] http-service: add ServletContextLogger.LEVEL context-param --- http-service/src/main/webapp/WEB-INF/web.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/http-service/src/main/webapp/WEB-INF/web.xml b/http-service/src/main/webapp/WEB-INF/web.xml index 47ba7366da..1abb728616 100644 --- a/http-service/src/main/webapp/WEB-INF/web.xml +++ b/http-service/src/main/webapp/WEB-INF/web.xml @@ -42,5 +42,10 @@ com.commongroundpublishing.slf4j.impl.ServletContextLoggerSCL - + + + + ServletContextLogger.LEVEL + INFO + \ No newline at end of file From 5250c4f1c3fb698b5b0a132053f1db3b2e7e7f93 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 15 May 2017 20:45:47 -0400 Subject: [PATCH 6/7] http-service: remove old servicerunner test - does not anymore due to guice+JNDI --- .../runelite/http/service/ServiceRunner.java | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 http-service/src/test/java/net/runelite/http/service/ServiceRunner.java diff --git a/http-service/src/test/java/net/runelite/http/service/ServiceRunner.java b/http-service/src/test/java/net/runelite/http/service/ServiceRunner.java deleted file mode 100644 index cd80592b97..0000000000 --- a/http-service/src/test/java/net/runelite/http/service/ServiceRunner.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2017, Adam - * 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); - } - } -} From 08fa07cf0644c501ec77de0382447241b7ee7872 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 15 May 2017 20:46:04 -0400 Subject: [PATCH 7/7] http-service: use open() not beginTransaction() in accountservice init --- .../java/net/runelite/http/service/account/AccountService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-service/src/main/java/net/runelite/http/service/account/AccountService.java b/http-service/src/main/java/net/runelite/http/service/account/AccountService.java index 732a52d111..33a30471e3 100644 --- a/http-service/src/main/java/net/runelite/http/service/account/AccountService.java +++ b/http-service/src/main/java/net/runelite/http/service/account/AccountService.java @@ -101,7 +101,7 @@ public class AccountService public void init() { - try (Connection con = sql2o.beginTransaction()) + try (Connection con = sql2o.open()) { con.createQuery(CREATE_SESSIONS) .executeUpdate();