mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-23 03:44:57 +00:00
Fully sanitize Discord messages
This commit is contained in:
parent
c71cf1a14c
commit
97c337d5a4
2 changed files with 9 additions and 4 deletions
|
@ -211,4 +211,10 @@ public class DiscordBridge {
|
|||
|
||||
Log.info("TFM 4.3 Reloaded Discord stopped.");
|
||||
}
|
||||
|
||||
public static String fullySanitizeDiscordMessage(String message)
|
||||
{
|
||||
String partiallySanitized = sanitizeMessage(message);
|
||||
return partiallySanitized.replaceAll("\\\\", "\\\\\\").replaceAll("([`_~*|])", "\\\\$1");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
|||
import me.StevenLawson.TotalFreedomMod.world.AdminWorld;
|
||||
import me.StevenLawson.TotalFreedomMod.world.RollbackManager;
|
||||
import me.StevenLawson.TotalFreedomMod.world.RollbackManager.RollbackEntry;
|
||||
import org.apache.commons.lang.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -632,7 +631,7 @@ public class PlayerListener implements Listener {
|
|||
event.setFormat(ChatColor.translateAlternateColorCodes('&', MainConfig.getString(ConfigurationEntry.CHAT_FORMAT)).replace("{RANK}", playerdata.getTag().replaceAll("%", "%%")));
|
||||
}
|
||||
|
||||
DiscordBridge.transmitMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()).replaceAll("([`_~*])", "\\\\$1"));
|
||||
DiscordBridge.transmitMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), DiscordBridge.fullySanitizeDiscordMessage(event.getMessage())));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -756,7 +755,7 @@ public class PlayerListener implements Listener {
|
|||
}
|
||||
|
||||
if (PlayerList.existsEntry(player)) {
|
||||
DiscordBridge.transmitMessage(String.format("**%s left the server**", DiscordBridge.sanitizeMessage(player.getDisplayName())));
|
||||
DiscordBridge.transmitMessage(String.format("**%s left the server**", DiscordBridge.fullySanitizeDiscordMessage(player.getDisplayName())));
|
||||
}
|
||||
|
||||
PlayerList.removeEntry(player);
|
||||
|
@ -908,7 +907,7 @@ public class PlayerListener implements Listener {
|
|||
PlayerData.getPlayerData(player).setTag(playerTag);
|
||||
}
|
||||
}
|
||||
DiscordBridge.transmitMessage(String.format("**%s joined the server**", DiscordBridge.sanitizeMessage(player.getDisplayName())));
|
||||
DiscordBridge.transmitMessage(String.format("**%s joined the server**", DiscordBridge.fullySanitizeDiscordMessage(player.getDisplayName())));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
|
Loading…
Reference in a new issue