Provide access to specific tournament controllers to stop active games

This commit is contained in:
Alexander Meech 2017-07-30 06:26:15 -04:00 committed by cnr
parent 99938b4462
commit d4071e6de5

View File

@ -165,10 +165,13 @@ import org.bukkit.util.Vector;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.HashSet;
public class ArcadeManager extends MiniPlugin implements IRelation
{
private static final List<String> TOURNAMENT_CONTROLLERS = Arrays.asList("Malfunction", "adeelzee", "gr8p", "HelloItsMeJack", "Aussi", "Jesusman3", "TyTy2017", "KingShook", "Sw1ck", "doodzee", "Chr1mz", "Giovanna", "xApolloJustice", "bawzee", "MessedUpLogic", "dehfi", "Geothermal", "captainfence", "Ecal", "Raydnn", "Otisdiver", "AussieFighter", "snevahmadaa", "eMoa", "Vilare", "xLouis", "PizzaMan319");
// Modules
private BlockRestore _blockRestore;
private Blood _blood;
@ -1390,6 +1393,38 @@ public class ArcadeManager extends MiniPlugin implements IRelation
event.SetCancelled(true);
}
}
@EventHandler
public void tournamentStopGame(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().trim().equalsIgnoreCase("/tstopgame") && TOURNAMENT_CONTROLLERS.contains(event.getPlayer().getName()))
{
event.setCancelled(true);
if (GetGame() == null)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "There is no game to stop!"));
return;
}
if (GetGame().GetState() == GameState.End || GetGame().GetState() == GameState.WinRoom)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "The game is already ending, it cannot be ended again"));
return;
}
else if (GetGame().GetState() == GameState.Recruit)
{
GetGame().SetState(GameState.Dead);
}
else
{
GetGame().SetState(GameState.End);
}
HandlerList.unregisterAll(GetGame());
GetGame().Announce(C.cAqua + C.Bold + event.getPlayer().getName() + " has stopped the game.");
}
}
@EventHandler
public void Observer(PlayerCommandPreprocessEvent event)
@ -2081,4 +2116,4 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return _sheetsManager;
}
}
}