Team Color #164
@ -20,6 +20,9 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||
import de.steamwar.bungeecore.schematic.SchemGUI;
|
||||
import de.steamwar.bungeecore.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
@ -40,6 +43,27 @@ import static de.steamwar.bungeecore.Storage.teamInvitations;
|
||||
|
||||
public class TeamCommand extends BasicCommand {
|
||||
|
||||
private static final List<SWListInv.SWListEntry<String>> COLOR_CODES = new ArrayList<>();
|
||||
|
||||
static {
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§4", 1), "4"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("brick", "§c"), "c"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§6", 14), "6"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§e", 11), "e"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§2", 2), "2"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§a", 10), "a"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§b", 12), "b"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§3", 6), "3"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§1", 4), "1"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§9", 6), "9"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§d", 9), "d"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§5", 13), "5"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§f", 15), "f"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§7", 7), "7"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§8", 8), "8"));
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§0", 0), "0"));
|
||||
}
|
||||
|
||||
public TeamCommand() {
|
||||
|
||||
super("team", "");
|
||||
}
|
||||
@ -67,6 +91,7 @@ public class TeamCommand extends BasicCommand {
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eteam remove §8- §7Entferne jemanden aus deinem Team");
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eteam changekuerzel §8- §7Ändere dein Teamkürzel");
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eteam changename §8- §7Ändere deinen Teamnamen");
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eteam changecolor §8- §7Ändere deine Teamfarbe");
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eteam changeleader §8- §7Ernenne jemanden zum Teamleader");
|
||||
}
|
||||
}
|
||||
@ -111,6 +136,9 @@ public class TeamCommand extends BasicCommand {
|
||||
case "changeleader":
|
||||
changeleader(player, user, team, args);
|
||||
break;
|
||||
case "changecolor":
|
||||
changeColor(player, user, team);
|
||||
break;
|
||||
case "info":
|
||||
info(player, user, team, args);
|
||||
break;
|
||||
@ -490,6 +518,23 @@ public class TeamCommand extends BasicCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void changeColor(ProxiedPlayer player, SteamwarUser user, Team team) {
|
||||
if(notLeader(player, user, team))
|
||||
return;
|
||||
|
||||
if(notDuringEvent(player))
|
||||
return;
|
||||
|
||||
List<SWListInv.SWListEntry<String>> colors = new ArrayList<>();
|
||||
COLOR_CODES.forEach(stringSWListEntry -> colors.add(new SWListInv.SWListEntry<>(stringSWListEntry.getItem().setName(stringSWListEntry.getItem().getTitle() + Team.get(user.getTeam()).getTeamKuerzel()), stringSWListEntry.getObject())));
|
||||
|
||||
SWListInv<String> inv = new SWListInv<>(player, "§6Farbe wählen", colors, (click, element) -> {
|
||||
SchemGUI.closeInventory(player);
|
||||
team.setTeamColor(element);
|
||||
});
|
||||
inv.open();
|
||||
Lixfel
hat
Nutze Inventory.close() (also inv.close()); Nutze Inventory.close() (also inv.close());
Chaoscaot
hat
Variable 'inv' might not have been initialized. Variable 'inv' might not have been initialized.
Lixfel
hat
Dann musst du den Callback evtl. nach der Initialisierung setzen. Dann musst du den Callback evtl. nach der Initialisierung setzen.
|
||||
}
|
||||
|
||||
private boolean checkTeamName(ProxiedPlayer player, Team team, String arg){
|
||||
if(arg.length() < 4 || arg.length() > 15){
|
||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEin Teamname muss aus 4 bis 15 Buchstaben bestehen");
|
||||
@ -566,6 +611,7 @@ public class TeamCommand extends BasicCommand {
|
||||
tab.add("changekuerzel");
|
||||
tab.add("changename");
|
||||
tab.add("changeleader");
|
||||
tab.add("changecolor");
|
||||
}else if(args.length == 2){
|
||||
if(args[1].equalsIgnoreCase("event")){
|
||||
List<Event> coming = Event.getComing();
|
||||
|
@ -97,8 +97,13 @@ public class SWItem {
|
||||
this.hideAttributes = hideAttributes;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public SWItem setName(String name) {
|
||||
title = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void addLore(String lore) {
|
||||
|
@ -166,7 +166,7 @@ public class ChatListener extends BasicListener {
|
||||
|
||||
String msg = name + "§7»" + chatcolor + " " + message;
|
||||
if(user.getTeam() != 0){
|
||||
msg = "§8" + Team.get(user.getTeam()).getTeamKuerzel() + " §r" + msg;
|
||||
msg = "§" + Team.get(user.getTeam()).getTeamColor() + Team.get(user.getTeam()).getTeamKuerzel() + " §r" + msg;
|
||||
Lixfel
hat
Bitte nur einmal Team.get() machen. Bitte nur einmal Team.get() machen.
|
||||
}
|
||||
|
||||
String[] msgSplits = msg.split(" ");
|
||||
|
@ -34,22 +34,24 @@ public class Team {
|
||||
private String teamKuerzel;
|
||||
private String teamName;
|
||||
private int teamLeader;
|
||||
private String teamColor;
|
||||
|
||||
private static final List<Team> teamCache = new LinkedList<>();
|
||||
private static final Team pub = new Team(0, "PUB", "Öffentlich", 0);
|
||||
private static final Team pub = new Team(0, "PUB", "Öffentlich", 0, "&7");
|
||||
Lixfel
hat
Das & wird Fehler verursachen Das & wird Fehler verursachen
|
||||
|
||||
private Team(int id, String kuerzel, String name, int leader){
|
||||
private Team(int id, String kuerzel, String name, int leader, String color){
|
||||
teamId = id;
|
||||
teamKuerzel = kuerzel;
|
||||
teamName = name;
|
||||
teamLeader = leader;
|
||||
teamColor = color;
|
||||
if (id != 0) {
|
||||
teamCache.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
private Team(ResultSet rs) throws SQLException {
|
||||
this(rs.getInt("TeamID"), rs.getString("TeamKuerzel"), rs.getString("TeamName"), rs.getInt("TeamLeader"));
|
||||
this(rs.getInt("TeamID"), rs.getString("TeamKuerzel"), rs.getString("TeamName"), rs.getInt("TeamLeader"), rs.getString("TeamColor"));
|
||||
}
|
||||
|
||||
public static void create(String kuerzel, String name, int leader){
|
||||
@ -58,7 +60,7 @@ public class Team {
|
||||
|
||||
public static Team get(int id){
|
||||
if(id == -1)
|
||||
return new Team(-1, "?", "?", 0);
|
||||
return new Team(-1, "?", "?", 0, "8");
|
||||
if(id == 0)
|
||||
return pub;
|
||||
for(Team team : teamCache)
|
||||
@ -108,7 +110,7 @@ public class Team {
|
||||
}
|
||||
|
||||
private void updateDB(){
|
||||
SQL.update("INSERT INTO Team (TeamID, TeamKuerzel, TeamName, TeamLeader) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE TeamName = VALUES(TeamName), TeamKuerzel = VALUES(TeamKuerzel), TeamLeader = VALUES(TeamLeader)", teamId, teamKuerzel, teamName, teamLeader);
|
||||
SQL.update("INSERT INTO Team (TeamID, TeamKuerzel, TeamName, TeamLeader, TeamColor) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE TeamName = VALUES(TeamName), TeamKuerzel = VALUES(TeamKuerzel), TeamLeader = VALUES(TeamLeader), TeamColor = VALUES(TeamColor)", teamId, teamKuerzel, teamName, teamLeader, teamColor);
|
||||
}
|
||||
|
||||
public int getTeamId() {
|
||||
@ -142,6 +144,14 @@ public class Team {
|
||||
updateDB();
|
||||
}
|
||||
|
||||
public String getTeamColor() {
|
||||
return teamColor;
|
||||
}
|
||||
|
||||
public void setTeamColor(String teamColor) {
|
||||
this.teamColor = teamColor;
|
||||
Lixfel
hat
Ich glaube, nach dem Set muss da updateDB() aufgerufen werden. Ich glaube, nach dem Set muss da updateDB() aufgerufen werden.
|
||||
}
|
||||
|
||||
public int size(){
|
||||
ResultSet rs = select("SELECT COUNT(id) FROM UserData WHERE Team = ?", teamId);
|
||||
try {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Welcher Block soll da wie eingefärbt werden?
Das sind die Color Codes auf die Farbstoff Items aus dem SpigotCore