Closes gh-287. Closes gh-288. flagpoints only setting now properly saved. autoassign:true setting at War level doesn't override the warzone-specific settings anymore. Can't drop items while still in spawn.

This commit is contained in:
taoneill 2011-09-18 15:35:43 -04:00
parent 48311e4d95
commit 9cc39281d7
6 changed files with 29 additions and 10 deletions

View File

@ -271,7 +271,7 @@ public class War extends JavaPlugin {
}
if (namedParams.containsKey("autoassign")) {
String onOff = namedParams.get("autoassign");
warzone.setAutoAssignOnly(onOff.equals("on") || onOff.equals("true"));
warzone.setAutoAssignOnlyAndResetLobby(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" autoassign set to " + String.valueOf(warzone.isAutoAssignOnly()) + ".");
}
if (namedParams.containsKey("flagpointsonly")) {

View File

@ -188,7 +188,7 @@ public class WarEntityListener extends EntityListener {
}
// pass pvp-damage
if (event instanceof EntityDamageByEntityEvent || event instanceof EntityDamageByProjectileEvent) {
if (event instanceof EntityDamageByEntityEvent) {
this.handlerAttackDefend((EntityDamageByEntityEvent) event);
} else {
// Detect death, prevent it and respawn the player

View File

@ -89,6 +89,13 @@ public class WarPlayerListener extends PlayerListener {
event.setCancelled(true);
return;
}
if (zone.getNewlyRespawned().keySet().contains(player.getName())) {
// still at spawn
War.war.badMsg(player, "Can't drop items while still in spawn.");
event.setCancelled(true);
return;
}
}
}
}
@ -480,7 +487,7 @@ public class WarPlayerListener extends PlayerListener {
if (currentIndex == 0) {
playerWarzone.resetInventory(playerTeam, event.getPlayer(), playerWarzone.getLoadout());
War.war.msg(event.getPlayer(), "Equiped default loadout.");
War.war.msg(event.getPlayer(), "Equipped default loadout.");
} else {
int i = 0;
Iterator it = playerWarzone.getExtraLoadouts().entrySet().iterator();
@ -488,7 +495,7 @@ public class WarPlayerListener extends PlayerListener {
Map.Entry pairs = (Map.Entry)it.next();
if (i == currentIndex - 1) {
playerWarzone.resetInventory(playerTeam, event.getPlayer(), (HashMap<Integer, ItemStack>)pairs.getValue());
War.war.msg(event.getPlayer(), "Equiped " + pairs.getKey() + " loadout.");
War.war.msg(event.getPlayer(), "Equipped " + pairs.getKey() + " loadout.");
}
i++;
}

View File

@ -59,10 +59,19 @@ public class JoinCommand extends AbstractWarCommand {
if (zone == null) {
return false;
}
String name = this.args[0];
TeamKind kind = TeamKind.teamKindFromString(this.args[0]);
// drop from old team if any
Team previousTeam = Team.getTeamByPlayerName(player.getName());
if (previousTeam != null) {
if (previousTeam.getName().startsWith(name) || previousTeam.getKind() == kind) {
// trying to join own team
War.war.badMsg(player, "Can't join your own team.");
return true;
}
Warzone oldZone = Warzone.getZoneByPlayerName(player.getName());
if (!previousTeam.removePlayer(player.getName())) {
War.war.log("Could not remove player " + player.getName() + " from team " + previousTeam.getName(), java.util.logging.Level.WARNING);
@ -80,8 +89,7 @@ public class JoinCommand extends AbstractWarCommand {
}
// join new team
String name = this.args[0];
TeamKind kind = TeamKind.teamKindFromString(this.args[0]);
if (zone.isDisabled()) {
this.msg("This warzone is disabled.");

View File

@ -82,7 +82,7 @@ public class Warzone {
this.setLoadout((HashMap<Integer, ItemStack>)War.war.getDefaultLoadout().clone());
this.extraLoadouts = (HashMap<String, HashMap<Integer, ItemStack>>)War.war.getDefaultExtraLoadouts().clone();
this.reward = (HashMap<Integer, ItemStack>)War.war.getDefaultReward().clone();
this.setAutoAssignOnly(War.war.isDefaultAutoAssignOnly());
this.autoAssignOnly = War.war.isDefaultAutoAssignOnly();
this.setFlagPointsOnly(War.war.isDefaultFlagPointsOnly());
this.teamCap = War.war.getDefaultTeamCap();
this.scoreCap = War.war.getDefaultScoreCap();
@ -751,12 +751,16 @@ public class Warzone {
return this.scoreCap;
}
public void setAutoAssignOnly(boolean autoAssignOnly) {
public void setAutoAssignOnlyAndResetLobby(boolean autoAssignOnly) {
this.autoAssignOnly = autoAssignOnly;
if (this.getLobby() != null) {
this.getLobby().setLocation(this.getTeleport());
}
}
public void setAutoAssignOnlyWithoutResettingLobby(boolean autoAssignOnly) {
this.autoAssignOnly = autoAssignOnly;
}
public boolean isAutoAssignOnly() {
return this.autoAssignOnly;

View File

@ -173,10 +173,10 @@ public class WarzoneMapper {
warzone.setMonumentHeal(warzoneConfig.getInt("monumentHeal"));
// autoAssignOnly
warzone.setAutoAssignOnly(warzoneConfig.getBoolean("autoAssignOnly"));
warzone.setAutoAssignOnlyWithoutResettingLobby(warzoneConfig.getBoolean("autoAssignOnly"));
// flagPointsOnly
warzone.setAutoAssignOnly(warzoneConfig.getBoolean("flagPointsOnly"));
warzone.setFlagPointsOnly(warzoneConfig.getBoolean("flagPointsOnly"));
// team cap
warzone.setTeamCap(warzoneConfig.getInt("teamCap"));