Compare commits

...

3 commits

Author SHA1 Message Date
grng
696e2b09aa /tc <message> doesnt work 2024-07-25 11:21:28 +01:00
grng
6dec52a317 /tc <message> doesnt work 2024-07-25 11:16:52 +01:00
grng
160677ff82 restyled team chat (buggy do not use) 2024-07-25 10:32:25 +01:00
5 changed files with 62 additions and 8 deletions

2
db.ps1 Normal file
View file

@ -0,0 +1,2 @@
docker-compose up
docker ps

8
docker-compose.yml Normal file
View file

@ -0,0 +1,8 @@
version: '3'
services:
civil_test_db:
environment:
- POSTGRES_PASSWORD=TEST123
image: postgres:16.3
ports:
- 5432:5432

View file

@ -13,7 +13,7 @@
<groupId>rip.iwakura</groupId>
<artifactId>CivilCore</artifactId>
<version>0.1a</version>
<version>0.1b</version>
<repositories>
<repository>

View file

@ -30,11 +30,11 @@ public class PlayerHandler implements Listener {
boolean inTeamChat = civilCore.teamChatRegister.contains(p);
DbPlayer dbPlayer = civilCore.db.getPlayerByName(player_name);
String prefix = (inTeamChat ? ChatColor.DARK_BLUE + "TC " + ChatColor.RESET : "")
String prefix = (inTeamChat ? ChatColor.DARK_GREEN + "TEAM >" + ChatColor.RESET : "")
+ (dbPlayer.team.prefix == null ?
"" :
ChatColor.translateAlternateColorCodes('&', "[" + dbPlayer.team.prefix + "]") + " ");
String message = String.format("%s%s: %s", prefix, player_name, e.getMessage());
ChatColor.translateAlternateColorCodes('&', inTeamChat ? "" : "[" + dbPlayer.team.prefix + "]"));
String message = String.format("%s %s: %s", prefix, player_name, e.getMessage());
if (!inTeamChat) {
Bukkit.broadcastMessage(message);

View file

@ -10,7 +10,9 @@ 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 java.util.List;
import java.util.Objects;
public class TeamChatCommand implements CommandExecutor {
@ -20,6 +22,14 @@ public class TeamChatCommand implements CommandExecutor {
this.civilCore = civilCore;
}
private String getPrefix(String name, boolean inTeamChat) {
DbPlayer dbPlayer = civilCore.db.getPlayerByName(name);
return (inTeamChat ? ChatColor.DARK_GREEN + "TEAM >" + ChatColor.RESET : "")
+ (dbPlayer.team.prefix == null ?
"" :
ChatColor.translateAlternateColorCodes('&', inTeamChat ? "" : "[" + dbPlayer.team.prefix + "]"));
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
args = Objects.requireNonNull(Utils.parser(args)).toArray(new String[0]);
@ -37,18 +47,52 @@ public class TeamChatCommand implements CommandExecutor {
}
String message = String.join(" ", args);
if (civilCore.teamChatRegister.contains(p)) {
String player_name = p.getName();
boolean inTeamChat = civilCore.teamChatRegister.contains(p);
DbPlayer dbPlayer = civilCore.db.getPlayerByName(player_name);
/*String prefix = (inTeamChat ? ChatColor.DARK_GREEN + "TEAM >" + ChatColor.RESET : "")
+ (dbPlayer.team.prefix == null ?
"" :
ChatColor.translateAlternateColorCodes('&', inTeamChat ? "" : "[" + dbPlayer.team.prefix + "]"));*/
/*if (civilCore.teamChatRegister.contains(p)) {
civilCore.teamChatRegister.remove(p);
Bukkit.broadcastMessage(ChatColor.DARK_GREEN + "TEAM > " + ChatColor.GREEN + p.getName() + ": " + message);
// Bukkit.broadcastMessage(ChatColor.DARK_GREEN + "TEAM > " + ChatColor.GREEN + p.getName() + ": " + message);
String formatted = String.format("%s%s: %s", getPrefix(player_name, inTeamChat) + " ", player_name, message);
Bukkit.broadcastMessage(formatted);
civilCore.teamChatRegister.add(p);
} else {
civilCore.teamChatRegister.add(p);
Bukkit.broadcastMessage(p.getName() + ": " + message);
String formatted = String.format("%s%s: %s", getPrefix(player_name, inTeamChat) + " ", player_name, message);
Bukkit.broadcastMessage(formatted);
civilCore.teamChatRegister.remove(p);
}*/
if (!inTeamChat) {
civilCore.teamChatRegister.remove(p);
String formatted = String.format("%s%s: %s", getPrefix(player_name, inTeamChat) + " ", player_name, message);
Bukkit.broadcastMessage(formatted);
civilCore.teamChatRegister.add(p);
} else {
civilCore.teamChatRegister.add(p);
String formatted = String.format("%s%s: %s", getPrefix(player_name, inTeamChat) + " ", player_name, message);
List<DbPlayer> players = civilCore.db.getPlayersInTeam(dbPlayer.team.name);
if (players == null) return true;
for (DbPlayer team_dbp : players) {
Player team_p = Bukkit.getPlayer(team_dbp.name);
if (team_p == null) continue;
team_p.sendMessage(message);
}
civilCore.teamChatRegister.remove(p);
}
return true;
}
}