Archiviert
1
0

Teamlist fix + Eventreschedule (unteseted) + TpCommand begin (unused)

Dieser Commit ist enthalten in:
Lixfel 2019-10-29 20:02:41 +01:00
Ursprung f55d8e3415
Commit 322ed3eda7
6 geänderte Dateien mit 143 neuen und 51 gelöschten Zeilen

Datei anzeigen

@ -81,6 +81,7 @@ public class BungeeCore extends Plugin {
new ForgeCommand(); new ForgeCommand();
new EventCommand(); new EventCommand();
new EventreloadCommand(); new EventreloadCommand();
new EventRescheduleCommand();
new PollCommand(); new PollCommand();
new MuteCommand(); new MuteCommand();

Datei anzeigen

@ -0,0 +1,58 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.sql.Event;
import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.bungeecore.sql.Team;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.ListIterator;
public class EventRescheduleCommand extends BasicCommand {
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){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c/eventreschedule [Team1 (Blue)] [Team2 (Red)]");
return;
}
Team teamBlue = Team.get(args[0]);
Team teamRed = Team.get(args[1]);
Event event = Event.get();
if(teamBlue == null || teamRed == null || event == null){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cEin Team ist unbekannt / Derzeit kein Event");
return;
}
List<EventFight> fights = EventFight.getEvent(event.getEventID());
ListIterator<EventFight> it = fights.listIterator(fights.size());
Timestamp now = Timestamp.from(new Date().toInstant());
while(it.hasPrevious()){
EventFight fight = it.previous();
if(fight.getStartTime().after(now))
continue;
if(fight.getTeamBlue() == teamBlue.getTeamId() && fight.getTeamRed() == teamRed.getTeamId()){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§aKampf startet in 30s");
fight.reschedule();
EventFight.loadAllComingFights();
return;
}
}
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cKein Kampf zwischen den Teams gefunden");
}
}

Datei anzeigen

@ -1,10 +1,6 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.SubserverSystem;
import de.steamwar.bungeecore.ArenaMode;
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.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;

Datei anzeigen

@ -344,18 +344,22 @@ public class TeamCommand extends BasicCommand {
BungeeCore.send(player, "§7Team §e" + team.getTeamName() + " §8[§e" + team.getTeamKuerzel() + "§8]"); BungeeCore.send(player, "§7Team §e" + team.getTeamName() + " §8[§e" + team.getTeamKuerzel() + "§8]");
BungeeCore.send(player, "§7Leader§8: " + SteamwarUser.get(team.getTeamLeader()).getUserName()); BungeeCore.send(player, "§7Leader§8: " + SteamwarUser.get(team.getTeamLeader()).getUserName());
if(team.getMembers().size() > 1) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("§7Member§8: §e"); sb.append("§7Member§8: §e");
List<Integer> members = team.getMembers(); List<Integer> members = team.getMembers();
for (int i : members) { for (int i : members) {
if (i == team.getTeamLeader())
continue;
SteamwarUser m = SteamwarUser.get(i); SteamwarUser m = SteamwarUser.get(i);
sb.append(m.getUserName()).append(" "); sb.append(m.getUserName()).append(" ");
} }
BungeeCore.send(player, sb.toString()); BungeeCore.send(player, sb.toString());
}
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId()); Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
if(!events.isEmpty()){ if(!events.isEmpty()){
sb = new StringBuilder("§7Events§8: §e"); StringBuilder sb = new StringBuilder("§7Events§8: §e");
for(Event e : events) for(Event e : events)
sb.append(e.getEventName()).append(" "); sb.append(e.getEventName()).append(" ");
BungeeCore.send(player, sb.toString()); BungeeCore.send(player, sb.toString());

Datei anzeigen

@ -0,0 +1,44 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ChatEvent;
public class TpCommand {
private TpCommand(){}
public static void onTp(ChatEvent e, String[] command){
if(!(e.getSender() instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
if(command.length == 1){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c/tp [Spieler]");
e.setCancelled(true);
return;
}
SteamwarUser user = SteamwarUser.get(player);
if(user == null){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cUnbekannter Spieler");
e.setCancelled(true);
return;
}
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(user.getUuid());
if(target == null){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist derzeit offline");
e.setCancelled(true);
return;
}
if(target.getServer() == player.getServer())
return;
e.setCancelled(true);
//TODO: Implement Joinme-Command Option
}
}

Datei anzeigen

@ -8,30 +8,37 @@ import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.*; import java.util.*;
import static java.time.temporal.ChronoUnit.SECONDS;
public class EventFight implements Comparable<EventFight> { public class EventFight implements Comparable<EventFight> {
private static Queue<EventFight> fights = new PriorityQueue<>(); private static Queue<EventFight> fights = new PriorityQueue<>();
private int eventID; private final int eventID;
private int fightID; private final int fightID;
private Timestamp startTime; private Timestamp startTime;
private ArenaMode spielmodus; private final ArenaMode spielmodus;
private String map; private final String map;
private int teamBlue; private final int teamBlue;
private int teamRed; private final int teamRed;
private int kampfleiter; private final int kampfleiter;
private int ergebnis; private final int ergebnis;
private EventFight(int eventID, int fightID, Timestamp startTime, ArenaMode spielmodus, String map, int teamBlue, int teamRed, int kampfleiter, int ergebnis){ private EventFight(ResultSet rs) throws SQLException {
this.eventID = eventID; eventID = rs.getInt("EventID");
this.fightID = fightID; fightID = rs.getInt("FightID");
this.startTime = startTime; startTime = rs.getTimestamp("StartTime");
this.spielmodus = spielmodus; spielmodus = ArenaMode.valueOf(rs.getString("Spielmodus"));
this.map = map; map = rs.getString("Map");
this.teamBlue = teamBlue; teamBlue = rs.getInt("TeamBlue");
this.teamRed = teamRed; teamRed = rs.getInt("TeamRed");
this.kampfleiter = kampfleiter; kampfleiter = rs.getInt("Kampfleiter");
this.ergebnis = ergebnis; ergebnis = rs.getInt("Ergebnis");
}
public void reschedule(){
startTime = Timestamp.from(new Date().toInstant().plus(30, SECONDS));
SQL.update("UPDATE EventFight SET StartTime = '" + startTime.toString() + "' WHERE EventID = " + eventID + " AND FightID = " + fightID);
} }
public static void loadAllComingFights(){ public static void loadAllComingFights(){
@ -39,16 +46,7 @@ public class EventFight implements Comparable<EventFight> {
fights.clear(); fights.clear();
try{ try{
while(rs.next()){ while(rs.next()){
fights.add(new EventFight( fights.add(new EventFight(rs));
rs.getInt("EventID"),
rs.getInt("FightID"),
rs.getTimestamp("StartTime"),
ArenaMode.valueOf(rs.getString("Spielmodus")),
rs.getString("Map"),
rs.getInt("TeamBlue"),
rs.getInt("TeamRed"),
rs.getInt("Kampfleiter"),
rs.getInt("Ergebnis")));
} }
}catch (SQLException e){ }catch (SQLException e){
BungeeCore.log("Failed to load EventFights", e); BungeeCore.log("Failed to load EventFights", e);
@ -60,16 +58,7 @@ public class EventFight implements Comparable<EventFight> {
List<EventFight> fights = new LinkedList<>(); List<EventFight> fights = new LinkedList<>();
try{ try{
while(rs.next()) while(rs.next())
fights.add(new EventFight( fights.add(new EventFight(rs));
eventID,
rs.getInt("FightID"),
rs.getTimestamp("StartTime"),
ArenaMode.valueOf(rs.getString("Spielmodus")),
rs.getString("Map"),
rs.getInt("TeamBlue"),
rs.getInt("TeamRed"),
rs.getInt("Kampfleiter"),
rs.getInt("Ergebnis")));
}catch (SQLException e){ }catch (SQLException e){
BungeeCore.log("Failed to load EventFights", e); BungeeCore.log("Failed to load EventFights", e);
} }