mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Remove hide-muted-player-join-messages
This commit is contained in:
11 files changed
+22
-385
No files matched your search
-65
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.bukkit.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class BukkitPlayerDeathListener implements Listener {
|
||||
|
||||
private final CarbonChat carbonChat;
|
||||
private final ConfigFactory configFactory;
|
||||
|
||||
@Inject
|
||||
public BukkitPlayerDeathListener(final CarbonChat carbonChat, final ConfigFactory configFactory) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.configFactory = configFactory;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(final PlayerDeathEvent event) {
|
||||
// Early exit in case "hide muted join / leave messages when muted" is disabled
|
||||
if (!this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ComponentPlayerResult<CarbonPlayer> result = this.carbonChat.server().player(event.getEntity().getUniqueId()).join();
|
||||
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (player.muted()) {
|
||||
event.deathMessage(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+5
-42
@@ -21,78 +21,41 @@ package net.draycia.carbon.bukkit.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.bukkit.users.CarbonPlayerBukkit;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.util.PlayerUtils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class BukkitPlayerJoinListener implements Listener {
|
||||
|
||||
private final CarbonChat carbonChat;
|
||||
private final ConfigFactory configFactory;
|
||||
private final UserManager<CarbonPlayerCommon> userManager;
|
||||
|
||||
@Inject
|
||||
public BukkitPlayerJoinListener(
|
||||
final CarbonChat carbonChat,
|
||||
final ConfigFactory configFactory,
|
||||
final UserManager<CarbonPlayerCommon> userManager
|
||||
) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.configFactory = configFactory;
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't show join messages when muted
|
||||
if (player.muted()) {
|
||||
event.joinMessage(null);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onQuit(final PlayerQuitEvent event) {
|
||||
final ComponentPlayerResult<CarbonPlayer> result =
|
||||
this.carbonChat.server().player(event.getPlayer().getUniqueId()).join();
|
||||
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
if (player.muted()) {
|
||||
event.quitMessage(null);
|
||||
this.carbonChat.server().player(event.getPlayer().getUniqueId()).thenAccept(result -> {
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerBukkit) player);
|
||||
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerBukkit) result.player());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,9 +43,6 @@ public class PrimaryConfig {
|
||||
@Comment("The service that will be used to store and load player information.")
|
||||
private StorageType storageType = StorageType.JSON;
|
||||
|
||||
@Comment("Should we hide join/quit and death messages of muted players?")
|
||||
private boolean hideMutedJoinLeaveQuit = false;
|
||||
|
||||
@Comment("Various ClearChat command settings.")
|
||||
private ClearChatSettings clearChatSettings = new ClearChatSettings();
|
||||
|
||||
@@ -73,10 +70,6 @@ public class PrimaryConfig {
|
||||
return this.storageType;
|
||||
}
|
||||
|
||||
public boolean hideMutedJoinLeaveQuit() {
|
||||
return this.hideMutedJoinLeaveQuit;
|
||||
}
|
||||
|
||||
public ClearChatSettings clearChatSettings() {
|
||||
return this.clearChatSettings;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,6 @@ import net.draycia.carbon.common.util.PlayerUtils;
|
||||
import net.draycia.carbon.fabric.callback.ChatCallback;
|
||||
import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
|
||||
import net.draycia.carbon.fabric.listeners.FabricChatListener;
|
||||
import net.draycia.carbon.fabric.listeners.FabricPlayerDeathListener;
|
||||
import net.draycia.carbon.fabric.listeners.FabricPlayerJoinListener;
|
||||
import net.draycia.carbon.fabric.listeners.FabricPlayerLeaveListener;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
@@ -119,9 +117,7 @@ public final class CarbonChatFabric implements ModInitializer, CarbonChat {
|
||||
}
|
||||
|
||||
private void registerPlayerStatusListeners() {
|
||||
PlayerStatusMessageEvents.JOIN_MESSAGE.register(this.injector.getInstance(FabricPlayerJoinListener.class));
|
||||
PlayerStatusMessageEvents.QUIT_MESSAGE.register(this.injector.getInstance(FabricPlayerLeaveListener.class));
|
||||
PlayerStatusMessageEvents.DEATH_MESSAGE.register(this.injector.getInstance(FabricPlayerDeathListener.class));
|
||||
}
|
||||
|
||||
private void registerTickListeners() {
|
||||
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.fabric.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class FabricPlayerDeathListener implements PlayerStatusMessageEvents.MessageEventListener {
|
||||
|
||||
private final CarbonChat carbonChat;
|
||||
private final ConfigFactory configFactory;
|
||||
|
||||
@Inject
|
||||
public FabricPlayerDeathListener(final CarbonChat carbonChat, final ConfigFactory configFactory) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.configFactory = configFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(final PlayerStatusMessageEvents.MessageEvent event) {
|
||||
// Early exit in case "hide muted join / leave messages when muted" is disabled
|
||||
if (!this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ComponentPlayerResult<CarbonPlayer> result = this.carbonChat.server().player(event.player().getUUID()).join();
|
||||
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (player.muted()) {
|
||||
event.disableMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.fabric.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class FabricPlayerJoinListener implements PlayerStatusMessageEvents.MessageEventListener {
|
||||
|
||||
private final CarbonChat carbonChat;
|
||||
private final ConfigFactory configFactory;
|
||||
|
||||
@Inject
|
||||
public FabricPlayerJoinListener(final CarbonChat carbonChat, final ConfigFactory configFactory) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.configFactory = configFactory;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't show join messages when muted
|
||||
if (player.muted()) {
|
||||
event.disableMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+5
-20
@@ -21,10 +21,7 @@ package net.draycia.carbon.fabric.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.util.PlayerUtils;
|
||||
import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents;
|
||||
@@ -36,38 +33,26 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
public class FabricPlayerLeaveListener implements PlayerStatusMessageEvents.MessageEventListener {
|
||||
|
||||
private final CarbonChat carbonChat;
|
||||
private final ConfigFactory configFactory;
|
||||
private final UserManager<CarbonPlayerCommon> userManager;
|
||||
|
||||
@Inject
|
||||
public FabricPlayerLeaveListener(
|
||||
final CarbonChat carbonChat,
|
||||
final ConfigFactory configFactory,
|
||||
final UserManager<CarbonPlayerCommon> userManager
|
||||
) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.configFactory = configFactory;
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(final PlayerStatusMessageEvents.MessageEvent event) {
|
||||
final ComponentPlayerResult<CarbonPlayer> result =
|
||||
this.carbonChat.server().player(event.player().getUUID()).join();
|
||||
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
if (player.muted()) {
|
||||
event.disableMessage();
|
||||
this.carbonChat.server().player(event.player().getUUID()).thenAccept(result -> {
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerFabric) player);
|
||||
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerFabric) result.player());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,7 +40,6 @@ import net.draycia.carbon.common.util.CloudUtils;
|
||||
import net.draycia.carbon.common.util.ListenerUtils;
|
||||
import net.draycia.carbon.common.util.PlayerUtils;
|
||||
import net.draycia.carbon.sponge.listeners.SpongeChatListener;
|
||||
import net.draycia.carbon.sponge.listeners.SpongePlayerDeathListener;
|
||||
import net.draycia.carbon.sponge.listeners.SpongePlayerJoinListener;
|
||||
import net.draycia.carbon.sponge.listeners.SpongeReloadListener;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -64,7 +63,7 @@ import org.spongepowered.plugin.builtin.jvm.Plugin;
|
||||
public final class CarbonChatSponge implements CarbonChat {
|
||||
|
||||
private static final Set<Class<?>> LISTENER_CLASSES = Set.of(SpongeChatListener.class,
|
||||
SpongePlayerDeathListener.class, SpongePlayerJoinListener.class, SpongeReloadListener.class);
|
||||
SpongePlayerJoinListener.class, SpongeReloadListener.class);
|
||||
|
||||
private static final int BSTATS_PLUGIN_ID = 11279;
|
||||
|
||||
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2021 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.sponge.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.entity.DestructEntityEvent;
|
||||
import org.spongepowered.api.event.filter.cause.First;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class SpongePlayerDeathListener {
|
||||
|
||||
private final CarbonChat carbonChat;
|
||||
private final ConfigFactory configFactory;
|
||||
|
||||
@Inject
|
||||
public SpongePlayerDeathListener(final CarbonChat carbonChat, final ConfigFactory configFactory) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.configFactory = configFactory;
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onPlayerDeath(final DestructEntityEvent.Death event, final @First Player player) {
|
||||
// Early exit in case "hide muted join / leave messages when muted" is disabled
|
||||
if (!this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ComponentPlayerResult<CarbonPlayer> result = this.carbonChat.server().player(player.uniqueId()).join();
|
||||
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CarbonPlayer carbonPlayer = result.player();
|
||||
|
||||
if (carbonPlayer.muted()) {
|
||||
event.setMessageCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+5
-41
@@ -21,16 +21,11 @@ package net.draycia.carbon.sponge.listeners;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.util.PlayerUtils;
|
||||
import net.draycia.carbon.sponge.users.CarbonPlayerSponge;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.network.ServerSideConnectionEvent;
|
||||
@@ -39,57 +34,26 @@ import org.spongepowered.api.event.network.ServerSideConnectionEvent;
|
||||
public class SpongePlayerJoinListener {
|
||||
|
||||
private final CarbonChat carbonChat;
|
||||
private final ConfigFactory configFactory;
|
||||
private final UserManager<CarbonPlayerCommon> userManager;
|
||||
|
||||
@Inject
|
||||
public SpongePlayerJoinListener(
|
||||
final CarbonChat carbonChat,
|
||||
final ConfigFactory configFactory,
|
||||
final UserManager<CarbonPlayerCommon> userManager
|
||||
) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.configFactory = configFactory;
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't show join messages when muted
|
||||
if (player.muted()) {
|
||||
event.setMessageCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onPlayerQuit(final ServerSideConnectionEvent.Disconnect event) {
|
||||
final ComponentPlayerResult<CarbonPlayer> result =
|
||||
this.carbonChat.server().player(event.player().uniqueId()).join();
|
||||
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
if (this.configFactory.primaryConfig().hideMutedJoinLeaveQuit()) {
|
||||
if (player.muted()) {
|
||||
event.setAudience(Audience.empty());
|
||||
this.carbonChat.server().player(event.player().uniqueId()).thenAccept(result -> {
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerSponge) player);
|
||||
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerSponge) result.player());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+6
-11
@@ -23,8 +23,6 @@ import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.ComponentPlayerResult;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.util.PlayerUtils;
|
||||
@@ -49,16 +47,13 @@ public class VelocityPlayerJoinListener {
|
||||
|
||||
@Subscribe
|
||||
public void onPlayerLeave(final DisconnectEvent event) {
|
||||
final ComponentPlayerResult<CarbonPlayer> result =
|
||||
this.carbonChat.server().player(event.getPlayer().getUniqueId()).join();
|
||||
this.carbonChat.server().player(event.getPlayer().getUniqueId()).thenAccept(result -> {
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.player() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerVelocity) player);
|
||||
PlayerUtils.saveAndInvalidatePlayer(this.carbonChat.server(), this.userManager, (CarbonPlayerVelocity) result.player());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user