timestamp: use steam client chat timestamp support
The chat building scripts have variables now for message timestamp, so we can just assign our timestamp to those instead.
This commit is contained in:
@@ -505,6 +505,8 @@ public class Instructions implements Opcodes
|
||||
add(CHAT_SETMESSAGEFILTER, "chat_setmessagefilter");
|
||||
add(CHAT_GETMESSAGEFILTER, "chat_getmessagefilter");
|
||||
add(WRITECONSOLE, "writeconsole");
|
||||
add(CHAT_GETHISTORYEX_BYTYPEANDLINE, "chat_gethistoryex_bytypeandline");
|
||||
add(CHAT_GETHISTORYEX_BYUID, "chat_gethistoryex_byuid");
|
||||
add(GETWINDOWMODE, "getwindowmode");
|
||||
add(SETWINDOWMODE, "setwindowmode");
|
||||
add(GETDEFAULTWINDOWMODE, "getdefaultwindowmode");
|
||||
|
||||
@@ -497,6 +497,8 @@ public interface Opcodes
|
||||
int CHAT_SETMESSAGEFILTER = 5021;
|
||||
int CHAT_GETMESSAGEFILTER = 5022;
|
||||
int WRITECONSOLE = 5023;
|
||||
int CHAT_GETHISTORYEX_BYTYPEANDLINE = 5030;
|
||||
int CHAT_GETHISTORYEX_BYUID = 5031;
|
||||
int GETWINDOWMODE = 5306;
|
||||
int SETWINDOWMODE = 5307;
|
||||
int GETDEFAULTWINDOWMODE = 5308;
|
||||
|
||||
@@ -36,13 +36,11 @@ import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MessageNode;
|
||||
import net.runelite.api.ScriptID;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.ScriptPreFired;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.api.events.ScriptCallbackEvent;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.util.ColorUtil;
|
||||
@@ -64,8 +62,6 @@ public class TimestampPlugin extends Plugin
|
||||
@Getter
|
||||
private SimpleDateFormat formatter;
|
||||
|
||||
private MessageNode currentlyBuildingMessage = null;
|
||||
|
||||
@Provides
|
||||
public TimestampConfig provideConfig(final ConfigManager configManager)
|
||||
{
|
||||
@@ -102,41 +98,10 @@ public class TimestampPlugin extends Plugin
|
||||
}
|
||||
|
||||
int uid = client.getIntStack()[client.getIntStackSize() - 1];
|
||||
currentlyBuildingMessage = client.getMessages().get(uid);
|
||||
}
|
||||
final MessageNode messageNode = client.getMessages().get(uid);
|
||||
assert messageNode != null : "chat message build for unknown message";
|
||||
|
||||
@Subscribe
|
||||
private void onScriptPreFired(ScriptPreFired ev)
|
||||
{
|
||||
int numStringArgs;
|
||||
int messagePrefixArg = 0;
|
||||
switch (ev.getScriptId())
|
||||
{
|
||||
case ScriptID.CHATBOX_BUILD_LINE_WITHOUT_USER:
|
||||
numStringArgs = 1;
|
||||
break;
|
||||
case ScriptID.CHATBOX_BUILD_LINE_WITH_USER:
|
||||
numStringArgs = 2;
|
||||
break;
|
||||
case ScriptID.CHATBOX_BUILD_LINE_WITH_CLAN:
|
||||
numStringArgs = 3;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentlyBuildingMessage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MessageNode messageNode = currentlyBuildingMessage;
|
||||
currentlyBuildingMessage = null;
|
||||
|
||||
String[] stringStack = client.getStringStack();
|
||||
int stringArgStart = client.getStringStackSize() - numStringArgs;
|
||||
|
||||
String timestamp = generateTimestamp(messageNode.getTimestamp(), ZoneId.systemDefault()) + " ";
|
||||
String timestamp = generateTimestamp(messageNode.getTimestamp(), ZoneId.systemDefault());
|
||||
|
||||
Color timestampColour = getTimestampColour();
|
||||
if (timestampColour != null)
|
||||
@@ -144,9 +109,7 @@ public class TimestampPlugin extends Plugin
|
||||
timestamp = ColorUtil.wrapWithColorTag(timestamp, timestampColour);
|
||||
}
|
||||
|
||||
String segment = stringStack[stringArgStart + messagePrefixArg];
|
||||
segment = timestamp + segment;
|
||||
stringStack[stringArgStart + messagePrefixArg] = segment;
|
||||
client.getStringStack()[client.getStringStackSize() - 1] = timestamp;
|
||||
}
|
||||
|
||||
private Color getTimestampColour()
|
||||
|
||||
@@ -343,9 +343,9 @@ LABEL319:
|
||||
jump LABEL1598
|
||||
LABEL323:
|
||||
iload 10
|
||||
5031
|
||||
chat_gethistoryex_byuid
|
||||
istore 21
|
||||
sstore 18
|
||||
sstore 18 ; timestamp
|
||||
istore 15
|
||||
sstore 15
|
||||
sstore 14
|
||||
@@ -390,9 +390,11 @@ LABEL341:
|
||||
jump LABEL1594
|
||||
LABEL355:
|
||||
iload 10 ; message uid
|
||||
sload 18 ; message timestamp
|
||||
sconst "chatMessageBuilding"
|
||||
runelite_callback
|
||||
pop_int ; pop uid
|
||||
sstore 18 ; message timestamp
|
||||
iload 11
|
||||
switch
|
||||
1: LABEL358
|
||||
|
||||
@@ -381,9 +381,9 @@ LABEL344:
|
||||
jump LABEL566
|
||||
LABEL350:
|
||||
iload 12
|
||||
5031
|
||||
chat_gethistoryex_byuid
|
||||
istore 15
|
||||
sstore 2
|
||||
sstore 2 ; timestamp
|
||||
istore 14
|
||||
sstore 0
|
||||
sstore 3
|
||||
@@ -413,9 +413,11 @@ CHAT_FILTER:
|
||||
jump LABEL562
|
||||
LABEL368:
|
||||
iload 12 ; message uid
|
||||
sload 2 ; message timestamp
|
||||
sconst "chatMessageBuilding"
|
||||
runelite_callback
|
||||
pop_int
|
||||
sstore 2 ; message timestamp
|
||||
iload 18
|
||||
switch
|
||||
3: LABEL371
|
||||
|
||||
Reference in New Issue
Block a user