mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-18 04:20:21 -07:00
Plumbed in varp update handling
This commit is contained in:
parent
d69ac42050
commit
4bbb8e0458
6 changed files with 103 additions and 2 deletions
|
|
@ -59,8 +59,26 @@ public abstract class Plugin {
|
||||||
*/
|
*/
|
||||||
public void NPCOverheadDraw(Npc npc, int screenX, int screenY) {}
|
public void NPCOverheadDraw(Npc npc, int screenX, int screenY) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProcessCommand is called when a user types and sends a message prefixed with ::
|
||||||
|
* @param commandStr the command the user used - should include :: in comparisons, eg <pre>commandStr.equals("::command")</pre>
|
||||||
|
* @param args any other tokens included with the initial message. Tokens are determined by spaces.
|
||||||
|
*/
|
||||||
public void ProcessCommand(String commandStr, String[] args) {}
|
public void ProcessCommand(String commandStr, String[] args) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ComponentDraw is called when an interface component is being rendered by the client.
|
||||||
|
* @param componentIndex the index of the component in its parent interface.
|
||||||
|
* @param component the component itself
|
||||||
|
* @param screenX the screen X coordinate of this component
|
||||||
|
* @param screenY the screen Y coordinate of this component
|
||||||
|
*/
|
||||||
public void ComponentDraw(int componentIndex, Component component, int screenX, int screenY) {}
|
public void ComponentDraw(int componentIndex, Component component, int screenX, int screenY) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OnVarpUpdate is called when varps are updated by the server sending packets.
|
||||||
|
* @param id the ID of the varp
|
||||||
|
* @param value the value the varp is being set to.
|
||||||
|
*/
|
||||||
|
public void OnVarpUpdate(int id, int value) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,4 +99,8 @@ public class PluginRepository {
|
||||||
public static void ComponentDraw(int componentIndex, Component component, int screenX, int screenY) {
|
public static void ComponentDraw(int componentIndex, Component component, int screenX, int screenY) {
|
||||||
loadedPlugins.values().forEach((plugin) -> plugin.ComponentDraw(componentIndex, component, screenX, screenY));
|
loadedPlugins.values().forEach((plugin) -> plugin.ComponentDraw(componentIndex, component, screenX, screenY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void OnVarpUpdate(int id, int value) {
|
||||||
|
loadedPlugins.values().forEach((plugin) -> plugin.OnVarpUpdate(id, value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package rt4;
|
||||||
import org.openrs2.deob.annotation.OriginalArg;
|
import org.openrs2.deob.annotation.OriginalArg;
|
||||||
import org.openrs2.deob.annotation.OriginalMember;
|
import org.openrs2.deob.annotation.OriginalMember;
|
||||||
import org.openrs2.deob.annotation.Pc;
|
import org.openrs2.deob.annotation.Pc;
|
||||||
|
import plugin.PluginRepository;
|
||||||
|
|
||||||
public class VarpDomain {
|
public class VarpDomain {
|
||||||
@OriginalMember(owner = "client!gj", name = "q", descriptor = "[I")
|
@OriginalMember(owner = "client!gj", name = "q", descriptor = "[I")
|
||||||
|
|
@ -36,6 +37,10 @@ public class VarpDomain {
|
||||||
|
|
||||||
@OriginalMember(owner = "client!nh", name = "a", descriptor = "(BII)V")
|
@OriginalMember(owner = "client!nh", name = "a", descriptor = "(BII)V")
|
||||||
public static void set(@OriginalArg(1) int value, @OriginalArg(2) int id) {
|
public static void set(@OriginalArg(1) int value, @OriginalArg(2) int id) {
|
||||||
|
PluginRepository.OnVarpUpdate(id, value);
|
||||||
|
|
||||||
|
if (id > varp.length) return;
|
||||||
|
|
||||||
varp[id] = value;
|
varp[id] = value;
|
||||||
@Pc(20) LongNode local20 = (LongNode) aClass133_20.get(id);
|
@Pc(20) LongNode local20 = (LongNode) aClass133_20.get(id);
|
||||||
if (local20 == null) {
|
if (local20 == null) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
AUTHOR='Me'
|
AUTHOR='Ceikry'
|
||||||
DESCRIPTION='Make sure to rename both the MyPlugin folder and the package statement in plugin.java!
|
DESCRIPTION='Enables visual display of component children and a log of interface-related varps.'
|
||||||
VERSION=-1.1
|
VERSION=-1.1
|
||||||
|
|
|
||||||
70
plugin-playground/src/main/java/VarpLogPlugin/plugin.java
Normal file
70
plugin-playground/src/main/java/VarpLogPlugin/plugin.java
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
package VarpLogPlugin;
|
||||||
|
|
||||||
|
import plugin.Plugin;
|
||||||
|
import plugin.api.*;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class plugin extends Plugin {
|
||||||
|
boolean isEnabled;
|
||||||
|
|
||||||
|
int MAX_VISIBLE_UPDATES = 5;
|
||||||
|
|
||||||
|
ArrayList<String> varpUpdates = new ArrayList<>();
|
||||||
|
ArrayList<String> updateCreationTime = new ArrayList<>();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Init() {
|
||||||
|
if (API.IsHD()) MAX_VISIBLE_UPDATES = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void OnVarpUpdate(int id, int value) {
|
||||||
|
if (!isEnabled) return;
|
||||||
|
|
||||||
|
if (varpUpdates.size() == MAX_VISIBLE_UPDATES) {
|
||||||
|
varpUpdates.remove(0);
|
||||||
|
updateCreationTime.remove(0);
|
||||||
|
}
|
||||||
|
varpUpdates.add(id + " =<gt> " + value);
|
||||||
|
String formattedTime = sdf.format(new Date());
|
||||||
|
updateCreationTime.add(formattedTime);
|
||||||
|
System.out.println("[VARP Update]" + formattedTime + " " + id + "->" + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Draw(long timeDelta) {
|
||||||
|
if (!isEnabled) return;
|
||||||
|
|
||||||
|
int startX = 10;
|
||||||
|
int startY = 30;
|
||||||
|
|
||||||
|
API.DrawText(FontType.SMALL, FontColor.YELLOW, TextModifier.LEFT, "Varp Updates:", startX, startY);
|
||||||
|
|
||||||
|
for (int i = 0; i < varpUpdates.size(); i++){
|
||||||
|
String update = varpUpdates.get(i);
|
||||||
|
String time = updateCreationTime.get(i);
|
||||||
|
|
||||||
|
API.DrawText(
|
||||||
|
FontType.SMALL,
|
||||||
|
FontColor.YELLOW,
|
||||||
|
TextModifier.LEFT,
|
||||||
|
"[" + time + "] " + update,
|
||||||
|
startX,
|
||||||
|
startY + (i + 1) * 15
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ProcessCommand(String commandStr, String[] args) {
|
||||||
|
if (!API.PlayerHasPrivilege(Privileges.JMOD)) return;
|
||||||
|
|
||||||
|
if (commandStr.equalsIgnoreCase("::varplog")) {
|
||||||
|
isEnabled = !isEnabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
AUTHOR='Ceikry'
|
||||||
|
DESCRIPTION='Draws some info about varp changes on the screen.'
|
||||||
|
VERSION=-1.0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue