Merge pull request 'Update EventRescheduleCommand' (#379) from CommandEventReschedule into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #379 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
2aee854b5c
@ -23,35 +23,29 @@ import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.sql.Event;
|
||||
import de.steamwar.bungeecore.sql.EventFight;
|
||||
import de.steamwar.bungeecore.sql.Team;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class EventRescheduleCommand extends BasicCommand {
|
||||
public class EventRescheduleCommand extends SWCommand {
|
||||
|
||||
public EventRescheduleCommand() {
|
||||
super("eventreschedule", "bungeecore.softreload");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!(sender instanceof ProxiedPlayer))
|
||||
return;
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
|
||||
if(args.length != 2){
|
||||
Message.send("EVENTRESCHEDULE_USAGE", player);
|
||||
return;
|
||||
}
|
||||
|
||||
Team teamBlue = Team.get(args[0]);
|
||||
Team teamRed = Team.get(args[1]);
|
||||
@Register
|
||||
public void reschedule(ProxiedPlayer player, Team teamBlue, Team teamRed) {
|
||||
Event event = Event.get();
|
||||
if(teamBlue == null || teamRed == null || event == null){
|
||||
if(event == null){
|
||||
Message.send("EVENTRESCHEDULE_UNKNOWN_TEAM", player);
|
||||
return;
|
||||
}
|
||||
@ -74,4 +68,22 @@ public class EventRescheduleCommand extends BasicCommand {
|
||||
|
||||
Message.send("EVENTRESCHEDULE_NO_FIGHT", player);
|
||||
}
|
||||
|
||||
@Register
|
||||
public TypeMapper<Team> teamTypeMapper() {
|
||||
return new TypeMapper<Team>() {
|
||||
@Override
|
||||
public Team map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return Team.get(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||
Event event = Event.get();
|
||||
if (event == null) return null;
|
||||
List<EventFight> fights = EventFight.getEvent(event.getEventID());
|
||||
return fights.stream().flatMap(fight -> Stream.of(fight.getTeamBlue(), fight.getTeamRed())).map(Team::get).map(Team::getTeamKuerzel).distinct().collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren