SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Deny starting multiple testarenas at once (based on noBauPassthrough)' (#239) from denyMultiTestarenaStart into master

Reviewed-on: #239
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2021-09-07 07:44:11 +02:00
Commit 3e676f3c39
2 geänderte Dateien mit 16 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -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()) { for (Subserver subserver : Subserver.getServerList()) {
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId())) { 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); Message.send("BAU_START_ALREADY", p);
return; return false;
} }
subserver.stop(); subserver.stop();
try { try {
@ -277,11 +277,12 @@ public class BauCommand extends BasicCommand {
break; break;
} }
} }
return true;
} }
private static void testarena(ProxiedPlayer p, String[] args){ 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(), () -> { FightCommand.createArena(p, "/bau testarena ", args, 1, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
stopBauserver(p); if(stopBauserver(p))
SubserverSystem.startTestServer(p, mode, map, 0, 0); SubserverSystem.startTestServer(p, mode, map, 0, 0);
})); }));
} }

Datei anzeigen

@ -234,7 +234,10 @@ public class CheckCommand extends BasicCommand {
this.checkList = checkQuestions.get(schematic.getSchemType()).listIterator(); this.checkList = checkQuestions.get(schematic.getSchemType()).listIterator();
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
BauCommand.stopBauserver(checker); if(!BauCommand.stopBauserver(checker)){
remove();
return;
}
ArenaMode mode = ArenaMode.getBySchemType(schematic.getSchemType().fightType()); ArenaMode mode = ArenaMode.getBySchemType(schematic.getSchemType().fightType());
SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID(), 0); SubserverSystem.startTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID(), 0);
@ -323,8 +326,7 @@ public class CheckCommand extends BasicCommand {
} }
private void stop(){ private void stop(){
currentCheckers.remove(checker.getUniqueId()); remove();
currentSchems.remove(schematic.getSchemID());
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
for (Subserver subserver : Subserver.getServerList()) { for (Subserver subserver : Subserver.getServerList()) {
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(checker.getUniqueId())) { 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());
}
} }
} }