mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-10-31 23:49:19 +00:00
Fully sanitize Discord messages
This commit is contained in:
parent
52f293a175
commit
bb4dd0f931
|
@ -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