From d0d0d14a2ff180ad19c13dc1d46463c1ee41eef7 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 8 Jun 2019 23:23:00 +0200 Subject: [PATCH 1/3] Add missing inventory grid files --- .../inventorygrid/InventoryGridConfig.java | 63 ++++++++++++++++++ .../inventorygrid/InventoryGridPlugin.java | 66 +++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridConfig.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridPlugin.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridConfig.java new file mode 100644 index 0000000000..eda6b7cbb8 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridConfig.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018, Jeremy Plsek + * 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.client.plugins.inventorygrid; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("inventorygrid") +public interface InventoryGridConfig extends Config +{ + @ConfigItem( + keyName = "showItem", + name = "Show item", + description = "Show a preview of the item in the new slot" + ) + default boolean showItem() + { + return true; + } + + @ConfigItem( + keyName = "showGrid", + name = "Show grid", + description = "Show a grid on the inventory while dragging" + ) + default boolean showGrid() + { + return true; + } + + @ConfigItem( + keyName = "showHighlight", + name = "Highlight background", + description = "Show a green background highlight on the new slot" + ) + default boolean showHighlight() + { + return true; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridPlugin.java new file mode 100644 index 0000000000..dc6b0ae372 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridPlugin.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018, Jeremy Plsek + * Copyright (c) 2019, 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.client.plugins.inventorygrid; + +import com.google.inject.Inject; +import com.google.inject.Provides; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.overlay.OverlayManager; + +@PluginDescriptor( + name = "Inventory Grid", + description = "Shows a grid over the inventory and a preview of where items will be dragged", + tags = {"items", "overlay"}, + enabledByDefault = false +) +public class InventoryGridPlugin extends Plugin +{ + @Inject + private InventoryGridOverlay overlay; + + @Inject + private OverlayManager overlayManager; + + @Override + public void startUp() + { + overlayManager.add(overlay); + } + + @Override + public void shutDown() + { + overlayManager.remove(overlay); + } + + @Provides + InventoryGridConfig getConfig(ConfigManager configManager) + { + return configManager.getConfig(InventoryGridConfig.class); + } +} From 3bbbda23edf554dfe3c9aba62741592ce6a9d0e8 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 8 Jun 2019 23:37:10 +0200 Subject: [PATCH 2/3] Checkstyle + overseen mistakes --- .../net/runelite/injector/InjectMojo.java | 2 +- .../net/runelite/client/rs/ClientLoader.java | 71 ++++++++++--------- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectMojo.java b/injector-plugin/src/main/java/net/runelite/injector/InjectMojo.java index 333bd1d9d3..08ac162588 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectMojo.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectMojo.java @@ -48,7 +48,7 @@ public class InjectMojo extends AbstractMojo @Parameter(defaultValue = "${project.build.outputDirectory}") private File outputDirectory; - @Parameter(defaultValue = "./rs-client/target/rs-client-${project.version}.jar", readonly = true, required = true) + @Parameter(defaultValue = "./runescape-client/target/rs-client-${project.version}.jar", readonly = true, required = true) private String rsClientPath; @Parameter(defaultValue = "${net.runelite.rs:vanilla:jar}", readonly = true, required = true) diff --git a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java index 71d44f9a8e..e02129c9a1 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java @@ -27,22 +27,16 @@ package net.runelite.client.rs; import net.runelite.api.Client; -import com.google.common.io.ByteStreams; -import io.sigpipe.jbsdiff.InvalidHeaderException; -import io.sigpipe.jbsdiff.Patch; import java.applet.Applet; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.nio.channels.Channels; -import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; import java.security.cert.Certificate; import java.security.cert.CertificateException; @@ -59,15 +53,11 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; - import static net.runelite.client.RuneLite.RUNELITE_DIR; -import static net.runelite.client.rs.ClientUpdateCheckMode.AUTO; import static net.runelite.client.rs.ClientUpdateCheckMode.CUSTOM; -import static net.runelite.client.rs.ClientUpdateCheckMode.NONE; import net.runelite.http.api.RuneLiteAPI; import okhttp3.Request; import okhttp3.Response; -import org.apache.commons.compress.compressors.CompressorException; @Slf4j @Singleton @@ -155,25 +145,32 @@ public class ClientLoader { URL url = new URL("https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/injected-client.jar"); ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream()); - File LOCAL_INJECTED_CLIENT = new File("./injected-client/target/injected-client-"+RuneLiteAPI.getVersion()+".jar"); - File INJECTED_CLIENT = new File(RUNELITE_DIR+"/injected-client.jar"); + File LOCAL_INJECTED_CLIENT = new File("./injected-client/target/injected-client-" + RuneLiteAPI.getVersion() + ".jar"); + File INJECTED_CLIENT = new File(RUNELITE_DIR + "/injected-client.jar"); INJECTED_CLIENT.mkdirs(); - if (INJECTED_CLIENT.exists()) { - if (getFileSize(INJECTED_CLIENT.toURI().toURL())!= getFileSize(url)) { + if (INJECTED_CLIENT.exists()) + { + if (getFileSize(INJECTED_CLIENT.toURI().toURL())!= getFileSize(url)) + { INJECTED_CLIENT.delete(); INJECTED_CLIENT.createNewFile(); System.out.println("Updating Injected Client"); updateInjectedClient(readableByteChannel); } - } else { + } + else + { INJECTED_CLIENT.createNewFile(); System.out.println("Initializing Inject Client"); updateInjectedClient(readableByteChannel); } JarInputStream fis; - if (useLocalInjected) { + if (useLocalInjected) + { fis = new JarInputStream(new FileInputStream(LOCAL_INJECTED_CLIENT)); - } else { + } + else + { fis = new JarInputStream(new FileInputStream(INJECTED_CLIENT)); } byte[] tmp = new byte[4096]; @@ -244,35 +241,43 @@ public class ClientLoader } } - private static int getFileSize(URL url) { + private static int getFileSize(URL url) + { URLConnection conn = null; - try { + try + { conn = url.openConnection(); - if(conn instanceof HttpURLConnection) { - ((HttpURLConnection)conn).setRequestMethod("HEAD"); + if (conn instanceof HttpURLConnection) + { + ((HttpURLConnection) conn).setRequestMethod("HEAD"); } conn.getInputStream(); return conn.getContentLength(); - } catch (IOException e) { + } + catch (IOException e) + { throw new RuntimeException(e); - } finally { - if(conn instanceof HttpURLConnection) { - ((HttpURLConnection)conn).disconnect(); + } + finally + { + if (conn instanceof HttpURLConnection) + { + ((HttpURLConnection) conn).disconnect(); } } } - private void updateInjectedClient(ReadableByteChannel readableByteChannel) { + private void updateInjectedClient(ReadableByteChannel readableByteChannel) + { File INJECTED_CLIENT = new File(RUNELITE_DIR,"injected-client.jar"); - FileOutputStream fileOutputStream = null; - try { - fileOutputStream = new FileOutputStream(INJECTED_CLIENT); - FileChannel fileChannel = fileOutputStream.getChannel(); + try + { + FileOutputStream fileOutputStream = new FileOutputStream(INJECTED_CLIENT); fileOutputStream.getChannel() .transferFrom(readableByteChannel, 0, Long.MAX_VALUE); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { + } + catch (IOException e) + { e.printStackTrace(); } } From cdc2f356c6b6302830ed1d08f8f0f4302491dd59 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 8 Jun 2019 23:43:51 +0200 Subject: [PATCH 3/3] Fix travis hopefully --- .travis.yml | 4 +++- .../src/main/java/net/runelite/client/rs/ClientLoader.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ada8108a37..76201d94c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,6 @@ jdk: - openjdk8 - openjdk11 install: true -script: ./travis/build.sh \ No newline at end of file +script: ./travis/build.sh +before_install: +- chmod +x ./travis/build.sh \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java index e02129c9a1..8acf7e9573 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java @@ -150,7 +150,7 @@ public class ClientLoader INJECTED_CLIENT.mkdirs(); if (INJECTED_CLIENT.exists()) { - if (getFileSize(INJECTED_CLIENT.toURI().toURL())!= getFileSize(url)) + if (getFileSize(INJECTED_CLIENT.toURI().toURL()) != getFileSize(url)) { INJECTED_CLIENT.delete(); INJECTED_CLIENT.createNewFile(); @@ -269,7 +269,7 @@ public class ClientLoader private void updateInjectedClient(ReadableByteChannel readableByteChannel) { - File INJECTED_CLIENT = new File(RUNELITE_DIR,"injected-client.jar"); + File INJECTED_CLIENT = new File(RUNELITE_DIR, "injected-client.jar"); try { FileOutputStream fileOutputStream = new FileOutputStream(INJECTED_CLIENT);