From 7d67c7615b13880fcf472b8858cc040186599b25 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 28 Dec 2020 17:33:24 +0100 Subject: [PATCH 01/13] Add Teamcolor --- .../bungeecore/commands/TeamCommand.java | 46 +++++++++++++++++++ .../steamwar/bungeecore/inventory/SWItem.java | 7 ++- .../bungeecore/listeners/ChatListener.java | 2 +- src/de/steamwar/bungeecore/sql/Team.java | 20 ++++++-- 4 files changed, 68 insertions(+), 7 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 601bd58..fa16480 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -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> 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> 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 inv = new SWListInv<>(player, "§6Farbe wählen", colors, (click, element) -> { + SchemGUI.closeInventory(player); + team.setTeamColor(element); + }); + inv.open(); + } + 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 coming = Event.getComing(); diff --git a/src/de/steamwar/bungeecore/inventory/SWItem.java b/src/de/steamwar/bungeecore/inventory/SWItem.java index 41f6ea1..2e9d80c 100644 --- a/src/de/steamwar/bungeecore/inventory/SWItem.java +++ b/src/de/steamwar/bungeecore/inventory/SWItem.java @@ -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) { diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 0ee6265..96a06e8 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -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; } String[] msgSplits = msg.split(" "); diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index d2416cc..2e7ba35 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -34,22 +34,24 @@ public class Team { private String teamKuerzel; private String teamName; private int teamLeader; + private String teamColor; private static final List 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"); - 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; + } + public int size(){ ResultSet rs = select("SELECT COUNT(id) FROM UserData WHERE Team = ?", teamId); try { From d86122a278ee25a360f4180b209edbf539ea4c26 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 28 Dec 2020 17:37:38 +0100 Subject: [PATCH 02/13] Fixing old Dependencies --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 5 +++-- src/de/steamwar/bungeecore/inventory/SWListInv.java | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index fa16480..aa72487 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -20,9 +20,10 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.comms.packets.CloseInventoryPacket; +import de.steamwar.bungeecore.inventory.SWInventory; 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; @@ -529,7 +530,7 @@ public class TeamCommand extends BasicCommand { COLOR_CODES.forEach(stringSWListEntry -> colors.add(new SWListInv.SWListEntry<>(stringSWListEntry.getItem().setName(stringSWListEntry.getItem().getTitle() + Team.get(user.getTeam()).getTeamKuerzel()), stringSWListEntry.getObject()))); SWListInv inv = new SWListInv<>(player, "§6Farbe wählen", colors, (click, element) -> { - SchemGUI.closeInventory(player); + SWListInv.closeInventory(player); team.setTeamColor(element); }); inv.open(); diff --git a/src/de/steamwar/bungeecore/inventory/SWListInv.java b/src/de/steamwar/bungeecore/inventory/SWListInv.java index bd43730..e10925c 100644 --- a/src/de/steamwar/bungeecore/inventory/SWListInv.java +++ b/src/de/steamwar/bungeecore/inventory/SWListInv.java @@ -19,8 +19,10 @@ package de.steamwar.bungeecore.inventory; +import de.steamwar.bungeecore.comms.packets.CloseInventoryPacket; import de.steamwar.bungeecore.sql.Schematic; import de.steamwar.bungeecore.sql.SchematicType; +import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -142,4 +144,8 @@ public class SWListInv extends SWInventory { return object; } } + + public static void closeInventory(ProxiedPlayer player) { + new CloseInventoryPacket(SteamwarUser.get(player).getId()).send(player); + } } From 14479271cde3a280dbb853de9d33c04998223750 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 28 Dec 2020 17:38:26 +0100 Subject: [PATCH 03/13] Optimize Imports --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index aa72487..e652d8d 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -20,8 +20,6 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.comms.packets.CloseInventoryPacket; -import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.inventory.SWListInv; import de.steamwar.bungeecore.sql.Event; From 065ab72625483e7690cc32bb2740b3e1419c0c48 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 28 Dec 2020 17:54:24 +0100 Subject: [PATCH 04/13] Improve Color List --- .../bungeecore/commands/TeamCommand.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index e652d8d..f1e2fda 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -45,22 +45,26 @@ public class TeamCommand extends BasicCommand { private static final List> 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")); + addColor("4", 1); + addColor("c", 15); + addColor("6", 14); + addColor("e", 11); + addColor("2", 2); + addColor("a", 10); + addColor("b", 12); + addColor("3", 6); + addColor("1", 4); + addColor("9", 6); + addColor("d", 9); + addColor("5", 5); + addColor("f", 15); + addColor("7", 7); + addColor("8", 8); + addColor("0", 0); + } + + private static void addColor(String color, int colorCode) { + COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§" + color, colorCode), color)); } public TeamCommand() { From a2169ec3e181b613d107b9d249cae4d4c469d763 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 28 Dec 2020 19:16:51 +0100 Subject: [PATCH 05/13] Fixing --- src/de/steamwar/bungeecore/commands/EventCommand.java | 4 ++-- src/de/steamwar/bungeecore/commands/TeamCommand.java | 9 +++++---- src/de/steamwar/bungeecore/inventory/SWListInv.java | 4 ---- src/de/steamwar/bungeecore/sql/Team.java | 1 + 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/EventCommand.java b/src/de/steamwar/bungeecore/commands/EventCommand.java index 4a93cc1..6e4b8e5 100644 --- a/src/de/steamwar/bungeecore/commands/EventCommand.java +++ b/src/de/steamwar/bungeecore/commands/EventCommand.java @@ -91,9 +91,9 @@ public class EventCommand extends BasicCommand { e.getEventName()); Set teams = TeamTeilnahme.getTeams(e.getEventID()); if(!teams.isEmpty()){ - StringBuilder tline = new StringBuilder("§7 Mit§8: §e"); + StringBuilder tline = new StringBuilder("§7 Mit§8: "); for(Team t : teams){ - tline.append(t.getTeamKuerzel()).append(" "); + tline.append("§").append(t.getTeamColor()).append(t.getTeamKuerzel()).append(" "); } BungeeCore.send(player, tline.toString()); } diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index f1e2fda..9b25543 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -402,7 +402,7 @@ public class TeamCommand extends BasicCommand { return; } - BungeeCore.send(player, "§7Team §e" + team.getTeamName() + " §8[§e" + team.getTeamKuerzel() + "§8]"); + BungeeCore.send(player, "§7Team §e" + team.getTeamName() + " §8[§" + team.getTeamColor() + team.getTeamKuerzel() + "§8]"); BungeeCore.send(player, "§7Leader§8: " + SteamwarUser.get(team.getTeamLeader()).getUserName()); if(team.getMembers().size() > 1) { @@ -454,7 +454,7 @@ public class TeamCommand extends BasicCommand { for(int i = (page-1) * TEAMS_PER_PAGE; i < (page-1) * TEAMS_PER_PAGE + TEAMS_PER_PAGE && i < all.size(); i++){ Team tm = all.get(i); BungeeCore.send(player, - "§8" + tm.getTeamKuerzel() + " §e" + tm.getTeamName() + " §8[§7" + SteamwarUser.get(tm.getTeamLeader()).getUserName() + "§8]", + "§" + tm.getTeamColor() + tm.getTeamKuerzel() + " §e" + tm.getTeamName() + " §8[§7" + SteamwarUser.get(tm.getTeamLeader()).getUserName() + "§8]", "§7Teaminfo", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + tm.getTeamKuerzel())); } @@ -531,8 +531,9 @@ public class TeamCommand extends BasicCommand { List> 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 inv = new SWListInv<>(player, "§6Farbe wählen", colors, (click, element) -> { - SWListInv.closeInventory(player); + SWListInv inv = new SWListInv<>(player, "§6Farbe wählen", colors, (click, element) -> {}); + inv.setCallback((click, element) -> { + inv.close(); team.setTeamColor(element); }); inv.open(); diff --git a/src/de/steamwar/bungeecore/inventory/SWListInv.java b/src/de/steamwar/bungeecore/inventory/SWListInv.java index e10925c..d12c432 100644 --- a/src/de/steamwar/bungeecore/inventory/SWListInv.java +++ b/src/de/steamwar/bungeecore/inventory/SWListInv.java @@ -144,8 +144,4 @@ public class SWListInv extends SWInventory { return object; } } - - public static void closeInventory(ProxiedPlayer player) { - new CloseInventoryPacket(SteamwarUser.get(player).getId()).send(player); - } } diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index 2e7ba35..8ca7124 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -150,6 +150,7 @@ public class Team { public void setTeamColor(String teamColor) { this.teamColor = teamColor; + updateDB(); } public int size(){ From 69e8a4e24f4a3547dc9ebbbad3ebf37628dcfc85 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 29 Dec 2020 01:38:47 +0100 Subject: [PATCH 06/13] Using more of Color --- src/de/steamwar/bungeecore/EventStarter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/EventStarter.java b/src/de/steamwar/bungeecore/EventStarter.java index 9cb1eaf..5271ecc 100644 --- a/src/de/steamwar/bungeecore/EventStarter.java +++ b/src/de/steamwar/bungeecore/EventStarter.java @@ -73,7 +73,7 @@ public class EventStarter implements Runnable { eventServer.put(blue.getTeamId(), subserver); eventServer.put(red.getTeamId(), subserver); - BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7Hier §eklicken §7für den Kampf §e" + blue.getTeamName() + " §8vs §e" + red.getTeamName(), + BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7Hier §eklicken §7für den Kampf §" + blue.getTeamColor() + blue.getTeamName() + " §8vs §" + red.getTeamColor() + red.getTeamName(), "§eEvent beitreten", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/event " + blue.getTeamKuerzel())); } From 4d752e033cf95a9a4f0019f34789fab491365009 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 29 Dec 2020 14:47:58 +0100 Subject: [PATCH 07/13] Fixing --- src/de/steamwar/bungeecore/listeners/ChatListener.java | 3 ++- src/de/steamwar/bungeecore/sql/Team.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 96a06e8..878ea45 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -166,7 +166,8 @@ public class ChatListener extends BasicListener { String msg = name + "§7»" + chatcolor + " " + message; if(user.getTeam() != 0){ - msg = "§" + Team.get(user.getTeam()).getTeamColor() + Team.get(user.getTeam()).getTeamKuerzel() + " §r" + msg; + Team team = Team.get(user.getTeam()); + msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg; } String[] msgSplits = msg.split(" "); diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index 8ca7124..1285547 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -37,7 +37,7 @@ public class Team { private String teamColor; private static final List teamCache = new LinkedList<>(); - private static final Team pub = new Team(0, "PUB", "Öffentlich", 0, "&7"); + private static final Team pub = new Team(0, "PUB", "Öffentlich", 0, "8"); private Team(int id, String kuerzel, String name, int leader, String color){ teamId = id; From 8128d440112d5d5ab99e35b132811d02c7d8687f Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 30 Dec 2020 17:12:28 +0100 Subject: [PATCH 08/13] Imports... --- src/de/steamwar/bungeecore/inventory/SWListInv.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/inventory/SWListInv.java b/src/de/steamwar/bungeecore/inventory/SWListInv.java index d12c432..bd43730 100644 --- a/src/de/steamwar/bungeecore/inventory/SWListInv.java +++ b/src/de/steamwar/bungeecore/inventory/SWListInv.java @@ -19,10 +19,8 @@ package de.steamwar.bungeecore.inventory; -import de.steamwar.bungeecore.comms.packets.CloseInventoryPacket; import de.steamwar.bungeecore.sql.Schematic; import de.steamwar.bungeecore.sql.SchematicType; -import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.connection.ProxiedPlayer; From 0ef5f6dcb9418978b7202becab54c99c22fe82aa Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 1 Jan 2021 02:15:12 +0100 Subject: [PATCH 09/13] Fixing Stuff... --- .../steamwar/bungeecore/commands/TeamCommand.java | 6 +++++- src/de/steamwar/bungeecore/inventory/SWItem.java | 14 ++++++++++++++ .../steamwar/bungeecore/inventory/SWListInv.java | 1 - 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 9b25543..51b33d0 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -529,7 +529,11 @@ public class TeamCommand extends BasicCommand { return; List> 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()))); + COLOR_CODES.forEach(stringSWListEntry -> { + SWItem item = stringSWListEntry.getItem().clone(); + item.setName(stringSWListEntry.getItem().getTitle() + Team.get(user.getTeam()).getTeamKuerzel()); + colors.add(new SWListInv.SWListEntry<>(item, stringSWListEntry.getObject())); + }); SWListInv inv = new SWListInv<>(player, "§6Farbe wählen", colors, (click, element) -> {}); inv.setCallback((click, element) -> { diff --git a/src/de/steamwar/bungeecore/inventory/SWItem.java b/src/de/steamwar/bungeecore/inventory/SWItem.java index 2e9d80c..f5a4476 100644 --- a/src/de/steamwar/bungeecore/inventory/SWItem.java +++ b/src/de/steamwar/bungeecore/inventory/SWItem.java @@ -156,4 +156,18 @@ public class SWItem { public void setLore(List lore) { this.lore = lore; } + + public SWItem clone() { + SWItem item; + if(color != 0) { + item = new SWItem(title, color); + }else { + item = new SWItem(material, title); + } + item.setLore(lore); + item.setCallback(callback); + item.setEnchanted(enchanted); + item.setHideAttributes(hideAttributes); + return item; + } } diff --git a/src/de/steamwar/bungeecore/inventory/SWListInv.java b/src/de/steamwar/bungeecore/inventory/SWListInv.java index bd43730..1161260 100644 --- a/src/de/steamwar/bungeecore/inventory/SWListInv.java +++ b/src/de/steamwar/bungeecore/inventory/SWListInv.java @@ -40,7 +40,6 @@ public class SWListInv extends SWInventory { @Override public void open(){ - setCallback(-999, (InvCallback.ClickType click) -> close()); if(elements.size() > 54){ if(page != 0) addItem(45, new SWItem("§eSeite zurück", 10), (InvCallback.ClickType click) -> { From e0d158b152345baa014433f348fc33fd84b03d9e Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 1 Jan 2021 13:30:13 +0100 Subject: [PATCH 10/13] Fix Color --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 51b33d0..f9cb50e 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -60,7 +60,7 @@ public class TeamCommand extends BasicCommand { addColor("f", 15); addColor("7", 7); addColor("8", 8); - addColor("0", 0); + addColor("0", 16); } private static void addColor(String color, int colorCode) { From 076a7d9bf2a32a4b09970234853838270bbb42a0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 2 Jan 2021 17:23:37 +0100 Subject: [PATCH 11/13] Work around new forge mod loader Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Message.java | 4 +-- .../listeners/mods/ModLoaderBlocker.java | 35 ++++++++++++++----- .../steamwar/messages/BungeeCore.properties | 4 +++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java index 1e5e0c0..65f1dec 100644 --- a/src/de/steamwar/bungeecore/Message.java +++ b/src/de/steamwar/bungeecore/Message.java @@ -48,10 +48,10 @@ public class Message { } private static String parse(String message, boolean prefixed, CommandSender sender,Object... params){ - Locale locale; + Locale locale = null; if(sender instanceof ProxiedPlayer) locale = ((ProxiedPlayer)sender).getLocale(); - else + if(locale == null) locale = Locale.getDefault(); ResourceBundle resourceBundle = ResourceBundle.getBundle("de.steamwar.messages.BungeeCore", locale); diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java index af123d8..11e8d87 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java +++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java @@ -19,10 +19,7 @@ package de.steamwar.bungeecore.listeners.mods; -import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.Servertype; -import de.steamwar.bungeecore.Storage; -import de.steamwar.bungeecore.Subserver; +import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.listeners.BasicListener; import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -31,6 +28,8 @@ import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.ServerSwitchEvent; import net.md_5.bungee.event.EventHandler; +import java.nio.charset.StandardCharsets; + public class ModLoaderBlocker extends BasicListener { @EventHandler @@ -45,17 +44,37 @@ public class ModLoaderBlocker extends BasicListener { if(new String(e.getData()).contains("fabric")){ ProxiedPlayer p = (ProxiedPlayer) sender; Storage.fabricPlayers.add(p); - BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du hast Fabric installiert. Mit Fabric kannst du nicht auf die Arenen"); + Message.send("MODLOADER_INSTALLED", p, "Fabric"); }else if(new String(e.getData()).contains("LiteLoader")) { ProxiedPlayer p = (ProxiedPlayer) sender; Storage.fabricPlayers.add(p); - BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du hast LiteLoader installiert. Mit LiteLoader kannst du nicht auf die Arenen"); + Message.send("MODLOADER_INSTALLED", p, "LiteLoader"); + } + } + + @EventHandler + public void onPluginMessage(PluginMessageEvent e){ + if(!e.getTag().equals("minecraft:register")) + return; + + Connection sender = e.getSender(); + if(!(sender instanceof ProxiedPlayer)) + return; + ProxiedPlayer p = (ProxiedPlayer) sender; + + if(p.getPendingConnection().getVersion() <= 340) + return; + + String registered = new String(e.getData(), StandardCharsets.UTF_8); + if(registered.contains("fml:loginwrapper") || registered.contains("fml:handshake") || registered.contains("fml:play")){ + Storage.fabricPlayers.add(p); + Message.send("MODLOADER_INSTALLED", p, "Forge"); } } @EventHandler public void onDisconnect(PlayerDisconnectEvent e){ - Storage.fabricPlayers.removeIf(player -> player == e.getPlayer()); + Storage.fabricPlayers.remove(e.getPlayer()); } @EventHandler @@ -64,7 +83,7 @@ public class ModLoaderBlocker extends BasicListener { && Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA && isFabric(event.getPlayer())) { event.getPlayer().connect(BungeeCore.get().getProxy().getServerInfo(BungeeCore.LOBBY_SERVER)); - BungeeCore.send(event.getPlayer(), BungeeCore.CHAT_PREFIX + "§cMit Fabric und LiteLoader kannst du nicht auf die Arenen"); + Message.send("MODLOADER_DENIED", event.getPlayer()); } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 73f532d..0b11312 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -5,6 +5,10 @@ UNKNOWN_COMMAND=§cUnbekannter Befehl. UNKNOWN_PLAYER=§cDiesen Spieler gibt es nicht. INVALID_TIME=§cUngültige Zeitangabe. +#ModLoader blocker +MODLOADER_INSTALLED=§7Du hast §e{0} §7installiert. Daher kannst du keinen Arenen beitreten. +MODLOADER_DENIED=§cMit Fabric, Forge und LiteLoader kannst du keinen Arenen beitreten. + #Help command HELP_LOBBY=§7Kehre von überall mit §8/§el §7zur Lobby zurück! HELP_LOBBY_HOVER=§eZurück zur Lobby From 1ac51e54e183bcf4cc5745ce42f18778703e735d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 4 Jan 2021 18:42:48 +0100 Subject: [PATCH 12/13] Green color online teammembers Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/TeamCommand.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index f9cb50e..0d503ce 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -389,6 +389,10 @@ public class TeamCommand extends BasicCommand { BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Du hast den Spieler §e" + args[1] + " §7zum Leader gemacht!"); } + private String playerName(SteamwarUser user){ + return ProxyServer.getInstance().getPlayer(user.getUuid()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName(); + } + private void info(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ if(args.length == 1 && user.getTeam() == 0){ BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§8/§eteam info §8[§eTeamname§8]"); @@ -403,17 +407,16 @@ public class TeamCommand extends BasicCommand { } BungeeCore.send(player, "§7Team §e" + team.getTeamName() + " §8[§" + team.getTeamColor() + team.getTeamKuerzel() + "§8]"); - BungeeCore.send(player, "§7Leader§8: " + SteamwarUser.get(team.getTeamLeader()).getUserName()); + BungeeCore.send(player, "§7Leader§8: " + playerName(SteamwarUser.get(team.getTeamLeader()))); if(team.getMembers().size() > 1) { StringBuilder sb = new StringBuilder(); - sb.append("§7Member§8: §e"); + sb.append("§7Member§8: "); List members = team.getMembers(); for (int i : members) { if (i == team.getTeamLeader()) continue; - SteamwarUser m = SteamwarUser.get(i); - sb.append(m.getUserName()).append(" "); + sb.append(playerName(SteamwarUser.get(i))).append(" "); } BungeeCore.send(player, sb.toString()); } From 0a472091ba3370b52069ae3f1399b69132bd4f71 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 14 Jan 2021 21:10:24 +0100 Subject: [PATCH 13/13] Hotfix testarena Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/FightCommand.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index 1c6cd2e..6a5dc65 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -128,15 +128,15 @@ public class FightCommand extends BasicCommand { if(!(sender instanceof ProxiedPlayer)) return; - if(ModLoaderBlocker.isFabric((ProxiedPlayer) sender) && !precommand.equals("/bau testarena")) { - BungeeCore.send((ProxiedPlayer) sender, BungeeCore.CHAT_PREFIX + "§cHabe ich dir nicht gesagt, dass man mit Fabric/LiteLoader nicht auf die Arenen darf?"); - return; - } - ProxiedPlayer player = (ProxiedPlayer) sender; if(alreadyInArena(player)) return; + if(ModLoaderBlocker.isFabric(player) && !precommand.equals("/bau testarena ")) { + BungeeCore.send((ProxiedPlayer) sender, BungeeCore.CHAT_PREFIX + "§cHabe ich dir nicht gesagt, dass man mit Fabric/LiteLoader nicht auf die Arenen darf?"); + return; + } + if(args.length < startArg+1){ getModes(sender, precommand, historic); return;