From b60422245088aa26a52fc8a957592a4474078f65 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 5 Sep 2021 18:47:04 +0200 Subject: [PATCH] Deny launching multiple bauservers Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/BauCommand.java | 11 ++++++----- .../steamwar/bungeecore/commands/CheckCommand.java | 13 ++++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index d50f7a76..e8274273 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -261,12 +261,12 @@ public class BauCommand extends BasicCommand { }); } - public static void stopBauserver(ProxiedPlayer p){ + public static boolean stopBauserver(ProxiedPlayer p){ for (Subserver subserver : Subserver.getServerList()) { if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId())) { - if(subserver.getServer().getPlayers().isEmpty()){ + if(!subserver.hasStarted()){ Message.send("BAU_START_ALREADY", p); - return; + return false; } subserver.stop(); try { @@ -277,12 +277,13 @@ public class BauCommand extends BasicCommand { break; } } + return true; } private static void testarena(ProxiedPlayer p, String[] args){ FightCommand.createArena(p, "/bau testarena ", args, 1, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { - stopBauserver(p); - SubserverSystem.startTestServer(p, mode, map, 0, 0); + if(stopBauserver(p)) + SubserverSystem.startTestServer(p, mode, map, 0, 0); })); } diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index c110b3c4..e61dd710 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -234,7 +234,10 @@ public class CheckCommand extends BasicCommand { this.checkList = checkQuestions.get(schematic.getSchemType()).listIterator(); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { - BauCommand.stopBauserver(checker); + if(!BauCommand.stopBauserver(checker)){ + remove(); + return; + } ArenaMode mode = ArenaMode.getBySchemType(schematic.getSchemType().fightType()); SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID(), 0); @@ -323,8 +326,7 @@ public class CheckCommand extends BasicCommand { } private void stop(){ - currentCheckers.remove(checker.getUniqueId()); - currentSchems.remove(schematic.getSchemID()); + remove(); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { for (Subserver subserver : Subserver.getServerList()) { if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(checker.getUniqueId())) { @@ -334,5 +336,10 @@ public class CheckCommand extends BasicCommand { } }); } + + private void remove() { + currentCheckers.remove(checker.getUniqueId()); + currentSchems.remove(schematic.getSchemID()); + } } }