SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Use new Referee table, Multi spectate server support' (#510) from wargearseason into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #510
Dieser Commit ist enthalten in:
Lixfel 2024-03-14 09:34:30 +01:00
Commit 1c99a9fb4b
4 geänderte Dateien mit 20 neuen und 29 gelöschten Zeilen

@ -1 +1 @@
Subproject commit bfc72ddcb77199bbb8eb19bdfc50744f7234745a
Subproject commit a473e59048a73aae4b40ecb5d6d6b79f0791a138

Datei anzeigen

@ -312,6 +312,10 @@ public class BungeeCore extends Plugin {
final Configuration server = servers.getSection(serverName);
List<String> cmds = server.getStringList("commands");
String cmd = cmds.remove(0);
if(server.contains("spectatePort"))
EventStarter.addSpectateServer(server.getInt("spectatePort"), cmd);
new ServerSwitchCommand(
cmd,
serverName,

Datei anzeigen

@ -20,40 +20,36 @@
package de.steamwar.bungeecore;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import de.steamwar.sql.Event;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.scheduler.ScheduledTask;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.TimeUnit;
import static de.steamwar.bungeecore.Storage.eventServer;
public class EventStarter implements Runnable {
public class EventStarter {
private static ScheduledTask task = null;
private static final Map<Integer, String> spectatePorts = new HashMap<>();
EventStarter(){
public static void addSpectateServer(int port, String command) {
spectatePorts.put(port, command);
}
public EventStarter() {
EventFight.loadAllComingFights();
if(task != null)
task.cancel();
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this, 1, 10, TimeUnit.SECONDS);
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::run, 1, 10, TimeUnit.SECONDS);
}
public static Map<Integer, Subserver> getEventServer() {
return eventServer;
}
@Override
public void run() {
private void run() {
eventServer.entrySet().removeIf(entry -> Subserver.getSubserver(entry.getValue().getServer()) == null);
Queue<EventFight> fights = EventFight.getFights();
@ -63,13 +59,9 @@ public class EventStarter implements Runnable {
Team red = Team.get(next.getTeamRed());
//Don't start EventServer if not the event bungee
if(BungeeCore.EVENT_MODE || !Event.get(next.getEventID()).spectateSystem()) {
if(BungeeCore.EVENT_MODE || next.getSpectatePort() == 0) {
ServerStarter starter = new ServerStarter().event(next);
ProxiedPlayer leiter = ProxyServer.getInstance().getPlayer(SteamwarUser.get(next.getKampfleiter()).getUUID());
if(leiter != null)
starter.send(leiter);
starter.callback(subserver -> {
eventServer.put(blue.getTeamId(), subserver);
eventServer.put(red.getTeamId(), subserver);
@ -79,7 +71,7 @@ public class EventStarter implements Runnable {
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/event " + blue.getTeamKuerzel()), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
} else {
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/spectate"), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + spectatePorts.get(next.getSpectatePort())), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
}
}
}

Datei anzeigen

@ -1,10 +1,7 @@
package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.Message;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.TeamTeilnahme;
import de.steamwar.sql.Event;
import de.steamwar.sql.*;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.event.EventHandler;
@ -24,10 +21,8 @@ public class EventModeListener extends BasicListener {
if(TeamTeilnahme.nimmtTeil(user.getTeam(), event.getEventID()))
return;
for(EventFight eventFight : EventFight.getEvent(event.getEventID())){
if(eventFight.getKampfleiter() == user.getId())
return;
}
if(Referee.get(event.getEventID()).contains(user.getId()))
return;
e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.parse("EVENTMODE_KICK", e.getPlayer())));
}