done (untested code)

This commit is contained in:
grng 2024-07-25 00:41:36 +01:00
parent 08cfd82d09
commit d10e195b35
2 changed files with 10 additions and 32 deletions

View file

@ -15,7 +15,7 @@ import rip.iwakura.civilcore.types.DbPlayer;
public class PlayerHandler implements Listener {
private CivilCore civilCore = null;
private final CivilCore civilCore;
public PlayerHandler(CivilCore civilCore) {
this.civilCore = civilCore;
@ -33,7 +33,7 @@ public class PlayerHandler implements Listener {
String prefix = (inTeamChat ? ChatColor.DARK_BLUE + "TC " + ChatColor.RESET : "")
+ (dbPlayer.team.prefix == null ?
"" :
ChatColor.translateAlternateColorCodes('&', dbPlayer.team.prefix) + " ");
ChatColor.translateAlternateColorCodes('&', "[" + dbPlayer.team.prefix + "]") + " ");
String message = String.format("%s%s: %s", prefix, player_name, e.getMessage());
if (!inTeamChat) {

View file

@ -1,61 +1,39 @@
package rip.iwakura.civilcore.commands;
import java.sql.SQLException;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerEvent;
import net.md_5.bungee.api.ChatColor;
import org.jetbrains.annotations.NotNull;
import rip.iwakura.civilcore.Utils;
import rip.iwakura.civilcore.CivilCore;
import rip.iwakura.civilcore.types.DbPlayer;
import rip.iwakura.civilcore.types.Team;
import java.util.Objects;
public class TeamChatCommand implements CommandExecutor {
private CivilCore civilCore = null;
private final CivilCore civilCore;
public TeamChatCommand(CivilCore civilCore) {
this.civilCore = civilCore;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
args = Utils.parser(args).toArray(new String[0]);
if (!(sender instanceof Player)) return true;
Player p = (Player) sender;
/*if (civilCore.teamChatRegister.contains(p)) {
civilCore.teamChatRegister.remove(p);
p.sendMessage(ChatColor.GREEN + "You are now in the " + ChatColor.GOLD + "GLOBAL" + ChatColor.GREEN + " channel");
return true;
}
if (civilCore.db.getPlayerByName(p.getName()).team.name == null) {
p.sendMessage(ChatColor.RED + "You aren't in a team :(");
return true;
}
civilCore.teamChatRegister.add(p);
p.sendMessage(ChatColor.GREEN + "You are now in the " + ChatColor.GOLD + "TEAM" + ChatColor.GREEN + " channel");*/
// /c [msg] -> if team chat toggled: broadcast to global chat, if global chat toggled send to team
// /tc or /c -> switch between global chat & team chat
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
args = Objects.requireNonNull(Utils.parser(args)).toArray(new String[0]);
if (!(sender instanceof Player p)) return true;
if (args.length == 0) {
if (civilCore.teamChatRegister.contains(p)) {
civilCore.teamChatRegister.remove(p);
p.sendMessage(ChatColor.GREEN + "You are now in the " + ChatColor.GOLD + "GLOBAL" + ChatColor.GREEN + " channel");
return true;
} else {
civilCore.teamChatRegister.add(p);
p.sendMessage(ChatColor.GREEN + "You are now in the " + ChatColor.GOLD + "TEAM" + ChatColor.GREEN + " channel");
return true;
}
return true;
}
String message = String.join(" ", args);