Archiviert
1
0

Merge branch 'master' into commonDB2

# Conflicts:
#	src/de/steamwar/bungeecore/commands/BasicCommand.java
#	src/de/steamwar/bungeecore/commands/EventCommand.java
#	src/de/steamwar/bungeecore/commands/JoinmeCommand.java
#	src/de/steamwar/bungeecore/commands/TeamCommand.java
#	src/de/steamwar/bungeecore/commands/TeamchatCommand.java
Dieser Commit ist enthalten in:
Lixfel 2023-02-22 07:12:23 +01:00
Commit 5c9394e4b0
12 geänderte Dateien mit 341 neuen und 497 gelöschten Zeilen

Datei anzeigen

@ -141,7 +141,7 @@ public class BungeeCore extends Plugin {
new KickCommand();
new JoinmeCommand();
new TpCommand();
new HelpCommand();
HelpCommand helpCommand = new HelpCommand();
new TeamCommand();
new ServerTeamchatCommand();
new DevCommand();
@ -183,7 +183,7 @@ public class BungeeCore extends Plugin {
new PunishmentCommand("note", Punishment.PunishmentType.Note);
if(!EVENT_MODE){
new BauCommand();
new BauCommand(helpCommand);
new WebpasswordCommand();
new FightCommand();
new ChallengeCommand();

Datei anzeigen

@ -1,69 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;
import java.util.ArrayList;
import java.util.List;
abstract class BasicCommand extends Command implements TabExecutor {
public BasicCommand(String name, String permission, String... aliases) {
super(name, permission, aliases);
BungeeCore.commands.put("/" + name, permission);
ProxyServer.getInstance().getPluginManager().registerCommand(BungeeCore.get(), this);
}
Iterable<String> allPlayers(String begin) {
List<String> suggestions = new ArrayList<>();
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
String playerName = player.getName();
if(playerName.startsWith(begin))
suggestions.add(playerName);
}
return suggestions;
}
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
return new ArrayList<>();
}
protected SteamwarUser existingUser(CommandSender sender, String arg){
SteamwarUser target = SteamwarUser.get(arg);
if(target == null)
Message.send("UNKNOWN_PLAYER", sender);
return target;
}
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(arg);
if(target == null)
Message.send("UNKNOWN_PLAYER", sender);
return target;
}
}

Datei anzeigen

@ -44,13 +44,16 @@ import java.util.Map;
public class BauCommand extends SWCommand {
public BauCommand(){
private final HelpCommand command;
public BauCommand(HelpCommand command){
super("bau", null, "b", "build", "gs");
this.command = command;
}
@Register(help = true)
@Register(noTabComplete = true)
public void genericHelp(ProxiedPlayer p, String... args) {
HelpCommand.sendBauHelp(ChatSender.of(p));
this.command.sendBauHelp(p);
}
@Register

Datei anzeigen

@ -25,54 +25,33 @@ import de.steamwar.sql.SchematicType;
import de.steamwar.sql.Team;
import de.steamwar.sql.TeamTeilnahme;
import de.steamwar.sql.Event;
import net.md_5.bungee.api.CommandSender;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class EventCommand extends BasicCommand {
public class EventCommand extends SWCommand {
public EventCommand() {
super("event", "");
super("event");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
Event currentEvent = Event.get();
if(currentEvent == null) {
noCurrentEvent(player);
return;
}
if(args.length != 1){
eventOverview(player, currentEvent);
return;
}
Team team = Team.get(args[0]);
if(team == null){
Message.send("EVENT_NO_TEAM", player);
return;
}
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
Message.send("EVENT_NO_FIGHT_TEAM", player);
return;
}
SubserverSystem.sendPlayer(eventArena, player);
@Validator("noEvent")
public TypeValidator<ProxiedPlayer> noEventValidator() {
return (sender, value, messageSender) -> Event.get() == null;
}
private void noCurrentEvent(ProxiedPlayer player){
@Register
public void noCurrentEvent(@Validator("noEvent") ProxiedPlayer player){
Message.send("EVENT_NO_CURRENT", player);
List<Event> coming = Event.getComing();
Instant now = Instant.now();
@ -103,7 +82,9 @@ public class EventCommand extends BasicCommand {
}
}
private void eventOverview(ProxiedPlayer player, Event currentEvent){
@Register
public void eventOverview(@Validator(value = "noEvent", invert = true) ProxiedPlayer player) {
Event currentEvent = Event.get();
Message.send("EVENT_USAGE", player);
List<EventFight> fights = EventFight.getEvent(currentEvent.getEventID());
@ -133,4 +114,26 @@ public class EventCommand extends BasicCommand {
BungeeCore.send(player, fline.toString());
}
}
@Register
public void eventWithTeam(@Validator(value = "noEvent", invert = true) ProxiedPlayer player, @ErrorMessage("EVENT_NO_TEAM") Team team) {
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
Message.send("EVENT_NO_FIGHT_TEAM", player);
return;
}
SubserverSystem.sendPlayer(eventArena, player);
}
@ClassMapper(Team.class)
@Cached(cacheDuration = 10, global = true)
public TypeMapper<Team> teamMapper() {
return SWCommandUtils.createMapper(Team::get, s -> EventStarter.getEventServer()
.keySet()
.stream()
.map(Team::get)
.map(t -> Arrays.asList(t.getTeamKuerzel(), t.getTeamColor()))
.flatMap(Collection::stream)
.collect(Collectors.toList()));
}
}

Datei anzeigen

@ -20,72 +20,61 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.packet.Chat;
public class HelpCommand extends BasicCommand {
public class HelpCommand extends SWCommand {
public HelpCommand() {
super("help", "", "?");
}
@Override
public void execute(CommandSender s, String[] args) {
ChatSender sender = ChatSender.of(s);
if (args.length < 1) {
printPage(sender, ClickEvent.Action.RUN_COMMAND,
"HELP_LOBBY", "/l",
"HELP_BAU", "/build",
"HELP_BAUSERVER", "/help build",
"HELP_FIGHT", "/fight",
"HELP_CHALLENGE", "/challenge",
"HELP_HISTORIC", "/historic",
"HELP_TEAM", "/team",
"HELP_JOIN", "/join",
"HELP_LOCAL", "/local");
}else if (args[0].equalsIgnoreCase("buildserver")) {
sendBauHelp(sender);
}else if (args[0].equalsIgnoreCase("build")) {
bauHelpGroup(sender, args);
}
}
@Register
public void genericCommand(ProxiedPlayer player) {
ChatSender sender = ChatSender.of(player);
private static void bauHelpGroup(ChatSender sender, String[] args) {
if (args.length < 2) {
sendBauHelpGroup(sender);
return;
}
switch (args[1].toLowerCase()) {
case "admin":
case "owner":
case "bauwelt":
sender.system("HELP_BAU_GROUP_ADMIN_TITLE");
sendBauHelp(sender);
return;
case "world":
printPage(sender, "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
return;
case "player":
printPage(sender, "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
return;
case "worldedit":
case "we":
case "world-edit":
case "edit":
printPage(sender, "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
return;
case "other":
printPage(sender, "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
return;
default:
sendBauHelpGroup(sender);
}
}
private static void sendBauHelpGroup(ChatSender sender) {
printPage(sender, ClickEvent.Action.RUN_COMMAND,
"HELP_LOBBY", "/l",
"HELP_BAU", "/build",
"HELP_BAUSERVER", "/help build",
"HELP_FIGHT", "/fight",
"HELP_CHALLENGE", "/challenge",
"HELP_HISTORIC", "/historic",
"HELP_TEAM", "/team",
"HELP_JOIN", "/join",
"HELP_LOCAL", "/local");
}
@Register({"build","world"})
public void buildWorld(ProxiedPlayer player) {
printPage(ChatSender.of(player), "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
}
@Register({"build","player"})
public void buildPlayer(ProxiedPlayer player) {
printPage(ChatSender.of(player), "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
}
@Register({"build","worldedit"})
@Register({"build","we"})
@Register({"build","world-edit"})
@Register({"build","edit"})
public void buildWorldedit(ProxiedPlayer player) {
printPage(ChatSender.of(player), "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
}
@Register({"build","other"})
public void buildOther(ProxiedPlayer player) {
printPage(ChatSender.of(player), "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
}
@Register("build")
public void sendBauHelpGroup(ProxiedPlayer player) {
printPage(ChatSender.of(player), ClickEvent.Action.RUN_COMMAND,
"HELP_BAU_GROUP_ADMIN", "/help build admin",
"HELP_BAU_GROUP_WORLD", "/help build world",
"HELP_BAU_GROUP_PLAYER", "/help build player",
@ -93,8 +82,12 @@ public class HelpCommand extends BasicCommand {
"HELP_BAU_GROUP_OTHER", "/help build other");
}
static void sendBauHelp(ChatSender sender) {
printPage(sender, ClickEvent.Action.SUGGEST_COMMAND,
@Register("buildserver")
@Register({"build","admin"})
@Register({"build","owner"})
@Register({"build","bauwelt"})
public void sendBauHelp(ProxiedPlayer player) {
printPage(ChatSender.of(player), ClickEvent.Action.SUGGEST_COMMAND,
"HELP_BAU_TP", "/build tp ",
"HELP_BAU_ADDMEMBER", "/build addmember ",
"HELP_BAU_DELMEMBER", "/build delmember ",

Datei anzeigen

@ -21,77 +21,74 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import de.steamwar.sql.BauweltMember;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList;
public class JoinmeCommand extends BasicCommand {
public class JoinmeCommand extends SWCommand {
public JoinmeCommand() {
super("joinme", "");
super("joinme");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(sender instanceof ProxiedPlayer) {
ProxiedPlayer player = (ProxiedPlayer) sender;
@Register(description = "JOINME_USAGE")
public void genericCommand(ProxiedPlayer player) {
if (!player.hasPermission("bungeecore.joinme")) {
Message.send("JOINME_USAGE", player);
return;
}
Message.broadcast("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER",
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player.getName(), player.getServer().getInfo().getName());
}
if (args.length == 0 && player.hasPermission("bungeecore.joinme")) {
Message.broadcast("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER"
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player.getName(), player.getServer().getInfo().getName());
} else if (args.length == 1) {
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
if(target == null || !target.isConnected()){
Message.send("JOINME_PLAYER_OFFLINE", player);
return;
}else if(target.equals(player)){
Message.send("JOINME_PLAYER_SELF", player);
return;
}
ServerInfo server = target.getServer().getInfo();
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
Subserver subserver = Subserver.getSubserver(target);
@Register
public void genericCommand(ProxiedPlayer player, @Validator ProxiedPlayer target) {
if (target.equals(player)){
Message.send("JOINME_PLAYER_SELF", player);
return;
}
ServerInfo server = target.getServer().getInfo();
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
Subserver subserver = Subserver.getSubserver(target);
if(subserver != null) {
Servertype type = subserver.getType();
if (type == Servertype.ARENA) {
SubserverSystem.sendPlayer(subserver, player);
} else if (type == Servertype.BAUSERVER) {
Bauserver bauserver = (Bauserver) subserver;
if (bauserver.getOwner().equals(player.getUniqueId()) ||
BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
SubserverSystem.sendPlayer(subserver, player);
} else {
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
Message.send("JOIN_PLAYER_BLOCK", player);
}
} else if(type == Servertype.BUILDER && !player.hasPermission("bungeecore.server.team")) {
Message.send("JOIN_PLAYER_BLOCK", player);
} else {
SubserverSystem.sendPlayer(subserver, player);
}
}else if(serverPerm != null && !player.hasPermission(serverPerm)){
if(subserver != null) {
Servertype type = subserver.getType();
if (type == Servertype.ARENA) {
SubserverSystem.sendPlayer(subserver, player);
} else if (type == Servertype.BAUSERVER) {
Bauserver bauserver = (Bauserver) subserver;
if (bauserver.getOwner().equals(player.getUniqueId()) ||
BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
SubserverSystem.sendPlayer(subserver, player);
} else {
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
Message.send("JOIN_PLAYER_BLOCK", player);
}else if(serverPerm == null && !player.getGroups().contains("team")) {
Message.send("JOIN_PLAYER_BLOCK", player);
}else{
player.connect(server);
}
} else if(type == Servertype.BUILDER && !player.hasPermission("bungeecore.server.team")) {
Message.send("JOIN_PLAYER_BLOCK", player);
} else {
Message.send("JOINME_USAGE", player);
SubserverSystem.sendPlayer(subserver, player);
}
}else if(serverPerm != null && !player.hasPermission(serverPerm)){
Message.send("JOIN_PLAYER_BLOCK", player);
}else if(serverPerm == null && !player.getGroups().contains("team")) {
Message.send("JOIN_PLAYER_BLOCK", player);
}else{
player.connect(server);
}
}
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 1){
return allPlayers(args[0]);
}
return new ArrayList<>();
@ClassValidator(ProxiedPlayer.class)
public TypeValidator<ProxiedPlayer> playerMapper() {
return (sender, value, messageSender) -> {
if (value == null || !value.isConnected()) {
messageSender.send("JOINME_PLAYER_OFFLINE", sender);
return false;
}
return true;
};
}
}

Datei anzeigen

@ -27,6 +27,9 @@ import de.steamwar.sql.Punishment;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import de.steamwar.sql.TeamTeilnahme;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.messages.ChatSender;
import de.steamwar.sql.Event;
import net.md_5.bungee.BungeeCord;
@ -45,15 +48,12 @@ import net.md_5.bungee.api.event.ServerConnectEvent;
import java.net.*;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import static de.steamwar.bungeecore.Storage.teamInvitations;
public class TeamCommand extends BasicCommand {
public class TeamCommand extends SWCommand {
private static final List<SWListInv.SWListEntry<String>> COLOR_CODES = new ArrayList<>();
@ -81,16 +81,17 @@ public class TeamCommand extends BasicCommand {
}
public TeamCommand() {
super("team", "");
super("team");
}
private void help(CommandSender sender){
@Register(noTabComplete = true)
public void help(CommandSender sender, String... args){
Message.send("TEAM_HELP_HEADER", sender);
Message.send("TEAM_HELP_LIST", sender);
Message.send("TEAM_HELP_INFO", sender);
Message.send("TEAM_HELP_TP", sender);
if(!(sender instanceof ProxiedPlayer))
return;
Message.send("TEAM_HELP_TP", sender);
ProxiedPlayer player = (ProxiedPlayer) sender;
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
@ -115,93 +116,28 @@ public class TeamCommand extends BasicCommand {
}
}
@Override
public void execute(CommandSender sender, String[] args){
if(args.length < 1){
help(sender);
return;
}
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
@Register(value = "create", description = "TEAM_CREATE_USAGE")
public void create(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
switch(args[0].toLowerCase()){
case "create":
create(player, user, team, args);
break;
case "join":
join(player, user, args);
break;
case "stepback":
stepBack(player,user,team);
break;
case "leave":
leave(player, user, team);
break;
case "invite":
invite(player, user, team, args);
break;
case "remove":
remove(player, user, team, args);
break;
case "changekuerzel":
changekuerzel(player, user, team, args);
break;
case "changename":
changename(player, user, team, args);
break;
case "promote":
promote(player, user, team, args);
break;
case "changecolor":
changeColor(player, user, team);
break;
case "info":
info(player, user, team, args);
break;
case "list":
list(player, args);
break;
case "event":
event(player, user, team, args);
break;
case "tp":
tp(player, user, team, args);
break;
case "server":
server(player, user, team, args);
break;
default:
help(player);
}
}
private void create(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if(unwantedInTeam(player, user))
return;
if(args.length < 3){
Message.send("TEAM_CREATE_USAGE", player);
return;
}
if(checkTeamKuerzel(player, team, args[1]))
if(checkTeamKuerzel(player, team, kuerzel))
return;
if(checkTeamName(player, team, args[2]))
if(checkTeamName(player, team, name))
return;
Team.create(args[1], args[2]);
user.setTeam(Team.get(args[1]).getTeamId());
Team.create(kuerzel, name);
user.setTeam(Team.get(kuerzel).getTeamId());
user.setLeader(true);
Message.send("TEAM_CREATE_CREATED", player, args[2]);
Message.send("TEAM_CREATE_CREATED", player, name);
}
private void join(ProxiedPlayer player, SteamwarUser user, String[] args){
@Register("join")
public void join(ProxiedPlayer player, String... args){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(unwantedInTeam(player, user))
return;
@ -249,8 +185,11 @@ public class TeamCommand extends BasicCommand {
Message.send("TEAM_JOIN_JOINED", player, Team.get(t).getTeamName());
}
private void stepBack(ProxiedPlayer player, SteamwarUser user, Team team) {
if(notLeader(player, user, team))
@Register("stepback")
public void stepBack(ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(team.size() > 1 && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){
@ -262,7 +201,10 @@ public class TeamCommand extends BasicCommand {
Message.send("TEAM_STEP_BACK", player);
}
private void leave(ProxiedPlayer player, SteamwarUser user, Team team){
@Register("leave")
public void leave(ProxiedPlayer player){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notInTeam(player, user))
return;
@ -282,19 +224,17 @@ public class TeamCommand extends BasicCommand {
}
private void invite(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if(notLeader(player, user, team))
@Register(value = "invite", description = "TEAM_INVITE_USAGE")
public void invite(ProxiedPlayer player, String toInvite){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
if(args.length != 2){
Message.send("TEAM_INVITE_USAGE", player);
return;
}
SteamwarUser target = SteamwarUser.get(args[1]);
SteamwarUser target = SteamwarUser.get(toInvite);
if(target == null){
Message.send("TEAM_INVITE_NO_PLAYER", player);
return;
@ -313,22 +253,20 @@ public class TeamCommand extends BasicCommand {
teamInvitations.get(target.getId()).add(team.getTeamId());
Message.send("TEAM_INVITE_INVITED", player, args[1]);
Message.send("TEAM_INVITE_INVITED", player, toInvite);
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID());
if(p != null)
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
}
private void remove(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if(notLeader(player, user, team))
@Register(value = "remove", description = "TEAM_REMOVE_USAGE")
public void remove(ProxiedPlayer player, String toRemove){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(args.length != 2){
Message.send("TEAM_REMOVE_USAGE", player);
return;
}
SteamwarUser target = SteamwarUser.get(args[1]);
SteamwarUser target = SteamwarUser.get(toRemove);
if(target == null){
Message.send("TEAM_REMOVE_NOT_PLAYER", player);
return;
@ -363,59 +301,52 @@ public class TeamCommand extends BasicCommand {
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
}
private void changekuerzel(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if(notLeader(player, user, team))
@Register(value = "changekurzel", description = "TEAM_KUERZEL_USAGE")
public void changekuerzel(ProxiedPlayer player, @Length(min = 2, max = 4) @ErrorMessage("TEAM_KUERZEL_LENGTH") String kuerzel){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
if(args.length < 2){
Message.send("TEAM_KUERZEL_USAGE", player);
return;
}
if(checkTeamKuerzel(player, team, args[1]))
if(checkTeamKuerzel(player, team, kuerzel))
return;
team.setTeamKuerzel(args[1]);
team.setTeamKuerzel(kuerzel);
Message.send("TEAM_KUERZEL_CHANGED", player);
}
private void changename(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if(notLeader(player, user, team))
@Register(value = "changename", description = "TEAM_NAME_USAGE")
public void changename(ProxiedPlayer player, @Length(min = 4, max = 15) @ErrorMessage("TEAM_NAME_LENGTH") String name){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
if(args.length < 2){
Message.send("TEAM_NAME_USAGE", player);
return;
}
if(checkTeamName(player, team, args[1]))
if(checkTeamName(player, team, name))
return;
team.setTeamName(args[1]);
team.setTeamName(name);
Message.send("TEAM_NAME_CHANGED", player);
}
private void promote(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if(notLeader(player, user, team))
@Register(value = "promote", description = "TEAM_LEADER_USAGE")
public void promote(ProxiedPlayer player, String toPromote){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
if(args.length < 2){
Message.send("TEAM_LEADER_USAGE", player);
return;
}
SteamwarUser target = SteamwarUser.get(args[1]);
SteamwarUser target = SteamwarUser.get(toPromote);
if(target == null){
Message.send("TEAM_LEADER_NOT_USER", player, args[1]);
Message.send("TEAM_LEADER_NOT_USER", player, toPromote);
return;
}
@ -425,14 +356,17 @@ public class TeamCommand extends BasicCommand {
}
target.setLeader(true);
Message.send("TEAM_LEADER_PROMOTED", player, args[1]);
Message.send("TEAM_LEADER_PROMOTED", player, toPromote);
}
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){
@Register("info")
public void info(ProxiedPlayer player, String... args){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(args.length == 1 && user.getTeam() == 0){
Message.send("TEAM_INFO_USAGE", player);
return;
@ -473,21 +407,10 @@ public class TeamCommand extends BasicCommand {
return sb.toString();
}
private void list(ProxiedPlayer player, String[] args){
@Register("list")
public void list(ProxiedPlayer player, @Min(intValue = 1) @OptionalValue("1") @ErrorMessage("TEAM_LIST_NOT_PAGE") int page){
final int TEAMS_PER_PAGE = 10;
int page;
if(args.length > 1){
try{
page = Integer.parseInt(args[1]);
}catch(NumberFormatException e){
Message.send("TEAM_LIST_NOT_PAGE", player);
return;
}
}else
page = 1;
List<Team> all = Team.getAll();
final int lastPage = ((all.size() - 1) / 10) + 1;
if(page < 1 || page > lastPage){
@ -524,34 +447,36 @@ public class TeamCommand extends BasicCommand {
player.sendMessage(beforePage);
}
private void event(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
@Register("event")
public void event(ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notInTeam(player, user))
return;
if(args.length < 2){
Message.send("TEAM_EVENT_USAGE", player);
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
if(!events.isEmpty()){
Message.send("TEAM_EVENT_HEADER", player);
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player));
for(Event e : events)
Message.sendPrefixless("TEAM_EVENT_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
}
return;
Message.send("TEAM_EVENT_USAGE", player);
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
if(!events.isEmpty()){
Message.send("TEAM_EVENT_HEADER", player);
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player));
for(Event e : events)
Message.sendPrefixless("TEAM_EVENT_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
}
}
if(notLeader(player, user, team))
@Register("event")
public void event(ProxiedPlayer player, Event event){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notInTeam(player, user))
return;
if(notLeader(player, user))
return;
if(notDuringEvent(player))
return;
Event event = Event.get(args[1]);
if(event == null){
Message.send("TEAM_EVENT_NO_EVENT", player);
return;
}
if(Instant.now().isAfter(event.getDeadline().toInstant())){
Message.send("TEAM_EVENT_OVER", player);
return;
@ -567,7 +492,10 @@ public class TeamCommand extends BasicCommand {
}
}
private void tp(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
@Register("tp")
public void tp(ProxiedPlayer player, String... args){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(args.length == 1){
if(notInTeam(player, user))
return;
@ -613,17 +541,16 @@ public class TeamCommand extends BasicCommand {
*/
}
private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
if(notLeader(player, user, team))
@Register(value = "server", description = "TEAM_SERVER_USAGE")
public void server(ProxiedPlayer player, String server, @Min(intValue = 1) @Max(intValue = 65535) @ErrorMessage("TEAM_SERVER_PORT_INVALID") int port){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if (PunishmentCommand.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
return;
}
if (args.length < 2) {
Message.send("TEAM_SERVER_USAGE", player);
return;
}
String server = args[1];
try {
if (isLocalhost(InetAddress.getByName(server))) {
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
@ -633,19 +560,7 @@ public class TeamCommand extends BasicCommand {
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
return;
}
int port = 25565;
if (args.length == 3) {
try {
port = Integer.parseInt(args[2]);
if (port < 1 || port > 65535) {
Message.send("TEAM_SERVER_PORT_INVALID", player);
return;
}
} catch (NumberFormatException e) {
Message.send("TEAM_SERVER_PORT_INVALID", player);
return;
}
}
team.setAddress(server);
team.setPort(port);
Storage.teamServers.remove(team.getTeamId());
@ -665,8 +580,11 @@ public class TeamCommand extends BasicCommand {
}
}
private void changeColor(ProxiedPlayer player, SteamwarUser user, Team team) {
if(notLeader(player, user, team))
@Register("color")
public void changeColor(ProxiedPlayer player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
Team team = Team.get(user.getTeam());
if(notLeader(player, user))
return;
if(notDuringEvent(player))
@ -687,12 +605,32 @@ public class TeamCommand extends BasicCommand {
inv.open();
}
private boolean checkTeamName(ProxiedPlayer player, Team team, String arg){
if(arg.length() < 4 || arg.length() > 15){
Message.send("TEAM_NAME_LENGHT", player);
return true;
}
@ClassMapper(Event.class)
public TypeMapper<Event> eventTypeMapper() {
return new TypeMapper<Event>() {
@Override
public Event map(CommandSender commandSender, String[] previousArguments, String s) {
return Event.get(s);
}
@Override
public boolean validate(CommandSender sender, Event value, MessageSender messageSender) {
if (value == null) {
messageSender.send("TEAM_EVENT_NO_EVENT", sender);
return false;
} else {
return true;
}
}
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
return Event.getComing().stream().map(Event::getEventName).collect(Collectors.toList());
}
};
}
private boolean checkTeamName(ProxiedPlayer player, Team team, String arg){
Team t = Team.get(arg);
if(t != null && t.getTeamId() != team.getTeamId()){
Message.send("TEAM_NAME_TAKEN", player);
@ -702,11 +640,6 @@ public class TeamCommand extends BasicCommand {
}
private boolean checkTeamKuerzel(ProxiedPlayer player, Team team, String arg){
if(arg.length() < 2 || arg.length() > 4){
Message.send("TEAM_KUERZEL_LENGHT", player);
return true;
}
Team t = Team.get(arg);
if(t != null && (team == null || t.getTeamId() != team.getTeamId())){
Message.send("TEAM_KUERZEL_TAKEN", player);
@ -731,7 +664,7 @@ public class TeamCommand extends BasicCommand {
return false;
}
private boolean notLeader(ProxiedPlayer player, SteamwarUser user, Team team){
private boolean notLeader(ProxiedPlayer player, SteamwarUser user){
if(notInTeam(player, user))
return true;
if(!user.isLeader()){
@ -748,37 +681,4 @@ public class TeamCommand extends BasicCommand {
}
return false;
}
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args){
List<String> tab = new ArrayList<>();
if(args.length == 1){
tab.add("create");
tab.add("join");
tab.add("invite");
tab.add("stepback");
tab.add("leave");
tab.add("info");
tab.add("remove");
tab.add("event");
tab.add("changekuerzel");
tab.add("changename");
tab.add("promote");
tab.add("changecolor");
tab.add("tp");
tab.add("server");
}else if(args.length == 2){
if(args[1].equalsIgnoreCase("event")){
List<Event> coming = Event.getComing();
coming.forEach(event -> tab.add(event.getEventName()));
}else if(args[1].equalsIgnoreCase("join") || args[1].equalsIgnoreCase("info") || args[1].equalsIgnoreCase("tp")){
List<Team> teams = Team.getAll();
teams.forEach(team -> {
tab.add(team.getTeamName());
tab.add(team.getTeamKuerzel());
});
}
}
return tab;
}
}

Datei anzeigen

@ -21,29 +21,27 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.listeners.ChatListener;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class TeamchatCommand extends BasicCommand {
public class TeamchatCommand extends SWCommand {
public TeamchatCommand() {
super("tc", "","teamchat");
}
@Override
public void execute(CommandSender s, String[] args) {
ChatSender sender = ChatSender.of(s);
if(args.length == 0){
sender.system("TC_USAGE");
return;
}
@Register(description = "TC_USAGE")
public void genericCommand(ProxiedPlayer player, @ErrorMessage(value = "TC_USAGE", allowEAs = false) String... args) {
ChatSender sender = ChatSender.of(player);
SteamwarUser user = sender.user();
if(user.getTeam() == 0){
sender.system("TC_NO_TEAM");
return;
}
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(player -> player.user().getTeam() == user.getTeam()), "CHAT_TEAM", null, String.join(" ", args));
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(p -> p.user().getTeam() == user.getTeam()), "CHAT_TEAM", null, String.join(" ", args));
}
}

Datei anzeigen

@ -26,6 +26,8 @@ import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import de.steamwar.bungeecore.util.BauLock;
import de.steamwar.bungeecore.util.Chat19;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.messages.ChatSender;
import de.steamwar.sql.Event;
import net.md_5.bungee.BungeeCord;
@ -35,45 +37,62 @@ import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class TpCommand extends BasicCommand {
public class TpCommand extends SWCommand {
public TpCommand(){
super("join", null, "tp", "teleport");
}
@Override
public void execute(CommandSender s, String[] args) {
if(!(s instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) s;
ChatSender sender = ChatSender.of(player);
if(args.length == 0){
if(Event.get() == null)
sender.system("TP_USAGE");
else
sender.system("TP_USAGE_EVENT");
return;
}
ServerInfo server = getTarget(args[0]);
boolean onTeamServer = Storage.teamServers.containsValue(player.getServer().getInfo());
//Give control of teleport command to server
if (server == player.getServer().getInfo() || onTeamServer || server == null) {
Chat19.chat(player, "/tp " + String.join(" ", args));
return;
}
teleport(player, server);
@Register
public void genericCommand(ProxiedPlayer p) {
ChatSender.of(p).system(Event.get() == null ? "TP_USAGE" : "TP_USAGE_EVENT");
}
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length > 0)
return allPlayers(args[args.length - 1]);
return new ArrayList<>();
@Register
public void teleportCommand(ProxiedPlayer p, @Mapper("to") String to, String... rest) {
ServerInfo server = getTarget(to);
//Give control of teleport command to server
if (server == p.getServer().getInfo() || server == null) {
if (rest.length == 0) {
Chat19.chat(p, "/tp " + to);
} else {
Chat19.chat(p, "/tp " + to + " " + String.join(" ", rest));
}
return;
}
teleport(p, server);
}
@Mapper("to")
@Cached(cacheDuration = 10, global = true)
public TypeMapper<String> tabCompleter() {
return new TypeMapper<String>() {
@Override
public String map(CommandSender commandSender, String[] previousArguments, String s) {
return s;
}
@Override
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
List<String> list = new ArrayList<>();
for (ProxiedPlayer player : BungeeCord.getInstance().getPlayers()) {
list.add(player.getName());
}
if (Event.get() != null) {
EventStarter.getEventServer().keySet().forEach(teamId -> {
Team team = Team.get(teamId);
list.add(team.getTeamName());
list.add(team.getTeamKuerzel());
});
}
return list;
}
};
}
public static void teleport(ProxiedPlayer player, ServerInfo server){

Datei anzeigen

@ -120,7 +120,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
ChatSender.of(sender).system(message, args);
}
@Register(help = true)
@Register(noTabComplete = true)
public void internalHelp(ProxiedPlayer p, String... args) {
ChatSender chatSender = ChatSender.of(p);
try {

Datei anzeigen

@ -446,13 +446,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cYou were removed from the team.
#Team Kuerzel
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eshortcut§8]
TEAM_KUERZEL_CHANGED=§7You changed your teams shortcut!
TEAM_KUERZEL_LENGHT=§cA team shortcut has to consist of 2 to 4 characters.
TEAM_KUERZEL_LENGTH=§cA team shortcut has to consist of 2 to 4 characters.
TEAM_KUERZEL_TAKEN=§cThere is already a team with that shortcut.
#Team Name
TEAM_NAME_USAGE=§8/§7team changename §8[§eteam name§8]
TEAM_NAME_CHANGED=§7You have renamed your team!
TEAM_NAME_LENGHT=§cA team name has to consist of 4 to 15 characters.
TEAM_NAME_LENGTH=§cA team name has to consist of 4 to 15 characters.
TEAM_NAME_TAKEN=§cThere is already a team with that name.
#Team Leader

Datei anzeigen

@ -424,13 +424,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cDu wurdest aus dem Team entfernt.
#Team Kuerzel
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eTeamkürzel§8]
TEAM_KUERZEL_CHANGED=§7Du hast das Kürzel des Teams geändert!
TEAM_KUERZEL_LENGHT=§cEin Teamkürzel muss aus 2 bis 4 Buchstaben bestehen.
TEAM_KUERZEL_LENGTH=§cEin Teamkürzel muss aus 2 bis 4 Buchstaben bestehen.
TEAM_KUERZEL_TAKEN=§cEs gibt bereits ein Team mit diesem Namen.
#Team Name
TEAM_NAME_USAGE=§8/§7team changename §8[§eTeamname§8]
TEAM_NAME_CHANGED=§7Du hast das Team umbenannt!
TEAM_NAME_LENGHT=§cEin Teamname muss aus 4 bis 15 Buchstaben bestehen.
TEAM_NAME_LENGTH=§cEin Teamname muss aus 4 bis 15 Buchstaben bestehen.
TEAM_NAME_TAKEN=§cEs gibt bereits ein Team mit diesem Namen.
#Team Leader