Merge branch 'master' into ban-rework
# Conflicts: # src/de/steamwar/bungeecore/Message.java
Dieser Commit ist enthalten in:
Commit
61057204c3
@ -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()));
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ public class Message {
|
||||
}
|
||||
|
||||
private static String parse(String message, boolean prefixed, CommandSender sender, int[] useFormatter, 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);
|
||||
@ -119,13 +119,9 @@ public class Message {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
public static void send(String message, boolean prefixed, CommandSender sender, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
||||
send(message, prefixed, sender, type, onHover, onClick, new int[0], params);
|
||||
}
|
||||
|
||||
public static void broadcast(String message, String onHover, ClickEvent onClick, Object... params){
|
||||
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers())
|
||||
send(message, player, parse(onHover, false, player, new int[0]), onClick, params);
|
||||
send(message, player, parse(onHover, false, player), onClick, params);
|
||||
}
|
||||
|
||||
public static void broadcast(String message, Object... params){
|
||||
@ -142,18 +138,13 @@ public class Message {
|
||||
}
|
||||
|
||||
public static void team(String message, Object... params){
|
||||
team(message, ChatMessageType.SYSTEM, new int[0], params);
|
||||
team(message, ChatMessageType.SYSTEM, params);
|
||||
}
|
||||
|
||||
public static void team(String message, int[] useChoice, Object... params){
|
||||
team(message, ChatMessageType.SYSTEM, useChoice, params);
|
||||
}
|
||||
|
||||
public static void team(String message, ChatMessageType type, int[] useFormatter, Object... params){
|
||||
public static void team(String message, ChatMessageType type, Object... params){
|
||||
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
||||
if(player.getGroups().contains(ConnectionListener.TEAM_GROUP)) {
|
||||
sendPrefixless(message, player, type, useFormatter, params);
|
||||
}
|
||||
if(player.getGroups().contains(ConnectionListener.TEAM_GROUP))
|
||||
sendPrefixless(message, player, type, params);
|
||||
}
|
||||
}
|
||||
}
|
@ -91,9 +91,9 @@ public class EventCommand extends BasicCommand {
|
||||
e.getEventName());
|
||||
Set<Team> 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());
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -20,6 +20,8 @@
|
||||
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.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
@ -40,6 +42,31 @@ import static de.steamwar.bungeecore.Storage.teamInvitations;
|
||||
|
||||
public class TeamCommand extends BasicCommand {
|
||||
|
||||
private static final List<SWListInv.SWListEntry<String>> COLOR_CODES = new ArrayList<>();
|
||||
|
||||
static {
|
||||
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", 16);
|
||||
}
|
||||
|
||||
private static void addColor(String color, int colorCode) {
|
||||
COLOR_CODES.add(new SWListInv.SWListEntry(new SWItem("§" + color, colorCode), color));
|
||||
}
|
||||
|
||||
public TeamCommand() {
|
||||
super("team", "");
|
||||
}
|
||||
@ -67,6 +94,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 +139,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;
|
||||
@ -358,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]");
|
||||
@ -371,18 +406,17 @@ public class TeamCommand extends BasicCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
BungeeCore.send(player, "§7Team §e" + team.getTeamName() + " §8[§e" + team.getTeamKuerzel() + "§8]");
|
||||
BungeeCore.send(player, "§7Leader§8: " + SteamwarUser.get(team.getTeamLeader()).getUserName());
|
||||
BungeeCore.send(player, "§7Team §e" + team.getTeamName() + " §8[§" + team.getTeamColor() + team.getTeamKuerzel() + "§8]");
|
||||
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<Integer> 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());
|
||||
}
|
||||
@ -423,7 +457,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()));
|
||||
}
|
||||
@ -490,6 +524,28 @@ 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 -> {
|
||||
SWItem item = stringSWListEntry.getItem().clone();
|
||||
item.setName(stringSWListEntry.getItem().getTitle() + Team.get(user.getTeam()).getTeamKuerzel());
|
||||
colors.add(new SWListInv.SWListEntry<>(item, stringSWListEntry.getObject()));
|
||||
});
|
||||
|
||||
SWListInv<String> inv = new SWListInv<>(player, "§6Farbe wählen", colors, (click, element) -> {});
|
||||
inv.setCallback((click, element) -> {
|
||||
inv.close();
|
||||
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 +622,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) {
|
||||
@ -151,4 +156,18 @@ public class SWItem {
|
||||
public void setLore(List<String> 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;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ public class SWListInv<T> 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) -> {
|
||||
|
@ -166,7 +166,8 @@ public class ChatListener extends BasicListener {
|
||||
|
||||
String msg = name + "§7»" + chatcolor + " " + message;
|
||||
if(user.getTeam() != 0){
|
||||
msg = "§8" + Team.get(user.getTeam()).getTeamKuerzel() + " §r" + msg;
|
||||
Team team = Team.get(user.getTeam());
|
||||
msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg;
|
||||
}
|
||||
|
||||
String[] msgSplits = msg.split(" ");
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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, "8");
|
||||
|
||||
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,15 @@ public class Team {
|
||||
updateDB();
|
||||
}
|
||||
|
||||
public String getTeamColor() {
|
||||
return teamColor;
|
||||
}
|
||||
|
||||
public void setTeamColor(String teamColor) {
|
||||
this.teamColor = teamColor;
|
||||
updateDB();
|
||||
}
|
||||
|
||||
public int size(){
|
||||
ResultSet rs = select("SELECT COUNT(id) FROM UserData WHERE Team = ?", teamId);
|
||||
try {
|
||||
|
@ -6,6 +6,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
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren