From b63b5f021c8b164d301b0de9efd1cb150cc9304c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 30 Oct 2020 08:03:11 +0100 Subject: [PATCH 1/3] Shorten name for ranked matches Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/SubserverSystem.java | 8 ++++++-- src/de/steamwar/bungeecore/commands/RankedCommand.java | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 66493aa..1f83898 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -82,8 +82,12 @@ public class SubserverSystem { //Generate missing parameters int port = freePort(2500); - if(serverName == null) - serverName = modus.getDisplayName() + (port - 2500); + if(serverName == null){ + if(ranked) + serverName = "Ranked" + (port - 2500); + else + serverName = modus.getDisplayName() + (port - 2500); + } if(mapName == null) mapName = serverName; diff --git a/src/de/steamwar/bungeecore/commands/RankedCommand.java b/src/de/steamwar/bungeecore/commands/RankedCommand.java index 5626f09..3f0914a 100644 --- a/src/de/steamwar/bungeecore/commands/RankedCommand.java +++ b/src/de/steamwar/bungeecore/commands/RankedCommand.java @@ -165,12 +165,11 @@ public class RankedCommand extends BasicCommand { removeFromAll(wp1.player); removeFromAll(wp2.player); - String serverName = wp1.player.getName() + " vs " + wp2.player.getName(); - Subserver arena = SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, serverName, serverName.replace(' ', '_'), wp1.player.getUniqueId(), wp2.player.getUniqueId(), true); + Subserver arena = SubserverSystem.startArena(mode, mode.getRandomMap(), 0, 0, null, null, wp1.player.getUniqueId(), wp2.player.getUniqueId(), true); arena.sendPlayer(wp1.player); arena.sendPlayer(wp2.player); - BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7" + mode.getDisplayName() + "§8-§7Ranglistenspiel§8: §e" + serverName, + BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7" + mode.getDisplayName() + "§8-§7Ranglistenspiel§8: §e" + wp1.player.getName() + " vs " + wp2.player.getName(), "§aZuschauen", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + wp1.player.getName())); } From f39b7787d98120736193aa43df65718b923f2fd5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 30 Oct 2020 14:49:45 +0100 Subject: [PATCH 2/3] Implementing event mode for event bungee Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 23 +++++++----- src/de/steamwar/bungeecore/EventStarter.java | 4 +++ .../bungeecore/commands/BauCommand.java | 3 ++ .../listeners/EventModeListener.java | 36 +++++++++++++++++++ src/de/steamwar/bungeecore/sql/Event.java | 5 +++ 5 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 src/de/steamwar/bungeecore/listeners/EventModeListener.java diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 466f971..25ccdf6 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -62,6 +62,7 @@ public class BungeeCore extends Plugin { public static String LOBBY_SERVER; public static String USERWORLDS15; public static String BAUWELT15; + public static boolean EVENT_MODE; private static BungeeCore instance; @@ -97,17 +98,14 @@ public class BungeeCore extends Plugin { new MsgCommand(); new RCommand(); new PingCommand(); - new WebregisterCommand(); new AlertCommand(); new KickCommand(); new JoinmeCommand(); new TpCommand(); - new FightCommand(); new HelpCommand(); new BanCommand(); new UnbanCommand(); new DenyCommand("watchcat", "wc"); - new ChallengeCommand(); new TeamCommand(); new ServerTeamchatCommand(); new EventCommand(); @@ -118,18 +116,26 @@ public class BungeeCore extends Plugin { new BugCommand(); new WhoisCommand(); new RegelnCommand(); - new HistoricCommand(); - new CheckCommand(); - new RankedCommand(); new RankCommand(); new IgnoreCommand(); 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 Broadcaster(); new SessionManager(); new SpigotReceiver(); - new TablistManager(); getProxy().getScheduler().schedule(this, () -> { @@ -226,6 +232,7 @@ public class BungeeCore extends Plugin { LOBBY_SERVER = config.getString("lobbyserver"); USERWORLDS15 = config.getString("userworlds15"); BAUWELT15 = config.getString("bauwelt15"); + EVENT_MODE = config.getBoolean("eventmode"); Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1])); PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers")); CheckCommand.loadCheckQuestions(config.getSection("checkquestions")); diff --git a/src/de/steamwar/bungeecore/EventStarter.java b/src/de/steamwar/bungeecore/EventStarter.java index e2a44f8..9cb1eaf 100644 --- a/src/de/steamwar/bungeecore/EventStarter.java +++ b/src/de/steamwar/bungeecore/EventStarter.java @@ -19,6 +19,7 @@ package de.steamwar.bungeecore; +import de.steamwar.bungeecore.sql.Event; import de.steamwar.bungeecore.sql.EventFight; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.Team; @@ -58,6 +59,9 @@ public class EventStarter implements Runnable { EventFight next; 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 red = Team.get(next.getTeamRed()); String serverName = blue.getTeamKuerzel() + " vs " + red.getTeamKuerzel(); diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 045e1bb..3385650 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -37,6 +37,9 @@ public class BauCommand { private static final String UNKNOWN_PLAYER = BungeeCore.CHAT_PREFIX + "§cUnbekannter Spieler"; public static void onBau(ChatEvent e, String[] command){ + if(BungeeCore.EVENT_MODE) + return; + ProxiedPlayer p = (ProxiedPlayer) e.getSender(); Subserver server = Subserver.getSubserver(p); Bauserver bau = (server != null && server.getType() == Servertype.BAUSERVER) ? (Bauserver)server : null; diff --git a/src/de/steamwar/bungeecore/listeners/EventModeListener.java b/src/de/steamwar/bungeecore/listeners/EventModeListener.java new file mode 100644 index 0000000..c5bc256 --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/EventModeListener.java @@ -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); + } +} diff --git a/src/de/steamwar/bungeecore/sql/Event.java b/src/de/steamwar/bungeecore/sql/Event.java index fae76cd..336128e 100644 --- a/src/de/steamwar/bungeecore/sql/Event.java +++ b/src/de/steamwar/bungeecore/sql/Event.java @@ -36,6 +36,7 @@ public class Event { private final Timestamp end; private final int maximumTeamMembers; private final boolean publicSchemsOnly; + private final boolean spectateSystem; private static Event current = null; @@ -46,6 +47,7 @@ public class Event { this.end = rs.getTimestamp("End"); this.maximumTeamMembers = rs.getInt("MaximumTeamMembers"); this.publicSchemsOnly = rs.getBoolean("PublicSchemsOnly"); + this.spectateSystem = rs.getBoolean("SpectateSystem"); } public static Event get(){ @@ -128,4 +130,7 @@ public class Event { public boolean publicSchemsOnly() { return publicSchemsOnly; } + public boolean spectateSystem(){ + return spectateSystem; + } } From 84c2c2f825b83ccc091a8cbb986b0615c5aaa4a0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 30 Oct 2020 15:16:34 +0100 Subject: [PATCH 3/3] Fix port clash Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/SubserverSystem.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 66493aa..3fcb39a 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -41,6 +41,15 @@ public class SubserverSystem { private static final String SERVER_PATH = BACKBONE + "server/"; 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). * @@ -80,10 +89,10 @@ 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){ //Generate missing parameters - int port = freePort(2500); + int port = freePort(firstArenaPort); if(serverName == null) - serverName = modus.getDisplayName() + (port - 2500); + serverName = modus.getDisplayName() + (port - firstArenaPort); if(mapName == null) mapName = serverName;