# 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:
Commit
5c9394e4b0
@ -141,7 +141,7 @@ public class BungeeCore extends Plugin {
|
|||||||
new KickCommand();
|
new KickCommand();
|
||||||
new JoinmeCommand();
|
new JoinmeCommand();
|
||||||
new TpCommand();
|
new TpCommand();
|
||||||
new HelpCommand();
|
HelpCommand helpCommand = new HelpCommand();
|
||||||
new TeamCommand();
|
new TeamCommand();
|
||||||
new ServerTeamchatCommand();
|
new ServerTeamchatCommand();
|
||||||
new DevCommand();
|
new DevCommand();
|
||||||
@ -183,7 +183,7 @@ public class BungeeCore extends Plugin {
|
|||||||
new PunishmentCommand("note", Punishment.PunishmentType.Note);
|
new PunishmentCommand("note", Punishment.PunishmentType.Note);
|
||||||
|
|
||||||
if(!EVENT_MODE){
|
if(!EVENT_MODE){
|
||||||
new BauCommand();
|
new BauCommand(helpCommand);
|
||||||
new WebpasswordCommand();
|
new WebpasswordCommand();
|
||||||
new FightCommand();
|
new FightCommand();
|
||||||
new ChallengeCommand();
|
new ChallengeCommand();
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -44,13 +44,16 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class BauCommand extends SWCommand {
|
public class BauCommand extends SWCommand {
|
||||||
|
|
||||||
public BauCommand(){
|
private final HelpCommand command;
|
||||||
|
|
||||||
|
public BauCommand(HelpCommand command){
|
||||||
super("bau", null, "b", "build", "gs");
|
super("bau", null, "b", "build", "gs");
|
||||||
|
this.command = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(help = true)
|
@Register(noTabComplete = true)
|
||||||
public void genericHelp(ProxiedPlayer p, String... args) {
|
public void genericHelp(ProxiedPlayer p, String... args) {
|
||||||
HelpCommand.sendBauHelp(ChatSender.of(p));
|
this.command.sendBauHelp(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
|
@ -25,54 +25,33 @@ import de.steamwar.sql.SchematicType;
|
|||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.sql.TeamTeilnahme;
|
import de.steamwar.sql.TeamTeilnahme;
|
||||||
import de.steamwar.sql.Event;
|
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 net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class EventCommand extends BasicCommand {
|
public class EventCommand extends SWCommand {
|
||||||
|
|
||||||
public EventCommand() {
|
public EventCommand() {
|
||||||
super("event", "");
|
super("event");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Validator("noEvent")
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public TypeValidator<ProxiedPlayer> noEventValidator() {
|
||||||
if(!(sender instanceof ProxiedPlayer))
|
return (sender, value, messageSender) -> Event.get() == null;
|
||||||
return;
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
||||||
|
|
||||||
Event currentEvent = Event.get();
|
|
||||||
|
|
||||||
if(currentEvent == null) {
|
|
||||||
noCurrentEvent(player);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.length != 1){
|
@Register
|
||||||
eventOverview(player, currentEvent);
|
public void noCurrentEvent(@Validator("noEvent") ProxiedPlayer player){
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void noCurrentEvent(ProxiedPlayer player){
|
|
||||||
Message.send("EVENT_NO_CURRENT", player);
|
Message.send("EVENT_NO_CURRENT", player);
|
||||||
List<Event> coming = Event.getComing();
|
List<Event> coming = Event.getComing();
|
||||||
Instant now = Instant.now();
|
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);
|
Message.send("EVENT_USAGE", player);
|
||||||
|
|
||||||
List<EventFight> fights = EventFight.getEvent(currentEvent.getEventID());
|
List<EventFight> fights = EventFight.getEvent(currentEvent.getEventID());
|
||||||
@ -133,4 +114,26 @@ public class EventCommand extends BasicCommand {
|
|||||||
BungeeCore.send(player, fline.toString());
|
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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,20 +20,23 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
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() {
|
public HelpCommand() {
|
||||||
super("help", "", "?");
|
super("help", "", "?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public void execute(CommandSender s, String[] args) {
|
public void genericCommand(ProxiedPlayer player) {
|
||||||
ChatSender sender = ChatSender.of(s);
|
ChatSender sender = ChatSender.of(player);
|
||||||
if (args.length < 1) {
|
|
||||||
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
||||||
"HELP_LOBBY", "/l",
|
"HELP_LOBBY", "/l",
|
||||||
"HELP_BAU", "/build",
|
"HELP_BAU", "/build",
|
||||||
@ -44,48 +47,34 @@ public class HelpCommand extends BasicCommand {
|
|||||||
"HELP_TEAM", "/team",
|
"HELP_TEAM", "/team",
|
||||||
"HELP_JOIN", "/join",
|
"HELP_JOIN", "/join",
|
||||||
"HELP_LOCAL", "/local");
|
"HELP_LOCAL", "/local");
|
||||||
}else if (args[0].equalsIgnoreCase("buildserver")) {
|
|
||||||
sendBauHelp(sender);
|
|
||||||
}else if (args[0].equalsIgnoreCase("build")) {
|
|
||||||
bauHelpGroup(sender, args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void bauHelpGroup(ChatSender sender, String[] args) {
|
@Register({"build","world"})
|
||||||
if (args.length < 2) {
|
public void buildWorld(ProxiedPlayer player) {
|
||||||
sendBauHelpGroup(sender);
|
printPage(ChatSender.of(player), "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (args[1].toLowerCase()) {
|
@Register({"build","player"})
|
||||||
case "admin":
|
public void buildPlayer(ProxiedPlayer player) {
|
||||||
case "owner":
|
printPage(ChatSender.of(player), "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
|
||||||
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) {
|
@Register({"build","worldedit"})
|
||||||
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
@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_ADMIN", "/help build admin",
|
||||||
"HELP_BAU_GROUP_WORLD", "/help build world",
|
"HELP_BAU_GROUP_WORLD", "/help build world",
|
||||||
"HELP_BAU_GROUP_PLAYER", "/help build player",
|
"HELP_BAU_GROUP_PLAYER", "/help build player",
|
||||||
@ -93,8 +82,12 @@ public class HelpCommand extends BasicCommand {
|
|||||||
"HELP_BAU_GROUP_OTHER", "/help build other");
|
"HELP_BAU_GROUP_OTHER", "/help build other");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sendBauHelp(ChatSender sender) {
|
@Register("buildserver")
|
||||||
printPage(sender, ClickEvent.Action.SUGGEST_COMMAND,
|
@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_TP", "/build tp ",
|
||||||
"HELP_BAU_ADDMEMBER", "/build addmember ",
|
"HELP_BAU_ADDMEMBER", "/build addmember ",
|
||||||
"HELP_BAU_DELMEMBER", "/build delmember ",
|
"HELP_BAU_DELMEMBER", "/build delmember ",
|
||||||
|
@ -21,34 +21,32 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.sql.BauweltMember;
|
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.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
public class JoinmeCommand extends SWCommand {
|
||||||
|
|
||||||
public class JoinmeCommand extends BasicCommand {
|
|
||||||
|
|
||||||
public JoinmeCommand() {
|
public JoinmeCommand() {
|
||||||
super("joinme", "");
|
super("joinme");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register(description = "JOINME_USAGE")
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void genericCommand(ProxiedPlayer player) {
|
||||||
if(sender instanceof ProxiedPlayer) {
|
if (!player.hasPermission("bungeecore.joinme")) {
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
Message.send("JOINME_USAGE", player);
|
||||||
|
|
||||||
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;
|
return;
|
||||||
}else if(target.equals(player)){
|
}
|
||||||
|
Message.broadcast("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER",
|
||||||
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player.getName(), player.getServer().getInfo().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(ProxiedPlayer player, @Validator ProxiedPlayer target) {
|
||||||
|
if (target.equals(player)){
|
||||||
Message.send("JOINME_PLAYER_SELF", player);
|
Message.send("JOINME_PLAYER_SELF", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -81,17 +79,16 @@ public class JoinmeCommand extends BasicCommand {
|
|||||||
}else{
|
}else{
|
||||||
player.connect(server);
|
player.connect(server);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Message.send("JOINME_USAGE", player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@ClassValidator(ProxiedPlayer.class)
|
||||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
public TypeValidator<ProxiedPlayer> playerMapper() {
|
||||||
if(args.length == 1){
|
return (sender, value, messageSender) -> {
|
||||||
return allPlayers(args[0]);
|
if (value == null || !value.isConnected()) {
|
||||||
|
messageSender.send("JOINME_PLAYER_OFFLINE", sender);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ import de.steamwar.sql.Punishment;
|
|||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.sql.TeamTeilnahme;
|
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.messages.ChatSender;
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.sql.Event;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
@ -45,15 +48,12 @@ import net.md_5.bungee.api.event.ServerConnectEvent;
|
|||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static de.steamwar.bungeecore.Storage.teamInvitations;
|
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<>();
|
private static final List<SWListInv.SWListEntry<String>> COLOR_CODES = new ArrayList<>();
|
||||||
|
|
||||||
@ -81,16 +81,17 @@ public class TeamCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TeamCommand() {
|
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_HEADER", sender);
|
||||||
Message.send("TEAM_HELP_LIST", sender);
|
Message.send("TEAM_HELP_LIST", sender);
|
||||||
Message.send("TEAM_HELP_INFO", sender);
|
Message.send("TEAM_HELP_INFO", sender);
|
||||||
Message.send("TEAM_HELP_TP", sender);
|
|
||||||
if(!(sender instanceof ProxiedPlayer))
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
return;
|
return;
|
||||||
|
Message.send("TEAM_HELP_TP", sender);
|
||||||
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
@ -115,93 +116,28 @@ public class TeamCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register(value = "create", description = "TEAM_CREATE_USAGE")
|
||||||
public void execute(CommandSender sender, String[] args){
|
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){
|
||||||
if(args.length < 1){
|
|
||||||
help(sender);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!(sender instanceof ProxiedPlayer))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
Team team = Team.get(user.getTeam());
|
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))
|
if(unwantedInTeam(player, user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(args.length < 3){
|
if(checkTeamKuerzel(player, team, kuerzel))
|
||||||
Message.send("TEAM_CREATE_USAGE", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(checkTeamKuerzel(player, team, args[1]))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(checkTeamName(player, team, args[2]))
|
if(checkTeamName(player, team, name))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Team.create(args[1], args[2]);
|
Team.create(kuerzel, name);
|
||||||
user.setTeam(Team.get(args[1]).getTeamId());
|
user.setTeam(Team.get(kuerzel).getTeamId());
|
||||||
user.setLeader(true);
|
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))
|
if(unwantedInTeam(player, user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -249,8 +185,11 @@ public class TeamCommand extends BasicCommand {
|
|||||||
Message.send("TEAM_JOIN_JOINED", player, Team.get(t).getTeamName());
|
Message.send("TEAM_JOIN_JOINED", player, Team.get(t).getTeamName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stepBack(ProxiedPlayer player, SteamwarUser user, Team team) {
|
@Register("stepback")
|
||||||
if(notLeader(player, user, team))
|
public void stepBack(ProxiedPlayer player) {
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
Team team = Team.get(user.getTeam());
|
||||||
|
if(notLeader(player, user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(team.size() > 1 && team.getMembers().stream().map(SteamwarUser::get).filter(member -> user != member).noneMatch(SteamwarUser::isLeader)){
|
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);
|
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))
|
if(notInTeam(player, user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -282,19 +224,17 @@ public class TeamCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void invite(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
@Register(value = "invite", description = "TEAM_INVITE_USAGE")
|
||||||
if(notLeader(player, user, team))
|
public void invite(ProxiedPlayer player, String toInvite){
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
Team team = Team.get(user.getTeam());
|
||||||
|
if(notLeader(player, user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(notDuringEvent(player))
|
if(notDuringEvent(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(args.length != 2){
|
SteamwarUser target = SteamwarUser.get(toInvite);
|
||||||
Message.send("TEAM_INVITE_USAGE", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SteamwarUser target = SteamwarUser.get(args[1]);
|
|
||||||
if(target == null){
|
if(target == null){
|
||||||
Message.send("TEAM_INVITE_NO_PLAYER", player);
|
Message.send("TEAM_INVITE_NO_PLAYER", player);
|
||||||
return;
|
return;
|
||||||
@ -313,22 +253,20 @@ public class TeamCommand extends BasicCommand {
|
|||||||
|
|
||||||
teamInvitations.get(target.getId()).add(team.getTeamId());
|
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());
|
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||||
if(p != null)
|
if(p != null)
|
||||||
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
|
Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void remove(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
@Register(value = "remove", description = "TEAM_REMOVE_USAGE")
|
||||||
if(notLeader(player, user, team))
|
public void remove(ProxiedPlayer player, String toRemove){
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
Team team = Team.get(user.getTeam());
|
||||||
|
if(notLeader(player, user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(args.length != 2){
|
SteamwarUser target = SteamwarUser.get(toRemove);
|
||||||
Message.send("TEAM_REMOVE_USAGE", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SteamwarUser target = SteamwarUser.get(args[1]);
|
|
||||||
if(target == null){
|
if(target == null){
|
||||||
Message.send("TEAM_REMOVE_NOT_PLAYER", player);
|
Message.send("TEAM_REMOVE_NOT_PLAYER", player);
|
||||||
return;
|
return;
|
||||||
@ -363,59 +301,52 @@ public class TeamCommand extends BasicCommand {
|
|||||||
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
|
Message.send("TEAM_REMOVE_REMOVED_TARGET", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changekuerzel(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
@Register(value = "changekurzel", description = "TEAM_KUERZEL_USAGE")
|
||||||
if(notLeader(player, user, team))
|
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;
|
return;
|
||||||
|
|
||||||
if(notDuringEvent(player))
|
if(notDuringEvent(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(args.length < 2){
|
if(checkTeamKuerzel(player, team, kuerzel))
|
||||||
Message.send("TEAM_KUERZEL_USAGE", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(checkTeamKuerzel(player, team, args[1]))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
team.setTeamKuerzel(args[1]);
|
team.setTeamKuerzel(kuerzel);
|
||||||
Message.send("TEAM_KUERZEL_CHANGED", player);
|
Message.send("TEAM_KUERZEL_CHANGED", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changename(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
@Register(value = "changename", description = "TEAM_NAME_USAGE")
|
||||||
if(notLeader(player, user, team))
|
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;
|
return;
|
||||||
|
|
||||||
if(notDuringEvent(player))
|
if(notDuringEvent(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(args.length < 2){
|
if(checkTeamName(player, team, name))
|
||||||
Message.send("TEAM_NAME_USAGE", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(checkTeamName(player, team, args[1]))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
team.setTeamName(args[1]);
|
team.setTeamName(name);
|
||||||
Message.send("TEAM_NAME_CHANGED", player);
|
Message.send("TEAM_NAME_CHANGED", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void promote(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
@Register(value = "promote", description = "TEAM_LEADER_USAGE")
|
||||||
if(notLeader(player, user, team))
|
public void promote(ProxiedPlayer player, String toPromote){
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
if(notLeader(player, user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(notDuringEvent(player))
|
if(notDuringEvent(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(args.length < 2){
|
SteamwarUser target = SteamwarUser.get(toPromote);
|
||||||
Message.send("TEAM_LEADER_USAGE", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SteamwarUser target = SteamwarUser.get(args[1]);
|
|
||||||
if(target == null){
|
if(target == null){
|
||||||
Message.send("TEAM_LEADER_NOT_USER", player, args[1]);
|
Message.send("TEAM_LEADER_NOT_USER", player, toPromote);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,14 +356,17 @@ public class TeamCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
target.setLeader(true);
|
target.setLeader(true);
|
||||||
Message.send("TEAM_LEADER_PROMOTED", player, args[1]);
|
Message.send("TEAM_LEADER_PROMOTED", player, toPromote);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String playerName(SteamwarUser user){
|
private String playerName(SteamwarUser user){
|
||||||
return ProxyServer.getInstance().getPlayer(user.getUUID()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName();
|
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){
|
if(args.length == 1 && user.getTeam() == 0){
|
||||||
Message.send("TEAM_INFO_USAGE", player);
|
Message.send("TEAM_INFO_USAGE", player);
|
||||||
return;
|
return;
|
||||||
@ -473,21 +407,10 @@ public class TeamCommand extends BasicCommand {
|
|||||||
return sb.toString();
|
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;
|
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();
|
List<Team> all = Team.getAll();
|
||||||
final int lastPage = ((all.size() - 1) / 10) + 1;
|
final int lastPage = ((all.size() - 1) / 10) + 1;
|
||||||
if(page < 1 || page > lastPage){
|
if(page < 1 || page > lastPage){
|
||||||
@ -524,11 +447,13 @@ public class TeamCommand extends BasicCommand {
|
|||||||
player.sendMessage(beforePage);
|
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))
|
if(notInTeam(player, user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(args.length < 2){
|
|
||||||
Message.send("TEAM_EVENT_USAGE", player);
|
Message.send("TEAM_EVENT_USAGE", player);
|
||||||
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
|
||||||
if(!events.isEmpty()){
|
if(!events.isEmpty()){
|
||||||
@ -537,21 +462,21 @@ public class TeamCommand extends BasicCommand {
|
|||||||
for(Event e : events)
|
for(Event e : events)
|
||||||
Message.sendPrefixless("TEAM_EVENT_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
|
Message.sendPrefixless("TEAM_EVENT_EVENT", player, e.getStart().toLocalDateTime().format(dateFormat), e.getEventName());
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
return;
|
||||||
|
|
||||||
if(notDuringEvent(player))
|
if(notDuringEvent(player))
|
||||||
return;
|
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())){
|
if(Instant.now().isAfter(event.getDeadline().toInstant())){
|
||||||
Message.send("TEAM_EVENT_OVER", player);
|
Message.send("TEAM_EVENT_OVER", player);
|
||||||
return;
|
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(args.length == 1){
|
||||||
if(notInTeam(player, user))
|
if(notInTeam(player, user))
|
||||||
return;
|
return;
|
||||||
@ -613,17 +541,16 @@ public class TeamCommand extends BasicCommand {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){
|
@Register(value = "server", description = "TEAM_SERVER_USAGE")
|
||||||
if(notLeader(player, user, team))
|
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;
|
return;
|
||||||
if (PunishmentCommand.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
if (PunishmentCommand.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length < 2) {
|
|
||||||
Message.send("TEAM_SERVER_USAGE", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String server = args[1];
|
|
||||||
try {
|
try {
|
||||||
if (isLocalhost(InetAddress.getByName(server))) {
|
if (isLocalhost(InetAddress.getByName(server))) {
|
||||||
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
|
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
|
||||||
@ -633,19 +560,7 @@ public class TeamCommand extends BasicCommand {
|
|||||||
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
|
Message.send("TEAM_SERVER_ADDRESS_INVALID", player);
|
||||||
return;
|
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.setAddress(server);
|
||||||
team.setPort(port);
|
team.setPort(port);
|
||||||
Storage.teamServers.remove(team.getTeamId());
|
Storage.teamServers.remove(team.getTeamId());
|
||||||
@ -665,8 +580,11 @@ public class TeamCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeColor(ProxiedPlayer player, SteamwarUser user, Team team) {
|
@Register("color")
|
||||||
if(notLeader(player, user, team))
|
public void changeColor(ProxiedPlayer player) {
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
Team team = Team.get(user.getTeam());
|
||||||
|
if(notLeader(player, user))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(notDuringEvent(player))
|
if(notDuringEvent(player))
|
||||||
@ -687,12 +605,32 @@ public class TeamCommand extends BasicCommand {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkTeamName(ProxiedPlayer player, Team team, String arg){
|
@ClassMapper(Event.class)
|
||||||
if(arg.length() < 4 || arg.length() > 15){
|
public TypeMapper<Event> eventTypeMapper() {
|
||||||
Message.send("TEAM_NAME_LENGHT", player);
|
return new TypeMapper<Event>() {
|
||||||
return true;
|
@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);
|
Team t = Team.get(arg);
|
||||||
if(t != null && t.getTeamId() != team.getTeamId()){
|
if(t != null && t.getTeamId() != team.getTeamId()){
|
||||||
Message.send("TEAM_NAME_TAKEN", player);
|
Message.send("TEAM_NAME_TAKEN", player);
|
||||||
@ -702,11 +640,6 @@ public class TeamCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkTeamKuerzel(ProxiedPlayer player, Team team, String arg){
|
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);
|
Team t = Team.get(arg);
|
||||||
if(t != null && (team == null || t.getTeamId() != team.getTeamId())){
|
if(t != null && (team == null || t.getTeamId() != team.getTeamId())){
|
||||||
Message.send("TEAM_KUERZEL_TAKEN", player);
|
Message.send("TEAM_KUERZEL_TAKEN", player);
|
||||||
@ -731,7 +664,7 @@ public class TeamCommand extends BasicCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean notLeader(ProxiedPlayer player, SteamwarUser user, Team team){
|
private boolean notLeader(ProxiedPlayer player, SteamwarUser user){
|
||||||
if(notInTeam(player, user))
|
if(notInTeam(player, user))
|
||||||
return true;
|
return true;
|
||||||
if(!user.isLeader()){
|
if(!user.isLeader()){
|
||||||
@ -748,37 +681,4 @@ public class TeamCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
return false;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,29 +21,27 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
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() {
|
public TeamchatCommand() {
|
||||||
super("tc", "","teamchat");
|
super("tc", "","teamchat");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register(description = "TC_USAGE")
|
||||||
public void execute(CommandSender s, String[] args) {
|
public void genericCommand(ProxiedPlayer player, @ErrorMessage(value = "TC_USAGE", allowEAs = false) String... args) {
|
||||||
ChatSender sender = ChatSender.of(s);
|
ChatSender sender = ChatSender.of(player);
|
||||||
if(args.length == 0){
|
|
||||||
sender.system("TC_USAGE");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SteamwarUser user = sender.user();
|
SteamwarUser user = sender.user();
|
||||||
|
|
||||||
if(user.getTeam() == 0){
|
if(user.getTeam() == 0){
|
||||||
sender.system("TC_NO_TEAM");
|
sender.system("TC_NO_TEAM");
|
||||||
return;
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ import de.steamwar.sql.SteamwarUser;
|
|||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.bungeecore.util.BauLock;
|
import de.steamwar.bungeecore.util.BauLock;
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.sql.Event;
|
||||||
import net.md_5.bungee.BungeeCord;
|
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 net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TpCommand extends BasicCommand {
|
public class TpCommand extends SWCommand {
|
||||||
|
|
||||||
public TpCommand(){
|
public TpCommand(){
|
||||||
super("join", null, "tp", "teleport");
|
super("join", null, "tp", "teleport");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Register
|
||||||
public void execute(CommandSender s, String[] args) {
|
public void genericCommand(ProxiedPlayer p) {
|
||||||
if(!(s instanceof ProxiedPlayer))
|
ChatSender.of(p).system(Event.get() == null ? "TP_USAGE" : "TP_USAGE_EVENT");
|
||||||
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]);
|
@Register
|
||||||
boolean onTeamServer = Storage.teamServers.containsValue(player.getServer().getInfo());
|
public void teleportCommand(ProxiedPlayer p, @Mapper("to") String to, String... rest) {
|
||||||
|
ServerInfo server = getTarget(to);
|
||||||
|
|
||||||
//Give control of teleport command to server
|
//Give control of teleport command to server
|
||||||
if (server == player.getServer().getInfo() || onTeamServer || server == null) {
|
if (server == p.getServer().getInfo() || server == null) {
|
||||||
Chat19.chat(player, "/tp " + String.join(" ", args));
|
if (rest.length == 0) {
|
||||||
|
Chat19.chat(p, "/tp " + to);
|
||||||
|
} else {
|
||||||
|
Chat19.chat(p, "/tp " + to + " " + String.join(" ", rest));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
teleport(player, server);
|
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
|
@Override
|
||||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||||
if(args.length > 0)
|
List<String> list = new ArrayList<>();
|
||||||
return allPlayers(args[args.length - 1]);
|
for (ProxiedPlayer player : BungeeCord.getInstance().getPlayers()) {
|
||||||
return new ArrayList<>();
|
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){
|
public static void teleport(ProxiedPlayer player, ServerInfo server){
|
||||||
|
@ -120,7 +120,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
|||||||
ChatSender.of(sender).system(message, args);
|
ChatSender.of(sender).system(message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(help = true)
|
@Register(noTabComplete = true)
|
||||||
public void internalHelp(ProxiedPlayer p, String... args) {
|
public void internalHelp(ProxiedPlayer p, String... args) {
|
||||||
ChatSender chatSender = ChatSender.of(p);
|
ChatSender chatSender = ChatSender.of(p);
|
||||||
try {
|
try {
|
||||||
|
@ -446,13 +446,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cYou were removed from the team.
|
|||||||
#Team Kuerzel
|
#Team Kuerzel
|
||||||
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eshortcut§8]
|
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eshortcut§8]
|
||||||
TEAM_KUERZEL_CHANGED=§7You changed your teams shortcut!
|
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_KUERZEL_TAKEN=§cThere is already a team with that shortcut.
|
||||||
|
|
||||||
#Team Name
|
#Team Name
|
||||||
TEAM_NAME_USAGE=§8/§7team changename §8[§eteam name§8]
|
TEAM_NAME_USAGE=§8/§7team changename §8[§eteam name§8]
|
||||||
TEAM_NAME_CHANGED=§7You have renamed your team!
|
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_NAME_TAKEN=§cThere is already a team with that name.
|
||||||
|
|
||||||
#Team Leader
|
#Team Leader
|
||||||
|
@ -424,13 +424,13 @@ TEAM_REMOVE_REMOVED_TARGET=§cDu wurdest aus dem Team entfernt.
|
|||||||
#Team Kuerzel
|
#Team Kuerzel
|
||||||
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eTeamkürzel§8]
|
TEAM_KUERZEL_USAGE=§8/§7team changekuerzel §8[§eTeamkürzel§8]
|
||||||
TEAM_KUERZEL_CHANGED=§7Du hast das Kürzel des Teams geändert!
|
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_KUERZEL_TAKEN=§cEs gibt bereits ein Team mit diesem Namen.
|
||||||
|
|
||||||
#Team Name
|
#Team Name
|
||||||
TEAM_NAME_USAGE=§8/§7team changename §8[§eTeamname§8]
|
TEAM_NAME_USAGE=§8/§7team changename §8[§eTeamname§8]
|
||||||
TEAM_NAME_CHANGED=§7Du hast das Team umbenannt!
|
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_NAME_TAKEN=§cEs gibt bereits ein Team mit diesem Namen.
|
||||||
|
|
||||||
#Team Leader
|
#Team Leader
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren