Fixes gh-239. Add joinmidbattle zonecfg option.

With this option set to false, new players cannot join the zone if the
zone already has enough players on all teams necessary to play.
This commit is contained in:
cmastudios 2013-07-13 17:00:56 -05:00
parent ebd95a4e16
commit fb375002de
4 changed files with 13 additions and 3 deletions

View File

@ -184,6 +184,7 @@ public class War extends JavaPlugin {
warzoneDefaultConfig.put(WarzoneConfig.RESETONUNLOAD, false);
warzoneDefaultConfig.put(WarzoneConfig.UNBREAKABLE, false);
warzoneDefaultConfig.put(WarzoneConfig.DEATHMESSAGES, true);
warzoneDefaultConfig.put(WarzoneConfig.JOINMIDBATTLE, true);
teamDefaultConfig.put(TeamConfig.FLAGMUSTBEHOME, true);
teamDefaultConfig.put(TeamConfig.FLAGPOINTSONLY, false);

View File

@ -77,9 +77,11 @@ public class JoinCommand extends AbstractWarCommand {
// join new team
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {
this.msg("This warzone is disabled.");
this.badMsg("This warzone is disabled.");
} else if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.AUTOASSIGN)) {
this.msg("This warzone requires you to be automatically assigned to a team. Please enter the autoassign gate instead.");
this.badMsg("This warzone requires you to be automatically assigned to a team. Please enter the autoassign gate instead.");
} else if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.JOINMIDBATTLE) && zone.isEnoughPlayers()) {
this.badMsg("You cannot join a battle in progress in this warzone.");
} else {
List<Team> teams = zone.getTeams();
boolean foundTeam = false;

View File

@ -19,7 +19,8 @@ public enum WarzoneConfig {
RESETONCONFIGCHANGE (Boolean.class),
RESETONLOAD (Boolean.class),
RESETONUNLOAD (Boolean.class),
UNBREAKABLE (Boolean.class);
UNBREAKABLE (Boolean.class),
JOINMIDBATTLE (Boolean.class);
private final Class<?> configType;

View File

@ -300,6 +300,9 @@ public class WarPlayerListener implements Listener {
if (isAutoAssignGate) {
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {
this.handleDisabledZone(event, player, zone);
} else if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.JOINMIDBATTLE) && zone.isEnoughPlayers()) {
event.setTo(zone.getTeleport());
War.war.badMsg(player, "You cannot join a battle in progress in this warzone.");
} else {
this.dropFromOldTeamIfAny(player);
int noOfPlayers = 0;
@ -334,6 +337,9 @@ public class WarPlayerListener implements Listener {
this.dropFromOldTeamIfAny(player);
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {
this.handleDisabledZone(event, player, zone);
} else if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.JOINMIDBATTLE) && zone.isEnoughPlayers()) {
event.setTo(zone.getTeleport());
War.war.badMsg(player, "You cannot join a battle in progress in this warzone.");
} else if (team.getPlayers().size() < team.getTeamConfig().resolveInt(TeamConfig.TEAMSIZE)
&& War.war.canPlayWar(player, team)) {
if (player.getWorld() != zone.getWorld()) {