Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
fix: problems with duplicate message sending
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Mar 30, 2024
1 parent 46f7865 commit bb0d7ad
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public void dispatch() {

// Send the broadcast
plugin.getOnlinePlayers().forEach(this::sendMessage);

// Log to console
if (settings.isLogToConsole()) {
plugin.log(Level.INFO, settings.getLogFormat() + message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,20 @@ public boolean dispatch() {
getPlugin().getLocales().sendLocalSpy(spy, color, getSender(), channel.get(), getMessage(), getPlugin());
}
}
});

// Log a message to console if enabled on the channel
if (channel.get().isLogToConsole()) {
final String logFormat = getPlugin().getChannels().getChannelLogFormat()
.replaceAll("%channel%", channel.get().getId().toUpperCase())
.replaceAll("%sender%", getSender().getName());
getPlugin().log(Level.INFO, logFormat + getMessage());
}
// Log a message to console if enabled on the channel
if (channel.get().isLogToConsole()) {
final String logFormat = getPlugin().getChannels().getChannelLogFormat()
.replaceAll("%channel%", channel.get().getId().toUpperCase())
.replaceAll("%sender%", getSender().getName());
getPlugin().log(Level.INFO, logFormat + getMessage());
}

// Dispatch message to a Discord webhook if enabled
if (getPlugin().getSettings().getDiscord().isEnabled()) {
getPlugin().getDiscordHook().ifPresent(hook -> hook.postMessage(this));
}
});
// Dispatch message to a Discord webhook if enabled
if (getPlugin().getSettings().getDiscord().isEnabled()) {
getPlugin().getDiscordHook().ifPresent(hook -> hook.postMessage(this));
}
});

// Non-passthrough messages should always be canceled in the proxy-specific code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ public void dispatch() {
plugin.getLocales().sendOutboundPrivateMessage(sender, receivers, finalMessage.get(), plugin);

// Show the received message
for (OnlineUser target : receivers) {
plugin.editUserCache(c -> receivers.forEach(target -> {
final ArrayList<OnlineUser> receivedMessageFrom = new ArrayList<>(receivers);
receivedMessageFrom.removeIf(player -> player.getUuid().equals(target.getUuid()));
receivedMessageFrom.add(0, sender);

plugin.editUserCache(c -> c.setLastMessenger(target.getUuid(), receivedMessageFrom));
}
c.setLastMessenger(target.getUuid(), receivedMessageFrom);
}));
plugin.getLocales().sendInboundPrivateMessage(receivers, sender, finalMessage.get(), plugin);

// Show a message to social spies
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.parallel=true
org.gradle.daemon=true
javaVersion=17

plugin_version=3.0.1
plugin_version=3.0.2
plugin_archive=huskchat
plugin_description=A simple & customizable no-frills Minecraft chat system

Expand Down

0 comments on commit bb0d7ad

Please sign in to comment.