Archiviert
1
0

Merge pull request 'Implementing event mode for event bungee' (#142) from eventMode into master

Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Lixfel 2020-10-30 21:53:39 +01:00
Commit 351a134e1e
6 geänderte Dateien mit 75 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -62,6 +62,7 @@ public class BungeeCore extends Plugin {
public static String LOBBY_SERVER; public static String LOBBY_SERVER;
public static String USERWORLDS15; public static String USERWORLDS15;
public static String BAUWELT15; public static String BAUWELT15;
public static boolean EVENT_MODE;
private static BungeeCore instance; private static BungeeCore instance;
@ -97,17 +98,14 @@ public class BungeeCore extends Plugin {
new MsgCommand(); new MsgCommand();
new RCommand(); new RCommand();
new PingCommand(); new PingCommand();
new WebregisterCommand();
new AlertCommand(); new AlertCommand();
new KickCommand(); new KickCommand();
new JoinmeCommand(); new JoinmeCommand();
new TpCommand(); new TpCommand();
new FightCommand();
new HelpCommand(); new HelpCommand();
new BanCommand(); new BanCommand();
new UnbanCommand(); new UnbanCommand();
new DenyCommand("watchcat", "wc"); new DenyCommand("watchcat", "wc");
new ChallengeCommand();
new TeamCommand(); new TeamCommand();
new ServerTeamchatCommand(); new ServerTeamchatCommand();
new EventCommand(); new EventCommand();
@ -118,18 +116,26 @@ public class BungeeCore extends Plugin {
new BugCommand(); new BugCommand();
new WhoisCommand(); new WhoisCommand();
new RegelnCommand(); new RegelnCommand();
new HistoricCommand();
new CheckCommand();
new RankedCommand();
new RankCommand(); new RankCommand();
new IgnoreCommand(); new IgnoreCommand();
new UnIgnoreCommand(); new UnIgnoreCommand();
if(!EVENT_MODE){
new WebregisterCommand();
new FightCommand();
new ChallengeCommand();
new HistoricCommand();
new CheckCommand();
new RankedCommand();
new Broadcaster();
}else{
new EventModeListener();
}
new EventStarter(); new EventStarter();
new Broadcaster();
new SessionManager(); new SessionManager();
new SpigotReceiver(); new SpigotReceiver();
new TablistManager(); new TablistManager();
getProxy().getScheduler().schedule(this, () -> { getProxy().getScheduler().schedule(this, () -> {
@ -226,6 +232,7 @@ public class BungeeCore extends Plugin {
LOBBY_SERVER = config.getString("lobbyserver"); LOBBY_SERVER = config.getString("lobbyserver");
USERWORLDS15 = config.getString("userworlds15"); USERWORLDS15 = config.getString("userworlds15");
BAUWELT15 = config.getString("bauwelt15"); BAUWELT15 = config.getString("bauwelt15");
EVENT_MODE = config.getBoolean("eventmode");
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1])); Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers")); PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
CheckCommand.loadCheckQuestions(config.getSection("checkquestions")); CheckCommand.loadCheckQuestions(config.getSection("checkquestions"));

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bungeecore; package de.steamwar.bungeecore;
import de.steamwar.bungeecore.sql.Event;
import de.steamwar.bungeecore.sql.EventFight; import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.Team;
@ -58,6 +59,9 @@ public class EventStarter implements Runnable {
EventFight next; EventFight next;
while((next = nextFight(fights)) != null){ while((next = nextFight(fights)) != null){
if(!BungeeCore.EVENT_MODE && Event.get(next.getEventID()).spectateSystem())
break; //Don't start EventServer if not the event bungee
Team blue = Team.get(next.getTeamBlue()); Team blue = Team.get(next.getTeamBlue());
Team red = Team.get(next.getTeamRed()); Team red = Team.get(next.getTeamRed());
String serverName = blue.getTeamKuerzel() + " vs " + red.getTeamKuerzel(); String serverName = blue.getTeamKuerzel() + " vs " + red.getTeamKuerzel();

Datei anzeigen

@ -41,6 +41,15 @@ public class SubserverSystem {
private static final String SERVER_PATH = BACKBONE + "server/"; private static final String SERVER_PATH = BACKBONE + "server/";
private static final String EVENT_PATH = BACKBONE + "event/"; private static final String EVENT_PATH = BACKBONE + "event/";
private static final int firstArenaPort;
static {
if(BungeeCore.EVENT_MODE)
firstArenaPort = 6000;
else
firstArenaPort = 2500;
}
/** /**
* This function starts every arena (even test- and eventarenas). * This function starts every arena (even test- and eventarenas).
* *
@ -80,13 +89,13 @@ public class SubserverSystem {
*/ */
public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, String serverName, String mapName, UUID player1, UUID player2, boolean ranked){ public static Subserver startArena(ArenaMode modus, String map, int eventFightID, int checkSchemID, String serverName, String mapName, UUID player1, UUID player2, boolean ranked){
//Generate missing parameters //Generate missing parameters
int port = freePort(2500); int port = freePort(firstArenaPort);
if(serverName == null){ if(serverName == null){
if(ranked) if(ranked)
serverName = "Ranked" + (port - 2500); serverName = "Ranked" + (port - firstArenaPort);
else else
serverName = modus.getDisplayName() + (port - 2500); serverName = modus.getDisplayName() + (port - firstArenaPort);
} }
if(mapName == null) if(mapName == null)
mapName = serverName; mapName = serverName;

Datei anzeigen

@ -37,6 +37,9 @@ public class BauCommand {
private static final String UNKNOWN_PLAYER = BungeeCore.CHAT_PREFIX + "§cUnbekannter Spieler"; private static final String UNKNOWN_PLAYER = BungeeCore.CHAT_PREFIX + "§cUnbekannter Spieler";
public static void onBau(ChatEvent e, String[] command){ public static void onBau(ChatEvent e, String[] command){
if(BungeeCore.EVENT_MODE)
return;
ProxiedPlayer p = (ProxiedPlayer) e.getSender(); ProxiedPlayer p = (ProxiedPlayer) e.getSender();
Subserver server = Subserver.getSubserver(p); Subserver server = Subserver.getSubserver(p);
Bauserver bau = (server != null && server.getType() == Servertype.BAUSERVER) ? (Bauserver)server : null; Bauserver bau = (server != null && server.getType() == Servertype.BAUSERVER) ? (Bauserver)server : null;

Datei anzeigen

@ -0,0 +1,36 @@
package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.sql.Event;
import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.TeamTeilnahme;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.event.EventHandler;
public class EventModeListener extends BasicListener {
private static final BaseComponent[] nonParticipant = TextComponent.fromLegacyText("§cDu bist kein Eventteilnehmer.");
@EventHandler
public void onPostLogin(PostLoginEvent e) {
SteamwarUser user = SteamwarUser.get(e.getPlayer().getUniqueId());
Event event = Event.get();
if(event == null){
e.getPlayer().disconnect(nonParticipant);
return;
}
if(TeamTeilnahme.nimmtTeil(user.getTeam(), event.getEventID()))
return;
for(EventFight eventFight : EventFight.getEvent(event.getEventID())){
if(eventFight.getKampfleiter() == user.getId())
return;
}
e.getPlayer().disconnect(nonParticipant);
}
}

Datei anzeigen

@ -36,6 +36,7 @@ public class Event {
private final Timestamp end; private final Timestamp end;
private final int maximumTeamMembers; private final int maximumTeamMembers;
private final boolean publicSchemsOnly; private final boolean publicSchemsOnly;
private final boolean spectateSystem;
private static Event current = null; private static Event current = null;
@ -46,6 +47,7 @@ public class Event {
this.end = rs.getTimestamp("End"); this.end = rs.getTimestamp("End");
this.maximumTeamMembers = rs.getInt("MaximumTeamMembers"); this.maximumTeamMembers = rs.getInt("MaximumTeamMembers");
this.publicSchemsOnly = rs.getBoolean("PublicSchemsOnly"); this.publicSchemsOnly = rs.getBoolean("PublicSchemsOnly");
this.spectateSystem = rs.getBoolean("SpectateSystem");
} }
public static Event get(){ public static Event get(){
@ -128,4 +130,7 @@ public class Event {
public boolean publicSchemsOnly() { public boolean publicSchemsOnly() {
return publicSchemsOnly; return publicSchemsOnly;
} }
public boolean spectateSystem(){
return spectateSystem;
}
} }