mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-10 10:20:44 -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
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
AUTHOR='Me'
|
||||
DESCRIPTION='Make sure to rename both the MyPlugin folder and the package statement in plugin.java!
|
||||
AUTHOR='Ceikry'
|
||||
DESCRIPTION='Enables visual display of component children and a log of interface-related varps.'
|
||||
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