diff --git a/Dalamud.Injector/Dalamud.Injector.csproj b/Dalamud.Injector/Dalamud.Injector.csproj
index 2788d54fc..e768c48f4 100644
--- a/Dalamud.Injector/Dalamud.Injector.csproj
+++ b/Dalamud.Injector/Dalamud.Injector.csproj
@@ -14,10 +14,10 @@
true
- 4.8.9.0
- 4.8.9.0
+ 4.9.1.0
+ 4.9.1.0
XIVLauncher addon injection
- 4.8.9.0
+ 4.9.1.0
diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs
index 9b5163efe..4d441b44a 100644
--- a/Dalamud/Dalamud.cs
+++ b/Dalamud/Dalamud.cs
@@ -23,6 +23,7 @@ using Dalamud.Game.Network;
using Dalamud.Interface;
using Dalamud.Plugin;
using ImGuiNET;
+using Lumina.Excel.GeneratedSheets;
using Newtonsoft.Json;
using Serilog;
using Serilog.Core;
@@ -93,6 +94,10 @@ namespace Dalamud {
this.WinSock2 = new WinSockHandlers();
AssetManager.EnsureAssets(this.baseDirectory).ContinueWith(async task => {
+ if (task.IsCanceled || task.IsFaulted) {
+ throw new Exception("Could not ensure assets.", task.Exception);
+ }
+
this.localizationMgr = new Localization(this.StartInfo.WorkingDirectory);
if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride)) {
this.localizationMgr.SetupWithLangCode(this.Configuration.LanguageOverride);
diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj
index 8207b6386..609c1e89b 100644
--- a/Dalamud/Dalamud.csproj
+++ b/Dalamud/Dalamud.csproj
@@ -14,9 +14,9 @@
true
- 4.8.9.0
- 4.8.9.0
- 4.8.9.0
+ 4.9.1.0
+ 4.9.1.0
+ 4.9.1.0
@@ -76,9 +76,4 @@
-
-
- PreserveNewest
-
-
diff --git a/Dalamud/Game/ChatHandlers.cs b/Dalamud/Game/ChatHandlers.cs
index aa4811b50..8ac099093 100644
--- a/Dalamud/Game/ChatHandlers.cs
+++ b/Dalamud/Game/ChatHandlers.cs
@@ -91,10 +91,33 @@ namespace Dalamud.Game {
public ChatHandlers(Dalamud dalamud) {
this.dalamud = dalamud;
-
+
+ dalamud.Framework.Gui.Chat.OnCheckMessageHandled += OnCheckMessageHandled;
dalamud.Framework.Gui.Chat.OnChatMessageRaw += OnChatMessage;
}
+ private void OnCheckMessageHandled(XivChatType type, uint senderid, ref SeString sender, ref SeString message, ref bool isHandled) {
+ var textVal = message.TextValue;
+
+ var matched = this.rmtRegex.IsMatch(textVal);
+ if (matched)
+ {
+ // This seems to be a RMT ad - let's not show it
+ Log.Debug("Handled RMT ad: " + message.TextValue);
+ isHandled = true;
+ return;
+ }
+
+
+ if (this.dalamud.Configuration.BadWords != null &&
+ this.dalamud.Configuration.BadWords.Any(x => textVal.Contains(x)))
+ {
+ // This seems to be in the user block list - let's not show it
+ Log.Debug("Blocklist triggered");
+ isHandled = true;
+ return;
+ }
+ }
public string LastLink { get; private set; }
@@ -142,25 +165,9 @@ namespace Dalamud.Game {
return;
#endif
- var matched = this.rmtRegex.IsMatch(message.Value);
- if (matched) {
- // This seems to be a RMT ad - let's not show it
- Log.Debug("Handled RMT ad");
- isHandled = true;
- return;
- }
-
var messageVal = message.Value;
var senderVal = sender.Value;
- if (this.dalamud.Configuration.BadWords != null &&
- this.dalamud.Configuration.BadWords.Any(x => messageVal.Contains(x))) {
- // This seems to be in the user block list - let's not show it
- Log.Debug("Blocklist triggered");
- isHandled = true;
- return;
- }
-
if (type == XivChatType.RetainerSale)
{
foreach (var regex in retainerSaleRegexes[dalamud.StartInfo.Language])
diff --git a/Dalamud/Game/Command/CommandManager.cs b/Dalamud/Game/Command/CommandManager.cs
index 98ca22642..794a0f93d 100644
--- a/Dalamud/Game/Command/CommandManager.cs
+++ b/Dalamud/Game/Command/CommandManager.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text.RegularExpressions;
using Dalamud.Game.Chat;
+using Dalamud.Game.Chat.SeStringHandling;
using Dalamud.Game.Internal.Libc;
using Serilog;
@@ -54,13 +55,12 @@ namespace Dalamud.Game.Command {
break;
}
- dalamud.Framework.Gui.Chat.OnChatMessageRaw += OnChatMessage;
+ dalamud.Framework.Gui.Chat.OnCheckMessageHandled += OnCheckMessageHandled;
}
- private void OnChatMessage(XivChatType type, uint senderId, ref StdString sender,
- ref StdString message, ref bool isHandled) {
+ private void OnCheckMessageHandled(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled) {
if (type == XivChatType.ErrorMessage && senderId == 0) {
- var cmdMatch = this.currentLangCommandRegex.Match(message.Value).Groups["command"];
+ var cmdMatch = this.currentLangCommandRegex.Match(message.TextValue).Groups["command"];
if (cmdMatch.Success) {
// Yes, it's a chat command.
var command = cmdMatch.Value;
diff --git a/Dalamud/Game/Internal/Gui/ChatGui.cs b/Dalamud/Game/Internal/Gui/ChatGui.cs
index d4b6c7fca..787741e01 100644
--- a/Dalamud/Game/Internal/Gui/ChatGui.cs
+++ b/Dalamud/Game/Internal/Gui/ChatGui.cs
@@ -11,30 +11,52 @@ using Serilog;
namespace Dalamud.Game.Internal.Gui {
public sealed class ChatGui : IDisposable {
+ private readonly Queue chatQueue = new Queue();
+
+ #region Events
+
+ public delegate void OnMessageDelegate(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled);
+ public delegate void OnMessageRawDelegate(XivChatType type, uint senderId, ref StdString sender, ref StdString message, ref bool isHandled);
+ public delegate void OnCheckMessageHandledDelegate(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled);
+
+ ///
+ /// Event that allows you to stop messages from appearing in chat by setting the isHandled parameter to true.
+ ///
+ public event OnCheckMessageHandledDelegate OnCheckMessageHandled;
+
+ ///
+ /// Event that will be fired when a chat message is sent to chat by the game.
+ ///
+ public event OnMessageDelegate OnChatMessage;
+
+ ///
+ /// Event that will be fired when a chat message is sent by the game, containing raw, unparsed data.
+ ///
+ [Obsolete("Please use OnChatMessage instead. For modifications, it will take precedence.")]
+ public event OnMessageRawDelegate OnChatMessageRaw;
+
+ #endregion
+
+ #region Hooks
+
+ private readonly Hook printMessageHook;
+
+ private readonly Hook populateItemLinkHook;
+
+ #endregion
+
+ #region Delegates
+
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate IntPtr PrintMessageDelegate(IntPtr manager, XivChatType chatType, IntPtr senderName,
- IntPtr message,
- uint senderId, IntPtr parameter);
-
- public delegate void OnMessageDelegate(XivChatType type, uint senderId, ref SeString sender, ref SeString message,
- ref bool isHandled);
-
- public delegate void OnMessageRawDelegate(XivChatType type, uint senderId, ref StdString sender, ref StdString message,
- ref bool isHandled);
+ IntPtr message,
+ uint senderId, IntPtr parameter);
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate void PopulateItemLinkDelegate(IntPtr linkObjectPtr, IntPtr itemInfoPtr);
- private readonly Queue chatQueue = new Queue();
-
- private readonly Hook printMessageHook;
-
- public event OnMessageDelegate OnChatMessage;
- [Obsolete("Please use OnChatMessage instead. For modifications, it will take precedence.")]
- public event OnMessageRawDelegate OnChatMessageRaw;
-
- private readonly Hook populateItemLinkHook;
+ #endregion
public int LastLinkedItemId { get; private set; }
public byte LastLinkedItemFlags { get; private set; }
@@ -106,6 +128,8 @@ namespace Dalamud.Game.Internal.Gui {
// Call events
var isHandled = false;
+ OnCheckMessageHandled?.Invoke(chattype, senderid, ref parsedSender, ref parsedMessage, ref isHandled);
+
OnChatMessage?.Invoke(chattype, senderid, ref parsedSender, ref parsedMessage, ref isHandled);
OnChatMessageRaw?.Invoke(chattype, senderid, ref sender, ref message, ref isHandled);
diff --git a/Dalamud/Plugin/PluginManager.cs b/Dalamud/Plugin/PluginManager.cs
index 56755bd53..2bf42e4f0 100644
--- a/Dalamud/Plugin/PluginManager.cs
+++ b/Dalamud/Plugin/PluginManager.cs
@@ -122,6 +122,23 @@ namespace Dalamud.Plugin
// Assembly.Load() by name here will not load multiple versions with the same name, in the case of updates
var pluginAssembly = Assembly.LoadFile(dllFile.FullName);
+ // Don't wanna fuck this up
+ // This is a fix for earlier Chat Extender versions, since they break command handlers
+ try
+ {
+ var ver = int.Parse(pluginAssembly.GetName().Version.ToString().Replace(".", ""));
+ if (dllFile.Name.Contains("ChatExtender") &&
+ ver < 1410)
+ {
+ Log.Information($"Found banned v{ver} ChatExtender, skipping...");
+ return false;
+ }
+ }
+ catch (Exception)
+ {
+ // ignored
+ }
+
if (pluginAssembly != null)
{
Log.Information("Loading types for {0}", pluginAssembly.FullName);