SteamWar/BungeeCore
Archiviert
13
2

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 EventCommand();
new EventreloadCommand();
new EventRescheduleCommand();
new PollCommand();
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;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.SubserverSystem;
import de.steamwar.bungeecore.ArenaMode;
import de.steamwar.bungeecore.*;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
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, "§7Leader§8: " + SteamwarUser.get(team.getTeamLeader()).getUserName());
StringBuilder sb = new StringBuilder();
sb.append("§7Member§8: §e");
List<Integer> members = team.getMembers();
for(int i : members){
SteamwarUser m = SteamwarUser.get(i);
sb.append(m.getUserName()).append(" ");
if(team.getMembers().size() > 1) {
StringBuilder sb = new StringBuilder();
sb.append("§7Member§8: §e");
List<Integer> members = team.getMembers();
for (int i : members) {
if (i == team.getTeamLeader())
continue;
SteamwarUser m = SteamwarUser.get(i);
sb.append(m.getUserName()).append(" ");
}
BungeeCore.send(player, sb.toString());
}
BungeeCore.send(player, sb.toString());
Set<Event> events = TeamTeilnahme.getEvents(team.getTeamId());
if(!events.isEmpty()){
sb = new StringBuilder("§7Events§8: §e");
StringBuilder sb = new StringBuilder("§7Events§8: §e");
for(Event e : events)
sb.append(e.getEventName()).append(" ");
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.util.*;
import static java.time.temporal.ChronoUnit.SECONDS;
public class EventFight implements Comparable<EventFight> {
private static Queue<EventFight> fights = new PriorityQueue<>();
private int eventID;
private int fightID;
private final int eventID;
private final int fightID;
private Timestamp startTime;
private ArenaMode spielmodus;
private String map;
private int teamBlue;
private int teamRed;
private int kampfleiter;
private int ergebnis;
private final ArenaMode spielmodus;
private final String map;
private final int teamBlue;
private final int teamRed;
private final int kampfleiter;
private final int ergebnis;
private EventFight(int eventID, int fightID, Timestamp startTime, ArenaMode spielmodus, String map, int teamBlue, int teamRed, int kampfleiter, int ergebnis){
this.eventID = eventID;
this.fightID = fightID;
this.startTime = startTime;
this.spielmodus = spielmodus;
this.map = map;
this.teamBlue = teamBlue;
this.teamRed = teamRed;
this.kampfleiter = kampfleiter;
this.ergebnis = ergebnis;
private EventFight(ResultSet rs) throws SQLException {
eventID = rs.getInt("EventID");
fightID = rs.getInt("FightID");
startTime = rs.getTimestamp("StartTime");
spielmodus = ArenaMode.valueOf(rs.getString("Spielmodus"));
map = rs.getString("Map");
teamBlue = rs.getInt("TeamBlue");
teamRed = rs.getInt("TeamRed");
kampfleiter = rs.getInt("Kampfleiter");
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(){
@ -39,16 +46,7 @@ public class EventFight implements Comparable<EventFight> {
fights.clear();
try{
while(rs.next()){
fights.add(new EventFight(
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")));
fights.add(new EventFight(rs));
}
}catch (SQLException e){
BungeeCore.log("Failed to load EventFights", e);
@ -60,16 +58,7 @@ public class EventFight implements Comparable<EventFight> {
List<EventFight> fights = new LinkedList<>();
try{
while(rs.next())
fights.add(new EventFight(
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")));
fights.add(new EventFight(rs));
}catch (SQLException e){
BungeeCore.log("Failed to load EventFights", e);
}