|
|
@ -9,7 +9,7 @@ namespace ConsoleImprovements.Client {
|
|
|
|
public class MessageCopyPatch {
|
|
|
|
public class MessageCopyPatch {
|
|
|
|
private static ILogicLogger _logger = null!;
|
|
|
|
private static ILogicLogger _logger = null!;
|
|
|
|
private static MethodInfo? _removeRichTextTagsMethod;
|
|
|
|
private static MethodInfo? _removeRichTextTagsMethod;
|
|
|
|
private static FieldInfo? _dataProperty;
|
|
|
|
private static FieldInfo? _dataField;
|
|
|
|
private static FieldInfo? _messageRichTextField;
|
|
|
|
private static FieldInfo? _messageRichTextField;
|
|
|
|
private static FieldInfo? _messageTypeField;
|
|
|
|
private static FieldInfo? _messageTypeField;
|
|
|
|
|
|
|
|
|
|
|
@ -17,36 +17,16 @@ namespace ConsoleImprovements.Client {
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
|
|
|
|
|
|
|
|
|
// Get the private RemoveRichTextTags method of Message
|
|
|
|
// Get the private RemoveRichTextTags method of Message
|
|
|
|
_removeRichTextTagsMethod = AccessTools.Method(
|
|
|
|
_removeRichTextTagsMethod = Methods.getPrivate(typeof(Message), "RemoveRichTextTags");
|
|
|
|
typeof(Message),
|
|
|
|
|
|
|
|
"RemoveRichTextTags",
|
|
|
|
|
|
|
|
new[] {typeof(string)}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
if (_removeRichTextTagsMethod == null) {
|
|
|
|
|
|
|
|
_logger.Error("Cannot get method RemoveRichTextTags of message");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get access to the Data property of Message, which is of internal type MessageData
|
|
|
|
// Get access to the Data field of Message, which is of internal type MessageData
|
|
|
|
_dataProperty = AccessTools.Field(typeof(Message), "Data");
|
|
|
|
_dataField = Fields.getPrivate(typeof(Message), "Data");
|
|
|
|
if (_dataProperty == null) {
|
|
|
|
|
|
|
|
_logger.Error("Cannot get field Data of message");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get access to the rich text string inside the MessageData class
|
|
|
|
// Get access to the rich text string inside the MessageData class
|
|
|
|
_messageRichTextField = AccessTools.Field(_dataProperty.FieldType, "messageRichText");
|
|
|
|
_messageRichTextField = Fields.getPublic(_dataField.FieldType, "messageRichText");
|
|
|
|
if (_messageRichTextField == null) {
|
|
|
|
|
|
|
|
_logger.Error("Cannot get field messageRichText of message data");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get access to the message type enum inside the MessageData class
|
|
|
|
// Get access to the message type enum inside the MessageData class
|
|
|
|
_messageTypeField = AccessTools.Field(_dataProperty.FieldType, "messageType");
|
|
|
|
_messageTypeField = Fields.getPublic(_dataField.FieldType, "messageType");
|
|
|
|
if (_messageTypeField == null) {
|
|
|
|
|
|
|
|
_logger.Error("Cannot get field messageRichText of message data");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -60,7 +40,7 @@ namespace ConsoleImprovements.Client {
|
|
|
|
// Prefix the CopyMessageToClipboard method with this one
|
|
|
|
// Prefix the CopyMessageToClipboard method with this one
|
|
|
|
// ReSharper disable once InconsistentNaming
|
|
|
|
// ReSharper disable once InconsistentNaming
|
|
|
|
public static bool Hook(Message __instance) {
|
|
|
|
public static bool Hook(Message __instance) {
|
|
|
|
var dataInstance = _dataProperty!.GetValue(__instance);
|
|
|
|
var dataInstance = _dataField!.GetValue(__instance);
|
|
|
|
if (dataInstance == null) {
|
|
|
|
if (dataInstance == null) {
|
|
|
|
_logger.Error("Cannot get instance of MessageData");
|
|
|
|
_logger.Error("Cannot get instance of MessageData");
|
|
|
|
return true; // Resume original functionality
|
|
|
|
return true; // Resume original functionality
|
|
|
|