Archiviert
1
0

Deny launching multiple bauservers

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-09-05 18:47:04 +02:00
Ursprung 7bd15ec63f
Commit b604222450
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,12 +277,13 @@ 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());
}
} }
} }