diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitDeathListener.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitDeathListener.java index d81228e8..81cae4e5 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitDeathListener.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitDeathListener.java @@ -75,7 +75,12 @@ public class BukkitDeathListener implements Listener { } boolean wasCancelled = cancelled; - discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( - new DeathMessageReceiveEvent(event, player, component, null, wasCancelled))); + discordSRV.eventBus().publish(new DeathMessageReceiveEvent( + event, + player, + component, + null, + wasCancelled + )); } } diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitStatusMessageListener.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitStatusMessageListener.java index 34c194d0..fe1103e2 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitStatusMessageListener.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/BukkitStatusMessageListener.java @@ -60,8 +60,13 @@ public class BukkitStatusMessageListener implements Listener { MinecraftComponent component = JOIN_HANDLE.getComponent(event); boolean firstJoin = !event.getPlayer().hasPlayedBefore(); - discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( - new JoinMessageReceiveEvent(event, player, component, null, firstJoin, false) + discordSRV.eventBus().publish(new JoinMessageReceiveEvent( + event, + player, + component, + null, + firstJoin, + false )); } @@ -70,8 +75,12 @@ public class BukkitStatusMessageListener implements Listener { DiscordSRVPlayer player = discordSRV.playerProvider().player(event.getPlayer()); MinecraftComponent component = QUIT_HANDLE.getComponent(event); - discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( - new LeaveMessageReceiveEvent(event, player, component, null, false) + discordSRV.eventBus().publish(new LeaveMessageReceiveEvent( + event, + player, + component, + null, + false )); } } diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAwardForwarder.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAwardForwarder.java index 4ad720a1..a38bd42b 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAwardForwarder.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/award/BukkitAwardForwarder.java @@ -21,7 +21,6 @@ package com.discordsrv.bukkit.listener.award; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.events.message.receive.game.AwardMessageReceiveEvent; import com.discordsrv.bukkit.BukkitDiscordSRV; -import com.discordsrv.common.abstraction.player.IPlayer; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.intellij.lang.annotations.Language; @@ -67,16 +66,13 @@ public class BukkitAwardForwarder implements IBukkitAwardForwarder { } public void publishEvent(Object triggeringEvent, Player player, MinecraftComponent advancementName, MinecraftComponent message, boolean cancelled) { - IPlayer srvPlayer = discordSRV.playerProvider().player(player); - discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( - new AwardMessageReceiveEvent( - triggeringEvent, - srvPlayer, - advancementName, - message, - null, - cancelled - ) + discordSRV.eventBus().publish(new AwardMessageReceiveEvent( + triggeringEvent, + discordSRV.playerProvider().player(player), + advancementName, + message, + null, + cancelled )); } } diff --git a/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatForwarder.java b/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatForwarder.java index 888c7034..0b359c4a 100644 --- a/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatForwarder.java +++ b/bukkit/src/main/java/com/discordsrv/bukkit/listener/chat/BukkitChatForwarder.java @@ -63,16 +63,13 @@ public class BukkitChatForwarder implements IBukkitChatForwarder { } @Override - public void forwardMessage(Event event, Player player, MinecraftComponent component, boolean cancelled) { - IPlayer srvPlayer = discordSRV.playerProvider().player(player); - discordSRV.scheduler().run(() -> discordSRV.eventBus().publish( - new GameChatMessageReceiveEvent( - event, - srvPlayer, - component, - new GlobalChannel(discordSRV), - cancelled - ) + public void forwardMessage(Event triggeringEvent, Player player, MinecraftComponent component, boolean cancelled) { + discordSRV.eventBus().publish(new GameChatMessageReceiveEvent( + triggeringEvent, + discordSRV.playerProvider().player(player), + component, + new GlobalChannel(discordSRV), + cancelled )); } } diff --git a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/AwardMessageModule.java b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/AwardMessageModule.java index f0eaa803..cf53605a 100644 --- a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/AwardMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/AwardMessageModule.java @@ -71,10 +71,11 @@ public class AwardMessageModule extends AbstractGameMessageModule process(event, event.getPlayer(), event.getGameChannel())); event.markAsProcessed(); } diff --git a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/DeathMessageModule.java b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/DeathMessageModule.java index 82ef0245..f95e17d8 100644 --- a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/DeathMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/DeathMessageModule.java @@ -45,7 +45,7 @@ public class DeathMessageModule extends AbstractGameMessageModule process(event, event.getPlayer(), event.getGameChannel())); event.markAsProcessed(); } diff --git a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/JoinMessageModule.java b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/JoinMessageModule.java index 717226ab..a9f31454 100644 --- a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/JoinMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/JoinMessageModule.java @@ -26,6 +26,7 @@ import com.discordsrv.api.eventbus.EventPriorities; import com.discordsrv.api.eventbus.Subscribe; import com.discordsrv.api.events.message.forward.game.JoinMessageForwardedEvent; import com.discordsrv.api.events.message.receive.game.JoinMessageReceiveEvent; +import com.discordsrv.api.player.DiscordSRVPlayer; import com.discordsrv.common.DiscordSRV; import com.discordsrv.common.abstraction.player.IPlayer; import com.discordsrv.common.config.main.channels.base.BaseChannelConfig; @@ -47,6 +48,7 @@ import java.util.concurrent.Future; public class JoinMessageModule extends AbstractGameMessageModule { private final Map> delayedTasks = new HashMap<>(); + private final ThreadLocal silentJoinPermission = new ThreadLocal<>(); public JoinMessageModule(DiscordSRV discordSRV) { super(discordSRV, "JOIN_MESSAGES"); @@ -58,7 +60,12 @@ public class JoinMessageModule extends AbstractGameMessageModule { + silentJoinPermission.set(silentJoin); + process(event, event.getPlayer(), event.getGameChannel()); + }); event.markAsProcessed(); } @@ -69,7 +76,7 @@ public class JoinMessageModule extends AbstractGameMessageModule { private final Map>> playersJoinedRecently = new ConcurrentHashMap<>(); + private final ThreadLocal silentQuitPermission = new ThreadLocal<>(); public LeaveMessageModule(DiscordSRV discordSRV) { super(discordSRV, "LEAVE_MESSAGES"); @@ -81,7 +83,12 @@ public class LeaveMessageModule extends AbstractGameMessageModule { + silentQuitPermission.set(silentQuit); + process(event, player, event.getGameChannel()); + }); event.markAsProcessed(); } @@ -93,7 +100,7 @@ public class LeaveMessageModule extends AbstractGameMessageModule> pair = playersJoinedRecently.remove(player.uniqueId()); + Pair> pair = playersJoinedRecently.get(player.uniqueId()); if (pair != null) { long delta = System.currentTimeMillis() - pair.getKey(); if (delta < config.leaveMessages.ignoreIfJoinedWithinMS) { @@ -103,7 +110,7 @@ public class LeaveMessageModule extends AbstractGameMessageModule process(event, event.getPlayer(), event.getGameChannel())); event.markAsProcessed(); } diff --git a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/ServerSwitchMessageModule.java b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/ServerSwitchMessageModule.java index 157ab8e8..28a15aab 100644 --- a/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/ServerSwitchMessageModule.java +++ b/common/src/main/java/com/discordsrv/common/feature/messageforwarding/game/ServerSwitchMessageModule.java @@ -46,7 +46,7 @@ public class ServerSwitchMessageModule extends AbstractGameMessageModule process(event, event.getPlayer(), null)); event.markAsProcessed(); }