Merge branch 'classes'

This commit is contained in:
taoneill 2011-09-18 16:19:03 -04:00
commit 095b073051
6 changed files with 64 additions and 11 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")) {
@ -370,6 +370,20 @@ public class War extends JavaPlugin {
}
returnMessage.append(" " + loadoutName + " respawn loadout updated.");
}
if (namedParams.containsKey("deleteloadout")) {
String loadoutName = namedParams.get("deleteloadout");
if (loadoutName.equals("default")) {
returnMessage.append(" Can't remove default loadout.");
} else {
HashMap<Integer, ItemStack> extraLoadout = warzone.getExtraLoadouts().get(loadoutName);
if (warzone.getExtraLoadouts().keySet().contains(loadoutName)) {
warzone.getExtraLoadouts().remove(loadoutName);
returnMessage.append(" " + loadoutName + " loadout removed.");
} else {
returnMessage.append(" " + loadoutName + " loadout not found.");
}
}
}
if (namedParams.containsKey("reward")) {
this.inventoryToLoadout(player, warzone.getReward());
returnMessage.append(" game end reward updated.");
@ -521,6 +535,20 @@ public class War extends JavaPlugin {
this.inventoryToLoadout(player, extraLoadout);
}
returnMessage.append(loadoutName + " respawn loadout updated.");
}
if (namedParams.containsKey("deleteloadout")) {
String loadoutName = namedParams.get("deleteloadout");
if (loadoutName.equals("default")) {
returnMessage.append(" Can't remove default loadout.");
} else {
HashMap<Integer, ItemStack> extraLoadout = this.getDefaultExtraLoadouts().get(loadoutName);
if (this.getDefaultExtraLoadouts().keySet().contains(loadoutName)) {
this.getDefaultExtraLoadouts().remove(loadoutName);
returnMessage.append(" " + loadoutName + " loadout removed.");
} else {
returnMessage.append(" " + loadoutName + " loadout not found.");
}
}
}
if (namedParams.containsKey("reward")) {
this.inventoryToLoadout(player, this.getDefaultReward());

View File

@ -191,7 +191,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;
}
}
}
}
@ -215,6 +222,12 @@ public class WarPlayerListener extends PlayerListener {
setter.placeCorner2(event.getClickedBlock());
event.setUseItemInHand(Result.ALLOW);
}
}
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
if (zone != null && zone.getNewlyRespawned().containsKey(player.getName()) && player.getItemInHand().getType() == Material.BOW) {
event.setUseItemInHand(Result.DENY);
War.war.badMsg(player, "Can't shoot from inside the spawn.");
}
}
}
@ -472,7 +485,7 @@ public class WarPlayerListener extends PlayerListener {
if (War.war.isLoaded() && event.isSneaking()) {
Warzone playerWarzone = Warzone.getZoneByLocation(event.getPlayer());
Team playerTeam = Team.getTeamByPlayerName(event.getPlayer().getName());
if (playerWarzone != null && playerTeam.getSpawnVolume().contains(event.getPlayer().getLocation())) {
if (playerWarzone != null && playerWarzone.getExtraLoadouts().keySet().size() > 0 && playerTeam.getSpawnVolume().contains(event.getPlayer().getLocation())) {
if (playerWarzone.getNewlyRespawned().keySet().contains(event.getPlayer().getName())) {
Integer currentIndex = playerWarzone.getNewlyRespawned().get(event.getPlayer().getName());
currentIndex = (currentIndex + 1) % (playerWarzone.getExtraLoadouts().keySet().size() + 1);
@ -480,7 +493,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 +501,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"));