Merge pull request 'Use new Referee table, Multi spectate server support' (#510) from wargearseason into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #510
Dieser Commit ist enthalten in:
Commit
1c99a9fb4b
@ -1 +1 @@
|
|||||||
Subproject commit bfc72ddcb77199bbb8eb19bdfc50744f7234745a
|
Subproject commit a473e59048a73aae4b40ecb5d6d6b79f0791a138
|
@ -312,6 +312,10 @@ public class BungeeCore extends Plugin {
|
|||||||
final Configuration server = servers.getSection(serverName);
|
final Configuration server = servers.getSection(serverName);
|
||||||
List<String> cmds = server.getStringList("commands");
|
List<String> cmds = server.getStringList("commands");
|
||||||
String cmd = cmds.remove(0);
|
String cmd = cmds.remove(0);
|
||||||
|
|
||||||
|
if(server.contains("spectatePort"))
|
||||||
|
EventStarter.addSpectateServer(server.getInt("spectatePort"), cmd);
|
||||||
|
|
||||||
new ServerSwitchCommand(
|
new ServerSwitchCommand(
|
||||||
cmd,
|
cmd,
|
||||||
serverName,
|
serverName,
|
||||||
|
@ -20,40 +20,36 @@
|
|||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import de.steamwar.sql.Event;
|
|
||||||
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;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static de.steamwar.bungeecore.Storage.eventServer;
|
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();
|
EventFight.loadAllComingFights();
|
||||||
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this::run, 1, 10, TimeUnit.SECONDS);
|
||||||
if(task != null)
|
|
||||||
task.cancel();
|
|
||||||
|
|
||||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this, 1, 10, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Integer, Subserver> getEventServer() {
|
public static Map<Integer, Subserver> getEventServer() {
|
||||||
return eventServer;
|
return eventServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void run() {
|
||||||
public void run() {
|
|
||||||
eventServer.entrySet().removeIf(entry -> Subserver.getSubserver(entry.getValue().getServer()) == null);
|
eventServer.entrySet().removeIf(entry -> Subserver.getSubserver(entry.getValue().getServer()) == null);
|
||||||
Queue<EventFight> fights = EventFight.getFights();
|
Queue<EventFight> fights = EventFight.getFights();
|
||||||
|
|
||||||
@ -63,13 +59,9 @@ public class EventStarter implements Runnable {
|
|||||||
Team red = Team.get(next.getTeamRed());
|
Team red = Team.get(next.getTeamRed());
|
||||||
|
|
||||||
//Don't start EventServer if not the event bungee
|
//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);
|
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 -> {
|
starter.callback(subserver -> {
|
||||||
eventServer.put(blue.getTeamId(), subserver);
|
eventServer.put(blue.getTeamId(), subserver);
|
||||||
eventServer.put(red.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());
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/event " + blue.getTeamKuerzel()), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||||
} else {
|
} else {
|
||||||
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.*;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.TeamTeilnahme;
|
|
||||||
import de.steamwar.sql.Event;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
@ -24,10 +21,8 @@ public class EventModeListener extends BasicListener {
|
|||||||
if(TeamTeilnahme.nimmtTeil(user.getTeam(), event.getEventID()))
|
if(TeamTeilnahme.nimmtTeil(user.getTeam(), event.getEventID()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(EventFight eventFight : EventFight.getEvent(event.getEventID())){
|
if(Referee.get(event.getEventID()).contains(user.getId()))
|
||||||
if(eventFight.getKampfleiter() == user.getId())
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.parse("EVENTMODE_KICK", e.getPlayer())));
|
e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.parse("EVENTMODE_KICK", e.getPlayer())));
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren