project: Java 17 support, update deps, rework some stupid logic

This commit is contained in:
Owain van Brakel
2021-09-22 14:09:38 +02:00
parent 7644d5e2d1
commit 6df0372290
85 changed files with 894 additions and 1448 deletions

View File

@@ -27,7 +27,7 @@ object ProjectVersions {
const val launcherVersion = "2.2.0" const val launcherVersion = "2.2.0"
const val rlVersion = "1.7.24" const val rlVersion = "1.7.24"
const val openosrsVersion = "4.10.0" const val openosrsVersion = "4.11.0"
const val rsversion = 199 const val rsversion = 199
const val cacheversion = 165 const val cacheversion = 165

View File

@@ -38,14 +38,14 @@ dependencies {
compileOnly(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion) compileOnly(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion)
implementation(group = "com.google.code.gson", name = "gson", version = "2.8.6") implementation(group = "com.google.code.gson", name = "gson", version = "2.8.5")
implementation(group = "com.google.guava", name = "guava", version = "30.0-jre") implementation(group = "com.google.guava", name = "guava", version = "30.1.1-jre")
implementation(group = "commons-cli", name = "commons-cli", version = "1.4") implementation(group = "commons-cli", name = "commons-cli", version = "1.4")
implementation(group = "io.netty", name = "netty-buffer", version = "4.1.54.Final") implementation(group = "io.netty", name = "netty-buffer", version = "4.1.54.Final")
implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "4.9.0") implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "4.9.1")
implementation(group = "org.antlr", name = "antlr4-runtime", version = "4.8-1") implementation(group = "org.antlr", name = "antlr4-runtime", version = "4.8-1")
implementation(group = "org.apache.commons", name = "commons-compress", version = "1.20") implementation(group = "org.apache.commons", name = "commons-compress", version = "1.21")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.30") implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
testAnnotationProcessor(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion) testAnnotationProcessor(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion)

View File

@@ -40,15 +40,15 @@ dependencies {
implementation(project(":runelite-api")) implementation(project(":runelite-api"))
implementation(project(":runescape-api")) implementation(project(":runescape-api"))
implementation(project(":cache")) implementation(project(":cache"))
implementation(group = "org.jetbrains", name = "annotations", version = "20.1.0") implementation(group = "org.jetbrains", name = "annotations", version = "22.0.0")
implementation(group = "org.ow2.asm", name = "asm", version = "9.0") implementation(group = "org.ow2.asm", name = "asm", version = "9.0")
implementation(group = "org.ow2.asm", name = "asm-util", version = "9.0") implementation(group = "org.ow2.asm", name = "asm-util", version = "9.0")
implementation(group = "net.runelite", name = "fernflower", version = "07082019") implementation(group = "net.runelite", name = "fernflower", version = "07082019")
implementation(group = "com.google.code.gson", name = "gson", version = "2.8.6") implementation(group = "com.google.code.gson", name = "gson", version = "2.8.6")
implementation(group = "com.google.guava", name = "guava", version = "23.2-jre") implementation(group = "com.google.guava", name = "guava", version = "30.1.1-jre")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.12") implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
runtimeOnly(group = "org.slf4j", name = "slf4j-simple", version = "1.7.12") runtimeOnly(group = "org.slf4j", name = "slf4j-simple", version = "1.7.32")
testImplementation(deobjars) testImplementation(deobjars)
testImplementation(group = "junit", name = "junit", version = "4.12") testImplementation(group = "junit", name = "junit", version = "4.12")

View File

@@ -34,14 +34,14 @@ dependencies {
implementation(project(":runelite-api")) implementation(project(":runelite-api"))
implementation(group = "com.google.code.gson", name = "gson", version = "2.8.5") implementation(group = "com.google.code.gson", name = "gson", version = "2.8.5")
implementation(group = "com.google.guava", name = "guava", version = "23.2-jre") implementation(group = "com.google.guava", name = "guava", version = "30.1.1-jre")
implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "3.7.0") implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "4.9.1")
implementation(group = "org.apache.commons", name = "commons-csv", version = "1.4") implementation(group = "org.apache.commons", name = "commons-csv", version = "1.9.0")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.12") implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
testImplementation(group = "com.squareup.okhttp3", name = "mockwebserver", version = "4.9.0") testImplementation(group = "com.squareup.okhttp3", name = "mockwebserver", version = "4.9.1")
testImplementation(group = "junit", name = "junit", version = "4.12") testImplementation(group = "junit", name = "junit", version = "4.12")
testImplementation(group = "org.slf4j", name = "slf4j-simple", version = "1.7.12") testImplementation(group = "org.slf4j", name = "slf4j-simple", version = "1.7.32")
} }
tasks { tasks {

View File

@@ -24,11 +24,11 @@ dependencies {
implementation(project(":runescape-client")) implementation(project(":runescape-client"))
implementation(project(":runelite-mixins")) implementation(project(":runelite-mixins"))
implementation(group = "org.ow2.asm", name = "asm", version = "8.0.1") implementation(group = "org.ow2.asm", name = "asm", version = "9.0")
implementation(group = "org.ow2.asm", name = "asm-util", version = "8.0.1") implementation(group = "org.ow2.asm", name = "asm-util", version = "9.0")
implementation(group = "org.jetbrains", name = "annotations", version = "19.0.0") implementation(group = "org.jetbrains", name = "annotations", version = "22.0.0")
implementation(group = "com.google.guava", name = "guava", version = "23.2-jre") implementation(group = "com.google.guava", name = "guava", version = "30.1.1-jre")
implementation(group = "net.sf.jopt-simple", name = "jopt-simple", version = "5.0.1") implementation(group = "net.sf.jopt-simple", name = "jopt-simple", version = "5.0.4")
} }
tasks.register<JavaExec>("inject") { tasks.register<JavaExec>("inject") {

View File

@@ -63,7 +63,7 @@ public abstract class InjectData
for (final ClassFile deobClass : deobfuscated) for (final ClassFile deobClass : deobfuscated)
{ {
if (deobClass.getName().startsWith("net/runelite/")) if (deobClass.getName().startsWith("net/runelite/") || deobClass.getName().startsWith("netscape"))
{ {
continue; continue;
} }

View File

@@ -31,9 +31,9 @@ dependencies {
compileOnly(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion) compileOnly(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion)
implementation(group = "com.google.code.findbugs", name = "jsr305", version = "3.0.2") implementation(group = "com.google.code.findbugs", name = "jsr305", version = "3.0.2")
implementation(group = "com.google.guava", name = "guava", version = "23.2-jre") implementation(group = "com.google.guava", name = "guava", version = "30.1.1-jre")
implementation(group = "org.apache.commons", name = "commons-text", version = "1.2") implementation(group = "org.apache.commons", name = "commons-text", version = "1.9")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.12") implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
testImplementation(group = "junit", name = "junit", version = "4.12") testImplementation(group = "junit", name = "junit", version = "4.12")
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, HSJ <https://github.com/HSJ-OSRS> * Copyright (c) 2018, Matthew Steglinski <https://github.com/sainttx>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -33,5 +33,5 @@ import net.runelite.api.Actor;
@Value @Value
public class ActorDeath public class ActorDeath
{ {
Actor actor; private final Actor actor;
} }

View File

@@ -1,7 +1,31 @@
/*
* Copyright (c) 2016-2017, Abel Briggs
* 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.api.events; package net.runelite.api.events;
import net.runelite.api.Actor;
import lombok.Data; import lombok.Data;
import net.runelite.api.Actor;
/** /**
* An event where the {@link Actor} has changed animations. * An event where the {@link Actor} has changed animations.

View File

@@ -33,7 +33,6 @@ public class AreaSoundEffectPlayed
{ {
@Nullable @Nullable
private final Actor source; private final Actor source;
private int soundId; private int soundId;
private int sceneX; private int sceneX;
private int sceneY; private int sceneY;

View File

@@ -24,11 +24,11 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.ChatMessageType;
import net.runelite.api.MessageNode;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.runelite.api.ChatMessageType;
import net.runelite.api.MessageNode;
/** /**
* An event where a new chat message is received. * An event where a new chat message is received.

View File

@@ -47,9 +47,9 @@ public class CommandExecuted
/** /**
* The name of the command entered. * The name of the command entered.
*/ */
String command; private String command;
/** /**
* The command arguments that have been entered. * The command arguments that have been entered.
*/ */
String[] arguments; private String[] arguments;
} }

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.DecorativeObject; import net.runelite.api.DecorativeObject;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Data;
/** /**
* An event where the {@link DecorativeObject} attached to a {@link Tile} * An event where the {@link DecorativeObject} attached to a {@link Tile}

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.DecorativeObject; import net.runelite.api.DecorativeObject;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Data;
/** /**
* An event where the {@link DecorativeObject} attached to a {@link Tile} * An event where the {@link DecorativeObject} attached to a {@link Tile}

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.DecorativeObject; import net.runelite.api.DecorativeObject;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Data;
/** /**
* An event where a {@link DecorativeObject} is attached to a {@link Tile}. * An event where a {@link DecorativeObject} is attached to a {@link Tile}.

View File

@@ -30,6 +30,6 @@ import net.runelite.api.Skill;
@Value @Value
public class FakeXpDrop public class FakeXpDrop
{ {
Skill skill; private final Skill skill;
int xp; private final int xp;
} }

View File

@@ -35,5 +35,5 @@ public class FriendsChatChanged
/** /**
* Whether or not the client is now in a friends chat. * Whether or not the client is now in a friends chat.
*/ */
boolean joined; private boolean joined;
} }

View File

@@ -33,5 +33,5 @@ public class FriendsChatMemberJoined
/** /**
* The member that joined * The member that joined
*/ */
FriendsChatMember member; private FriendsChatMember member;
} }

View File

@@ -33,5 +33,5 @@ public class FriendsChatMemberLeft
/** /**
* The member that left * The member that left
*/ */
FriendsChatMember member; private FriendsChatMember member;
} }

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.GameObject; import net.runelite.api.GameObject;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Data;
/** /**
* An event where a {@link GameObject} on a {@link Tile} is removed. * An event where a {@link GameObject} on a {@link Tile} is removed.

View File

@@ -37,9 +37,9 @@ public class GameObjectSpawned
/** /**
* The affected tile. * The affected tile.
*/ */
Tile tile; private Tile tile;
/** /**
* The newly spawned game object. * The newly spawned game object.
*/ */
GameObject gameObject; private GameObject gameObject;
} }

View File

@@ -24,8 +24,8 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.GameState;
import lombok.Data; import lombok.Data;
import net.runelite.api.GameState;
/** /**
* An event where the clients game state has changed. * An event where the clients game state has changed.

View File

@@ -24,20 +24,21 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.GrandExchangeOffer;
import lombok.Data; import lombok.Data;
import net.runelite.api.GrandExchangeOffer;
import net.runelite.api.GrandExchangeOfferState;
/** /**
* An event where a {GrandExchangeOffer} has been updated with * An event where a {@link GrandExchangeOffer} has been updated with
* new information. * new information.
* <p> * <p>
* When the client initially logs in, this event is called for all grand * When the client initially logs in, this event is called for all grand
* exchange slots with the {GrandExchangeOfferState#EMPTY} state, * exchange slots with the {@link GrandExchangeOfferState#EMPTY} state,
* regardless of whether any slots have offers. Once the exchange is * regardless of whether any slots have offers. Once the exchange is
* initialized, the client then updates any offers with items as it * initialized, the client then updates any offers with items as it
* receives information from the server. * receives information from the server.
* <p> * <p>
* See {GrandExchangeOfferState} for potential states an offer * See {@link GrandExchangeOfferState} for potential states an offer
* can change into. * can change into.
*/ */
@Data @Data

View File

@@ -1,3 +1,27 @@
/*
* Copyright (c) 2018, 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.api.events; package net.runelite.api.events;
import lombok.Data; import lombok.Data;

View File

@@ -24,8 +24,8 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.GraphicsObject;
import lombok.Value; import lombok.Value;
import net.runelite.api.GraphicsObject;
/** /**
* An event where a new {@link GraphicsObject} has been created. * An event where a new {@link GraphicsObject} has been created.
@@ -36,5 +36,5 @@ public class GraphicsObjectCreated
/** /**
* The newly created graphics object. * The newly created graphics object.
*/ */
GraphicsObject graphicsObject; private final GraphicsObject graphicsObject;
} }

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.GroundObject; import net.runelite.api.GroundObject;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Data;
/** /**
* An event where the {@link GroundObject} on a {@link Tile} has been changed. * An event where the {@link GroundObject} on a {@link Tile} has been changed.

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.GroundObject; import net.runelite.api.GroundObject;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Data;
/** /**
* An event where a {@link GroundObject} on a {@link Tile} has been removed. * An event where a {@link GroundObject} on a {@link Tile} has been removed.

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.GroundObject; import net.runelite.api.GroundObject;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Data;
/** /**
* An event where a {@link GroundObject} is added to a {@link Tile}. * An event where a {@link GroundObject} is added to a {@link Tile}.

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.Hitsplat; import net.runelite.api.Hitsplat;
import lombok.Data;
/** /**
* An event called when a {@link Hitsplat} is processed on an {@link Actor}. * An event called when a {@link Hitsplat} is processed on an {@link Actor}.

View File

@@ -1,7 +1,31 @@
/*
* Copyright (c) 2018, 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.api.events; package net.runelite.api.events;
import net.runelite.api.Actor;
import lombok.Value; import lombok.Value;
import net.runelite.api.Actor;
/** /**
* An event called when the actor an actor is interacting with changes * An event called when the actor an actor is interacting with changes
@@ -9,10 +33,10 @@ import lombok.Value;
@Value @Value
public class InteractingChanged public class InteractingChanged
{ {
Actor source; private final Actor source;
/** /**
* Target actor, may be null * Target actor, may be null
*/ */
Actor target; private final Actor target;
} }

View File

@@ -24,8 +24,8 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.ItemContainer;
import lombok.Value; import lombok.Value;
import net.runelite.api.ItemContainer;
/** /**
* An event called whenever the stack size of an {@link net.runelite.api.Item} * An event called whenever the stack size of an {@link net.runelite.api.Item}
@@ -44,10 +44,10 @@ public class ItemContainerChanged
/** /**
* The modified container's ID. * The modified container's ID.
*/ */
int containerId; private final int containerId;
/** /**
* The modified item container. * The modified item container.
*/ */
ItemContainer itemContainer; private final ItemContainer itemContainer;
} }

View File

@@ -25,9 +25,8 @@
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Value;
import net.runelite.api.TileItem;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Value; import net.runelite.api.TileItem;
/** /**
* Called when an item pile despawns from the ground. When the client loads a new scene, * Called when an item pile despawns from the ground. When the client loads a new scene,
@@ -36,6 +35,6 @@ import lombok.Value;
@Value @Value
public class ItemDespawned public class ItemDespawned
{ {
Tile tile; private final Tile tile;
TileItem item; private final TileItem item;
} }

View File

@@ -25,9 +25,8 @@
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Value;
import net.runelite.api.TileItem;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Value; import net.runelite.api.TileItem;
/** /**
* Called when the quantity of an item pile changes. * Called when the quantity of an item pile changes.
@@ -35,8 +34,8 @@ import lombok.Value;
@Value @Value
public class ItemQuantityChanged public class ItemQuantityChanged
{ {
TileItem item; private final TileItem item;
Tile tile; private final Tile tile;
int oldQuantity; private final int oldQuantity;
int newQuantity; private final int newQuantity;
} }

View File

@@ -25,9 +25,8 @@
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Value;
import net.runelite.api.TileItem;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import lombok.Value; import net.runelite.api.TileItem;
/** /**
* Called when an item pile spawns on the ground. When the client loads a new scene, * Called when an item pile spawns on the ground. When the client loads a new scene,
@@ -36,6 +35,6 @@ import lombok.Value;
@Value @Value
public class ItemSpawned public class ItemSpawned
{ {
Tile tile; private final Tile tile;
TileItem item; private final TileItem item;
} }

View File

@@ -24,8 +24,8 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.Nameable;
import lombok.Value; import lombok.Value;
import net.runelite.api.Nameable;
/** /**
* An event where a {@link Nameable} has had their name changed. * An event where a {@link Nameable} has had their name changed.
@@ -36,5 +36,5 @@ public class NameableNameChanged
/** /**
* The nameable that changed names. * The nameable that changed names.
*/ */
Nameable nameable; private final Nameable nameable;
} }

View File

@@ -37,11 +37,10 @@ public class NpcChanged
/** /**
* The NPC of which the composition changed. * The NPC of which the composition changed.
*/ */
NPC npc; private final NPC npc;
/** /**
* The old composition of the NPC * The old composition of the NPC
*/ */
NPCComposition old; private final NPCComposition old;
} }

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import lombok.Value;
/** /**
* An event where an {@link NPC} has despawned. * An event where an {@link NPC} has despawned.
@@ -37,7 +37,7 @@ public class NpcDespawned
/** /**
* The despawned NPC. * The despawned NPC.
*/ */
NPC npc; private final NPC npc;
public Actor getActor() public Actor getActor()
{ {

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.NPC; import net.runelite.api.NPC;
import lombok.Value;
/** /**
* An event where an {@link NPC} has spawned. * An event where an {@link NPC} has spawned.
@@ -37,7 +37,7 @@ public class NpcSpawned
/** /**
* The spawned NPC. * The spawned NPC.
*/ */
NPC npc; private final NPC npc;
public Actor getActor() public Actor getActor()
{ {

View File

@@ -1,12 +1,39 @@
/*
* Copyright (c) 2018, Magic fTail
* 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.api.events; package net.runelite.api.events;
import net.runelite.api.Actor;
import lombok.Value; import lombok.Value;
import net.runelite.api.Actor;
/**
* Event fired when an actors overhead text is changed.
*/
@Value @Value
public class OverheadTextChanged public class OverheadTextChanged
{ {
Actor actor; private final Actor actor;
String overheadText; private final String overheadText;
} }

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.Player; import net.runelite.api.Player;
import lombok.Value;
/** /**
* An event where a {@link Player} has despawned. * An event where a {@link Player} has despawned.
@@ -39,7 +39,7 @@ public class PlayerDespawned
/** /**
* The despawned player. * The despawned player.
*/ */
Player player; private final Player player;
public Actor getActor() public Actor getActor()
{ {

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value;
import net.runelite.api.Actor; import net.runelite.api.Actor;
import net.runelite.api.Player; import net.runelite.api.Player;
import lombok.Value;
/** /**
* An event where a {@link Player} has spawned. * An event where a {@link Player} has spawned.
@@ -37,7 +37,7 @@ public class PlayerSpawned
/** /**
* The spawned player. * The spawned player.
*/ */
Player player; private final Player player;
public Actor getActor() public Actor getActor()
{ {

View File

@@ -24,8 +24,8 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.HealthBar;
import lombok.Data; import lombok.Data;
import net.runelite.api.HealthBar;
@Data @Data
public class PostHealthBar public class PostHealthBar

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.Projectile; import net.runelite.api.Projectile;
import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.LocalPoint;
import lombok.Data;
/** /**
* An event called whenever a {@link Projectile} has moved towards a point. * An event called whenever a {@link Projectile} has moved towards a point.

View File

@@ -24,8 +24,8 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.Script;
import lombok.Data; import lombok.Data;
import net.runelite.api.Script;
/** /**
* A callback from a runelite_callback opcode in a cs2 * A callback from a runelite_callback opcode in a cs2

View File

@@ -35,5 +35,5 @@ public class ScriptPostFired
/** /**
* The script id of the invoked script * The script id of the invoked script
*/ */
int scriptId; private final int scriptId;
} }

View File

@@ -24,22 +24,22 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Value; import lombok.Data;
import net.runelite.api.ScriptEvent; import net.runelite.api.ScriptEvent;
/** /**
* An event that is fired before the designated script is ran * An event that is fired before the designated script is ran
*/ */
@Value @Data
public class ScriptPreFired public class ScriptPreFired
{ {
/** /**
* The script id of the invoked script * The script id of the invoked script
*/ */
int scriptId; private final int scriptId;
/** /**
* The input of the script invoke, this will be null unless it is the root script * The input of the script invoke, this will be null unless it is the root script
*/ */
ScriptEvent scriptEvent; private ScriptEvent scriptEvent;
} }

View File

@@ -33,10 +33,8 @@ public class SoundEffectPlayed
{ {
@Nullable @Nullable
private final Actor source; private final Actor source;
private int soundId; private int soundId;
private int delay; private int delay;
private int npcid;
private boolean consumed; private boolean consumed;

View File

@@ -33,8 +33,8 @@ import net.runelite.api.Skill;
@Value @Value
public class StatChanged public class StatChanged
{ {
Skill skill; private final Skill skill;
int xp; private final int xp;
int level; private final int level;
int boostedLevel; private final int boostedLevel;
} }

View File

@@ -28,11 +28,10 @@ package net.runelite.api.events;
import lombok.Value; import lombok.Value;
/** /**
* An event where a client int var has changed.
* @see net.runelite.api.VarClientInt * @see net.runelite.api.VarClientInt
*/ */
@Value @Value
public class VarClientIntChanged public class VarClientIntChanged
{ {
int index; private int index;
} }

View File

@@ -28,11 +28,10 @@ package net.runelite.api.events;
import lombok.Value; import lombok.Value;
/** /**
* An event where a client var string has changed.
* @see net.runelite.api.VarClientStr * @see net.runelite.api.VarClientStr
*/ */
@Value @Value
public class VarClientStrChanged public class VarClientStrChanged
{ {
int index; private int index;
} }

View File

@@ -37,5 +37,5 @@ public class VolumeChanged
AREA AREA
} }
Type type; private final Type type;
} }

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.WallObject; import net.runelite.api.WallObject;
import lombok.Data;
/** /**
* An event where the {@link WallObject} of a {@link Tile} has been changed. * An event where the {@link WallObject} of a {@link Tile} has been changed.

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.WallObject; import net.runelite.api.WallObject;
import lombok.Data;
/** /**
* An event where a {@link WallObject} on a {@link Tile} has been removed. * An event where a {@link WallObject} on a {@link Tile} has been removed.

View File

@@ -24,9 +24,9 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import lombok.Data;
import net.runelite.api.Tile; import net.runelite.api.Tile;
import net.runelite.api.WallObject; import net.runelite.api.WallObject;
import lombok.Data;
/** /**
* An event where a {@link WallObject} is added to a {@link Tile}. * An event where a {@link WallObject} is added to a {@link Tile}.

View File

@@ -24,8 +24,8 @@
*/ */
package net.runelite.api.events; package net.runelite.api.events;
import net.runelite.api.World;
import lombok.Value; import lombok.Value;
import net.runelite.api.World;
/** /**
* Event when the world list is loaded for the world switcher * Event when the world list is loaded for the world switcher
@@ -33,5 +33,5 @@ import lombok.Value;
@Value @Value
public class WorldListLoad public class WorldListLoad
{ {
World[] worlds; private final World[] worlds;
} }

View File

@@ -44,7 +44,7 @@ description = "RuneLite Client"
dependencies { dependencies {
annotationProcessor(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion) annotationProcessor(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion)
annotationProcessor(group = "org.pf4j", name = "pf4j", version = "3.5.0") annotationProcessor(group = "org.pf4j", name = "pf4j", version = "3.6.0")
api(project(":runelite-api")) api(project(":runelite-api"))
@@ -56,23 +56,24 @@ dependencies {
implementation(project(":runelite-jshell")) implementation(project(":runelite-jshell"))
implementation(group = "ch.qos.logback", name = "logback-classic", version = "1.2.3") implementation(group = "ch.qos.logback", name = "logback-classic", version = "1.2.3")
implementation(group = "com.google.code.gson", name = "gson", version = "2.8.5") implementation(group = "com.google.code.gson", name = "gson", version = "2.8.5")
implementation(group = "com.google.guava", name = "guava", version = "23.2-jre") implementation(group = "com.google.guava", name = "guava", version = "30.1.1-jre")
implementation(group = "com.google.inject", name = "guice", version = "4.1.0", classifier = "no_aop") implementation(group = "com.google.inject", name = "guice", version = "5.0.1")
implementation(group = "com.h2database", name = "h2", version = "1.4.200") implementation(group = "com.h2database", name = "h2", version = "1.4.200")
implementation(group = "com.jakewharton.rxrelay3", name = "rxrelay", version = "3.0.0") implementation(group = "com.jakewharton.rxrelay3", name = "rxrelay", version = "3.0.1")
implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "3.7.0") implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "4.9.1")
implementation(group = "io.reactivex.rxjava3", name = "rxjava", version = "3.0.10") implementation(group = "io.reactivex.rxjava3", name = "rxjava", version = "3.1.1")
implementation(group = "org.jgroups", name = "jgroups", version = "5.1.9.Final")
implementation(group = "net.java.dev.jna", name = "jna", version = "5.9.0") implementation(group = "net.java.dev.jna", name = "jna", version = "5.9.0")
implementation(group = "org.jgroups", name = "jgroups", version = "5.0.4.Final")
implementation(group = "net.java.dev.jna", name = "jna-platform", version = "5.9.0") implementation(group = "net.java.dev.jna", name = "jna-platform", version = "5.9.0")
implementation(group = "net.runelite", name = "discord", version = "1.4") implementation(group = "net.runelite", name = "discord", version = "1.4")
implementation(group = "net.runelite.pushingpixels", name = "substance", version = "8.0.02") implementation(group = "org.pushing-pixels", name = "radiance-substance", version = "4.0.0")
implementation(group = "net.sf.jopt-simple", name = "jopt-simple", version = "5.0.1") implementation(group = "net.sf.jopt-simple", name = "jopt-simple", version = "5.0.4")
implementation(group = "org.apache.commons", name = "commons-text", version = "1.2") implementation(group = "org.madlonkay", name = "desktopsupport", version = "0.6.0")
implementation(group = "org.apache.commons", name = "commons-text", version = "1.9")
implementation(group = "commons-io", name = "commons-io", version = "2.8.0") implementation(group = "commons-io", name = "commons-io", version = "2.8.0")
implementation(group = "org.jetbrains", name = "annotations", version = "20.1.0") implementation(group = "org.jetbrains", name = "annotations", version = "22.0.0")
implementation(group = "com.github.zafarkhaja", name = "java-semver", version = "0.9.0") implementation(group = "com.github.zafarkhaja", name = "java-semver", version = "0.9.0")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.12") implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
implementation(group = "org.pf4j", name = "pf4j", version = "3.6.0") { implementation(group = "org.pf4j", name = "pf4j", version = "3.6.0") {
exclude(group = "org.slf4j") exclude(group = "org.slf4j")
} }
@@ -105,8 +106,8 @@ dependencies {
testImplementation(group = "junit", name = "junit", version = "4.12") testImplementation(group = "junit", name = "junit", version = "4.12")
testImplementation(group = "org.mockito", name = "mockito-core", version = "3.1.0") testImplementation(group = "org.mockito", name = "mockito-core", version = "3.1.0")
testImplementation(group = "org.mockito", name = "mockito-inline", version = "3.1.0") testImplementation(group = "org.mockito", name = "mockito-inline", version = "3.1.0")
testImplementation(group = "com.squareup.okhttp3", name = "mockwebserver", version = "3.7.0") testImplementation(group = "com.squareup.okhttp3", name = "mockwebserver", version = "4.9.1")
testImplementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.12") testImplementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
} }
fun formatDate(date: Date?) = with(date ?: Date()) { fun formatDate(date: Date?) = with(date ?: Date()) {

View File

@@ -354,7 +354,7 @@ public class RuneLite
oprsExternalPluginManager.setOutdated(isOutdated); oprsExternalPluginManager.setOutdated(isOutdated);
// Update external plugins // Update external plugins
oprsExternalPluginManager.update(); //TODO: Re-enable after fixing actions for new repo oprsExternalPluginManager.update();
// Load the plugins, but does not start them yet. // Load the plugins, but does not start them yet.
// This will initialize configuration // This will initialize configuration

View File

@@ -0,0 +1,24 @@
package net.runelite.client.plugins;
import java.nio.file.Path;
import lombok.extern.slf4j.Slf4j;
import org.pf4j.BasePluginLoader;
import org.pf4j.PluginClassLoader;
import org.pf4j.PluginClasspath;
import org.pf4j.PluginDescriptor;
import org.pf4j.PluginManager;
@Slf4j
class OPRSExternalBasePluginLoader extends BasePluginLoader
{
OPRSExternalBasePluginLoader(PluginManager pluginManager, PluginClasspath pluginClasspath)
{
super(pluginManager, pluginClasspath);
}
@Override
protected PluginClassLoader createPluginClassLoader(Path pluginPath, PluginDescriptor pluginDescriptor)
{
return new OPRSExternalClassLoader(pluginManager, pluginDescriptor, getClass().getClassLoader());
}
}

View File

@@ -0,0 +1,142 @@
package net.runelite.client.plugins;
import java.lang.invoke.MethodHandles;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.util.ReflectUtil;
import org.pf4j.ClassLoadingStrategy;
import org.pf4j.PluginClassLoader;
import org.pf4j.PluginDependency;
import org.pf4j.PluginDescriptor;
import org.pf4j.PluginManager;
@Slf4j
class OPRSExternalClassLoader extends PluginClassLoader implements ReflectUtil.PrivateLookupableClassLoader
{
private static final String JAVA_PACKAGE_PREFIX = "java.";
private static final String PLUGIN_PACKAGE_PREFIX = "org.pf4j.";
@Getter
@Setter
private MethodHandles.Lookup lookup;
private final PluginManager pluginManager;
private final PluginDescriptor pluginDescriptor;
private final ClassLoadingStrategy classLoadingStrategy;
OPRSExternalClassLoader(PluginManager pluginManager, PluginDescriptor pluginDescriptor, ClassLoader parent)
{
super(pluginManager, pluginDescriptor, parent);
this.pluginManager = pluginManager;
this.pluginDescriptor = pluginDescriptor;
this.classLoadingStrategy = ClassLoadingStrategy.PDA;
ReflectUtil.installLookupHelper(this);
}
@Override
public Class<?> defineClass0(String name, byte[] b, int off, int len) throws ClassFormatError
{
return super.defineClass(name, b, off, len);
}
@Override
protected Class<?> loadClassFromDependencies(String className)
{
log.trace("Search in dependencies for class '{}'", className);
List<org.pf4j.PluginDependency> dependencies = pluginDescriptor.getDependencies();
for (PluginDependency dependency : dependencies)
{
ClassLoader classLoader = pluginManager.getPluginClassLoader(dependency.getPluginId());
// If the dependency is marked as optional, its class loader might not be available.
if (classLoader == null && dependency.isOptional())
{
continue;
}
try
{
if (classLoader != null)
{
return classLoader.loadClass(className);
}
}
catch (ClassNotFoundException e)
{
// try next dependency
}
}
return null;
}
@Override
public Class<?> loadClass(String className) throws ClassNotFoundException
{
synchronized (getClassLoadingLock(className))
{
// first check whether it's a system class, delegate to the system loader
if (className.startsWith(JAVA_PACKAGE_PREFIX))
{
return findSystemClass(className);
}
// if the class is part of the plugin engine use parent class loader
if (className.startsWith(PLUGIN_PACKAGE_PREFIX) && !className.startsWith("org.pf4j.demo"))
{
// log.trace("Delegate the loading of PF4J class '{}' to parent", className);
return getParent().loadClass(className);
}
log.trace("Received request to load class '{}'", className);
// second check whether it's already been loaded
Class<?> loadedClass = findLoadedClass(className);
if (loadedClass != null)
{
log.trace("Found loaded class '{}'", className);
return loadedClass;
}
for (ClassLoadingStrategy.Source classLoadingSource : this.classLoadingStrategy.getSources())
{
Class<?> c = null;
try
{
switch (classLoadingSource)
{
case APPLICATION:
c = super.loadClass(className);
break;
case PLUGIN:
c = findClass(className);
break;
case DEPENDENCIES:
c = loadClassFromDependencies(className);
break;
}
}
catch (ClassNotFoundException ignored)
{
}
if (c != null)
{
log.trace("Found class '{}' in {} classpath", className, classLoadingSource);
return c;
}
else
{
log.trace("Couldn't find class '{}' in {} classpath", className, classLoadingSource);
}
}
throw new ClassNotFoundException(className);
}
}
}

View File

@@ -0,0 +1,26 @@
package net.runelite.client.plugins;
import java.nio.file.Path;
import lombok.extern.slf4j.Slf4j;
import org.pf4j.JarPluginLoader;
import org.pf4j.PluginClassLoader;
import org.pf4j.PluginDescriptor;
import org.pf4j.PluginManager;
@Slf4j
class OPRSExternalJarPluginLoader extends JarPluginLoader
{
public OPRSExternalJarPluginLoader(PluginManager pluginManager)
{
super(pluginManager);
}
@Override
public ClassLoader loadPlugin(Path pluginPath, PluginDescriptor pluginDescriptor)
{
PluginClassLoader pluginClassLoader = new OPRSExternalClassLoader(pluginManager, pluginDescriptor, getClass().getClassLoader());
pluginClassLoader.addFile(pluginPath.toFile());
return pluginClassLoader;
}
}

View File

@@ -17,13 +17,11 @@ import java.util.Set;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.pf4j.BasePluginLoader;
import org.pf4j.CompoundPluginLoader; import org.pf4j.CompoundPluginLoader;
import org.pf4j.CompoundPluginRepository; import org.pf4j.CompoundPluginRepository;
import org.pf4j.DefaultPluginManager; import org.pf4j.DefaultPluginManager;
import org.pf4j.DependencyResolver; import org.pf4j.DependencyResolver;
import org.pf4j.DevelopmentPluginRepository; import org.pf4j.DevelopmentPluginRepository;
import org.pf4j.JarPluginLoader;
import org.pf4j.JarPluginRepository; import org.pf4j.JarPluginRepository;
import org.pf4j.ManifestPluginDescriptorFinder; import org.pf4j.ManifestPluginDescriptorFinder;
import org.pf4j.PluginAlreadyLoadedException; import org.pf4j.PluginAlreadyLoadedException;
@@ -105,8 +103,8 @@ class OPRSExternalPf4jPluginManager extends DefaultPluginManager
protected PluginLoader createPluginLoader() protected PluginLoader createPluginLoader()
{ {
return new CompoundPluginLoader() return new CompoundPluginLoader()
.add(new BasePluginLoader(this, new OPRSExternalPluginClasspath()), this::isDevelopment) .add(new OPRSExternalBasePluginLoader(this, new OPRSExternalPluginClasspath()), this::isDevelopment)
.add(new JarPluginLoader(this), this::isNotDevelopment); .add(new OPRSExternalJarPluginLoader(this), this::isNotDevelopment);
} }
@Override @Override

View File

@@ -39,7 +39,13 @@ import com.google.inject.Injector;
import com.google.inject.Key; import com.google.inject.Key;
import com.google.inject.Module; import com.google.inject.Module;
import java.io.IOException; import java.io.IOException;
import java.lang.invoke.CallSite;
import java.lang.invoke.LambdaMetafactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@@ -69,9 +75,12 @@ import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.PluginChanged; import net.runelite.client.events.PluginChanged;
import net.runelite.client.events.SessionClose; import net.runelite.client.events.SessionClose;
import net.runelite.client.events.SessionOpen; import net.runelite.client.events.SessionOpen;
import net.runelite.client.task.Schedule;
import net.runelite.client.task.ScheduledMethod;
import net.runelite.client.task.Scheduler; import net.runelite.client.task.Scheduler;
import net.runelite.client.ui.SplashScreen; import net.runelite.client.ui.SplashScreen;
import net.runelite.client.util.GameEventManager; import net.runelite.client.util.GameEventManager;
import net.runelite.client.util.ReflectUtil;
@Singleton @Singleton
@Slf4j @Slf4j
@@ -651,14 +660,59 @@ public class PluginManager
private void schedule(Plugin plugin) private void schedule(Plugin plugin)
{ {
// note to devs: this method will almost certainly merge conflict in the future, just apply the changes in the scheduler instead for (Method method : plugin.getClass().getMethods())
scheduler.registerObject(plugin); {
Schedule schedule = method.getAnnotation(Schedule.class);
if (schedule == null)
{
continue;
}
Runnable runnable = null;
try
{
final Class<?> clazz = method.getDeclaringClass();
final MethodHandles.Lookup caller = ReflectUtil.privateLookupIn(clazz);
final MethodType subscription = MethodType.methodType(method.getReturnType(), method.getParameterTypes());
final MethodHandle target = caller.findVirtual(clazz, method.getName(), subscription);
final CallSite site = LambdaMetafactory.metafactory(
caller,
"run",
MethodType.methodType(Runnable.class, clazz),
subscription,
target,
subscription);
final MethodHandle factory = site.getTarget();
runnable = (Runnable) factory.bindTo(plugin).invokeExact();
}
catch (Throwable e)
{
log.warn("Unable to create lambda for method {}", method, e);
}
ScheduledMethod scheduledMethod = new ScheduledMethod(schedule, method, plugin, runnable);
log.debug("Scheduled task {}", scheduledMethod);
scheduler.addScheduledMethod(scheduledMethod);
}
} }
private void unschedule(Plugin plugin) private void unschedule(Plugin plugin)
{ {
// note to devs: this method will almost certainly merge conflict in the future, just apply the changes in the scheduler instead List<ScheduledMethod> methods = new ArrayList<>(scheduler.getScheduledMethods());
scheduler.unregisterObject(plugin);
for (ScheduledMethod method : methods)
{
if (method.getObject() != plugin)
{
continue;
}
log.debug("Removing scheduled task {}", method);
scheduler.removeScheduledMethod(method);
}
} }
/** /**

View File

@@ -115,6 +115,7 @@ import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.ColorJButton; import net.runelite.client.ui.components.ColorJButton;
import net.runelite.client.ui.components.ComboBoxListRenderer; import net.runelite.client.ui.components.ComboBoxListRenderer;
import net.runelite.client.ui.components.ToggleButton;
import net.runelite.client.ui.components.colorpicker.ColorPickerManager; import net.runelite.client.ui.components.colorpicker.ColorPickerManager;
import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker; import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker;
import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ColorUtil;
@@ -487,8 +488,7 @@ class ConfigPanel extends PluginPanel
if (cid.getType() == boolean.class) if (cid.getType() == boolean.class)
{ {
JCheckBox checkbox = new JCheckBox(); JCheckBox checkbox = new ToggleButton();
checkbox.setBackground(ColorScheme.LIGHT_GRAY_COLOR);
checkbox.setSelected(Boolean.parseBoolean(configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName()))); checkbox.setSelected(Boolean.parseBoolean(configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName())));
checkbox.addActionListener(ae -> changeConfiguration(checkbox, cd, cid)); checkbox.addActionListener(ae -> changeConfiguration(checkbox, cd, cid));
@@ -864,8 +864,8 @@ class ConfigPanel extends PluginPanel
{ {
String option = String.valueOf(obj).toLowerCase().replace("_", " "); String option = String.valueOf(obj).toLowerCase().replace("_", " ");
JCheckBox checkbox = new JCheckBox(option); JCheckBox checkbox = new ToggleButton(option);
checkbox.setBackground(ColorScheme.LIGHT_GRAY_COLOR); checkbox.setBackground(ColorScheme.DARK_GRAY_COLOR);
checkbox.setSelected(enumSet.contains(obj)); checkbox.setSelected(enumSet.contains(obj));
jcheckboxes.add(checkbox); jcheckboxes.add(checkbox);

View File

@@ -26,41 +26,18 @@
package net.runelite.client.plugins.config; package net.runelite.client.plugins.config;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.util.List; import java.util.List;
import javax.swing.ImageIcon; import net.runelite.client.ui.components.ToggleButton;
import javax.swing.JToggleButton;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.SwingUtil;
class PluginToggleButton extends JToggleButton class PluginToggleButton extends ToggleButton
{ {
private static final ImageIcon ON_SWITCHER;
private static final ImageIcon OFF_SWITCHER;
static
{
BufferedImage onSwitcher = ImageUtil.loadImageResource(ConfigPanel.class, "switcher_on.png");
ON_SWITCHER = new ImageIcon(ImageUtil.recolorImage(onSwitcher, ColorScheme.BRAND_BLUE));
OFF_SWITCHER = new ImageIcon(ImageUtil.flipImage(
ImageUtil.luminanceScale(
ImageUtil.grayscaleImage(onSwitcher),
0.61f
),
true,
false
));
}
private String conflictString = ""; private String conflictString = "";
public PluginToggleButton() public PluginToggleButton()
{ {
super(OFF_SWITCHER); super();
setSelectedIcon(ON_SWITCHER);
SwingUtil.removeButtonDecorations(this);
setPreferredSize(new Dimension(25, 0)); setPreferredSize(new Dimension(25, 0));
addItemListener(l -> updateTooltip()); addItemListener(l -> updateTooltip());
updateTooltip(); updateTooltip();
} }

View File

@@ -78,7 +78,7 @@ import okhttp3.Response;
public class ClientLoader implements Supplier<Applet> public class ClientLoader implements Supplier<Applet>
{ {
private static final String INJECTED_CLIENT_NAME = "/injected-client.oprs"; private static final String INJECTED_CLIENT_NAME = "/injected-client.oprs";
private static final int NUM_ATTEMPTS = 6; private static final int NUM_ATTEMPTS = 0;
private static File LOCK_FILE = new File(RuneLite.CACHE_DIR, "cache.lock"); private static File LOCK_FILE = new File(RuneLite.CACHE_DIR, "cache.lock");
private static File VANILLA_CACHE = new File(RuneLite.CACHE_DIR, "vanilla.cache"); private static File VANILLA_CACHE = new File(RuneLite.CACHE_DIR, "vanilla.cache");
private static File PATCHED_CACHE = new File(RuneLite.CACHE_DIR, "patched.cache"); private static File PATCHED_CACHE = new File(RuneLite.CACHE_DIR, "patched.cache");

View File

@@ -24,16 +24,10 @@
*/ */
package net.runelite.client.task; package net.runelite.client.task;
import java.lang.invoke.CallSite;
import java.lang.invoke.LambdaMetafactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@@ -66,63 +60,6 @@ public class Scheduler
return Collections.unmodifiableList(scheduledMethods); return Collections.unmodifiableList(scheduledMethods);
} }
public void registerObject(Object obj)
{
for (Method method : obj.getClass().getMethods())
{
Schedule schedule = method.getAnnotation(Schedule.class);
if (schedule == null)
{
continue;
}
Runnable runnable = null;
try
{
final Class<?> clazz = method.getDeclaringClass();
final MethodHandles.Lookup caller = MethodHandles.privateLookupIn(clazz, MethodHandles.lookup());
final MethodType subscription = MethodType.methodType(method.getReturnType(), method.getParameterTypes());
final MethodHandle target = caller.findVirtual(clazz, method.getName(), subscription);
final CallSite site = LambdaMetafactory.metafactory(
caller,
"run",
MethodType.methodType(Runnable.class, clazz),
subscription,
target,
subscription);
final MethodHandle factory = site.getTarget();
runnable = (Runnable) factory.bindTo(obj).invokeExact();
}
catch (Throwable e)
{
log.warn("Unable to create lambda for method {}", method, e);
}
ScheduledMethod scheduledMethod = new ScheduledMethod(schedule, method, obj, runnable);
log.debug("Scheduled task {}", scheduledMethod);
addScheduledMethod(scheduledMethod);
}
}
public void unregisterObject(Object obj)
{
List<ScheduledMethod> methods = new ArrayList<>(getScheduledMethods());
for (ScheduledMethod method : methods)
{
if (method.getObject() != obj)
{
continue;
}
log.debug("Removing scheduled task {}", method);
removeScheduledMethod(method);
}
}
public void tick() public void tick()
{ {
Instant now = Instant.now(); Instant now = Instant.now();

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2019 Abex
* 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.ui.components;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.SwingUtil;
public class ToggleButton extends JCheckBox
{
private static final ImageIcon ON_SWITCHER;
private static final ImageIcon OFF_SWITCHER;
private static final ImageIcon DISABLED_SWITCHER;
static
{
BufferedImage onSwitcher = ImageUtil.loadImageResource(ToggleButton.class, "switcher_on.png");
ON_SWITCHER = new ImageIcon(ImageUtil.recolorImage(onSwitcher, ColorScheme.BRAND_BLUE));
OFF_SWITCHER = new ImageIcon(ImageUtil.flipImage(
ImageUtil.luminanceScale(
ImageUtil.grayscaleImage(onSwitcher),
0.61f
),
true,
false
));
DISABLED_SWITCHER = new ImageIcon(ImageUtil.flipImage(
ImageUtil.luminanceScale(
ImageUtil.grayscaleImage(onSwitcher),
0.4f
),
true,
false
));
}
public ToggleButton()
{
super(OFF_SWITCHER);
setSelectedIcon(ON_SWITCHER);
setDisabledIcon(DISABLED_SWITCHER);
SwingUtil.removeButtonDecorations(this);
}
public ToggleButton(String text)
{
super(text, OFF_SWITCHER, false);
setSelectedIcon(ON_SWITCHER);
setDisabledIcon(DISABLED_SWITCHER);
SwingUtil.removeButtonDecorations(this);
}
}

View File

@@ -59,7 +59,7 @@ public class ObsidianSkin extends SubstanceSkin
ObsidianSkin() ObsidianSkin()
{ {
final SubstanceSkin.ColorSchemes schemes = SubstanceSkin final SubstanceSkin.ColorSchemes schemes = SubstanceSkin
.getColorSchemes(getClass().getResource(NAME + ".colorschemes")); .getColorSchemes(getClass().getResourceAsStream(NAME + ".colorschemes"));
final SubstanceColorScheme activeScheme = schemes.get("RuneLite Active"); final SubstanceColorScheme activeScheme = schemes.get("RuneLite Active");
final SubstanceColorScheme enabledScheme = schemes.get("RuneLite Enabled"); final SubstanceColorScheme enabledScheme = schemes.get("RuneLite Enabled");
@@ -119,7 +119,7 @@ public class ObsidianSkin extends SubstanceSkin
.get("RuneLite Decorations Watermark"); .get("RuneLite Decorations Watermark");
this.registerDecorationAreaSchemeBundle(decorationsSchemeBundle, decorationsWatermarkScheme, this.registerDecorationAreaSchemeBundle(decorationsSchemeBundle, decorationsWatermarkScheme,
DecorationAreaType.TOOLBAR, DecorationAreaType.GENERAL, DecorationAreaType.FOOTER); DecorationAreaType.TOOLBAR, DecorationAreaType.CONTROL_PANE, DecorationAreaType.FOOTER);
final SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle(activeScheme, final SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle(activeScheme,
enabledScheme, enabledScheme); enabledScheme, enabledScheme);
@@ -184,7 +184,6 @@ public class ObsidianSkin extends SubstanceSkin
} }
}; };
this.watermark = null;
this.fillPainter = new FractionBasedFillPainter("RuneLite", this.fillPainter = new FractionBasedFillPainter("RuneLite",
new float[]{0.0f, 0.5f, 1.0f}, new float[]{0.0f, 0.5f, 1.0f},
new ColorSchemeSingleColorQuery[]{ColorSchemeSingleColorQuery.ULTRALIGHT, new ColorSchemeSingleColorQuery[]{ColorSchemeSingleColorQuery.ULTRALIGHT,

View File

@@ -24,10 +24,9 @@
*/ */
package net.runelite.client.util; package net.runelite.client.util;
import com.apple.eawt.Application;
import com.apple.eawt.FullScreenUtilities;
import javax.swing.JFrame; import javax.swing.JFrame;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.madlonkay.desktopsupport.DesktopSupport;
/** /**
* A class with OSX-specific functions to improve integration. * A class with OSX-specific functions to improve integration.
@@ -44,7 +43,7 @@ public class OSXUtil
{ {
if (OSType.getOSType() == OSType.MacOS) if (OSType.getOSType() == OSType.MacOS)
{ {
FullScreenUtilities.setWindowCanFullScreen(gui, true); DesktopSupport.getSupport().setWindowCanFullScreen(gui, true);
log.debug("Enabled fullscreen on macOS"); log.debug("Enabled fullscreen on macOS");
} }
} }
@@ -54,8 +53,7 @@ public class OSXUtil
*/ */
public static void requestUserAttention() public static void requestUserAttention()
{ {
Application app = Application.getApplication(); DesktopSupport.getSupport().requestUserAttention(true);
app.requestUserAttention(true);
log.debug("Requested user attention on macOS"); log.debug("Requested user attention on macOS");
} }
@@ -64,8 +62,7 @@ public class OSXUtil
*/ */
public static void requestForeground() public static void requestForeground()
{ {
Application app = Application.getApplication(); DesktopSupport.getSupport().requestForeground(true);
app.requestForeground(true);
log.debug("Forced focus on macOS"); log.debug("Forced focus on macOS");
} }
} }

View File

@@ -62,6 +62,7 @@ import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.components.CustomScrollBarUI; import net.runelite.client.ui.components.CustomScrollBarUI;
import net.runelite.client.ui.components.SliderUI; import net.runelite.client.ui.components.SliderUI;
import org.pushingpixels.substance.api.SubstanceSlices;
import org.pushingpixels.substance.internal.SubstanceSynapse; import org.pushingpixels.substance.internal.SubstanceSynapse;
/** /**
@@ -217,7 +218,7 @@ public class SwingUtil
button.setSize(scaledImage.getWidth(), scaledImage.getHeight()); button.setSize(scaledImage.getWidth(), scaledImage.getHeight());
button.setToolTipText(navigationButton.getTooltip()); button.setToolTipText(navigationButton.getTooltip());
button.setIcon(new ImageIcon(scaledImage)); button.setIcon(new ImageIcon(scaledImage));
button.putClientProperty(SubstanceSynapse.FLAT_LOOK, Boolean.TRUE); button.putClientProperty(SubstanceSynapse.BACKGROUND_APPEARANCE_STRATEGY, SubstanceSlices.BackgroundAppearanceStrategy.FLAT);
button.setFocusable(false); button.setFocusable(false);
button.addActionListener(e -> button.addActionListener(e ->
{ {

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

View File

@@ -32,8 +32,8 @@ dependencies {
compileOnly(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion) compileOnly(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion)
implementation(group = "com.google.code.findbugs", name = "jsr305", version = "3.0.2") implementation(group = "com.google.code.findbugs", name = "jsr305", version = "3.0.2")
implementation(group = "com.google.inject", name = "guice", version = "4.1.0", classifier = "no_aop") implementation(group = "com.google.inject", name = "guice", version = "5.0.1")
implementation(group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.1.2") implementation(group = "com.fifesoft", name = "rsyntaxtextarea", version = "3.1.2")
implementation(group = "com.fifesoft", name = "autocomplete", version = "3.1.1") implementation(group = "com.fifesoft", name = "autocomplete", version = "3.1.1")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.12") implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
} }

View File

@@ -25,9 +25,9 @@
description = "RuneLite Mixins" description = "RuneLite Mixins"
dependencies { dependencies {
compileOnly(group = "com.google.guava", name = "guava", version = "23.2-jre") compileOnly(group = "com.google.guava", name = "guava", version = "30.1.1-jre")
compileOnly(group = "javax.inject", name = "javax.inject", version = "1") compileOnly(group = "javax.inject", name = "javax.inject", version = "1")
compileOnly(group = "org.slf4j", name = "slf4j-api", version = "1.7.12") compileOnly(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
compileOnly(group = "commons-io", name = "commons-io", version = "2.8.0") compileOnly(group = "commons-io", name = "commons-io", version = "2.8.0")
compileOnly(project(":injection-annotations")) compileOnly(project(":injection-annotations"))
compileOnly(project(":runescape-api")) compileOnly(project(":runescape-api"))

View File

@@ -65,7 +65,8 @@ public abstract class ScriptVMMixin implements RSClient
{ {
if (script != null) if (script != null)
{ {
ScriptPreFired event = new ScriptPreFired((int) script.getHash(), rootScriptEvent); ScriptPreFired event = new ScriptPreFired((int) script.getHash());
event.setScriptEvent(rootScriptEvent);
client.getCallbacks().post(event); client.getCallbacks().post(event);
} }
@@ -127,7 +128,7 @@ public abstract class ScriptVMMixin implements RSClient
return true; return true;
case INVOKE: case INVOKE:
int scriptId = currentScript.getIntOperands()[currentScriptPC]; int scriptId = currentScript.getIntOperands()[currentScriptPC];
client.getCallbacks().post(new ScriptPreFired(scriptId, null)); client.getCallbacks().post(new ScriptPreFired(scriptId));
return false; return false;
case RETURN: case RETURN:
client.getCallbacks().post(new ScriptPostFired((int) currentScript.getHash())); client.getCallbacks().post(new ScriptPostFired((int) currentScript.getHash()));

View File

@@ -35,7 +35,6 @@ import net.runelite.api.mixins.Replace;
import net.runelite.api.mixins.Shadow; import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSActor; import net.runelite.rs.api.RSActor;
import net.runelite.rs.api.RSClient; import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSNPC;
import net.runelite.rs.api.RSPcmStream; import net.runelite.rs.api.RSPcmStream;
import net.runelite.rs.api.RSRawPcmStream; import net.runelite.rs.api.RSRawPcmStream;
import net.runelite.rs.api.RSRawSound; import net.runelite.rs.api.RSRawSound;
@@ -53,18 +52,11 @@ public abstract class SoundEffectMixin implements RSClient
@Inject @Inject
private static RSActor lastSoundEffectSourceActor; private static RSActor lastSoundEffectSourceActor;
@Inject
private static int lastSoundEffectSourceNPCid;
@Copy("updateActorSequence") @Copy("updateActorSequence")
@Replace("updateActorSequence") @Replace("updateActorSequence")
@SuppressWarnings("InfiniteRecursion") @SuppressWarnings("InfiniteRecursion")
public static void copy$updateActorSequence(RSActor actor, int size) public static void copy$updateActorSequence(RSActor actor, int size)
{ {
if (actor instanceof RSNPC)
{
lastSoundEffectSourceNPCid = ((RSNPC) actor).getId();
}
lastSoundEffectSourceActor = actor; lastSoundEffectSourceActor = actor;
copy$updateActorSequence(actor, size); copy$updateActorSequence(actor, size);
@@ -87,8 +79,6 @@ public abstract class SoundEffectMixin implements RSClient
{ {
// Regular sound effect // Regular sound effect
SoundEffectPlayed event = new SoundEffectPlayed(lastSoundEffectSourceActor); SoundEffectPlayed event = new SoundEffectPlayed(lastSoundEffectSourceActor);
event.setNpcid(lastSoundEffectSourceNPCid);
lastSoundEffectSourceNPCid = -1;
event.setSoundId(client.getQueuedSoundEffectIDs()[soundIndex]); event.setSoundId(client.getQueuedSoundEffectIDs()[soundIndex]);
event.setDelay(client.getQueuedSoundEffectDelays()[soundIndex]); event.setDelay(client.getQueuedSoundEffectDelays()[soundIndex]);
client.getCallbacks().post(event); client.getCallbacks().post(event);

View File

@@ -34,9 +34,9 @@ dependencies {
implementation(project(":cache")) implementation(project(":cache"))
implementation(project(":runelite-api")) implementation(project(":runelite-api"))
implementation(group = "com.google.guava", name = "guava", version = "23.2-jre") implementation(group = "com.google.guava", name = "guava", version = "30.1.1-jre")
implementation(group = "org.apache.maven", name = "maven-plugin-api", version = "3.6.3") implementation(group = "org.apache.maven", name = "maven-plugin-api", version = "3.6.3")
implementation(group = "org.slf4j", name = "slf4j-nop", version = "1.7.12") implementation(group = "org.slf4j", name = "slf4j-nop", version = "1.7.32")
} }
tasks { tasks {

View File

@@ -30,10 +30,9 @@ dependencies {
implementation(project(":injection-annotations")) implementation(project(":injection-annotations"))
implementation(group = "org.bouncycastle", name = "bcprov-jdk15on", version = "1.52") implementation(group = "org.bouncycastle", name = "bcprov-jdk15on", version = "1.52")
testImplementation(group = "junit", name = "junit", version = "4.12") testImplementation(group = "junit", name = "junit", version = "4.12")
testImplementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.12") testImplementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
testImplementation(group = "org.slf4j", name = "slf4j-simple", version = "1.7.12") testImplementation(group = "org.slf4j", name = "slf4j-simple", version = "1.7.32")
} }
tasks { tasks {

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package netscape.javascript;
/**
* Thrown when an exception is raised in the JavaScript engine. This is merely
* a marker class to indicate an exception relating to the JavaScript
* interface.
*/
public class JSException extends RuntimeException {
private static final long serialVersionUID = 2778103758223661489L;
/**
* Constructs a new JavaScript exception with null as it's detail message.
*/
public JSException() {
super();
}
/**
* Construct a new JavaScript exception with the specified detail message.
*
* @param s The detail message
*/
public JSException(String s) {
super(s);
}
/**
* Construct a new JavaScript exception with the specified cause.
*
* @param t Throwable cause
*/
public JSException(Throwable t) {
super(t);
}
}

View File

@@ -0,0 +1,189 @@
/*
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package netscape.javascript;
import java.applet.Applet;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.ServiceLoader;
/**
* <p>
* Allows Java code to manipulate JavaScript objects.
* </p>
*
* <p>
* When a JavaScript object is passed or returned to Java code, it
* is wrapped in an instance of {@code JSObject}. When a
* {@code JSObject} instance is passed to the JavaScript engine,
* it is unwrapped back to its original JavaScript object. The
* {@code JSObject} class provides a way to invoke JavaScript
* methods and examine JavaScript properties.
* </p>
*
* <p> Any data returned from the JavaScript engine to Java is
* converted to Java data types. Certain data passed to the JavaScript
* engine is converted to JavaScript data types.
* </p>
*
*/
@SuppressWarnings("deprecation")
public abstract class JSObject {
/**
* Constructs a new JSObject. Users should neither call this method nor
* subclass JSObject.
*/
protected JSObject() {
}
/**
* Calls a JavaScript method. Equivalent to
* "this.methodName(args[0], args[1], ...)" in JavaScript.
*
* @param methodName The name of the JavaScript method to be invoked.
* @param args the Java objects passed as arguments to the method.
* @return Result of the method.
* @throws JSException when an error is reported from the browser or
* JavaScript engine.
*/
public abstract Object call(String methodName, Object... args) throws JSException;
/**
* Evaluates a JavaScript expression. The expression is a string of
* JavaScript source code which will be evaluated in the context given by
* "this".
*
* @param s The JavaScript expression.
* @return Result of the JavaScript evaluation.
* @throws JSException when an error is reported from the browser or
* JavaScript engine.
*/
public abstract Object eval(String s) throws JSException;
/**
* Retrieves a named member of a JavaScript object. Equivalent to
* "this.name" in JavaScript.
*
* @param name The name of the JavaScript property to be accessed.
* @return The value of the propery.
* @throws JSException when an error is reported from the browser or
* JavaScript engine.
*/
public abstract Object getMember(String name) throws JSException;
/**
* Sets a named member of a JavaScript object. Equivalent to
* "this.name = value" in JavaScript.
*
* @param name The name of the JavaScript property to be accessed.
* @param value The value of the propery.
* @throws JSException when an error is reported from the browser or
* JavaScript engine.
*/
public abstract void setMember(String name, Object value) throws JSException;
/**
* Removes a named member of a JavaScript object. Equivalent
* to "delete this.name" in JavaScript.
*
* @param name The name of the JavaScript property to be removed.
* @throws JSException when an error is reported from the browser or
* JavaScript engine.
*/
public abstract void removeMember(String name) throws JSException;
/**
* Retrieves an indexed member of a JavaScript object. Equivalent to
* "this[index]" in JavaScript.
*
* @param index The index of the array to be accessed.
* @return The value of the indexed member.
* @throws JSException when an error is reported from the browser or
* JavaScript engine.
*/
public abstract Object getSlot(int index) throws JSException;
/**
* Sets an indexed member of a JavaScript object. Equivalent to
* "this[index] = value" in JavaScript.
*
* @param index The index of the array to be accessed.
* @param value The value to set
* @throws JSException when an error is reported from the browser or
* JavaScript engine.
*/
public abstract void setSlot(int index, Object value) throws JSException;
/**
* Returns a JSObject for the window containing the given applet. This
* method only works when the Java code is running in a browser as an
* applet. The object returned may be used to access the HTML DOM directly.
*
* @param applet The applet.
* @return JSObject representing the window containing the given applet or
* {@code null} if we are not connected to a browser.
* @throws JSException when an error is reported from the browser or
* JavaScript engine or if applet is {@code null}
*
* @deprecated The Applet API is deprecated. See the
* <a href="{@docRoot}/java.desktop/java/applet/package-summary.html">
* java.applet package documentation</a> for further information.
*/
@Deprecated(since = "9")
@SuppressWarnings("exports")
public static JSObject getWindow(Applet applet) throws JSException {
return ProviderLoader.callGetWindow(applet);
}
private static class ProviderLoader {
private static final JSObjectProvider provider;
static {
provider = AccessController.doPrivileged(
new PrivilegedAction<JSObjectProvider>() {
@Override
public JSObjectProvider run() {
Iterator<JSObjectProvider> providers =
ServiceLoader.loadInstalled(JSObjectProvider.class).iterator();
if (providers.hasNext()) {
return providers.next();
}
return null;
}
}
);
}
private static JSObject callGetWindow(Applet applet) {
if (provider != null) {
return provider.getWindow(applet);
}
return null;
}
}
}

View File

@@ -0,0 +1,20 @@
package netscape.javascript;
import java.applet.Applet;
import netscape.javascript.JSException;
import netscape.javascript.JSObject;
@SuppressWarnings("deprecation")
public interface JSObjectProvider {
/**
* Return a JSObject for the window containing the given applet.
* Implementations of this class should return null if not connected to a
* browser, for example, when running in AppletViewer.
*
* @param applet The applet.
* @return JSObject for the window containing the given applet or null if we
* are not connected to a browser.
* @throws JSException when an error is encountered.
*/
public JSObject getWindow(Applet applet) throws JSException;
}

View File

@@ -34,11 +34,11 @@ dependencies {
compileOnly(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion) compileOnly(group = "org.projectlombok", name = "lombok", version = ProjectVersions.lombokVersion)
implementation(group = "com.google.code.gson", name = "gson", version = "2.8.5") implementation(group = "com.google.code.gson", name = "gson", version = "2.8.5")
implementation(group = "com.google.guava", name = "guava", version = "23.2-jre") implementation(group = "com.google.guava", name = "guava", version = "30.1.1-jre")
implementation(group = "com.github.petitparser", name = "java-petitparser", version = "2.3.1") implementation(group = "com.github.petitparser", name = "java-petitparser", version = "2.3.1")
implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "3.7.0") implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "4.9.1")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.12") implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32")
implementation(group = "org.slf4j", name = "slf4j-simple", version = "1.7.12") implementation(group = "org.slf4j", name = "slf4j-simple", version = "1.7.32")
implementation(group = "org.junit.jupiter", name = "junit-jupiter-api", version = "5.7.0") implementation(group = "org.junit.jupiter", name = "junit-jupiter-api", version = "5.7.0")
} }