mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Always early exit in join listeners
This commit is contained in:
3 files changed
+15
-3
No files matched your search
+5
-1
@@ -57,6 +57,10 @@ public class BukkitPlayerJoinListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void handleJoinMessages(final PlayerJoinEvent event) {
|
||||
if (!this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ComponentPlayerResult<CarbonPlayer> result =
|
||||
this.carbonChat.server().player(event.getPlayer().getUniqueId()).join();
|
||||
final @Nullable CarbonPlayer player = result.player();
|
||||
@@ -66,7 +70,7 @@ public class BukkitPlayerJoinListener implements Listener {
|
||||
}
|
||||
|
||||
// Don't show join messages when muted
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit() && player.muted()) {
|
||||
if (player.muted()) {
|
||||
event.joinMessage(null);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -43,6 +43,10 @@ public class FabricPlayerJoinListener implements PlayerStatusMessageEvents.Messa
|
||||
|
||||
@Override
|
||||
public void onMessage(final PlayerStatusMessageEvents.MessageEvent event) {
|
||||
if (!this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ComponentPlayerResult<CarbonPlayer> result =
|
||||
this.carbonChat.server().player(event.player().getUUID()).join();
|
||||
final @Nullable CarbonPlayer player = result.player();
|
||||
@@ -52,7 +56,7 @@ public class FabricPlayerJoinListener implements PlayerStatusMessageEvents.Messa
|
||||
}
|
||||
|
||||
// Don't show join messages when muted
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit() && player.muted()) {
|
||||
if (player.muted()) {
|
||||
event.disableMessage();
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -55,6 +55,10 @@ public class SpongePlayerJoinListener {
|
||||
|
||||
@Listener
|
||||
public void onPlayerLogin(final ServerSideConnectionEvent.Join event) {
|
||||
if (!this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ComponentPlayerResult<CarbonPlayer> result = this.carbonChat.server().player(event.player().uniqueId()).join();
|
||||
final @Nullable CarbonPlayer player = result.player();
|
||||
|
||||
@@ -63,7 +67,7 @@ public class SpongePlayerJoinListener {
|
||||
}
|
||||
|
||||
// Don't show join messages when muted
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit() && player.muted()) {
|
||||
if (player.muted()) {
|
||||
event.setMessageCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user