This commit is contained in:
Trixkz 2021-11-23 08:37:03 -05:00
commit fb7c67b4ce

View File

@ -7,6 +7,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.managers.party.Party;
import rip.tilly.bedwars.playerdata.PlayerData;
import rip.tilly.bedwars.playerdata.PlayerSettings;
import rip.tilly.bedwars.utils.CC;
public class PartyChatListener implements Listener {
@ -18,17 +19,23 @@ public class PartyChatListener implements Listener {
Player player = event.getPlayer();
Party party = this.plugin.getPartyManager().getParty(player.getUniqueId());
PlayerData playerData = this.plugin.getPlayerDataManager().getPlayerData(player.getUniqueId());
PlayerSettings settings = playerData.getPlayerSettings();
if (party == null && !settings.isPartyChatEnabled()) {
return;
}
String chatMessage = event.getMessage();
if (party != null) {
if (playerData.getPlayerSettings().isPartyChatEnabled()) {
if (settings.isPartyChatEnabled()) {
event.setCancelled(true);
String message = CC.translate("&9Party > &d" + player.getDisplayName() + "&f: " + chatMessage);
party.broadcast(message);
}
} else if (playerData.getPlayerSettings().isPartyChatEnabled()) {
} else if (settings.isPartyChatEnabled()) {
event.setCancelled(true);
player.sendMessage(CC.translate("&cSince you are not in a party we toggled your party chat to false!"));
playerData.getPlayerSettings().setPartyChatEnabled(!playerData.getPlayerSettings().isPartyChatEnabled());
settings.setPartyChatEnabled(!settings.isPartyChatEnabled());
}
}
}