Closes gh-73. Closes gh-292. Easy spleef with two new settings: pvpinzone (default true) and instabreak (default false). Former off, latter on makes for spleef. Killing by arrows now can't be done through spawn protection. I got carried away and prettied up the kill messages. Also added check in mappers so that default values don't get overridden by 0 or false from the config file reader.

This commit is contained in:
taoneill 2011-09-26 22:08:34 -04:00
parent 599e6b11d5
commit 0811431b0a
9 changed files with 306 additions and 120 deletions

View File

@ -63,6 +63,8 @@ public class War extends JavaPlugin {
private boolean pvpInZonesOnly = false; private boolean pvpInZonesOnly = false;
private boolean disablePvpMessage = false; private boolean disablePvpMessage = false;
private boolean buildInZonesOnly = false; private boolean buildInZonesOnly = false;
private final List<String> deadlyAdjectives = new ArrayList<String>();
private final List<String> killerVerbs = new ArrayList<String>();
// Default warzone settings // Default warzone settings
private final HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>(); private final HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
@ -78,6 +80,8 @@ public class War extends JavaPlugin {
private boolean defaultUnbreakableZoneBlocks = false; private boolean defaultUnbreakableZoneBlocks = false;
private boolean defaultNoCreatures = false; private boolean defaultNoCreatures = false;
private boolean defaultGlassWalls = true; private boolean defaultGlassWalls = true;
private boolean defaultPvpInZone = true;
private boolean defaultInstaBreak = false;
private int defaultMinPlayers = 1; // By default, 1 player on 1 team is enough for unlocking the cant-exit-spawn guard private int defaultMinPlayers = 1; // By default, 1 player on 1 team is enough for unlocking the cant-exit-spawn guard
private int defaultMinTeams = 1; private int defaultMinTeams = 1;
private FlagReturn defaultFlagReturn = FlagReturn.BOTH; private FlagReturn defaultFlagReturn = FlagReturn.BOTH;
@ -138,17 +142,39 @@ public class War extends JavaPlugin {
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this); pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_DAMAGE, this.blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Priority.Normal, this);
} }
// Load files from disk or create them (using these defaults) // Load files from disk or create them (using these defaults)
this.getDefaultLoadout().clear();
this.getDefaultLoadout().put(0, new ItemStack(Material.STONE_SWORD, 1, (byte) 8)); this.getDefaultLoadout().put(0, new ItemStack(Material.STONE_SWORD, 1, (byte) 8));
this.getDefaultLoadout().put(1, new ItemStack(Material.BOW, 1, (byte) 8)); this.getDefaultLoadout().put(1, new ItemStack(Material.BOW, 1, (byte) 8));
this.getDefaultLoadout().put(2, new ItemStack(Material.ARROW, 7)); this.getDefaultLoadout().put(2, new ItemStack(Material.ARROW, 7));
this.getDefaultLoadout().put(3, new ItemStack(Material.IRON_PICKAXE, 1, (byte) 8)); this.getDefaultLoadout().put(3, new ItemStack(Material.IRON_PICKAXE, 1, (byte) 8));
this.getDefaultLoadout().put(4, new ItemStack(Material.STONE_SPADE, 1, (byte) 8)); this.getDefaultLoadout().put(4, new ItemStack(Material.STONE_SPADE, 1, (byte) 8));
this.getDefaultReward().clear();
this.getDefaultReward().put(0, new ItemStack(Material.CAKE, 1)); this.getDefaultReward().put(0, new ItemStack(Material.CAKE, 1));
this.getDeadlyAdjectives().clear();
this.getDeadlyAdjectives().add("");
this.getDeadlyAdjectives().add("");
this.getDeadlyAdjectives().add("mighty ");
this.getDeadlyAdjectives().add("deadly ");
this.getDeadlyAdjectives().add("fine ");
this.getDeadlyAdjectives().add("precise ");
this.getDeadlyAdjectives().add("brutal ");
this.getKillerVerbs().clear();
this.getKillerVerbs().add("killed");
this.getKillerVerbs().add("killed");
this.getKillerVerbs().add("killed");
this.getKillerVerbs().add("finished");
this.getKillerVerbs().add("annihilated");
this.getKillerVerbs().add("murdered");
this.getKillerVerbs().add("obliterated");
this.getKillerVerbs().add("exterminated");
WarMapper.load(); WarMapper.load();
HelmetProtectionTask helmetProtectionTask = new HelmetProtectionTask(); HelmetProtectionTask helmetProtectionTask = new HelmetProtectionTask();
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, helmetProtectionTask, 250, 100); this.getServer().getScheduler().scheduleSyncRepeatingTask(this, helmetProtectionTask, 250, 100);
@ -320,6 +346,16 @@ public class War extends JavaPlugin {
warzone.setGlassWalls(onOff.equals("on") || onOff.equals("true")); warzone.setGlassWalls(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" glasswalls set to " + String.valueOf(warzone.isGlassWalls()) + "."); returnMessage.append(" glasswalls set to " + String.valueOf(warzone.isGlassWalls()) + ".");
} }
if (namedParams.containsKey("pvpinzone")) {
String onOff = namedParams.get("pvpinzone");
warzone.setPvpInZone(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" pvpinzone set to " + String.valueOf(warzone.isPvpInZone()) + ".");
}
if (namedParams.containsKey("instabreak")) {
String onOff = namedParams.get("instabreak");
warzone.setInstaBreak(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" instabreak set to " + String.valueOf(warzone.isInstaBreak()) + ".");
}
if (namedParams.containsKey("minplayers")) { if (namedParams.containsKey("minplayers")) {
int val = Integer.parseInt(namedParams.get("minplayers")); int val = Integer.parseInt(namedParams.get("minplayers"));
if (val > warzone.getTeamCap()) { if (val > warzone.getTeamCap()) {
@ -491,6 +527,16 @@ public class War extends JavaPlugin {
this.setDefaultGlassWalls(onOff.equals("on") || onOff.equals("true")); this.setDefaultGlassWalls(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" glasswalls set to " + String.valueOf(war.isDefaultGlassWalls()) + "."); returnMessage.append(" glasswalls set to " + String.valueOf(war.isDefaultGlassWalls()) + ".");
} }
if (namedParams.containsKey("pvpinzone")) {
String onOff = namedParams.get("pvpinzone");
this.setDefaultPvpInZone(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" pvpinzone set to " + String.valueOf(war.isDefaultPvpInZone()) + ".");
}
if (namedParams.containsKey("instabreak")) {
String onOff = namedParams.get("instabreak");
this.setDefaultInstaBreak(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" instabreak set to " + String.valueOf(war.isDefaultInstaBreak()) + ".");
}
if (namedParams.containsKey("minplayers")) { if (namedParams.containsKey("minplayers")) {
int val = Integer.parseInt(namedParams.get("minplayers")); int val = Integer.parseInt(namedParams.get("minplayers"));
if (val > this.getDefaultTeamCap()) { if (val > this.getDefaultTeamCap()) {
@ -583,6 +629,8 @@ public class War extends JavaPlugin {
+ " disabled:" + String.valueOf(zone.isDisabled()) + " disabled:" + String.valueOf(zone.isDisabled())
+ " nocreatures:" + String.valueOf(zone.isNoCreatures()) + " nocreatures:" + String.valueOf(zone.isNoCreatures())
+ " glasswalls:" + String.valueOf(zone.isGlassWalls()) + " glasswalls:" + String.valueOf(zone.isGlassWalls())
+ " pvpinzone:" + String.valueOf(zone.isPvpInZone())
+ " instabreak:" + String.valueOf(zone.isInstaBreak())
+ " minplayers:" + zone.getMinPlayers() + " minplayers:" + zone.getMinPlayers()
+ " minteams:" + zone.getMinTeams() + " minteams:" + zone.getMinTeams()
+ " resetonempty:" + String.valueOf(zone.isResetOnEmpty()) + " resetonempty:" + String.valueOf(zone.isResetOnEmpty())
@ -609,6 +657,8 @@ public class War extends JavaPlugin {
+ " unbreakable:" + String.valueOf(this.isDefaultUnbreakableZoneBlocks()) + " unbreakable:" + String.valueOf(this.isDefaultUnbreakableZoneBlocks())
+ " nocreatures:" + String.valueOf(this.isDefaultNoCreatures()) + " nocreatures:" + String.valueOf(this.isDefaultNoCreatures())
+ " glasswalls:" + String.valueOf(this.isDefaultGlassWalls()) + " glasswalls:" + String.valueOf(this.isDefaultGlassWalls())
+ " pvpinzone:" + String.valueOf(this.isDefaultPvpInZone())
+ " instabreak:" + String.valueOf(this.isDefaultInstaBreak())
+ " minplayers:" + this.getDefaultMinPlayers() + " minplayers:" + this.getDefaultMinPlayers()
+ " minteams:" + this.getDefaultMinTeams() + " minteams:" + this.getDefaultMinTeams()
+ " resetonempty:" + String.valueOf(this.isDefaultResetOnEmpty()) + " resetonempty:" + String.valueOf(this.isDefaultResetOnEmpty())
@ -1100,4 +1150,28 @@ public class War extends JavaPlugin {
public HashMap<String, HashMap<Integer, ItemStack>> getDefaultExtraLoadouts() { public HashMap<String, HashMap<Integer, ItemStack>> getDefaultExtraLoadouts() {
return defaultExtraLoadouts; return defaultExtraLoadouts;
} }
public void setDefaultPvpInZone(boolean defaultPvpInZone) {
this.defaultPvpInZone = defaultPvpInZone;
}
public boolean isDefaultPvpInZone() {
return defaultPvpInZone;
}
public void setDefaultInstaBreak(boolean defaultInstaBreak) {
this.defaultInstaBreak = defaultInstaBreak;
}
public boolean isDefaultInstaBreak() {
return defaultInstaBreak;
}
public List<String> getDeadlyAdjectives() {
return deadlyAdjectives;
}
public List<String> getKillerVerbs() {
return killerVerbs;
}
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -129,6 +130,21 @@ public class WarBlockListener extends BlockListener {
} }
} }
public void onBlockDamage(BlockDamageEvent event) {
if (!War.war.isLoaded()) {
return;
}
Player player = event.getPlayer();
Block block = event.getBlock();
Warzone playerZone = Warzone.getZoneByLocation(player);
if (player != null && block != null && playerZone != null && playerZone.isInstaBreak()) {
Warzone blockZone = Warzone.getZoneByLocation(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
if (blockZone != null && blockZone == playerZone) {
event.setInstaBreak(true);
}
}
}
private void handleBreakOrDamage(Player player, Block block, Cancellable event) { private void handleBreakOrDamage(Player player, Block block, Cancellable event) {
Warzone warzone = Warzone.getZoneByLocation(player); Warzone warzone = Warzone.getZoneByLocation(player);
Team team = Team.getTeamByPlayerName(player.getName()); Team team = Team.getTeamByPlayerName(player.getName());

View File

@ -1,21 +1,22 @@
package bukkit.tommytony.war; package bukkit.tommytony.war;
import java.awt.Color;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftTNTPrimed; import org.bukkit.craftbukkit.entity.CraftTNTPrimed;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener; import org.bukkit.event.entity.EntityListener;
@ -33,6 +34,8 @@ import com.tommytony.war.Warzone;
*/ */
public class WarEntityListener extends EntityListener { public class WarEntityListener extends EntityListener {
private Random killSeed = new Random();
/** /**
* Handles PVP-Damage * Handles PVP-Damage
* *
@ -43,6 +46,11 @@ public class WarEntityListener extends EntityListener {
Entity attacker = event.getDamager(); Entity attacker = event.getDamager();
Entity defender = event.getEntity(); Entity defender = event.getEntity();
// Maybe an arrow was thrown
if (attacker != null && event.getDamager() instanceof Projectile && ((Projectile)event.getDamager()).getShooter() instanceof Player){
attacker = ((Player)((Projectile)event.getDamager()).getShooter());
}
if (attacker != null && defender != null && attacker instanceof Player && defender instanceof Player) { if (attacker != null && defender != null && attacker instanceof Player && defender instanceof Player) {
// only let adversaries (same warzone, different team) attack each other // only let adversaries (same warzone, different team) attack each other
Player a = (Player) attacker; Player a = (Player) attacker;
@ -58,21 +66,53 @@ public class WarEntityListener extends EntityListener {
if (!defenderWarzone.isFlagThief(d.getName())) { // thieves can always be attacked if (!defenderWarzone.isFlagThief(d.getName())) { // thieves can always be attacked
War.war.badMsg(a, "Can't attack a player that's inside his team's spawn."); War.war.badMsg(a, "Can't attack a player that's inside his team's spawn.");
event.setCancelled(true); event.setCancelled(true);
return;
} }
} else if (attackerTeam.getSpawnVolume().contains(a.getLocation()) && !attackerTeam.getSpawnVolume().contains(d.getLocation())) { } else if (attackerTeam.getSpawnVolume().contains(a.getLocation()) && !attackerTeam.getSpawnVolume().contains(d.getLocation())) {
// only let a player inside spawn attack an enemy player if that player enters the spawn // only let a player inside spawn attack an enemy player if that player enters the spawn
if (!attackerWarzone.isFlagThief(a.getName())) { // thieves can always attack if (!attackerWarzone.isFlagThief(a.getName())) { // thieves can always attack
War.war.badMsg(a, "Can't attack a player from inside your spawn."); War.war.badMsg(a, "Can't attack a player from inside your spawn.");
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }
if (!attackerWarzone.isPvpInZone()) {
// spleef-like, non-pvp, zone
event.setCancelled(true);
return;
}
// Detect death, prevent it and respawn the player // Detect death, prevent it and respawn the player
if (event.getDamage() >= d.getHealth()) { if (event.getDamage() >= d.getHealth()) {
String killMessage = ""; String killMessage = "";
String attackerString = attackerTeam.getKind().getColor() + a.getDisplayName(); String attackerString = attackerTeam.getKind().getColor() + a.getDisplayName();
String defenderString = defenderTeam.getKind().getColor() + d.getDisplayName(); String defenderString = defenderTeam.getKind().getColor() + d.getDisplayName();
killMessage = attackerString + ChatColor.WHITE + " killed " + defenderString;
Material killerWeapon = a.getItemInHand().getType();
String weaponString = killerWeapon.toString();
if (killerWeapon == Material.AIR) {
weaponString = "fist";
} else if (killerWeapon == Material.BOW || event.getDamager() instanceof Arrow) {
int rand = killSeed.nextInt(3);
if (rand == 0) {
weaponString = "arrow";
} else if (rand == 1) {
weaponString = "bow";
} else {
weaponString = "aim";
}
} else if (event.getDamager() instanceof Projectile) {
weaponString = "aim";
}
String adjectiveString = War.war.getDeadlyAdjectives().get(this.killSeed.nextInt(War.war.getDeadlyAdjectives().size()));
String verbString = War.war.getKillerVerbs().get(this.killSeed.nextInt(War.war.getKillerVerbs().size()));
killMessage = attackerString + ChatColor.WHITE + "'s " + adjectiveString + weaponString.toLowerCase().replace('_', ' ')
+ " " + verbString + " " + defenderString;
for (Team team : defenderWarzone.getTeams()) { for (Team team : defenderWarzone.getTeams()) {
team.teamcast(killMessage); team.teamcast(killMessage);
} }
@ -117,11 +157,11 @@ public class WarEntityListener extends EntityListener {
if (d != null && defenderWarzone != null && event.getDamage() >= d.getHealth()) { if (d != null && defenderWarzone != null && event.getDamage() >= d.getHealth()) {
String deathMessage = ""; String deathMessage = "";
String defenderString = Team.getTeamByPlayerName(d.getName()).getKind().getColor() + d.getDisplayName(); String defenderString = Team.getTeamByPlayerName(d.getName()).getKind().getColor() + d.getDisplayName();
if (event.getDamager() instanceof Projectile && ((Projectile)event.getDamager()).getShooter() instanceof Player){ /* if (event.getDamager() instanceof Projectile && ((Projectile)event.getDamager()).getShooter() instanceof Player){
Player shooter = ((Player)((Projectile)event.getDamager()).getShooter()); Player shooter = ((Player)((Projectile)event.getDamager()).getShooter());
Team shooterTeam = Team.getTeamByPlayerName(shooter.getName()); Team shooterTeam = Team.getTeamByPlayerName(shooter.getName());
deathMessage = shooterTeam.getKind().getColor() + shooter.getDisplayName() + ChatColor.WHITE + "'s deadly aim killed " + defenderString; deathMessage = shooterTeam.getKind().getColor() + shooter.getDisplayName() + ChatColor.WHITE + "'s deadly aim killed " + defenderString;
} else if (event.getDamager() instanceof CraftTNTPrimed) { } else */ if (event.getDamager() instanceof CraftTNTPrimed) {
deathMessage = defenderString + ChatColor.WHITE + " exploded"; deathMessage = defenderString + ChatColor.WHITE + " exploded";
} else { } else {
deathMessage = defenderString + ChatColor.WHITE + " died"; deathMessage = defenderString + ChatColor.WHITE + " died";

View File

@ -39,8 +39,8 @@ public class Warzone {
private final List<Monument> monuments = new ArrayList<Monument>(); private final List<Monument> monuments = new ArrayList<Monument>();
private Location teleport; private Location teleport;
private boolean friendlyFire; private boolean friendlyFire = false;
private int lifePool; private int lifePool = 7;
private HashMap<Integer, ItemStack> loadout = new HashMap<Integer, ItemStack>(); private HashMap<Integer, ItemStack> loadout = new HashMap<Integer, ItemStack>();
private HashMap<String, HashMap<Integer, ItemStack>> extraLoadouts = new HashMap<String, HashMap<Integer, ItemStack>>(); private HashMap<String, HashMap<Integer, ItemStack>> extraLoadouts = new HashMap<String, HashMap<Integer, ItemStack>>();
private int teamCap = 5; private int teamCap = 5;
@ -57,13 +57,15 @@ public class Warzone {
private final int minSafeDistanceFromWall = 6; private final int minSafeDistanceFromWall = 6;
private List<ZoneWallGuard> zoneWallGuards = new ArrayList<ZoneWallGuard>(); private List<ZoneWallGuard> zoneWallGuards = new ArrayList<ZoneWallGuard>();
private ZoneLobby lobby; private ZoneLobby lobby;
private boolean autoAssignOnly; private boolean autoAssignOnly = false;
private boolean flagPointsOnly; private boolean flagPointsOnly = false;
private boolean blockHeads; private boolean blockHeads = true;
private boolean unbreakableZoneBlocks; private boolean unbreakableZoneBlocks = false;
private boolean disabled = false; private boolean disabled = false;
private boolean noCreatures = false; private boolean noCreatures = false;
private boolean glassWalls = true; private boolean glassWalls = true;
private boolean pvpInZone = true;
private boolean instaBreak = false;
private int minPlayers = 1; private int minPlayers = 1;
private int minTeams = 1; private int minTeams = 1;
@ -74,6 +76,7 @@ public class Warzone {
private HashMap<String, PlayerState> deadMenInventories = new HashMap<String, PlayerState>(); private HashMap<String, PlayerState> deadMenInventories = new HashMap<String, PlayerState>();
private Location rallyPoint; private Location rallyPoint;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Warzone(World world, String name) { public Warzone(World world, String name) {
this.world = world; this.world = world;
@ -94,6 +97,8 @@ public class Warzone {
this.setUnbreakableZoneBlocks(War.war.isDefaultUnbreakableZoneBlocks()); this.setUnbreakableZoneBlocks(War.war.isDefaultUnbreakableZoneBlocks());
this.setNoCreatures(War.war.isDefaultNoCreatures()); this.setNoCreatures(War.war.isDefaultNoCreatures());
this.setGlassWalls(War.war.isDefaultGlassWalls()); this.setGlassWalls(War.war.isDefaultGlassWalls());
this.setPvpInZone(War.war.isDefaultPvpInZone());
this.setInstaBreak(War.war.isDefaultInstaBreak());
this.setMinPlayers(War.war.getDefaultMinPlayers()); this.setMinPlayers(War.war.getDefaultMinPlayers());
this.setMinTeams(War.war.getDefaultMinTeams()); this.setMinTeams(War.war.getDefaultMinTeams());
this.setResetOnEmpty(War.war.isDefaultResetOnEmpty()); this.setResetOnEmpty(War.war.isDefaultResetOnEmpty());
@ -1171,4 +1176,20 @@ public class Warzone {
public HashMap<String, Integer> getNewlyRespawned() { public HashMap<String, Integer> getNewlyRespawned() {
return newlyRespawned; return newlyRespawned;
} }
public boolean isPvpInZone() {
return pvpInZone;
}
public void setPvpInZone(boolean stopPvp) {
this.pvpInZone = stopPvp;
}
public boolean isInstaBreak() {
return instaBreak;
}
public void setInstaBreak(boolean instaBreak) {
this.instaBreak = instaBreak;
}
} }

View File

@ -111,40 +111,59 @@ public class WarMapper {
} }
// defaultLifePool // defaultLifePool
if (warConfig.keyExists("defaultLifePool")) {
War.war.setDefaultLifepool(warConfig.getInt("defaultLifePool")); War.war.setDefaultLifepool(warConfig.getInt("defaultLifePool"));
}
// defaultMonumentHeal // defaultMonumentHeal
if (warConfig.keyExists("defaultMonumentHeal")) {
War.war.setDefaultMonumentHeal(warConfig.getInt("defaultMonumentHeal")); War.war.setDefaultMonumentHeal(warConfig.getInt("defaultMonumentHeal"));
}
// defaultMonumentHeal
War.war.setDefaultMonumentHeal(warConfig.getInt("defaultMonumentHeal"));
// defaultFriendlyFire // defaultFriendlyFire
if (warConfig.keyExists("defaultFriendlyFire")) {
War.war.setDefaultFriendlyFire(warConfig.getBoolean("defaultFriendlyFire")); War.war.setDefaultFriendlyFire(warConfig.getBoolean("defaultFriendlyFire"));
}
// defaultAutoAssignOnly // defaultAutoAssignOnly
if (warConfig.keyExists("defaultAutoAssignOnly")) {
War.war.setDefaultAutoAssignOnly(warConfig.getBoolean("defaultAutoAssignOnly")); War.war.setDefaultAutoAssignOnly(warConfig.getBoolean("defaultAutoAssignOnly"));
}
// defaultFlagPointsOnly // defaultFlagPointsOnly
if (warConfig.keyExists("defaultFlagPointsOnly")) {
War.war.setDefaultFlagPointsOnly(warConfig.getBoolean("defaultFlagPointsOnly")); War.war.setDefaultFlagPointsOnly(warConfig.getBoolean("defaultFlagPointsOnly"));
}
// defaultTeamCap // defaultTeamCap
if (warConfig.keyExists("defaultTeamCap")) {
War.war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap")); War.war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap"));
}
// defaultScoreCap // defaultScoreCap
if (warConfig.keyExists("defaultScoreCap")) {
War.war.setDefaultScoreCap(warConfig.getInt("defaultScoreCap")); War.war.setDefaultScoreCap(warConfig.getInt("defaultScoreCap"));
}
// pvpInZonesOnly // pvpInZonesOnly
if (warConfig.keyExists("pvpInZonesOnly")) {
War.war.setPvpInZonesOnly(warConfig.getBoolean("pvpInZonesOnly")); War.war.setPvpInZonesOnly(warConfig.getBoolean("pvpInZonesOnly"));
}
// defaultBlockHeads // defaultBlockHeads
if (warConfig.keyExists("defaultBlockHeads")) {
War.war.setDefaultBlockHeads(warConfig.getBoolean("defaultBlockHeads")); War.war.setDefaultBlockHeads(warConfig.getBoolean("defaultBlockHeads"));
}
// buildInZonesOnly // buildInZonesOnly
if (warConfig.keyExists("buildInZonesOnly")) {
War.war.setBuildInZonesOnly(warConfig.getBoolean("buildInZonesOnly")); War.war.setBuildInZonesOnly(warConfig.getBoolean("buildInZonesOnly"));
}
// disablePVPMessage // disablePVPMessage
if (warConfig.keyExists("disablePvpMessage")) {
War.war.setDisablePvpMessage(warConfig.getBoolean("disablePvpMessage")); War.war.setDisablePvpMessage(warConfig.getBoolean("disablePvpMessage"));
}
// defaultSpawnStyle // defaultSpawnStyle
String spawnStyle = warConfig.getString("defaultspawnStyle"); String spawnStyle = warConfig.getString("defaultspawnStyle");
@ -173,28 +192,54 @@ public class WarMapper {
} }
// defaultUnbreakableZoneBlocks // defaultUnbreakableZoneBlocks
if (warConfig.keyExists("defaultUnbreakableZoneBlocks")) {
War.war.setDefaultUnbreakableZoneBlocks(warConfig.getBoolean("defaultUnbreakableZoneBlocks")); War.war.setDefaultUnbreakableZoneBlocks(warConfig.getBoolean("defaultUnbreakableZoneBlocks"));
}
// defaultNoCreatures // defaultNoCreatures
if (warConfig.keyExists("defaultNoCreatures")) {
War.war.setDefaultNoCreatures(warConfig.getBoolean("defaultNoCreatures")); War.war.setDefaultNoCreatures(warConfig.getBoolean("defaultNoCreatures"));
}
// defaultGlassWalls // defaultGlassWalls
if (warConfig.keyExists("defaultGlassWalls")) {
War.war.setDefaultGlassWalls(warConfig.getBoolean("defaultGlassWalls")); War.war.setDefaultGlassWalls(warConfig.getBoolean("defaultGlassWalls"));
}
// defaultPvpInZone
if (warConfig.keyExists("defaultPvpInZone")) {
War.war.setDefaultPvpInZone(warConfig.getBoolean("defaultPvpInZone"));
}
// defaultInstaBreak
if (warConfig.keyExists("defaultInstaBreak")) {
War.war.setDefaultInstaBreak(warConfig.getBoolean("defaultInstaBreak"));
}
// defaultMinPlayers // defaultMinPlayers
if (warConfig.keyExists("defaultMinPlayers")) {
War.war.setDefaultMinPlayers(warConfig.getInt("defaultMinPlayers")); War.war.setDefaultMinPlayers(warConfig.getInt("defaultMinPlayers"));
}
// defaultMinTeams // defaultMinTeams
if (warConfig.keyExists("defaultMinTeams")) {
War.war.setDefaultMinTeams(warConfig.getInt("defaultMinTeams")); War.war.setDefaultMinTeams(warConfig.getInt("defaultMinTeams"));
}
// defaultResetOnEmpty // defaultResetOnEmpty
if (warConfig.keyExists("defaultResetOnEmpty")) {
War.war.setDefaultResetOnEmpty(warConfig.getBoolean("defaultResetOnEmpty")); War.war.setDefaultResetOnEmpty(warConfig.getBoolean("defaultResetOnEmpty"));
}
// defaultResetOnLoad // defaultResetOnLoad
if (warConfig.keyExists("defaultResetOnLoad")) {
War.war.setDefaultResetOnLoad(warConfig.getBoolean("defaultResetOnLoad")); War.war.setDefaultResetOnLoad(warConfig.getBoolean("defaultResetOnLoad"));
}
// defaultResetOnUnload // defaultResetOnUnload
if (warConfig.keyExists("defaultResetOnUnload")) {
War.war.setDefaultResetOnUnload(warConfig.getBoolean("defaultResetOnUnload")); War.war.setDefaultResetOnUnload(warConfig.getBoolean("defaultResetOnUnload"));
}
// warhub // warhub
String hubStr = warConfig.getString("warhub"); String hubStr = warConfig.getString("warhub");
@ -319,6 +364,12 @@ public class WarMapper {
// defaultGlassWalls // defaultGlassWalls
warConfig.setBoolean("defaultGlassWalls", War.war.isDefaultGlassWalls()); warConfig.setBoolean("defaultGlassWalls", War.war.isDefaultGlassWalls());
// defaultPvpInZone
warConfig.setBoolean("defaultPvpInZone", War.war.isDefaultPvpInZone());
// defaultInstaBreak
warConfig.setBoolean("defaultInstaBreak", War.war.isDefaultInstaBreak());
// defaultMinPlayers // defaultMinPlayers
warConfig.setInt("defaultMinPlayers", War.war.getDefaultMinPlayers()); warConfig.setInt("defaultMinPlayers", War.war.getDefaultMinPlayers());

View File

@ -125,7 +125,9 @@ public class WarzoneMapper {
} }
// ff // ff
if (warzoneConfig.containsKey("friendlyFire")) {
warzone.setFriendlyFire(warzoneConfig.getBoolean("friendlyFire")); warzone.setFriendlyFire(warzoneConfig.getBoolean("friendlyFire"));
}
// loadout // loadout
String loadoutStr = warzoneConfig.getString("loadout"); String loadoutStr = warzoneConfig.getString("loadout");
@ -167,25 +169,39 @@ public class WarzoneMapper {
// life pool (always set after teams, so the teams' remaining lives get initialized properly by this setter) // life pool (always set after teams, so the teams' remaining lives get initialized properly by this setter)
if (warzoneConfig.containsKey("lifePool")) {
warzone.setLifePool(warzoneConfig.getInt("lifePool")); warzone.setLifePool(warzoneConfig.getInt("lifePool"));
}
// monument heal // monument heal
if (warzoneConfig.containsKey("monumentHeal")) {
warzone.setMonumentHeal(warzoneConfig.getInt("monumentHeal")); warzone.setMonumentHeal(warzoneConfig.getInt("monumentHeal"));
}
// autoAssignOnly // autoAssignOnly
if (warzoneConfig.containsKey("autoAssignOnly")) {
warzone.setAutoAssignOnlyWithoutResettingLobby(warzoneConfig.getBoolean("autoAssignOnly")); warzone.setAutoAssignOnlyWithoutResettingLobby(warzoneConfig.getBoolean("autoAssignOnly"));
}
// flagPointsOnly // flagPointsOnly
if (warzoneConfig.containsKey("flagPointsOnly")) {
warzone.setFlagPointsOnly(warzoneConfig.getBoolean("flagPointsOnly")); warzone.setFlagPointsOnly(warzoneConfig.getBoolean("flagPointsOnly"));
}
// team cap // team cap
if (warzoneConfig.containsKey("teamCap")) {
warzone.setTeamCap(warzoneConfig.getInt("teamCap")); warzone.setTeamCap(warzoneConfig.getInt("teamCap"));
}
// score cap // score cap
if (warzoneConfig.containsKey("scoreCap")) {
warzone.setScoreCap(warzoneConfig.getInt("scoreCap")); warzone.setScoreCap(warzoneConfig.getInt("scoreCap"));
}
// blockHeads // blockHeads
if (warzoneConfig.containsKey("blockHeads")) {
warzone.setBlockHeads(warzoneConfig.getBoolean("blockHeads")); warzone.setBlockHeads(warzoneConfig.getBoolean("blockHeads"));
}
// spawnStyle // spawnStyle
String spawnStyle = warzoneConfig.getString("spawnStyle"); String spawnStyle = warzoneConfig.getString("spawnStyle");
@ -214,31 +230,59 @@ public class WarzoneMapper {
} }
// unbreakableZoneBlocks // unbreakableZoneBlocks
if (warzoneConfig.containsKey("unbreakableZoneBlocks")) {
warzone.setUnbreakableZoneBlocks(warzoneConfig.getBoolean("unbreakableZoneBlocks")); warzone.setUnbreakableZoneBlocks(warzoneConfig.getBoolean("unbreakableZoneBlocks"));
}
// disabled // disabled
if (warzoneConfig.containsKey("disabled")) {
warzone.setDisabled(warzoneConfig.getBoolean("disabled")); warzone.setDisabled(warzoneConfig.getBoolean("disabled"));
}
// noCreatures // noCreatures
if (warzoneConfig.containsKey("noCreatures")) {
warzone.setNoCreatures(warzoneConfig.getBoolean("noCreatures")); warzone.setNoCreatures(warzoneConfig.getBoolean("noCreatures"));
}
// glassWalls // glassWalls
if (warzoneConfig.containsKey("glassWalls")) {
warzone.setGlassWalls(warzoneConfig.getBoolean("glassWalls")); warzone.setGlassWalls(warzoneConfig.getBoolean("glassWalls"));
}
// pvpInZone
if (warzoneConfig.containsKey("pvpInZone")) {
warzone.setPvpInZone(warzoneConfig.getBoolean("pvpInZone"));
}
// instaBreak
if (warzoneConfig.containsKey("instaBreak")) {
warzone.setInstaBreak(warzoneConfig.getBoolean("instaBreak"));
}
// minPlayers // minPlayers
if (warzoneConfig.containsKey("minPlayers")) {
warzone.setMinPlayers(warzoneConfig.getInt("minPlayers")); warzone.setMinPlayers(warzoneConfig.getInt("minPlayers"));
}
// minTeams // minTeams
if (warzoneConfig.containsKey("minTeams")) {
warzone.setMinTeams(warzoneConfig.getInt("minTeams")); warzone.setMinTeams(warzoneConfig.getInt("minTeams"));
}
// resetOnEmpty // resetOnEmpty
if (warzoneConfig.containsKey("resetOnEmpty")) {
warzone.setResetOnEmpty(warzoneConfig.getBoolean("resetOnEmpty")); warzone.setResetOnEmpty(warzoneConfig.getBoolean("resetOnEmpty"));
}
// resetOnLoad // resetOnLoad
if (warzoneConfig.containsKey("resetOnLoad")) {
warzone.setResetOnLoad(warzoneConfig.getBoolean("resetOnLoad")); warzone.setResetOnLoad(warzoneConfig.getBoolean("resetOnLoad"));
}
// resetOnUnload // resetOnUnload
if (warzoneConfig.containsKey("resetOnUnload")) {
warzone.setResetOnUnload(warzoneConfig.getBoolean("resetOnUnload")); warzone.setResetOnUnload(warzoneConfig.getBoolean("resetOnUnload"));
}
// rallyPoint // rallyPoint
String rallyPointStr = warzoneConfig.getString("rallyPoint"); String rallyPointStr = warzoneConfig.getString("rallyPoint");
@ -451,6 +495,12 @@ public class WarzoneMapper {
// glassWalls // glassWalls
warzoneConfig.setBoolean("glassWalls", warzone.isGlassWalls()); warzoneConfig.setBoolean("glassWalls", warzone.isGlassWalls());
// pvpInZone
warzoneConfig.setBoolean("pvpInZone", warzone.isPvpInZone());
// instaBreak
warzoneConfig.setBoolean("instaBreak", warzone.isInstaBreak());
// minPlayers // minPlayers
warzoneConfig.setInt("minPlayers", warzone.getMinPlayers()); warzoneConfig.setInt("minPlayers", warzone.getMinPlayers());

View File

@ -1,66 +0,0 @@
package com.tommytony.war.utils;
import org.bukkit.inventory.ItemStack;
public class InventoryStash {
private ItemStack[] contents;
private ItemStack helmet;
private ItemStack chest;
private ItemStack legs;
private ItemStack feet;
public InventoryStash(ItemStack[] contents) {
this.setContents(contents);
}
public InventoryStash(ItemStack[] contents, ItemStack helmet, ItemStack chest, ItemStack legs, ItemStack feet) {
this.setContents(contents);
this.setHelmet(helmet);
this.setChest(chest);
this.setLegs(legs);
this.setFeet(feet);
}
public void setContents(ItemStack[] contents) {
this.contents = contents;
}
public ItemStack[] getContents() {
return this.contents;
}
public void setHelmet(ItemStack helmet) {
this.helmet = helmet;
}
public ItemStack getHelmet() {
return this.helmet;
}
public void setChest(ItemStack chest) {
this.chest = chest;
}
public ItemStack getChest() {
return this.chest;
}
public void setLegs(ItemStack legs) {
this.legs = legs;
}
public ItemStack getLegs() {
return this.legs;
}
public void setFeet(ItemStack feet) {
this.feet = feet;
}
public ItemStack getFeet() {
return this.feet;
}
}

View File

@ -1,5 +1,5 @@
name: War name: War
version: 1.6 (de Gaulle) PREVIEW 6 version: 1.6 (de Gaulle) FINAL
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience. description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
author: tommytony author: tommytony
website: war.tommytony.com website: war.tommytony.com

View File

@ -1,5 +1,5 @@
name: War name: War
version: 1.6 (de Gaulle) PREVIEW 6 version: 1.6 (de Gaulle) FINAL
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience. description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
author: tommytony author: tommytony
website: war.tommytony.com website: war.tommytony.com