diff --git a/http-api/src/main/java/net/runelite/http/api/account/OAuthResponse.java b/http-api/src/main/java/net/runelite/http/api/account/OAuthResponse.java index dc9d3c34ad..930540b6eb 100644 --- a/http-api/src/main/java/net/runelite/http/api/account/OAuthResponse.java +++ b/http-api/src/main/java/net/runelite/http/api/account/OAuthResponse.java @@ -25,29 +25,11 @@ package net.runelite.http.api.account; import java.util.UUID; +import lombok.Data; +@Data public class OAuthResponse { private String oauthUrl; private UUID uid; - - public String getOauthUrl() - { - return oauthUrl; - } - - public void setOauthUrl(String oauthUrl) - { - this.oauthUrl = oauthUrl; - } - - public UUID getUid() - { - return uid; - } - - public void setUid(UUID uid) - { - this.uid = uid; - } } diff --git a/http-api/src/main/java/net/runelite/http/api/cache/Cache.java b/http-api/src/main/java/net/runelite/http/api/cache/Cache.java deleted file mode 100644 index 0fe91d6f98..0000000000 --- a/http-api/src/main/java/net/runelite/http/api/cache/Cache.java +++ /dev/null @@ -1,104 +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.api.cache; - -import java.time.Instant; -import java.util.Objects; - -public class Cache -{ - private final int id; - private final int revision; - private final Instant date; - - public Cache(int id, int revision, Instant date) - { - this.id = id; - this.revision = revision; - this.date = date; - } - - @Override - public String toString() - { - return "Cache{" + "id=" + id + ", revision=" + revision + ", date=" + date + '}'; - } - - @Override - public int hashCode() - { - int hash = 5; - hash = 29 * hash + this.id; - hash = 29 * hash + this.revision; - hash = 29 * hash + Objects.hashCode(this.date); - return hash; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - final Cache other = (Cache) obj; - if (this.id != other.id) - { - return false; - } - if (this.revision != other.revision) - { - return false; - } - if (!Objects.equals(this.date, other.date)) - { - return false; - } - return true; - } - - public int getId() - { - return id; - } - - public int getRevision() - { - return revision; - } - - public Instant getDate() - { - return date; - } -} diff --git a/http-api/src/main/java/net/runelite/http/api/cache/CacheArchive.java b/http-api/src/main/java/net/runelite/http/api/cache/CacheArchive.java deleted file mode 100644 index a642f1fe4e..0000000000 --- a/http-api/src/main/java/net/runelite/http/api/cache/CacheArchive.java +++ /dev/null @@ -1,97 +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.api.cache; - -public class CacheArchive -{ - private final int archiveId; - private final int nameHash; - private final int revision; - - public CacheArchive(int archiveId, int nameHash, int revision) - { - this.archiveId = archiveId; - this.nameHash = nameHash; - this.revision = revision; - } - - @Override - public String toString() - { - return "CacheArchive{" + "archiveId=" + archiveId + ", nameHash=" + nameHash + ", revision=" + revision + '}'; - } - - @Override - public int hashCode() - { - int hash = 5; - hash = 71 * hash + this.archiveId; - hash = 71 * hash + this.nameHash; - hash = 71 * hash + this.revision; - return hash; - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - final CacheArchive other = (CacheArchive) obj; - if (this.archiveId != other.archiveId) - { - return false; - } - if (this.nameHash != other.nameHash) - { - return false; - } - if (this.revision != other.revision) - { - return false; - } - return true; - } - - public int getArchiveId() - { - return archiveId; - } - - public int getNameHash() - { - return nameHash; - } - - public int getRevision() - { - return revision; - } -} diff --git a/http-api/src/main/java/net/runelite/http/api/cache/CacheIndex.java b/http-api/src/main/java/net/runelite/http/api/cache/CacheIndex.java deleted file mode 100644 index 17558e4531..0000000000 --- a/http-api/src/main/java/net/runelite/http/api/cache/CacheIndex.java +++ /dev/null @@ -1,85 +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.api.cache; - -public class CacheIndex -{ - private final int indexId; - private final int revision; - - public CacheIndex(int indexId, int revision) - { - this.indexId = indexId; - this.revision = revision; - } - - @Override - public String toString() - { - return "CacheIndex{" + "indexId=" + indexId + ", revision=" + revision + '}'; - } - - @Override - public int hashCode() - { - int hash = 5; - hash = 61 * hash + this.indexId; - hash = 61 * hash + this.revision; - return hash; - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - final CacheIndex other = (CacheIndex) obj; - if (this.indexId != other.indexId) - { - return false; - } - if (this.revision != other.revision) - { - return false; - } - return true; - } - - public int getIndexId() - { - return indexId; - } - - public int getRevision() - { - return revision; - } -} diff --git a/http-api/src/main/java/net/runelite/http/api/ws/messages/Handshake.java b/http-api/src/main/java/net/runelite/http/api/ws/messages/Handshake.java index 557f8f524b..5320c95ab5 100644 --- a/http-api/src/main/java/net/runelite/http/api/ws/messages/Handshake.java +++ b/http-api/src/main/java/net/runelite/http/api/ws/messages/Handshake.java @@ -25,19 +25,11 @@ package net.runelite.http.api.ws.messages; import java.util.UUID; +import lombok.Data; import net.runelite.http.api.ws.WebsocketMessage; +@Data public class Handshake extends WebsocketMessage { private UUID session; - - public UUID getSession() - { - return session; - } - - public void setSession(UUID session) - { - this.session = session; - } } diff --git a/http-api/src/main/java/net/runelite/http/api/ws/messages/LoginResponse.java b/http-api/src/main/java/net/runelite/http/api/ws/messages/LoginResponse.java index b517e773a2..8f22db8f80 100644 --- a/http-api/src/main/java/net/runelite/http/api/ws/messages/LoginResponse.java +++ b/http-api/src/main/java/net/runelite/http/api/ws/messages/LoginResponse.java @@ -24,29 +24,14 @@ */ package net.runelite.http.api.ws.messages; +import lombok.Data; import net.runelite.http.api.ws.WebsocketMessage; /** * Called after a successful login to the server - * @author Adam */ +@Data public class LoginResponse extends WebsocketMessage { private String username; - - public String getUsername() - { - return username; - } - - public void setUsername(String username) - { - this.username = username; - } - - @Override - public String toString() - { - return "LoginResponse{" + "username=" + username + '}'; - } } diff --git a/http-api/src/main/java/net/runelite/http/api/xtea/XteaKey.java b/http-api/src/main/java/net/runelite/http/api/xtea/XteaKey.java index c108f223cb..bed2a017f1 100644 --- a/http-api/src/main/java/net/runelite/http/api/xtea/XteaKey.java +++ b/http-api/src/main/java/net/runelite/http/api/xtea/XteaKey.java @@ -24,28 +24,11 @@ */ package net.runelite.http.api.xtea; +import lombok.Data; + +@Data public class XteaKey { private int region; private int keys[]; - - public int getRegion() - { - return region; - } - - public void setRegion(int region) - { - this.region = region; - } - - public int[] getKeys() - { - return keys; - } - - public void setKeys(int[] keys) - { - this.keys = keys; - } } diff --git a/http-api/src/main/java/net/runelite/http/api/xtea/XteaRequest.java b/http-api/src/main/java/net/runelite/http/api/xtea/XteaRequest.java index f84c85b83b..fdce607f59 100644 --- a/http-api/src/main/java/net/runelite/http/api/xtea/XteaRequest.java +++ b/http-api/src/main/java/net/runelite/http/api/xtea/XteaRequest.java @@ -26,27 +26,14 @@ package net.runelite.http.api.xtea; import java.util.ArrayList; import java.util.List; +import lombok.Data; +@Data public class XteaRequest { private int revision; private List keys = new ArrayList<>(); - public int getRevision() - { - return revision; - } - - public void setRevision(int revision) - { - this.revision = revision; - } - - public List getKeys() - { - return keys; - } - public void addKey(XteaKey key) { keys.add(key); diff --git a/injector/src/main/java/com/openosrs/injector/Injector.java b/injector/src/main/java/com/openosrs/injector/Injector.java index 2264ff15f1..b767970b3f 100644 --- a/injector/src/main/java/com/openosrs/injector/Injector.java +++ b/injector/src/main/java/com/openosrs/injector/Injector.java @@ -18,6 +18,7 @@ import com.openosrs.injector.injectors.RSApiInjector; import com.openosrs.injector.injectors.raw.AddPlayerToMenu; import com.openosrs.injector.injectors.raw.ClearColorBuffer; import com.openosrs.injector.injectors.raw.DrawMenu; +import com.openosrs.injector.injectors.raw.GameDrawingMode; import com.openosrs.injector.injectors.raw.GraphicsObject; import com.openosrs.injector.injectors.raw.Occluder; import com.openosrs.injector.injectors.raw.RasterizerAlpha; @@ -149,6 +150,8 @@ public class Injector extends InjectData implements InjectTaskHandler inject(new DrawMenu(this)); + inject(new GameDrawingMode(this)); + inject(new AddPlayerToMenu(this)); inject(new RuneliteMenuEntry(this)); diff --git a/injector/src/main/java/com/openosrs/injector/injectors/raw/GameDrawingMode.java b/injector/src/main/java/com/openosrs/injector/injectors/raw/GameDrawingMode.java new file mode 100644 index 0000000000..977d304a89 --- /dev/null +++ b/injector/src/main/java/com/openosrs/injector/injectors/raw/GameDrawingMode.java @@ -0,0 +1,50 @@ +package com.openosrs.injector.injectors.raw; + +import com.openosrs.injector.InjectUtil; +import com.openosrs.injector.injection.InjectData; +import com.openosrs.injector.injectors.AbstractInjector; +import java.util.ListIterator; +import net.runelite.asm.ClassFile; +import net.runelite.asm.Method; +import net.runelite.asm.attributes.code.Instruction; +import net.runelite.asm.attributes.code.Instructions; +import net.runelite.asm.attributes.code.instructions.LDC; +import net.runelite.asm.attributes.code.instructions.PutStatic; +import net.runelite.asm.pool.Field; + +public class GameDrawingMode extends AbstractInjector +{ + public GameDrawingMode(InjectData inject) + { + super(inject); + } + + public void inject() + { + final ClassFile clientVanilla = inject.toVanilla( + inject.getDeobfuscated() + .findClass("Client") + ); + final Field gameDrawingMode = InjectUtil.findField(inject, "gameDrawingMode", "Client").getPoolField(); + + Method clinit = clientVanilla.findMethod(""); + + Instructions ins = clinit.getCode().getInstructions(); + ListIterator iterator = ins.getInstructions().listIterator(); + while (iterator.hasNext()) + { + Instruction i = iterator.next(); + + if (i instanceof PutStatic) + { + Field field = ((PutStatic) i).getField(); + + if (field.getName().equals(gameDrawingMode.getName())) + { + iterator.add(new LDC(ins, 2)); + iterator.add(new PutStatic(ins, gameDrawingMode)); + } + } + } + } +} diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 8d2f72637b..3416338a3b 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -965,20 +965,6 @@ public interface Client extends GameEngine */ long getOverallExperience(); - /** - * Gets the game drawing mode. - * - * @return the game drawing mode - */ - int getGameDrawingMode(); - - /** - * Sets the games drawing mode. - * - * @param gameDrawingMode the new drawing mode - */ - void setGameDrawingMode(int gameDrawingMode); - /** * Refreshes the chat. */ diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLite.java b/runelite-client/src/main/java/net/runelite/client/RuneLite.java index 857752fb1d..96b5ed19b2 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -30,19 +30,27 @@ import com.google.common.annotations.VisibleForTesting; import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.Injector; +import com.openosrs.client.OpenOSRS; import com.openosrs.client.game.PlayerManager; +import com.openosrs.client.ui.OpenOSRSSplashScreen; +import java.applet.Applet; import java.io.File; +import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.net.Authenticator; import java.net.PasswordAuthentication; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; +import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.security.cert.X509Certificate; import java.util.Locale; import java.util.Optional; +import java.util.stream.Stream; import javax.annotation.Nullable; import javax.inject.Provider; import javax.inject.Singleton; @@ -50,8 +58,6 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import javax.swing.SwingUtilities; - -import com.openosrs.client.OpenOSRS; import joptsimple.ArgumentAcceptingOptionSpec; import joptsimple.OptionParser; import joptsimple.OptionSet; @@ -61,6 +67,7 @@ import joptsimple.util.EnumConverter; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; +import net.runelite.api.Constants; import net.runelite.client.account.SessionManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.discord.DiscordService; @@ -73,7 +80,6 @@ import net.runelite.client.rs.ClientLoader; import net.runelite.client.rs.ClientUpdateCheckMode; import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.FatalErrorDialog; -import com.openosrs.client.ui.OpenOSRSSplashScreen; import net.runelite.client.ui.SplashScreen; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.WidgetOverlay; @@ -92,7 +98,8 @@ import org.slf4j.LoggerFactory; @Slf4j public class RuneLite { - public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), ".openosrs"); + public static final String OPENOSRS = ".openosrs"; + public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), OPENOSRS); public static final File CACHE_DIR = new File(RUNELITE_DIR, "cache"); public static final File PLUGINS_DIR = new File(RUNELITE_DIR, "plugin-hub"); public static final File PROFILES_DIR = new File(RUNELITE_DIR, "profiles"); @@ -151,6 +158,10 @@ public class RuneLite @Inject private WorldService worldService; + @Inject + @Nullable + private Applet applet; + @Inject @Nullable private Client client; @@ -336,6 +347,28 @@ public class RuneLite injector.injectMembers(client); } + // Start the applet + if (applet != null) + { + copyJagexCache(); + + // Client size must be set prior to init + applet.setSize(Constants.GAME_FIXED_SIZE); + + // Change user.home so the client places jagexcache in the .runelite directory + String oldHome = System.setProperty("user.home", RUNELITE_DIR.getAbsolutePath()); + try + { + applet.init(); + } + finally + { + System.setProperty("user.home", oldHome); + } + + applet.start(); + } + SplashScreen.stage(.57, null, "Loading configuration"); // Load user configuration @@ -558,4 +591,36 @@ public class RuneLite String launcherVersion = System.getProperty("launcher.version"); System.setProperty("runelite.launcher.version", launcherVersion == null ? "unknown" : launcherVersion); } -} \ No newline at end of file + + private static void copyJagexCache() + { + Path from = Paths.get(System.getProperty("user.home"), "jagexcache"); + Path to = Paths.get(System.getProperty("user.home"), OPENOSRS, "jagexcache"); + if (Files.exists(to) || !Files.exists(from)) + { + return; + } + + log.info("Copying jagexcache from {} to {}", from, to); + + // Recursively copy path https://stackoverflow.com/a/50418060 + try (Stream stream = Files.walk(from)) + { + stream.forEach(source -> + { + try + { + Files.copy(source, to.resolve(from.relativize(source)), COPY_ATTRIBUTES); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + }); + } + catch (Exception e) + { + log.warn("unable to copy jagexcache", e); + } + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index 1b0e33560a..37ab9c7c99 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -27,7 +27,6 @@ package net.runelite.client.config; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.ComparisonChain; -import com.google.common.collect.ImmutableSet; import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; import com.google.gson.Gson; @@ -78,11 +77,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import java.util.function.Predicate; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.annotation.Nullable; import javax.inject.Inject; @@ -166,7 +161,7 @@ public class ConfigManager this.propertiesFile = getPropertiesFile(); this.gson = gson; - scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS); + scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 5 * 60, TimeUnit.SECONDS); } public String getRSProfileKey() @@ -268,8 +263,6 @@ public class ConfigManager } } } - - migrateConfig(); } private void syncPropertiesFromFile(File propertiesFile) @@ -1254,116 +1247,6 @@ public class ConfigManager return new String[]{group, profile, key}; } - private synchronized void migrateConfig() - { - String migrationKey = "profileMigrationDone"; - if (getConfiguration("runelite", migrationKey) != null) - { - return; - } - - Map profiles = new HashMap<>(); - - AtomicInteger changes = new AtomicInteger(); - List> migrators = new ArrayList<>(); - for (String[] tpl : new String[][] - { - {"(grandexchange)\\.buylimit_(%)\\.(#)", "$1.buylimit.$3"}, - {"(timetracking)\\.(%)\\.(autoweed|contract)", "$1.$3"}, - {"(timetracking)\\.(%)\\.(#\\.#)", "$1.$3"}, - {"(timetracking)\\.(%)\\.(birdhouse)\\.(#)", "$1.$3.$4"}, - {"(killcount|personalbest)\\.(%)\\.([^.]+)", "$1.$3"}, - {"(geoffer)\\.(%)\\.(#)", "$1.$3"}, - }) - { - String replace = tpl[1]; - String pat = ("^" + tpl[0] + "$") - .replace("#", "-?[0-9]+") - .replace("(%)", "(?.*)"); - Pattern p = Pattern.compile(pat); - - migrators.add(oldkey -> - { - Matcher m = p.matcher(oldkey); - if (!m.find()) - { - return false; - } - - String newKey = m.replaceFirst(replace); - String username = m.group("login").toLowerCase(Locale.US); - - if (username.startsWith(RSPROFILE_GROUP + ".")) - { - return false; - } - - String profKey = profiles.computeIfAbsent(username, u -> - findRSProfile(getRSProfiles(), u, RuneScapeProfileType.STANDARD, u, true).getKey()); - - String[] oldKeySplit = splitKey(oldkey); - if (oldKeySplit == null) - { - log.warn("skipping migration of invalid key \"{}\"", oldkey); - return false; - } - if (oldKeySplit[KEY_SPLITTER_PROFILE] != null) - { - log.debug("skipping migrated key \"{}\"", oldkey); - return false; - } - - String[] newKeySplit = splitKey(newKey); - if (newKeySplit == null || newKeySplit[KEY_SPLITTER_PROFILE] != null) - { - log.warn("migration produced a bad key: \"{}\" -> \"{}\"", oldkey, newKey); - return false; - } - - if (changes.getAndAdd(1) <= 0) - { - File file = new File(propertiesFile.getParent(), propertiesFile.getName() + "." + TIME_FORMAT.format(new Date())); - log.info("backing up pre-migration config to {}", file); - try - { - saveToFile(file); - } - catch (IOException e) - { - log.error("Backup failed", e); - throw new RuntimeException(e); - } - } - - String oldGroup = oldKeySplit[KEY_SPLITTER_GROUP]; - String oldKeyPart = oldKeySplit[KEY_SPLITTER_KEY]; - String value = getConfiguration(oldGroup, oldKeyPart); - setConfiguration(newKeySplit[KEY_SPLITTER_GROUP], profKey, newKeySplit[KEY_SPLITTER_KEY], value); - unsetConfiguration(oldGroup, oldKeyPart); - return true; - }); - } - - Set keys = (Set) ImmutableSet.copyOf((Set) properties.keySet()); - keys: - for (String key : keys) - { - for (Predicate mig : migrators) - { - if (mig.test(key)) - { - continue keys; - } - } - } - - if (changes.get() > 0) - { - log.info("migrated {} config keys", changes); - } - setConfiguration("runelite", migrationKey, 1); - } - /** * Retrieves a consumer from config group and key name */ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java index aa2e397f99..ec934a7d6d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/HotColdClue.java @@ -66,10 +66,6 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat "Jorral", "Speak to Jorral to receive a strange device.", new WorldPoint(2436, 3347, 0)); - private static final HotColdClue MASTER_CLUE_LEAGUE = new HotColdClue("Buried beneath the ground, who knows where it's found. Lucky for you, A man called Watson may have a clue.", - "Watson", - "Speak to Watson to receive a strange device.", - new WorldPoint(1645, 3572, 0)); private final String text; private final String npc; @@ -91,11 +87,6 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat MASTER_CLUE.reset(); return MASTER_CLUE; } - else if (MASTER_CLUE_LEAGUE.text.equalsIgnoreCase(text)) - { - MASTER_CLUE_LEAGUE.reset(); - return MASTER_CLUE_LEAGUE; - } return null; } @@ -290,7 +281,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat { temperatureSet = HotColdTemperature.BEGINNER_HOT_COLD_TEMPERATURES; } - else if (this == MASTER_CLUE || this == MASTER_CLUE_LEAGUE) + else if (this == MASTER_CLUE) { temperatureSet = HotColdTemperature.MASTER_HOT_COLD_TEMPERATURES; } @@ -314,9 +305,8 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat return false; } - boolean master = this == MASTER_CLUE || this == MASTER_CLUE_LEAGUE; if ((this == BEGINNER_CLUE && temperature == HotColdTemperature.BEGINNER_VISIBLY_SHAKING) - || (master && temperature == HotColdTemperature.MASTER_VISIBLY_SHAKING)) + || (this == MASTER_CLUE && temperature == HotColdTemperature.MASTER_VISIBLY_SHAKING)) { markFinalSpot(localWorld); } @@ -346,7 +336,7 @@ public class HotColdClue extends ClueScroll implements LocationClueScroll, Locat { isBeginner = true; } - else if (this == MASTER_CLUE || this == MASTER_CLUE_LEAGUE) + else if (this == MASTER_CLUE) { isBeginner = false; } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java index c7ccb1a3ed..9b284bf6df 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientPanel.java @@ -29,7 +29,6 @@ import java.awt.BorderLayout; import java.awt.Color; import javax.annotation.Nullable; import javax.swing.JPanel; -import net.runelite.api.Client; import net.runelite.api.Constants; final class ClientPanel extends JPanel @@ -47,20 +46,6 @@ final class ClientPanel extends JPanel return; } - client.setLayout(null); - client.setSize(Constants.GAME_FIXED_SIZE); - - client.init(); - client.start(); - add(client, BorderLayout.CENTER); - - // This causes the whole game frame to be redrawn each frame instead - // of only the viewport, so we can hook to MainBufferProvider#draw - // and draw anywhere without it leaving artifacts - if (client instanceof Client) - { - ((Client)client).setGameDrawingMode(2); - } } } \ No newline at end of file diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java index 556bcbf8f0..548c8e015b 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -149,6 +149,7 @@ import net.runelite.rs.api.RSEvictingDualNodeHashTable; import net.runelite.rs.api.RSFriendSystem; import net.runelite.rs.api.RSIndexedSprite; import net.runelite.rs.api.RSInterfaceParent; +import net.runelite.rs.api.RSItemComposition; import net.runelite.rs.api.RSItemContainer; import net.runelite.rs.api.RSModelData; import net.runelite.rs.api.RSNPC; @@ -1729,6 +1730,18 @@ public abstract class RSClientMixin implements RSClient client.getScene().menuOpen(client.getPlane(), x - client.getViewportXOffset(), y - client.getViewportYOffset(), false); } + @Copy("addWidgetItemMenuItem") + @Replace("addWidgetItemMenuItem") + static void copy$addWidgetItemMenuItem(RSWidget var0, RSItemComposition var1, int var2, int var3, boolean var4) + { + String[] var5 = var1.getInventoryActions(); + + if (var5.length > var3) + { + copy$addWidgetItemMenuItem(var0, var1, var2, var3, var4); + } + } + @Inject @MethodHook("updateNpcs") public static void updateNpcs(boolean var0, RSPacketBuffer var1) @@ -1760,18 +1773,15 @@ public abstract class RSClientMixin implements RSClient client.getCallbacks().post(chatMessage); } - @Inject - @MethodHook("draw") - public void draw(boolean var1) + @Copy("draw") + @Replace("draw") + public void copy$draw(boolean var1) { callbacks.frame(); updateCamera(); - } - @Inject - @MethodHook(value = "draw", end = true) - public void drawEnd(boolean var1) - { + copy$draw(var1); + checkResize(); } @@ -2063,7 +2073,7 @@ public abstract class RSClientMixin implements RSClient if (len > 0) { int type = getMenuOpcodes()[len - 1]; - return type == MenuAction.RUNELITE_OVERLAY.getId(); + return type == MenuAction.RUNELITE_OVERLAY.getId() || type == MenuAction.RUNELITE_OVERLAY_CONFIG.getId() || type == MenuAction.RUNELITE_INFOBOX.getId(); } return false; diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSItemCompositionMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSItemCompositionMixin.java index 8662d5e513..f959656734 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSItemCompositionMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSItemCompositionMixin.java @@ -30,6 +30,12 @@ public abstract class RSItemCompositionMixin implements RSItemComposition cachedModels2.resize(1024); } + @Inject + RSItemCompositionMixin() + { + + } + @Inject @Override public boolean isStackable() diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSObjectCompositionMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSObjectCompositionMixin.java index 22f0037936..64dc949aba 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSObjectCompositionMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSObjectCompositionMixin.java @@ -25,6 +25,12 @@ public abstract class RSObjectCompositionMixin implements RSObjectComposition objectDefinitionModelsCache.resize(256); } + @Inject + RSObjectCompositionMixin() + { + + } + @Inject @Override public int getAccessBitMask() diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java index 7efa44cba7..12a87220d3 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java @@ -538,14 +538,6 @@ public interface RSClient extends RSGameEngine, Client @Override int[][] getXteaKeys(); - @Import("gameDrawingMode") - @Override - int getGameDrawingMode(); - - @Import("gameDrawingMode") - @Override - void setGameDrawingMode(int gameDrawingMode); - @Import("cycleCntr") int getCycleCntr(); diff --git a/runescape-client/src/main/java/RuneLiteMenuEntry.java b/runescape-client/src/main/java/RuneLiteMenuEntry.java index 30681ec768..05fca5a859 100644 --- a/runescape-client/src/main/java/RuneLiteMenuEntry.java +++ b/runescape-client/src/main/java/RuneLiteMenuEntry.java @@ -341,4 +341,11 @@ public class RuneLiteMenuEntry implements MenuEntry return hash; } + + @Override + public String toString() + { + return "MenuEntryImpl(getOption=" + this.getOption() + ", getTarget=" + this.getTarget() + ", getIdentifier=" + this.getIdentifier() + ", getType=" + this.getType() + ", getParam0=" + this.getParam0() + ", getParam1=" + this.getParam1() + ", isForceLeftClick=" + this.isForceLeftClick() + ", isDeprioritized=" + this.isDeprioritized() + ")"; + + } }