diff --git a/docs/config/messages.player.md b/docs/config/messages.player.md
index 9bbdc77..8f348d7 100644
--- a/docs/config/messages.player.md
+++ b/docs/config/messages.player.md
@@ -20,6 +20,7 @@
| `%DAY_NUMBER%` | Current day number on server | Any messages |
| `%WORLD_NAME%` | World name of the world used on the server | Any messages |
| `%NUM_PLAYERS%` | Number of currently online players | Any messages |
+| `%JOIN_CODE%` | Server's join code (only if a join code exists, blank otherwise) | Any messages |
:::
:::details Random Messages
diff --git a/docs/config/messages.playerfirsts.md b/docs/config/messages.playerfirsts.md
index fa1ef68..82f2e72 100644
--- a/docs/config/messages.playerfirsts.md
+++ b/docs/config/messages.playerfirsts.md
@@ -19,6 +19,7 @@
| `%DAY_NUMBER%` | Current day number on server | Any messages |
| `%WORLD_NAME%` | World name of the world used on the server | Any messages |
| `%NUM_PLAYERS%` | Number of currently online players | Any messages |
+| `%JOIN_CODE%` | Server's join code (only if a join code exists, blank otherwise) | Any messages |
:::
:::details Random Messages
diff --git a/docs/config/messages.server.md b/docs/config/messages.server.md
index ac16eb0..f2ff673 100644
--- a/docs/config/messages.server.md
+++ b/docs/config/messages.server.md
@@ -9,6 +9,7 @@
| `%DAY_NUMBER%` | Current day number on server | Any messages |
| `%WORLD_NAME%` | World name of the world used on the server | Any messages |
| `%NUM_PLAYERS%` | Number of currently online players | Any messages |
+| `%JOIN_CODE%` | Server's join code (only if a join code exists, blank otherwise) | Any messages |
:::
## Server Launch Message
diff --git a/src/MessageTransformer.cs b/src/MessageTransformer.cs
index 08c88eb..c949e1f 100644
--- a/src/MessageTransformer.cs
+++ b/src/MessageTransformer.cs
@@ -27,6 +27,7 @@ internal static class MessageTransformer
private const string WORLD_NAME = "%WORLD_NAME%";
private const string DAY_NUMBER = "%DAY_NUMBER%";
private const string NUM_PLAYERS = "%NUM_PLAYERS%";
+ private const string JOIN_CODE = "%JOIN_CODE%";
private static readonly Regex OpenCaretRegex = new(@"<[\w=]+>");
private static readonly Regex CloseCaretRegex = new(@"[\w]+>");
@@ -59,6 +60,7 @@ private static string ReplaceVariables(string rawMessage)
/// - `%WORLD_NAME%` with the name of the world
/// - `%DAY_NUMBER%` with the current day number
/// - `%NUM_PLAYERS%` with the number of players in the server
+ /// - `%JOIN_CODE%` with the join code of the server
///
/// Raw message to format
private static string ReplaceDynamicVariables(string rawMessage)
@@ -68,10 +70,21 @@ private static string ReplaceDynamicVariables(string rawMessage)
dynamicReplacedMessage = ReplaceWorldName(dynamicReplacedMessage);
dynamicReplacedMessage = ReplaceDayNumber(dynamicReplacedMessage);
dynamicReplacedMessage = ReplaceNumPlayers(dynamicReplacedMessage);
+ dynamicReplacedMessage = ReplaceJoinCode(dynamicReplacedMessage);
return dynamicReplacedMessage;
}
+ ///
+ /// Replace the join code in the message. Uses the ZPlayFabMatchmaking class to get the join code.
+ ///
+ /// Raw message to format
+ private static string ReplaceJoinCode(string rawMessage)
+ {
+ return rawMessage
+ .Replace(JOIN_CODE, ZPlayFabMatchmaking.JoinCode);
+ }
+
///
/// Replace the day number in the message. Uses the EnvMan instance to get the current day.
/// This will only replace `%DAY_NUMBER%` with the current day if the EnvMan instance is available.