Skip to content

Commit

Permalink
Merge branch 'development' into 94-disabled-servers
Browse files Browse the repository at this point in the history
  • Loading branch information
beanbeanjuice authored Aug 31, 2024
2 parents 73cb75c + e245a0d commit be1fbc7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ file-version: 9
* `%from%` - The server the player just disconnected from. Uses the alias if one is specified.
* `%original_from%` - Same as `%from%`, but does not use the alias.
* `%player%` - The player's Minecraft username.
* `%escaped_player%` - The escaped player's Minecraft username. (Adds '\\' before the '_' to prevent italics.)
* `%sender%` - The person sending the private message. **Private Messaging Only**
* `%receiver%` - The person receiving the private message. **Private Messaging Only**
* `%user%` - The player's Discord username.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public void runProxyChatMessage(ChatMessageData chatMessageData) {
replacements.add(Tuple.of("to", aliasedServerName));
replacements.add(Tuple.of("original_to", serverName));
replacements.add(Tuple.of("player", playerName));
replacements.add(Tuple.of("escaped_player", Helper.escapeString(playerName)));
replacements.add(Tuple.of("epoch", String.valueOf(epochHelper.getEpochSecond())));
replacements.add(Tuple.of("time", getTimeString()));
replacements.add(Tuple.of("plugin-prefix", config.get(ConfigKey.PLUGIN_PREFIX).asString()));
Expand All @@ -144,6 +145,7 @@ public void runProxyChatMessage(ChatMessageData chatMessageData) {

chat(chatMessageData, minecraftMessage, discordMessage, discordEmbedTitle, discordEmbedMessage);
}

public void runProxyLeaveMessage(String playerName, UUID playerUUID, String serverName,
BiConsumer<String, Permission> minecraftLogger) {
String configString = config.get(ConfigKey.MINECRAFT_LEAVE).asString();
Expand All @@ -153,6 +155,7 @@ public void runProxyLeaveMessage(String playerName, UUID playerUUID, String serv

List<Tuple<String, String>> replacements = new ArrayList<>();
replacements.add(Tuple.of("player", playerName));
replacements.add(Tuple.of("escaped_player", Helper.escapeString(playerName)));
replacements.add(Tuple.of("server", aliasedServerName));
replacements.add(Tuple.of("original_server", serverName));
replacements.add(Tuple.of("to", aliasedServerName));
Expand Down Expand Up @@ -190,6 +193,7 @@ public void runProxyJoinMessage(String playerName, UUID playerUUID, String serve

List<Tuple<String, String>> replacements = new ArrayList<>();
replacements.add(Tuple.of("player", playerName));
replacements.add(Tuple.of("escaped_player", Helper.escapeString(playerName)));
replacements.add(Tuple.of("server", Helper.convertAlias(config, serverName)));
replacements.add(Tuple.of("to", Helper.convertAlias(config, serverName)));
replacements.add(Tuple.of("server", aliasedServerName));
Expand Down Expand Up @@ -238,6 +242,7 @@ public void runProxySwitchMessage(String from, String to, String playerName, UUI
replacements.add(Tuple.of("server", aliasedTo));
replacements.add(Tuple.of("original_server", to));
replacements.add(Tuple.of("player", playerName));
replacements.add(Tuple.of("escaped_player", Helper.escapeString(playerName)));
replacements.add(Tuple.of("epoch", String.valueOf(epochHelper.getEpochSecond())));
replacements.add(Tuple.of("time", getTimeString()));
replacements.add(Tuple.of("plugin-prefix", config.get(ConfigKey.PLUGIN_PREFIX).asString()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,8 @@ public static String replaceKeys(String string, Tuple<String, String>... entries
return string;
}

public static String escapeString(String string) {
return string.replaceAll("_", "\\_");
}

}

0 comments on commit be1fbc7

Please sign in to comment.