reverted unrelated changes

This commit is contained in:
William Beemer 2024-01-23 00:23:43 -08:00
parent b92e0432c3
commit 95cd4ad376
1 changed files with 5 additions and 10 deletions

View File

@ -75,7 +75,7 @@ public class JDADiscordService implements DiscordService, IEssentialsModule {
private final static Logger logger = EssentialsDiscord.getWrappedLogger(); private final static Logger logger = EssentialsDiscord.getWrappedLogger();
private final EssentialsDiscord plugin; private final EssentialsDiscord plugin;
private final Unsafe unsafe = this::getJda; private final Unsafe unsafe = this::getJda;
private JDA jda; private JDA jda;
private Guild guild; private Guild guild;
private TextChannel primaryChannel; private TextChannel primaryChannel;
@ -89,24 +89,24 @@ public class JDADiscordService implements DiscordService, IEssentialsModule {
private InteractionControllerImpl interactionController; private InteractionControllerImpl interactionController;
private Listener chatListener; private Listener chatListener;
private boolean invalidStartup = false; private boolean invalidStartup = false;
public JDADiscordService(EssentialsDiscord plugin) { public JDADiscordService(EssentialsDiscord plugin) {
this.plugin = plugin; this.plugin = plugin;
for (final MessageType type : MessageType.DefaultTypes.values()) { for (final MessageType type : MessageType.DefaultTypes.values()) {
registerMessageType(plugin, type); registerMessageType(plugin, type);
} }
} }
public TextChannel getChannel(String key, boolean primaryFallback) { public TextChannel getChannel(String key, boolean primaryFallback) {
if (NumberUtil.isLong(key)) { if (NumberUtil.isLong(key)) {
return getDefinedChannel(key, primaryFallback); return getDefinedChannel(key, primaryFallback);
} }
return getDefinedChannel(getSettings().getMessageChannel(key), primaryFallback); return getDefinedChannel(getSettings().getMessageChannel(key), primaryFallback);
} }
public TextChannel getDefinedChannel(String key, boolean primaryFallback) { public TextChannel getDefinedChannel(String key, boolean primaryFallback) {
final long resolvedId = getSettings().getChannelId(key); final long resolvedId = getSettings().getChannelId(key);
if (isDebug()) { if (isDebug()) {
logger.log(Level.INFO, "Channel definition " + key + " resolved as " + resolvedId); logger.log(Level.INFO, "Channel definition " + key + " resolved as " + resolvedId);
} }
@ -136,10 +136,6 @@ public class JDADiscordService implements DiscordService, IEssentialsModule {
public void sendMessage(DiscordMessageEvent event, String message, boolean groupMentions) { public void sendMessage(DiscordMessageEvent event, String message, boolean groupMentions) {
final TextChannel channel = getChannel(event.getType().getKey(), true); final TextChannel channel = getChannel(event.getType().getKey(), true);
final boolean isSilentMessage = message.startsWith("@silent");
if (isSilentMessage) message = message.replace("@silent", "");
final String strippedContent = FormatUtil.stripFormat(message); final String strippedContent = FormatUtil.stripFormat(message);
final String webhookChannelId = typeToChannelId.get(event.getType()); final String webhookChannelId = typeToChannelId.get(event.getType());
@ -161,7 +157,6 @@ public class JDADiscordService implements DiscordService, IEssentialsModule {
channel.sendMessage(strippedContent) channel.sendMessage(strippedContent)
.setAllowedMentions(groupMentions ? null : DiscordUtil.NO_GROUP_MENTIONS) .setAllowedMentions(groupMentions ? null : DiscordUtil.NO_GROUP_MENTIONS)
.setSuppressedNotifications(isSilentMessage)
.queue(); .queue();
} }