geforkt von SteamWar/BungeeCore
Fix another one
Dieser Commit ist enthalten in:
Ursprung
87db98a310
Commit
ba064a1f9e
@ -24,7 +24,9 @@ import de.steamwar.bungeecore.Storage;
|
|||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||||
import de.steamwar.bungeecore.sql.*;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@ -42,10 +44,7 @@ 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;
|
||||||
@ -445,23 +444,28 @@ public class TeamCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register("event")
|
@Register("event")
|
||||||
public void event(ProxiedPlayer player, String... args){
|
public void event(ProxiedPlayer player) {
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
Team team = Team.get(user.getTeam());
|
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()){
|
Message.send("TEAM_EVENT_HEADER", player);
|
||||||
Message.send("TEAM_EVENT_HEADER", player);
|
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player));
|
||||||
DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(Message.parse("EVENT_DATE_FORMAT", player));
|
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;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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))
|
if(notLeader(player, user))
|
||||||
return;
|
return;
|
||||||
@ -469,12 +473,6 @@ public class TeamCommand extends SWCommand {
|
|||||||
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;
|
||||||
@ -603,6 +601,31 @@ public class TeamCommand extends SWCommand {
|
|||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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){
|
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()){
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren