mirror of
https://github.com/taoneill/war.git
synced 2025-02-18 20:31:39 +01:00
Removing trailing whitespace
Adding this everywhere Adding annotations Use the block-style for if and consorts
This commit is contained in:
parent
ba30e6ca42
commit
88b2e5051d
File diff suppressed because it is too large
Load Diff
@ -29,13 +29,14 @@ public class WarBlockListener extends BlockListener {
|
||||
this.war = war;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
if (player != null && block != null) {
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
Warzone zone = war.warzone(player.getLocation());
|
||||
Team team = this.war.getPlayerTeam(player.getName());
|
||||
Warzone zone = this.war.warzone(player.getLocation());
|
||||
if (team != null && block != null && zone != null
|
||||
&& zone.isMonumentCenterBlock(block)
|
||||
&& block.getType() == team.getKind().getMaterial()
|
||||
@ -50,35 +51,35 @@ public class WarBlockListener extends BlockListener {
|
||||
event.setCancelled(false);
|
||||
return; // important otherwise cancelled down a few line by isImportantblock
|
||||
} else {
|
||||
war.badMsg(player, "You can't capture a monument without a block of your team's material. Get one from your team spawn.");
|
||||
this.war.badMsg(player, "You can't capture a monument without a block of your team's material. Get one from your team spawn.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
boolean isZoneMaker = war.isZoneMaker(player);
|
||||
boolean isZoneMaker = this.war.isZoneMaker(player);
|
||||
if (zone != null && zone.isImportantBlock(block) && (!isZoneMaker || (isZoneMaker && team != null))) {
|
||||
war.badMsg(player, "Can't build here.");
|
||||
this.war.badMsg(player, "Can't build here.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
// protect warzone lobbies
|
||||
for (Warzone wz: war.getWarzones()) {
|
||||
for (Warzone wz: this.war.getWarzones()) {
|
||||
if (wz.getLobby() != null && wz.getLobby().getVolume() != null && wz.getLobby().getVolume().contains(block)) {
|
||||
war.badMsg(player, "Can't build here.");
|
||||
this.war.badMsg(player, "Can't build here.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// protect the hub
|
||||
if (war.getWarHub() != null && war.getWarHub().getVolume().contains(block)) {
|
||||
war.badMsg(player, "Can't build here.");
|
||||
if (this.war.getWarHub() != null && this.war.getWarHub().getVolume().contains(block)) {
|
||||
this.war.badMsg(player, "Can't build here.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// buildInZonesOnly
|
||||
if (zone == null && war.isBuildInZonesOnly() && !war.canBuildOutsideZone(player)) {
|
||||
war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
||||
if (zone == null && this.war.isBuildInZonesOnly() && !this.war.canBuildOutsideZone(player)) {
|
||||
this.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -86,14 +87,14 @@ public class WarBlockListener extends BlockListener {
|
||||
// can't place a block of your team's color
|
||||
if (team != null && block.getType() == team.getKind().getMaterial()
|
||||
&& block.getData() == team.getKind().getData()) {
|
||||
war.badMsg(player, "You can only use your team's blocks to capture monuments.");
|
||||
this.war.badMsg(player, "You can only use your team's blocks to capture monuments.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (team != null && zone != null && zone.isFlagThief(player.getName())) {
|
||||
// a flag thief can't drop his flag
|
||||
war.badMsg(player, "Can't drop the flag. What are you doing? Run!");
|
||||
this.war.badMsg(player, "Can't drop the flag. What are you doing? Run!");
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
@ -104,7 +105,7 @@ public class WarBlockListener extends BlockListener {
|
||||
|| (isZoneMaker && team != null))
|
||||
) {
|
||||
// if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks)
|
||||
war.badMsg(player, "The blocks in this zone are unbreakable - this also means you can't build!");
|
||||
this.war.badMsg(player, "The blocks in this zone are unbreakable - this also means you can't build!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -112,12 +113,13 @@ public class WarBlockListener extends BlockListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
if (player != null && block != null) {
|
||||
handleBreakOrDamage(player, block, event);
|
||||
this.handleBreakOrDamage(player, block, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,13 +134,13 @@ public class WarBlockListener extends BlockListener {
|
||||
// }
|
||||
|
||||
private void handleBreakOrDamage(Player player, Block block, Cancellable event) {
|
||||
Warzone warzone = war.warzone(player.getLocation());
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
boolean isZoneMaker = war.isZoneMaker(player);
|
||||
Warzone warzone = this.war.warzone(player.getLocation());
|
||||
Team team = this.war.getPlayerTeam(player.getName());
|
||||
boolean isZoneMaker = this.war.isZoneMaker(player);
|
||||
|
||||
if (warzone != null && team == null && !isZoneMaker) {
|
||||
// can't actually destroy blocks in a warzone if not part of a team
|
||||
war.badMsg(player, "Can't destroy part of a warzone if you're not in a team.");
|
||||
this.war.badMsg(player, "Can't destroy part of a warzone if you're not in a team.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (team != null && block != null && warzone != null
|
||||
@ -159,7 +161,7 @@ public class WarBlockListener extends BlockListener {
|
||||
if (team != null && team.getSpawnVolume().contains(block)) {
|
||||
ItemStack teamKindBlock = new ItemStack(team.getKind().getMaterial(), team.getKind().getData());
|
||||
if (player.getInventory().contains(teamKindBlock)) {
|
||||
war.badMsg(player, "You already have a " + team.getName() + " block.");
|
||||
this.war.badMsg(player, "You already have a " + team.getName() + " block.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else {
|
||||
@ -170,7 +172,7 @@ public class WarBlockListener extends BlockListener {
|
||||
} else if (team != null && warzone.isEnemyTeamFlagBlock(team, block)) {
|
||||
if (warzone.isFlagThief(player.getName())) {
|
||||
// detect audacious thieves
|
||||
war.badMsg(player, "You can only steal one flag at a time!");
|
||||
this.war.badMsg(player, "You can only steal one flag at a time!");
|
||||
} else {
|
||||
Team lostFlagTeam = warzone.getTeamForFlagBlock(block);
|
||||
if (lostFlagTeam.getPlayers().size() != 0) {
|
||||
@ -187,15 +189,15 @@ public class WarBlockListener extends BlockListener {
|
||||
t.teamcast("Prevent " + player.getName() + " from reaching team " + team.getName() + "'s spawn or flag.");
|
||||
}
|
||||
}
|
||||
war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn or flag to capture it!");
|
||||
this.war.msg(player, "You have team " + lostFlagTeam.getName() + "'s flag. Reach your team spawn or flag to capture it!");
|
||||
} else {
|
||||
war.msg(player, "You can't steal team " + lostFlagTeam.getName() + "'s flag since no players are on that team.");
|
||||
this.war.msg(player, "You can't steal team " + lostFlagTeam.getName() + "'s flag since no players are on that team.");
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (!warzone.isMonumentCenterBlock(block)){
|
||||
war.badMsg(player, "Can't destroy this.");
|
||||
this.war.badMsg(player, "Can't destroy this.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -203,10 +205,10 @@ public class WarBlockListener extends BlockListener {
|
||||
|
||||
// protect warzone lobbies
|
||||
if (block != null) {
|
||||
for (Warzone zone: war.getWarzones()) {
|
||||
for (Warzone zone: this.war.getWarzones()) {
|
||||
if (zone.getLobby() != null && zone.getLobby().getVolume() != null &&
|
||||
zone.getLobby().getVolume().contains(block)) {
|
||||
war.badMsg(player, "Can't destroy this.");
|
||||
this.war.badMsg(player, "Can't destroy this.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -214,18 +216,18 @@ public class WarBlockListener extends BlockListener {
|
||||
}
|
||||
|
||||
// protect the hub
|
||||
if (war.getWarHub() != null && war.getWarHub().getVolume().contains(block)) {
|
||||
war.badMsg(player, "Can't destroy this.");
|
||||
if (this.war.getWarHub() != null && this.war.getWarHub().getVolume().contains(block)) {
|
||||
this.war.badMsg(player, "Can't destroy this.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// buildInZonesOnly
|
||||
Warzone blockZone = war.warzone(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
|
||||
Warzone blockZone = this.war.warzone(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
|
||||
if (blockZone == null
|
||||
&& war.isBuildInZonesOnly()
|
||||
&& !war.canBuildOutsideZone(player)) {
|
||||
war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
||||
&& this.war.isBuildInZonesOnly()
|
||||
&& !this.war.canBuildOutsideZone(player)) {
|
||||
this.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -236,7 +238,7 @@ public class WarBlockListener extends BlockListener {
|
||||
|| (isZoneMaker && team != null))
|
||||
) {
|
||||
// if the zone is unbreakable, no one but zone makers can break blocks (even then, zone makers in a team can't break blocks
|
||||
war.badMsg(player, "The blocks in this zone are unbreakable!");
|
||||
this.war.badMsg(player, "The blocks in this zone are unbreakable!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -34,14 +34,15 @@ public class WarEntityListener extends EntityListener {
|
||||
this.war = war;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Entity e = event.getEntity();
|
||||
if (e instanceof Player) {
|
||||
Player player = (Player)e;
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
Team team = this.war.getPlayerTeam(player.getName());
|
||||
if (team != null) {
|
||||
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
|
||||
zone.handleDeath(player);
|
||||
// if (zone.isDropLootOnDeath()) {
|
||||
// war.getServer().getScheduler().scheduleAsyncDelayedTask(war,
|
||||
@ -62,23 +63,23 @@ public class WarEntityListener extends EntityListener {
|
||||
// only let adversaries (same warzone, different team) attack each other
|
||||
Player a = (Player)attacker;
|
||||
Player d = (Player)defender;
|
||||
Warzone attackerWarzone = war.getPlayerTeamWarzone(a.getName());
|
||||
Team attackerTeam = war.getPlayerTeam(a.getName());
|
||||
Warzone defenderWarzone = war.getPlayerTeamWarzone(d.getName());
|
||||
Team defenderTeam = war.getPlayerTeam(d.getName());
|
||||
Warzone attackerWarzone = this.war.getPlayerTeamWarzone(a.getName());
|
||||
Team attackerTeam = this.war.getPlayerTeam(a.getName());
|
||||
Warzone defenderWarzone = this.war.getPlayerTeamWarzone(d.getName());
|
||||
Team defenderTeam = this.war.getPlayerTeam(d.getName());
|
||||
if (attackerTeam != null && defenderTeam != null
|
||||
&& attackerTeam != defenderTeam
|
||||
&& attackerWarzone == defenderWarzone) {
|
||||
// Make sure one of the players isn't in the spawn
|
||||
if (defenderTeam.getSpawnVolume().contains(d.getLocation())) { // attacking person in spawn
|
||||
if (!defenderWarzone.isFlagThief(d.getName())) { // thiefs can always be attacked
|
||||
war.badMsg(a, "Can't attack a player that's inside his team's spawn.");
|
||||
this.war.badMsg(a, "Can't attack a player that's inside his team's spawn.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} 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
|
||||
if (!attackerWarzone.isFlagThief(a.getName())) { // thiefs can always attack
|
||||
war.badMsg(a, "Can't attack a player from inside your spawn.");
|
||||
this.war.badMsg(a, "Can't attack a player from inside your spawn.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -86,7 +87,7 @@ public class WarEntityListener extends EntityListener {
|
||||
// Detect death, prevent it and respawn the player
|
||||
if (event.getDamage() >= d.getHealth()) {
|
||||
defenderWarzone.handleDeath(d);
|
||||
if (war.getServer().getPluginManager().getPlugin("HeroicDeath") != null) {
|
||||
if (this.war.getServer().getPluginManager().getPlugin("HeroicDeath") != null) {
|
||||
|
||||
}
|
||||
event.setCancelled(true);
|
||||
@ -97,32 +98,32 @@ public class WarEntityListener extends EntityListener {
|
||||
&& attacker.getEntityId() != defender.getEntityId()) {
|
||||
// same team, but not same person
|
||||
if (attackerWarzone.getFriendlyFire()) {
|
||||
war.badMsg(a, "Friendly fire is on! Please, don't hurt your teammates."); // if ff is on, let the attack go through
|
||||
this.war.badMsg(a, "Friendly fire is on! Please, don't hurt your teammates."); // if ff is on, let the attack go through
|
||||
} else {
|
||||
war.badMsg(a, "Your attack missed! Your target is on your team.");
|
||||
this.war.badMsg(a, "Your attack missed! Your target is on your team.");
|
||||
event.setCancelled(true); // ff is off
|
||||
}
|
||||
} else if (attackerTeam == null && defenderTeam == null && war.canPvpOutsideZones(a)){
|
||||
} else if (attackerTeam == null && defenderTeam == null && this.war.canPvpOutsideZones(a)){
|
||||
// let normal PVP through is its not turned off or if you have perms
|
||||
} else if (attackerTeam == null && defenderTeam == null && !war.canPvpOutsideZones(a)) {
|
||||
if (!war.isDisablePvpMessage()) {
|
||||
war.badMsg(a, "You need the 'war.pvp' permission to attack players outside warzones.");
|
||||
} else if (attackerTeam == null && defenderTeam == null && !this.war.canPvpOutsideZones(a)) {
|
||||
if (!this.war.isDisablePvpMessage()) {
|
||||
this.war.badMsg(a, "You need the 'war.pvp' permission to attack players outside warzones.");
|
||||
}
|
||||
event.setCancelled(true); // global pvp is off
|
||||
} else {
|
||||
war.badMsg(a, "Your attack missed!");
|
||||
this.war.badMsg(a, "Your attack missed!");
|
||||
if (attackerTeam == null) {
|
||||
war.badMsg(a, "You must join a team " +
|
||||
this.war.badMsg(a, "You must join a team " +
|
||||
", then you'll be able to damage people " +
|
||||
"in the other teams in that warzone.");
|
||||
} else if (defenderTeam == null) {
|
||||
war.badMsg(a, "Your target is not in a team.");
|
||||
this.war.badMsg(a, "Your target is not in a team.");
|
||||
} else if (attacker != null && defender != null && attacker.getEntityId() == defender.getEntityId()) {
|
||||
// You just hit yourself, probably with a bouncing arrow
|
||||
} else if (attackerTeam == defenderTeam) {
|
||||
war.badMsg(a, "Your target is on your team.");
|
||||
this.war.badMsg(a, "Your target is on your team.");
|
||||
} else if (attackerWarzone != defenderWarzone) {
|
||||
war.badMsg(a, "Your target is playing in another warzone.");
|
||||
this.war.badMsg(a, "Your target is playing in another warzone.");
|
||||
}
|
||||
event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team
|
||||
}
|
||||
@ -131,7 +132,7 @@ public class WarEntityListener extends EntityListener {
|
||||
// attacked by dispenser arrow most probably
|
||||
// Detect death, prevent it and respawn the player
|
||||
Player d = (Player) defender;
|
||||
Warzone defenderWarzone = war.getPlayerTeamWarzone(d.getName());
|
||||
Warzone defenderWarzone = this.war.getPlayerTeamWarzone(d.getName());
|
||||
if (d != null && defenderWarzone != null && event.getDamage() >= d.getHealth()) {
|
||||
defenderWarzone.handleDeath(d);
|
||||
event.setCancelled(true);
|
||||
@ -139,24 +140,25 @@ public class WarEntityListener extends EntityListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
// protect zones elements, lobbies and warhub from creepers
|
||||
List<Block> explodedBlocks = event.blockList();
|
||||
for (Block block : explodedBlocks) {
|
||||
if (war.getWarHub() != null && war.getWarHub().getVolume().contains(block)) {
|
||||
if (this.war.getWarHub() != null && this.war.getWarHub().getVolume().contains(block)) {
|
||||
event.setCancelled(true);
|
||||
war.logInfo("Explosion prevented at warhub.");
|
||||
this.war.logInfo("Explosion prevented at warhub.");
|
||||
return;
|
||||
}
|
||||
for (Warzone zone : war.getWarzones()) {
|
||||
for (Warzone zone : this.war.getWarzones()) {
|
||||
if (zone.isImportantBlock(block)) {
|
||||
event.setCancelled(true);
|
||||
war.logInfo("Explosion prevented in zone " + zone.getName() + ".");
|
||||
this.war.logInfo("Explosion prevented in zone " + zone.getName() + ".");
|
||||
return;
|
||||
} else if (zone.getLobby() != null && zone.getLobby().getVolume().contains(block)) {
|
||||
event.setCancelled(true);
|
||||
war.logInfo("Explosion prevented at zone " + zone.getName() + " lobby.");
|
||||
this.war.logInfo("Explosion prevented at zone " + zone.getName() + " lobby.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -164,21 +166,22 @@ public class WarEntityListener extends EntityListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player && war.getPlayerTeamWarzone(((Player) entity).getName()) != null) {
|
||||
if (entity instanceof Player && this.war.getPlayerTeamWarzone(((Player) entity).getName()) != null) {
|
||||
event.setCancelled(false);
|
||||
}
|
||||
|
||||
if (event instanceof EntityDamageByEntityEvent ||
|
||||
event instanceof EntityDamageByProjectileEvent) {
|
||||
handlerAttackDefend((EntityDamageByEntityEvent)event);
|
||||
this.handlerAttackDefend((EntityDamageByEntityEvent)event);
|
||||
} else {
|
||||
// Detect death (from , prevent it and respawn the player
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
|
||||
if (zone != null && event.getDamage() >= player.getHealth()) {
|
||||
zone.handleDeath(player);
|
||||
event.setCancelled(true);
|
||||
@ -188,12 +191,13 @@ public class WarEntityListener extends EntityListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCombust(EntityCombustEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
Team team = this.war.getPlayerTeam(player.getName());
|
||||
if (team != null && team.getSpawnVolume().contains(player.getLocation())) {
|
||||
// smother out the fire that didn't burn out when you respawned
|
||||
//Stop fire (upcast, watch out!)
|
||||
@ -207,10 +211,11 @@ public class WarEntityListener extends EntityListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Location location = event.getLocation();
|
||||
Warzone zone = war.warzone(location);
|
||||
Warzone zone = this.war.warzone(location);
|
||||
if (zone != null && zone.isNoCreatures()) {
|
||||
event.setCancelled(true);
|
||||
//war.logInfo("Prevented " + event.getMobType().getName() + " from spawning in zone " + zone.getName());
|
||||
@ -218,13 +223,14 @@ public class WarEntityListener extends EntityListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
if (war.isLoaded() && event.getRegainReason() == RegainReason.REGEN) {
|
||||
if (this.war.isLoaded() && event.getRegainReason() == RegainReason.REGEN) {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
Location location = player.getLocation();
|
||||
Warzone zone = war.warzone(location);
|
||||
Warzone zone = this.war.warzone(location);
|
||||
if (zone != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -41,35 +41,37 @@ public class WarPlayerListener extends PlayerListener {
|
||||
|
||||
public WarPlayerListener(War war) {
|
||||
this.war = war;
|
||||
random = new Random();
|
||||
this.random = new Random();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
Team team = this.war.getPlayerTeam(player.getName());
|
||||
if (team != null) {
|
||||
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
|
||||
if (zone != null) {
|
||||
zone.handlePlayerLeave(player, zone.getTeleport(), true);
|
||||
}
|
||||
}
|
||||
if (war.isWandBearer(player)) {
|
||||
war.removeWandBearer(player);
|
||||
if (this.war.isWandBearer(player)) {
|
||||
this.war.removeWandBearer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
Team team = this.war.getPlayerTeam(player.getName());
|
||||
if (team != null) {
|
||||
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
|
||||
|
||||
if (zone.isFlagThief(player.getName())) {
|
||||
// a flag thief can't drop his flag
|
||||
war.badMsg(player, "Can't drop items while stealing flag. What are you doing?! Run!");
|
||||
this.war.badMsg(player, "Can't drop items while stealing flag. What are you doing?! Run!");
|
||||
event.setCancelled(true);
|
||||
|
||||
} else {
|
||||
@ -80,36 +82,37 @@ public class WarPlayerListener extends PlayerListener {
|
||||
&& itemStack.getType() == team.getKind().getMaterial()
|
||||
&& itemStack.getData().getData() == team.getKind().getData()) {
|
||||
// Can't drop your team's kind block
|
||||
war.badMsg(player, "Can't drop " + team.getName() + " block blocks.");
|
||||
this.war.badMsg(player, "Can't drop " + team.getName() + " block blocks.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (zone.isNearWall(player.getLocation()) && itemStack != null) {
|
||||
war.badMsg(player, "Can't drop items near the zone border!");
|
||||
this.war.badMsg(player, "Can't drop items near the zone border!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (war.isWandBearer(player)) {
|
||||
if (this.war.isWandBearer(player)) {
|
||||
Item item = event.getItemDrop();
|
||||
if (item.getItemStack().getType() == Material.WOOD_SWORD) {
|
||||
String zoneName = war.getWandBearerZone(player);
|
||||
war.removeWandBearer(player);
|
||||
war.msg(player, "You dropped the zone " + zoneName + " wand.");
|
||||
String zoneName = this.war.getWandBearerZone(player);
|
||||
this.war.removeWandBearer(player);
|
||||
this.war.msg(player, "You dropped the zone " + zoneName + " wand.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
Team team = this.war.getPlayerTeam(player.getName());
|
||||
if (team != null) {
|
||||
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
||||
Warzone zone = this.war.getPlayerTeamWarzone(player.getName());
|
||||
|
||||
if (zone.isFlagThief(player.getName())) {
|
||||
// a flag thief can't pick up anything
|
||||
@ -134,11 +137,12 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryOpen(PlayerInventoryEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Inventory inventory = event.getInventory();
|
||||
Team team = war.getPlayerTeam(player.getName());
|
||||
Team team = this.war.getPlayerTeam(player.getName());
|
||||
if (team != null && inventory instanceof PlayerInventory) {
|
||||
// make sure the player doesn't have too many precious blocks
|
||||
// or illegal armor (i.e. armor not found in loadout)
|
||||
@ -147,20 +151,21 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if (playerInv.contains(teamKindBlock, 2)) {
|
||||
playerInv.remove(teamKindBlock);
|
||||
playerInv.addItem(teamKindBlock);
|
||||
war.badMsg(player, "All that " + team.getName() + " must have been heavy!");
|
||||
this.war.badMsg(player, "All that " + team.getName() + " must have been heavy!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Team talkingPlayerTeam = war.getPlayerTeam(player.getName());
|
||||
Team talkingPlayerTeam = this.war.getPlayerTeam(player.getName());
|
||||
if (talkingPlayerTeam != null) {
|
||||
String msg = event.getMessage();
|
||||
String[] split = msg.split(" ");
|
||||
if (!war.isZoneMaker(player) && split.length > 0 && split[0].startsWith("/")) {
|
||||
if (!this.war.isZoneMaker(player) && split.length > 0 && split[0].startsWith("/")) {
|
||||
String command = split[0].substring(1);
|
||||
if (!command.equals("war") && !command.equals("zones") && !command.equals("warzones")
|
||||
&& !command.equals("zone") && !command.equals("warzone")
|
||||
@ -170,7 +175,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
&& !command.equals("team")
|
||||
&& !command.equals("warhub")
|
||||
&& !command.equals("zonemaker")) {
|
||||
war.badMsg(player, "Can't use anything but War commands (e.g. /leave, /warhub) while you're playing in a warzone.");
|
||||
this.war.badMsg(player, "Can't use anything but War commands (e.g. /leave, /warhub) while you're playing in a warzone.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -178,33 +183,35 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
String reason = event.getReason();
|
||||
if (reason.contains("moved") || reason.contains("too quickly") || reason.contains("Hacking")) {
|
||||
boolean inWarzone = war.inAnyWarzone(player.getLocation());
|
||||
boolean inLobby = war.inAnyWarzone(player.getLocation());
|
||||
boolean inWarzone = this.war.inAnyWarzone(player.getLocation());
|
||||
boolean inLobby = this.war.inAnyWarzone(player.getLocation());
|
||||
boolean inWarhub = false;
|
||||
if (war.getWarHub() != null && war.getWarHub().getVolume().contains(player.getLocation())) {
|
||||
if (this.war.getWarHub() != null && this.war.getWarHub().getVolume().contains(player.getLocation())) {
|
||||
inWarhub = true;
|
||||
}
|
||||
if (inWarzone || inLobby || inWarhub) {
|
||||
event.setCancelled(true);
|
||||
war.logWarn("Prevented " + player.getName() + " from getting kicked.");
|
||||
this.war.logWarn("Prevented " + player.getName() + " from getting kicked.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.getItemInHand().getType() == Material.WOOD_SWORD && war.isWandBearer(player)) {
|
||||
String zoneName = war.getWandBearerZone(player);
|
||||
ZoneSetter setter = new ZoneSetter(war, player, zoneName);
|
||||
if (player.getItemInHand().getType() == Material.WOOD_SWORD && this.war.isWandBearer(player)) {
|
||||
String zoneName = this.war.getWandBearerZone(player);
|
||||
ZoneSetter setter = new ZoneSetter(this.war, player, zoneName);
|
||||
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) {
|
||||
war.badMsg(player, "Too far.");
|
||||
this.war.badMsg(player, "Too far.");
|
||||
} else if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
setter.placeCorner1(event.getClickedBlock());
|
||||
event.setUseItemInHand(Result.ALLOW);
|
||||
@ -216,26 +223,27 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (war.isLoaded()) {
|
||||
if (this.war.isLoaded()) {
|
||||
Player player = event.getPlayer();
|
||||
Location playerLoc = event.getFrom(); // same as player.getLoc. Don't call again we need same result.
|
||||
Warzone locZone = null;
|
||||
ZoneLobby locLobby = null;
|
||||
locZone = war.warzone(playerLoc);
|
||||
locLobby = war.lobby(playerLoc);
|
||||
boolean canPlay = war.canPlayWar(player);
|
||||
boolean isMaker = war.isZoneMaker(player);
|
||||
locZone = this.war.warzone(playerLoc);
|
||||
locLobby = this.war.lobby(playerLoc);
|
||||
boolean canPlay = this.war.canPlayWar(player);
|
||||
boolean isMaker = this.war.isZoneMaker(player);
|
||||
|
||||
// Zone walls
|
||||
Team currentTeam = war.getPlayerTeam(player.getName());
|
||||
Warzone playerWarzone = war.getPlayerTeamWarzone(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
|
||||
Team currentTeam = this.war.getPlayerTeam(player.getName());
|
||||
Warzone playerWarzone = this.war.getPlayerTeamWarzone(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
|
||||
boolean protecting = false;
|
||||
if (currentTeam != null) {
|
||||
//Warzone nearbyZone = war.zoneOfZoneWallAtProximity(playerLoc);
|
||||
protecting = playerWarzone.protectZoneWallAgainstPlayer(player);
|
||||
} else {
|
||||
Warzone nearbyZone = war.zoneOfZoneWallAtProximity(playerLoc);
|
||||
Warzone nearbyZone = this.war.zoneOfZoneWallAtProximity(playerLoc);
|
||||
if (nearbyZone != null && !isMaker) {
|
||||
protecting = nearbyZone.protectZoneWallAgainstPlayer(player);
|
||||
}
|
||||
@ -244,7 +252,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if (!protecting) {
|
||||
// zone makers still need to delete their walls
|
||||
// make sure to delete any wall guards as you leave
|
||||
for (Warzone zone : war.getWarzones()) {
|
||||
for (Warzone zone : this.war.getWarzones()) {
|
||||
zone.dropZoneWallGuardIfAny(player);
|
||||
}
|
||||
}
|
||||
@ -252,15 +260,15 @@ public class WarPlayerListener extends PlayerListener {
|
||||
// Warzone lobby gates
|
||||
if (locLobby != null) {
|
||||
Warzone zone = locLobby.getZone();
|
||||
Team oldTeam = war.getPlayerTeam(player.getName());
|
||||
Team oldTeam = this.war.getPlayerTeam(player.getName());
|
||||
boolean isAutoAssignGate = false;
|
||||
if (oldTeam == null && canPlay) { // trying to counter spammy player move
|
||||
isAutoAssignGate = zone.getLobby().isAutoAssignGate(playerLoc);
|
||||
if (isAutoAssignGate) {
|
||||
if (zone.isDisabled()){
|
||||
handleDisabledZone(event, player, zone);
|
||||
this.handleDisabledZone(event, player, zone);
|
||||
} else {
|
||||
dropFromOldTeamIfAny(player);
|
||||
this.dropFromOldTeamIfAny(player);
|
||||
int noOfPlayers = 0;
|
||||
for (Team t : zone.getTeams()) {
|
||||
noOfPlayers += t.getPlayers().size();
|
||||
@ -268,13 +276,13 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if (noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
|
||||
zone.autoAssign(player);
|
||||
|
||||
if (war.getWarHub() != null) {
|
||||
war.getWarHub().resetZoneSign(zone);
|
||||
if (this.war.getWarHub() != null) {
|
||||
this.war.getWarHub().resetZoneSign(zone);
|
||||
}
|
||||
} else {
|
||||
event.setTo(zone.getTeleport());
|
||||
//player.teleport(zone.getTeleport());
|
||||
war.badMsg(player, "All teams are full.");
|
||||
this.war.badMsg(player, "All teams are full.");
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -283,35 +291,35 @@ public class WarPlayerListener extends PlayerListener {
|
||||
// go through all the team gates
|
||||
for (Team team : zone.getTeams()){
|
||||
if (zone.getLobby().isInTeamGate(team, playerLoc)) {
|
||||
dropFromOldTeamIfAny(player);
|
||||
this.dropFromOldTeamIfAny(player);
|
||||
if (zone.isDisabled()){
|
||||
handleDisabledZone(event, player, zone);
|
||||
this.handleDisabledZone(event, player, zone);
|
||||
} else if (team.getPlayers().size() < zone.getTeamCap()) {
|
||||
team.addPlayer(player);
|
||||
team.resetSign();
|
||||
if (war.getWarHub() != null) {
|
||||
war.getWarHub().resetZoneSign(zone);
|
||||
if (this.war.getWarHub() != null) {
|
||||
this.war.getWarHub().resetZoneSign(zone);
|
||||
}
|
||||
zone.keepPlayerInventory(player);
|
||||
war.msg(player, "Your inventory is in storage until you /leave.");
|
||||
this.war.msg(player, "Your inventory is in storage until you /leave.");
|
||||
zone.respawnPlayer(event, team, player);
|
||||
for (Team t : zone.getTeams()){
|
||||
t.teamcast("" + player.getName() + " joined team " + team.getName() + ".");
|
||||
}
|
||||
} else {
|
||||
event.setTo(zone.getTeleport());
|
||||
war.badMsg(player, "Team " + team.getName() + " is full.");
|
||||
this.war.badMsg(player, "Team " + team.getName() + " is full.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (war.getWarHub() != null && zone.getLobby().isInWarHubLinkGate(playerLoc)
|
||||
&& !war.getWarHub().getVolume().contains(player.getLocation())){
|
||||
dropFromOldTeamIfAny(player);
|
||||
event.setTo(war.getWarHub().getLocation());
|
||||
if (this.war.getWarHub() != null && zone.getLobby().isInWarHubLinkGate(playerLoc)
|
||||
&& !this.war.getWarHub().getVolume().contains(player.getLocation())){
|
||||
this.dropFromOldTeamIfAny(player);
|
||||
event.setTo(this.war.getWarHub().getLocation());
|
||||
//player.teleport(war.getWarHub().getLocation());
|
||||
war.msg(player, "Welcome to the War hub.");
|
||||
this.war.msg(player, "Welcome to the War hub.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -319,19 +327,19 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
|
||||
// Warhub zone gates
|
||||
WarHub hub = war.getWarHub();
|
||||
WarHub hub = this.war.getWarHub();
|
||||
if (hub != null && hub.getVolume().contains(player.getLocation())) {
|
||||
Warzone zone = hub.getDestinationWarzoneForLocation(playerLoc);
|
||||
if (zone != null && zone.getTeleport() != null) {
|
||||
event.setTo(zone.getTeleport());
|
||||
//player.teleport(zone.getTeleport());
|
||||
war.msg(player, "Welcome to warzone " + zone.getName() + ".");
|
||||
this.war.msg(player, "Welcome to warzone " + zone.getName() + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isLeaving = playerWarzone != null && playerWarzone.getLobby().isLeavingZone(playerLoc);
|
||||
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||
Team playerTeam = this.war.getPlayerTeam(player.getName());
|
||||
if (isLeaving) { // already in a team and in warzone, leaving
|
||||
// same as leave
|
||||
if (playerTeam != null) {
|
||||
@ -350,7 +358,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if (locZone == null && playerTeam != null && playerWarzone.getLobby() != null
|
||||
&& !playerWarzone.getLobby().getVolume().contains(playerLoc)
|
||||
&& !isLeaving) {
|
||||
war.badMsg(player, "Use /leave to exit the zone.");
|
||||
this.war.badMsg(player, "Use /leave to exit the zone.");
|
||||
event.setTo(playerTeam.getTeamSpawn());
|
||||
return;
|
||||
}
|
||||
@ -360,21 +368,26 @@ public class WarPlayerListener extends PlayerListener {
|
||||
&& playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam)
|
||||
&& player.getHealth() < 20
|
||||
&& player.getHealth() > 0 // don't heal the dead
|
||||
&& random.nextInt(77) == 3 ) { // one chance out of many of getting healed
|
||||
&& this.random.nextInt(77) == 3 ) { // one chance out of many of getting healed
|
||||
int currentHp = player.getHealth();
|
||||
int newHp = currentHp + locZone.getMonumentHeal();
|
||||
if (newHp > 20) newHp = 20;
|
||||
if (newHp > 20) {
|
||||
newHp = 20;
|
||||
}
|
||||
player.setHealth(newHp);
|
||||
String isS = "s"; // no 's' in 'hearts' when it's just one heart
|
||||
if (newHp-currentHp==2) isS="";
|
||||
if (newHp-currentHp==2) {
|
||||
isS="";
|
||||
}
|
||||
String heartNum = ""; // since (newHp-currentHp)/2 won't give the right amount
|
||||
if (newHp-currentHp==2)
|
||||
heartNum="1 ";
|
||||
else if (newHp-currentHp%2==0) // for some reason
|
||||
heartNum=((newHp-currentHp)/2)+" ";
|
||||
else
|
||||
heartNum=((newHp-currentHp-1)/2)+".5 ";
|
||||
war.msg(player, "Your dance pleases the monument's voodoo. You gain "+heartNum+"heart"+isS+"!");
|
||||
if (newHp-currentHp==2) {
|
||||
heartNum="1 ";
|
||||
} else if (newHp-currentHp%2==0) {
|
||||
heartNum=((newHp-currentHp)/2)+" ";
|
||||
} else {
|
||||
heartNum=((newHp-currentHp-1)/2)+".5 ";
|
||||
}
|
||||
this.war.msg(player, "Your dance pleases the monument's voodoo. You gain "+heartNum+"heart"+isS+"!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -383,7 +396,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
&& (playerTeam.getSpawnVolume().contains(player.getLocation())
|
||||
|| (playerTeam.getFlagVolume() != null && playerTeam.getFlagVolume().contains(player.getLocation())))) {
|
||||
if (playerWarzone.isTeamFlagStolen(playerTeam)) {
|
||||
war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned.");
|
||||
this.war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned.");
|
||||
} else {
|
||||
synchronized(playerWarzone) {
|
||||
// flags can be captured at own spawn or own flag pole
|
||||
@ -416,10 +429,10 @@ public class WarPlayerListener extends PlayerListener {
|
||||
} else if (locZone != null && locZone.getLobby() != null
|
||||
&& !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
||||
// player is not in any team, but inside warzone boundaries, get him out
|
||||
Warzone zone = war.warzone(playerLoc);
|
||||
Warzone zone = this.war.warzone(playerLoc);
|
||||
event.setTo(zone.getTeleport());
|
||||
//player.teleport(zone.getTeleport());
|
||||
war.badMsg(player, "You can't be inside a warzone without a team.");
|
||||
this.war.badMsg(player, "You can't be inside a warzone without a team.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -427,25 +440,25 @@ public class WarPlayerListener extends PlayerListener {
|
||||
|
||||
private void handleDisabledZone(PlayerMoveEvent event, Player player, Warzone zone) {
|
||||
if (zone.getLobby() != null) {
|
||||
war.badMsg(player, "This warzone is disabled.");
|
||||
this.war.badMsg(player, "This warzone is disabled.");
|
||||
event.setTo(zone.getTeleport());
|
||||
}
|
||||
}
|
||||
|
||||
private void dropFromOldTeamIfAny(Player player) {
|
||||
// drop from old team if any
|
||||
Team previousTeam = war.getPlayerTeam(player.getName());
|
||||
Team previousTeam = this.war.getPlayerTeam(player.getName());
|
||||
if (previousTeam != null) {
|
||||
if (!previousTeam.removePlayer(player.getName())){
|
||||
war.logWarn("Could not remove player " + player.getName() + " from team " + previousTeam.getName());
|
||||
this.war.logWarn("Could not remove player " + player.getName() + " from team " + previousTeam.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getAllTeamsMsg(Player player){
|
||||
String teamsMessage = "Teams: ";
|
||||
Warzone warzone = war.warzone(player.getLocation());
|
||||
ZoneLobby lobby = war.lobby(player.getLocation());
|
||||
Warzone warzone = this.war.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.war.lobby(player.getLocation());
|
||||
if (warzone == null && lobby != null) {
|
||||
warzone = lobby.getZone();
|
||||
} else {
|
||||
|
@ -26,7 +26,7 @@ public class Monument {
|
||||
this.name = name;
|
||||
this.location = location;
|
||||
this.warzone = warzone;
|
||||
volume = new Volume(name, war, warzone.getWorld());
|
||||
this.volume = new Volume(name, war, warzone.getWorld());
|
||||
this.setLocation(location);
|
||||
|
||||
this.addMonumentBlocks();
|
||||
@ -36,99 +36,97 @@ public class Monument {
|
||||
this.volume.setToMaterial(Material.AIR);
|
||||
|
||||
this.ownerTeam = null;
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
int x = this.location.getBlockX();
|
||||
int y = this.location.getBlockY();
|
||||
int z = this.location.getBlockZ();
|
||||
|
||||
// center
|
||||
warzone.getWorld().getBlockAt(x, y-1, z).getState().setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z).getState().setType(Material.OBSIDIAN);
|
||||
|
||||
// inner ring
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y-1, z).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y-1, z).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
|
||||
// outer ring
|
||||
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z+2).setType(Material.GLOWSTONE);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z-2).setType(Material.GLOWSTONE);
|
||||
this.warzone.getWorld().getBlockAt(x+2, y-1, z+2).setType(Material.GLOWSTONE);
|
||||
this.warzone.getWorld().getBlockAt(x+2, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+2, y-1, z).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+2, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+2, y-1, z-2).setType(Material.GLOWSTONE);
|
||||
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z+2).setType(Material.GLOWSTONE);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z-2).setType(Material.GLOWSTONE);
|
||||
this.warzone.getWorld().getBlockAt(x-2, y-1, z+2).setType(Material.GLOWSTONE);
|
||||
this.warzone.getWorld().getBlockAt(x-2, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-2, y-1, z).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-2, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-2, y-1, z-2).setType(Material.GLOWSTONE);
|
||||
|
||||
// block holder
|
||||
warzone.getWorld().getBlockAt(x, y, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y, z).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y, z+1).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x, y+1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y+1, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y+1, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y+1, z+1).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x, y+2, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y+2, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y+2, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y+2, z).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y+2, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y+2, z+1).setType(Material.OBSIDIAN);
|
||||
|
||||
}
|
||||
|
||||
public boolean isNear(Location playerLocation) {
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
int playerX = (int)playerLocation.getBlockX();
|
||||
int playerY = (int)playerLocation.getBlockY();
|
||||
int playerZ = (int)playerLocation.getBlockZ();
|
||||
int x = this.location.getBlockX();
|
||||
int y = this.location.getBlockY();
|
||||
int z = this.location.getBlockZ();
|
||||
int playerX = playerLocation.getBlockX();
|
||||
int playerY = playerLocation.getBlockY();
|
||||
int playerZ = playerLocation.getBlockZ();
|
||||
int diffX = Math.abs(playerX - x);
|
||||
int diffY = Math.abs(playerY - y);
|
||||
int diffZ = Math.abs(playerZ - z);
|
||||
if (diffX < 6 && diffY < 6 && diffZ < 6) {
|
||||
return true;
|
||||
}
|
||||
if (diffX < 6 && diffY < 6 && diffZ < 6)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOwner(Team team) {
|
||||
if (team == ownerTeam) {
|
||||
return true;
|
||||
}
|
||||
if (team == this.ownerTeam)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasOwner() {
|
||||
return ownerTeam != null;
|
||||
return this.ownerTeam != null;
|
||||
}
|
||||
|
||||
public void capture(Team team) {
|
||||
ownerTeam = team;
|
||||
this.ownerTeam = team;
|
||||
}
|
||||
|
||||
public void uncapture() {
|
||||
ownerTeam = null;
|
||||
this.ownerTeam = null;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
return this.location;
|
||||
}
|
||||
|
||||
public void setOwnerTeam(Team team) {
|
||||
@ -137,20 +135,20 @@ public class Monument {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
Block locationBlock = warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
volume.setCornerOne(locationBlock.getFace(BlockFace.DOWN).getFace(BlockFace.EAST, 2).getFace(BlockFace.SOUTH, 2));
|
||||
volume.setCornerTwo(locationBlock.getFace(BlockFace.UP, 2).getFace(BlockFace.WEST, 2).getFace(BlockFace.NORTH, 2));
|
||||
volume.saveBlocks();
|
||||
Block locationBlock = this.warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
this.volume.setCornerOne(locationBlock.getFace(BlockFace.DOWN).getFace(BlockFace.EAST, 2).getFace(BlockFace.SOUTH, 2));
|
||||
this.volume.setCornerTwo(locationBlock.getFace(BlockFace.UP, 2).getFace(BlockFace.WEST, 2).getFace(BlockFace.NORTH, 2));
|
||||
this.volume.saveBlocks();
|
||||
this.location = location;
|
||||
this.addMonumentBlocks();
|
||||
}
|
||||
|
||||
public Volume getVolume() {
|
||||
return volume;
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
public void setVolume(Volume newVolume) {
|
||||
@ -160,6 +158,6 @@ public class Monument {
|
||||
|
||||
public Team getOwnerTeam() {
|
||||
|
||||
return ownerTeam;
|
||||
return this.ownerTeam;
|
||||
}
|
||||
}
|
||||
|
@ -43,25 +43,27 @@ public class Team {
|
||||
}
|
||||
|
||||
public TeamKind getKind() {
|
||||
return kind;
|
||||
return this.kind;
|
||||
}
|
||||
|
||||
private void setSpawnVolume() {
|
||||
if (spawnVolume.isSaved()) spawnVolume.resetBlocks();
|
||||
int x = teamSpawn.getBlockX();
|
||||
int y = teamSpawn.getBlockY();
|
||||
int z = teamSpawn.getBlockZ();
|
||||
if (this.spawnVolume.isSaved()) {
|
||||
this.spawnVolume.resetBlocks();
|
||||
}
|
||||
int x = this.teamSpawn.getBlockX();
|
||||
int y = this.teamSpawn.getBlockY();
|
||||
int z = this.teamSpawn.getBlockZ();
|
||||
|
||||
if (warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
|
||||
this.spawnVolume.setCornerOne(warzone.getWorld().getBlockAt(x, y-1, z));
|
||||
this.spawnVolume.setCornerTwo(warzone.getWorld().getBlockAt(x, y+3, z));
|
||||
} else if (warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)) {
|
||||
this.spawnVolume.setCornerOne(warzone.getWorld().getBlockAt(x-1, y-1, z-1));
|
||||
this.spawnVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+1, y+3, z+1));
|
||||
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
|
||||
this.spawnVolume.setCornerOne(this.warzone.getWorld().getBlockAt(x, y-1, z));
|
||||
this.spawnVolume.setCornerTwo(this.warzone.getWorld().getBlockAt(x, y+3, z));
|
||||
} else if (this.warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)) {
|
||||
this.spawnVolume.setCornerOne(this.warzone.getWorld().getBlockAt(x-1, y-1, z-1));
|
||||
this.spawnVolume.setCornerTwo(this.warzone.getWorld().getBlockAt(x+1, y+3, z+1));
|
||||
} else {
|
||||
// flat or big
|
||||
this.spawnVolume.setCornerOne(warzone.getWorld().getBlockAt(x-2, y-1, z-2));
|
||||
this.spawnVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+2, y+3, z+2));
|
||||
this.spawnVolume.setCornerOne(this.warzone.getWorld().getBlockAt(x-2, y-1, z-2));
|
||||
this.spawnVolume.setCornerTwo(this.warzone.getWorld().getBlockAt(x+2, y+3, z+2));
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,39 +73,39 @@ public class Team {
|
||||
this.spawnVolume.setToMaterial(Material.AIR);
|
||||
|
||||
// Set the spawn
|
||||
int x = teamSpawn.getBlockX();
|
||||
int y = teamSpawn.getBlockY();
|
||||
int z = teamSpawn.getBlockZ();
|
||||
int x = this.teamSpawn.getBlockX();
|
||||
int y = this.teamSpawn.getBlockY();
|
||||
int z = this.teamSpawn.getBlockZ();
|
||||
|
||||
if (warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
|
||||
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
|
||||
// nothing but glowstone
|
||||
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
|
||||
} else {
|
||||
// first ring
|
||||
setBlock(x+1, y-1, z+1, kind);
|
||||
setBlock(x+1, y-1, z, kind);
|
||||
setBlock(x+1, y-1, z-1, kind);
|
||||
setBlock(x, y-1, z+1, kind);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
|
||||
setBlock(x, y-1, z-1, kind);
|
||||
setBlock(x-1, y-1, z+1, kind);
|
||||
setBlock(x-1, y-1, z, kind);
|
||||
setBlock(x-1, y-1, z-1, kind);
|
||||
this.setBlock(x+1, y-1, z+1, this.kind);
|
||||
this.setBlock(x+1, y-1, z, this.kind);
|
||||
this.setBlock(x+1, y-1, z-1, this.kind);
|
||||
this.setBlock(x, y-1, z+1, this.kind);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
|
||||
this.setBlock(x, y-1, z-1, this.kind);
|
||||
this.setBlock(x-1, y-1, z+1, this.kind);
|
||||
this.setBlock(x-1, y-1, z, this.kind);
|
||||
this.setBlock(x-1, y-1, z-1, this.kind);
|
||||
}
|
||||
|
||||
// Orientation
|
||||
int yaw = 0;
|
||||
if (teamSpawn.getYaw() >= 0){
|
||||
yaw = (int)(teamSpawn.getYaw() % 360);
|
||||
if (this.teamSpawn.getYaw() >= 0){
|
||||
yaw = (int)(this.teamSpawn.getYaw() % 360);
|
||||
} else {
|
||||
yaw = (int)(360 + (teamSpawn.getYaw() % 360));
|
||||
yaw = (int)(360 + (this.teamSpawn.getYaw() % 360));
|
||||
}
|
||||
Block signBlock = null;
|
||||
int signData = 0;
|
||||
|
||||
if (warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)){
|
||||
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)){
|
||||
// INVISIBLE style
|
||||
signBlock = warzone.getWorld().getBlockAt(x, y, z);
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z);
|
||||
if (yaw >= 0 && yaw < 90) {
|
||||
signData = 10;
|
||||
}else if (yaw >= 90 && yaw <= 180) {
|
||||
@ -113,43 +115,43 @@ public class Team {
|
||||
} else if (yaw >= 270 && yaw <= 360) {
|
||||
signData = 6;
|
||||
}
|
||||
} else if (warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)){
|
||||
} else if (this.warzone.getSpawnStyle().equals(TeamSpawnStyles.SMALL)){
|
||||
// SMALL style
|
||||
if (yaw >= 0 && yaw < 90) {
|
||||
signData = 10;
|
||||
signBlock = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH).getFace(BlockFace.WEST);
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH).getFace(BlockFace.WEST);
|
||||
}else if (yaw >= 90 && yaw <= 180) {
|
||||
signData = 14;
|
||||
signBlock = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH).getFace(BlockFace.EAST);
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH).getFace(BlockFace.EAST);
|
||||
} else if (yaw >= 180 && yaw < 270) {
|
||||
signData = 2;
|
||||
signBlock = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH).getFace(BlockFace.EAST);
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH).getFace(BlockFace.EAST);
|
||||
} else if (yaw >= 270 && yaw <= 360) {
|
||||
signData = 6;
|
||||
signBlock = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH).getFace(BlockFace.WEST);
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH).getFace(BlockFace.WEST);
|
||||
}
|
||||
} else {
|
||||
// outer ring (FLAT or BIG)
|
||||
setBlock(x+2, y-1, z+2, kind);
|
||||
setBlock(x+2, y-1, z+1, kind);
|
||||
setBlock(x+2, y-1, z, kind);
|
||||
setBlock(x+2, y-1, z-1, kind);
|
||||
setBlock(x+2, y-1, z-2, kind);
|
||||
this.setBlock(x+2, y-1, z+2, this.kind);
|
||||
this.setBlock(x+2, y-1, z+1, this.kind);
|
||||
this.setBlock(x+2, y-1, z, this.kind);
|
||||
this.setBlock(x+2, y-1, z-1, this.kind);
|
||||
this.setBlock(x+2, y-1, z-2, this.kind);
|
||||
|
||||
setBlock(x-1, y-1, z+2, kind);
|
||||
setBlock(x-1, y-1, z-2, kind);
|
||||
this.setBlock(x-1, y-1, z+2, this.kind);
|
||||
this.setBlock(x-1, y-1, z-2, this.kind);
|
||||
|
||||
setBlock(x, y-1, z+2, kind);
|
||||
setBlock(x, y-1, z-2, kind);
|
||||
this.setBlock(x, y-1, z+2, this.kind);
|
||||
this.setBlock(x, y-1, z-2, this.kind);
|
||||
|
||||
setBlock(x+1, y-1, z+2, kind);
|
||||
setBlock(x+1, y-1, z-2, kind);
|
||||
this.setBlock(x+1, y-1, z+2, this.kind);
|
||||
this.setBlock(x+1, y-1, z-2, this.kind);
|
||||
|
||||
setBlock(x-2, y-1, z+2, kind);
|
||||
setBlock(x-2, y-1, z+1, kind);
|
||||
setBlock(x-2, y-1, z, kind);
|
||||
setBlock(x-2, y-1, z-1, kind);
|
||||
setBlock(x-2, y-1, z-2, kind);
|
||||
this.setBlock(x-2, y-1, z+2, this.kind);
|
||||
this.setBlock(x-2, y-1, z+1, this.kind);
|
||||
this.setBlock(x-2, y-1, z, this.kind);
|
||||
this.setBlock(x-2, y-1, z-1, this.kind);
|
||||
this.setBlock(x-2, y-1, z-2, this.kind);
|
||||
|
||||
BlockFace facing = null;
|
||||
BlockFace opposite = null;
|
||||
@ -157,130 +159,130 @@ public class Team {
|
||||
facing = BlockFace.NORTH_WEST;
|
||||
opposite = BlockFace.SOUTH_EAST;
|
||||
signData = 10;
|
||||
signBlock = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST, 2);
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST, 2);
|
||||
|
||||
if (warzone.getSpawnStyle().equals(TeamSpawnStyles.BIG)) {
|
||||
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyles.BIG)) {
|
||||
// rim
|
||||
setBlock(x-2, y, z-1, kind);
|
||||
setBlock(x-2, y, z-2, kind);
|
||||
setBlock(x-1, y, z-2, kind);
|
||||
setBlock(x, y, z-2, kind);
|
||||
setBlock(x+1, y, z-2, kind);
|
||||
setBlock(x+2, y, z-2, kind);
|
||||
setBlock(x+2, y, z-1, kind);
|
||||
setBlock(x+2, y, z, kind);
|
||||
setBlock(x+2, y, z+1, kind);
|
||||
setBlock(x+2, y, z+2, kind);
|
||||
setBlock(x+1, y, z+2, kind);
|
||||
this.setBlock(x-2, y, z-1, this.kind);
|
||||
this.setBlock(x-2, y, z-2, this.kind);
|
||||
this.setBlock(x-1, y, z-2, this.kind);
|
||||
this.setBlock(x, y, z-2, this.kind);
|
||||
this.setBlock(x+1, y, z-2, this.kind);
|
||||
this.setBlock(x+2, y, z-2, this.kind);
|
||||
this.setBlock(x+2, y, z-1, this.kind);
|
||||
this.setBlock(x+2, y, z, this.kind);
|
||||
this.setBlock(x+2, y, z+1, this.kind);
|
||||
this.setBlock(x+2, y, z+2, this.kind);
|
||||
this.setBlock(x+1, y, z+2, this.kind);
|
||||
|
||||
// tower
|
||||
setBlock(x, y+1, z-2, kind);
|
||||
setBlock(x+1, y+1, z-2, kind);
|
||||
setBlock(x+2, y+1, z-2, kind);
|
||||
setBlock(x+2, y+1, z-1, kind);
|
||||
setBlock(x+2, y+1, z, kind);
|
||||
this.setBlock(x, y+1, z-2, this.kind);
|
||||
this.setBlock(x+1, y+1, z-2, this.kind);
|
||||
this.setBlock(x+2, y+1, z-2, this.kind);
|
||||
this.setBlock(x+2, y+1, z-1, this.kind);
|
||||
this.setBlock(x+2, y+1, z, this.kind);
|
||||
|
||||
setBlock(x+1, y+2, z-2, kind);
|
||||
setBlock(x+2, y+2, z-2, kind);
|
||||
setBlock(x+2, y+2, z-1, kind);
|
||||
this.setBlock(x+1, y+2, z-2, this.kind);
|
||||
this.setBlock(x+2, y+2, z-2, this.kind);
|
||||
this.setBlock(x+2, y+2, z-1, this.kind);
|
||||
|
||||
setBlock(x+2, y+3, z-2, kind);
|
||||
this.setBlock(x+2, y+3, z-2, this.kind);
|
||||
}
|
||||
} else if (yaw >= 90 && yaw <= 180) {
|
||||
facing = BlockFace.NORTH_EAST;
|
||||
opposite = BlockFace.SOUTH_WEST;
|
||||
signData = 14;
|
||||
signBlock = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH, 2).getFace(BlockFace.EAST, 2);
|
||||
if (warzone.getSpawnStyle().equals(TeamSpawnStyles.BIG)) {
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH, 2).getFace(BlockFace.EAST, 2);
|
||||
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyles.BIG)) {
|
||||
// rim
|
||||
setBlock(x+1, y, z-2, kind);
|
||||
setBlock(x+2, y, z-2, kind);
|
||||
setBlock(x+2, y, z-1, kind);
|
||||
setBlock(x+2, y, z, kind);
|
||||
setBlock(x+2, y, z+1, kind);
|
||||
setBlock(x+2, y, z+2, kind);
|
||||
setBlock(x+1, y, z+2, kind);
|
||||
setBlock(x, y, z+2, kind);
|
||||
setBlock(x-1, y, z+2, kind);
|
||||
setBlock(x-2, y, z+2, kind);
|
||||
setBlock(x-2, y, z+1, kind);
|
||||
this.setBlock(x+1, y, z-2, this.kind);
|
||||
this.setBlock(x+2, y, z-2, this.kind);
|
||||
this.setBlock(x+2, y, z-1, this.kind);
|
||||
this.setBlock(x+2, y, z, this.kind);
|
||||
this.setBlock(x+2, y, z+1, this.kind);
|
||||
this.setBlock(x+2, y, z+2, this.kind);
|
||||
this.setBlock(x+1, y, z+2, this.kind);
|
||||
this.setBlock(x, y, z+2, this.kind);
|
||||
this.setBlock(x-1, y, z+2, this.kind);
|
||||
this.setBlock(x-2, y, z+2, this.kind);
|
||||
this.setBlock(x-2, y, z+1, this.kind);
|
||||
|
||||
// tower
|
||||
setBlock(x+2, y+1, z, kind);
|
||||
setBlock(x+2, y+1, z+1, kind);
|
||||
setBlock(x+2, y+1, z+2, kind);
|
||||
setBlock(x+1, y+1, z+2, kind);
|
||||
setBlock(x, y+1, z+2, kind);
|
||||
this.setBlock(x+2, y+1, z, this.kind);
|
||||
this.setBlock(x+2, y+1, z+1, this.kind);
|
||||
this.setBlock(x+2, y+1, z+2, this.kind);
|
||||
this.setBlock(x+1, y+1, z+2, this.kind);
|
||||
this.setBlock(x, y+1, z+2, this.kind);
|
||||
|
||||
setBlock(x+2, y+2, z+1, kind);
|
||||
setBlock(x+2, y+2, z+2, kind);
|
||||
setBlock(x+1, y+2, z+2, kind);
|
||||
this.setBlock(x+2, y+2, z+1, this.kind);
|
||||
this.setBlock(x+2, y+2, z+2, this.kind);
|
||||
this.setBlock(x+1, y+2, z+2, this.kind);
|
||||
|
||||
setBlock(x+2, y+3, z+2, kind);
|
||||
this.setBlock(x+2, y+3, z+2, this.kind);
|
||||
}
|
||||
} else if (yaw >= 180 && yaw < 270) {
|
||||
facing = BlockFace.SOUTH_EAST;
|
||||
opposite = BlockFace.NORTH_WEST;
|
||||
signData = 2;
|
||||
signBlock = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH, 2).getFace(BlockFace.EAST, 2);
|
||||
if (warzone.getSpawnStyle().equals(TeamSpawnStyles.BIG)) {
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH, 2).getFace(BlockFace.EAST, 2);
|
||||
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyles.BIG)) {
|
||||
// rim
|
||||
setBlock(x+2, y, z+1, kind);
|
||||
setBlock(x+2, y, z+2, kind);
|
||||
setBlock(x+1, y, z+2, kind);
|
||||
setBlock(x, y, z+2, kind);
|
||||
setBlock(x-1, y, z+2, kind);
|
||||
setBlock(x-2, y, z+2, kind);
|
||||
setBlock(x-2, y, z+1, kind);
|
||||
setBlock(x-2, y, z, kind);
|
||||
setBlock(x-2, y, z-1, kind);
|
||||
setBlock(x-2, y, z-2, kind);
|
||||
setBlock(x-1, y, z-2, kind);
|
||||
this.setBlock(x+2, y, z+1, this.kind);
|
||||
this.setBlock(x+2, y, z+2, this.kind);
|
||||
this.setBlock(x+1, y, z+2, this.kind);
|
||||
this.setBlock(x, y, z+2, this.kind);
|
||||
this.setBlock(x-1, y, z+2, this.kind);
|
||||
this.setBlock(x-2, y, z+2, this.kind);
|
||||
this.setBlock(x-2, y, z+1, this.kind);
|
||||
this.setBlock(x-2, y, z, this.kind);
|
||||
this.setBlock(x-2, y, z-1, this.kind);
|
||||
this.setBlock(x-2, y, z-2, this.kind);
|
||||
this.setBlock(x-1, y, z-2, this.kind);
|
||||
|
||||
// tower
|
||||
setBlock(x, y+1, z+2, kind);
|
||||
setBlock(x-1, y+1, z+2, kind);
|
||||
setBlock(x-2, y+1, z+2, kind);
|
||||
setBlock(x-2, y+1, z+1, kind);
|
||||
setBlock(x-2, y+1, z, kind);
|
||||
this.setBlock(x, y+1, z+2, this.kind);
|
||||
this.setBlock(x-1, y+1, z+2, this.kind);
|
||||
this.setBlock(x-2, y+1, z+2, this.kind);
|
||||
this.setBlock(x-2, y+1, z+1, this.kind);
|
||||
this.setBlock(x-2, y+1, z, this.kind);
|
||||
|
||||
setBlock(x-1, y+2, z+2, kind);
|
||||
setBlock(x-2, y+2, z+2, kind);
|
||||
setBlock(x-2, y+2, z+1, kind);
|
||||
this.setBlock(x-1, y+2, z+2, this.kind);
|
||||
this.setBlock(x-2, y+2, z+2, this.kind);
|
||||
this.setBlock(x-2, y+2, z+1, this.kind);
|
||||
|
||||
setBlock(x-2, y+3, z+2, kind);
|
||||
this.setBlock(x-2, y+3, z+2, this.kind);
|
||||
}
|
||||
} else if (yaw >= 270 && yaw <= 360) {
|
||||
facing = BlockFace.SOUTH_WEST;
|
||||
opposite = BlockFace.NORTH_EAST;
|
||||
signData = 6;
|
||||
signBlock = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST, 2);
|
||||
if (warzone.getSpawnStyle().equals(TeamSpawnStyles.BIG)) {
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST, 2);
|
||||
if (this.warzone.getSpawnStyle().equals(TeamSpawnStyles.BIG)) {
|
||||
// rim
|
||||
setBlock(x-1, y, z+2, kind);
|
||||
setBlock(x-2, y, z+2, kind);
|
||||
setBlock(x-2, y, z+1, kind);
|
||||
setBlock(x-2, y, z, kind);
|
||||
setBlock(x-2, y, z-1, kind);
|
||||
setBlock(x-2, y, z-2, kind);
|
||||
setBlock(x-1, y, z-2, kind);
|
||||
setBlock(x, y, z-2, kind);
|
||||
setBlock(x+1, y, z-2, kind);
|
||||
setBlock(x+2, y, z-2, kind);
|
||||
setBlock(x+2, y, z-1, kind);
|
||||
this.setBlock(x-1, y, z+2, this.kind);
|
||||
this.setBlock(x-2, y, z+2, this.kind);
|
||||
this.setBlock(x-2, y, z+1, this.kind);
|
||||
this.setBlock(x-2, y, z, this.kind);
|
||||
this.setBlock(x-2, y, z-1, this.kind);
|
||||
this.setBlock(x-2, y, z-2, this.kind);
|
||||
this.setBlock(x-1, y, z-2, this.kind);
|
||||
this.setBlock(x, y, z-2, this.kind);
|
||||
this.setBlock(x+1, y, z-2, this.kind);
|
||||
this.setBlock(x+2, y, z-2, this.kind);
|
||||
this.setBlock(x+2, y, z-1, this.kind);
|
||||
|
||||
// tower
|
||||
setBlock(x-2, y+1, z, kind);
|
||||
setBlock(x-2, y+1, z-1, kind);
|
||||
setBlock(x-2, y+1, z-2, kind);
|
||||
setBlock(x-1, y+1, z-2, kind);
|
||||
setBlock(x, y+1, z-2, kind);
|
||||
this.setBlock(x-2, y+1, z, this.kind);
|
||||
this.setBlock(x-2, y+1, z-1, this.kind);
|
||||
this.setBlock(x-2, y+1, z-2, this.kind);
|
||||
this.setBlock(x-1, y+1, z-2, this.kind);
|
||||
this.setBlock(x, y+1, z-2, this.kind);
|
||||
|
||||
setBlock(x-2, y+2, z-1, kind);
|
||||
setBlock(x-2, y+2, z-2, kind);
|
||||
setBlock(x-1, y+2, z-2, kind);
|
||||
this.setBlock(x-2, y+2, z-1, this.kind);
|
||||
this.setBlock(x-2, y+2, z-2, this.kind);
|
||||
this.setBlock(x-1, y+2, z-2, this.kind);
|
||||
|
||||
setBlock(x-2, y+3, z-2, kind);
|
||||
this.setBlock(x-2, y+3, z-2, this.kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -296,21 +298,21 @@ public class Team {
|
||||
// }
|
||||
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "Team " + name;
|
||||
lines[1] = players.size() + "/" + warzone.getTeamCap() + " players";
|
||||
lines[2] = points + "/" + warzone.getScoreCap() + " pts";
|
||||
if (warzone.getLifePool() == -1) {
|
||||
lines[0] = "Team " + this.name;
|
||||
lines[1] = this.players.size() + "/" + this.warzone.getTeamCap() + " players";
|
||||
lines[2] = this.points + "/" + this.warzone.getScoreCap() + " pts";
|
||||
if (this.warzone.getLifePool() == -1) {
|
||||
lines[3] = "unlimited lives";
|
||||
} else {
|
||||
lines[3] = remainingLives + "/" + warzone.getLifePool() + " lives left";
|
||||
lines[3] = this.remainingLives + "/" + this.warzone.getLifePool() + " lives left";
|
||||
}
|
||||
|
||||
SignHelper.setToSign(war, signBlock, (byte)signData, lines);
|
||||
SignHelper.setToSign(this.war, signBlock, (byte)signData, lines);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBlock(int x, int y, int z, TeamKind kind) {
|
||||
Block block = warzone.getWorld().getBlockAt(x, y, z);
|
||||
Block block = this.warzone.getWorld().getBlockAt(x, y, z);
|
||||
block.setType(kind.getMaterial());
|
||||
block.setData(kind.getData());
|
||||
}
|
||||
@ -321,13 +323,13 @@ public class Team {
|
||||
|
||||
// this resets the block to old state
|
||||
this.setSpawnVolume();
|
||||
getSpawnVolume().saveBlocks();
|
||||
this.getSpawnVolume().saveBlocks();
|
||||
|
||||
initializeTeamSpawn();
|
||||
this.initializeTeamSpawn();
|
||||
}
|
||||
|
||||
public Location getTeamSpawn() {
|
||||
return teamSpawn;
|
||||
return this.teamSpawn;
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
@ -335,12 +337,12 @@ public class Team {
|
||||
}
|
||||
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
return this.players;
|
||||
}
|
||||
|
||||
public void teamcast(String message) {
|
||||
for (Player player : players) {
|
||||
war.msg(player, message);
|
||||
for (Player player : this.players) {
|
||||
this.war.msg(player, message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,18 +351,18 @@ public class Team {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean removePlayer(String name) {
|
||||
Player thePlayer = null;
|
||||
for (Player player : players) {
|
||||
for (Player player : this.players) {
|
||||
if (player.getName().equals(name)) {
|
||||
thePlayer = player;
|
||||
}
|
||||
}
|
||||
if (thePlayer != null) {
|
||||
players.remove(thePlayer);
|
||||
this.players.remove(thePlayer);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -371,32 +373,32 @@ public class Team {
|
||||
}
|
||||
|
||||
public int getRemainingLifes() {
|
||||
return remainingLives;
|
||||
return this.remainingLives;
|
||||
}
|
||||
|
||||
public void addPoint() {
|
||||
boolean atLeastOnePlayerOnTeam = players.size() != 0;
|
||||
boolean atLeastOnePlayerOnTeam = this.players.size() != 0;
|
||||
boolean atLeastOnePlayerOnOtherTeam = false;
|
||||
for (Team team : warzone.getTeams()) {
|
||||
for (Team team : this.warzone.getTeams()) {
|
||||
if (!team.getName().equals(this.getName())
|
||||
&& team.getPlayers().size() > 0) {
|
||||
atLeastOnePlayerOnOtherTeam = true;
|
||||
}
|
||||
}
|
||||
if (atLeastOnePlayerOnTeam && atLeastOnePlayerOnOtherTeam) {
|
||||
points++;
|
||||
this.points++;
|
||||
} else if (!atLeastOnePlayerOnOtherTeam) {
|
||||
this.teamcast("Can't score until at least one player joins another team.");
|
||||
}
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return points;
|
||||
return this.points;
|
||||
}
|
||||
|
||||
public Volume getSpawnVolume() {
|
||||
|
||||
return spawnVolume;
|
||||
return this.spawnVolume;
|
||||
}
|
||||
|
||||
public void resetSign(){
|
||||
@ -431,8 +433,8 @@ public class Team {
|
||||
// state.update(true);
|
||||
// }
|
||||
|
||||
if (warzone.getLobby() != null) {
|
||||
warzone.getLobby().resetTeamGateSign(this);
|
||||
if (this.warzone.getLobby() != null) {
|
||||
this.warzone.getLobby().resetTeamGateSign(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,17 +451,21 @@ public class Team {
|
||||
}
|
||||
|
||||
public Volume getFlagVolume() {
|
||||
return flagVolume;
|
||||
return this.flagVolume;
|
||||
}
|
||||
|
||||
private void setFlagVolume() {
|
||||
if (flagVolume == null) flagVolume = new Volume(getName() + "flag", war, warzone.getWorld());
|
||||
if (flagVolume.isSaved()) flagVolume.resetBlocks();
|
||||
int x = teamFlag.getBlockX();
|
||||
int y = teamFlag.getBlockY();
|
||||
int z = teamFlag.getBlockZ();
|
||||
this.flagVolume.setCornerOne(warzone.getWorld().getBlockAt(x-1, y-1, z-1));
|
||||
this.flagVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+1, y+3, z+1));
|
||||
if (this.flagVolume == null) {
|
||||
this.flagVolume = new Volume(this.getName() + "flag", this.war, this.warzone.getWorld());
|
||||
}
|
||||
if (this.flagVolume.isSaved()) {
|
||||
this.flagVolume.resetBlocks();
|
||||
}
|
||||
int x = this.teamFlag.getBlockX();
|
||||
int y = this.teamFlag.getBlockY();
|
||||
int z = this.teamFlag.getBlockZ();
|
||||
this.flagVolume.setCornerOne(this.warzone.getWorld().getBlockAt(x-1, y-1, z-1));
|
||||
this.flagVolume.setCornerTwo(this.warzone.getWorld().getBlockAt(x+1, y+3, z+1));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -468,59 +474,59 @@ public class Team {
|
||||
this.flagVolume.setToMaterial(Material.AIR);
|
||||
|
||||
// Set the flag blocks
|
||||
int x = teamFlag.getBlockX();
|
||||
int y = teamFlag.getBlockY();
|
||||
int z = teamFlag.getBlockZ();
|
||||
int x = this.teamFlag.getBlockX();
|
||||
int y = this.teamFlag.getBlockY();
|
||||
int z = this.teamFlag.getBlockZ();
|
||||
|
||||
// first ring
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y-1, z).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
|
||||
this.warzone.getWorld().getBlockAt(x, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y-1, z).setType(Material.OBSIDIAN);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
|
||||
// flag
|
||||
warzone.getWorld().getBlockAt(x, y+1, z).setType(kind.getMaterial());
|
||||
warzone.getWorld().getBlockAt(x, y+1, z).setData(kind.getData());
|
||||
warzone.getWorld().getBlockAt(x, y+2, z).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x, y+1, z).setType(this.kind.getMaterial());
|
||||
this.warzone.getWorld().getBlockAt(x, y+1, z).setData(this.kind.getData());
|
||||
this.warzone.getWorld().getBlockAt(x, y+2, z).setType(Material.FENCE);
|
||||
|
||||
// Flag post using Orientation
|
||||
int yaw = 0;
|
||||
if (teamFlag.getYaw() >= 0){
|
||||
yaw = (int)(teamFlag.getYaw() % 360);
|
||||
if (this.teamFlag.getYaw() >= 0){
|
||||
yaw = (int)(this.teamFlag.getYaw() % 360);
|
||||
} else {
|
||||
yaw = (int)(360 + (teamFlag.getYaw() % 360));
|
||||
yaw = (int)(360 + (this.teamFlag.getYaw() % 360));
|
||||
}
|
||||
BlockFace facing = null;
|
||||
BlockFace opposite = null;
|
||||
if ((yaw >= 0 && yaw < 45) || (yaw >= 315 && yaw <= 360)) {
|
||||
facing = BlockFace.WEST;
|
||||
opposite = BlockFace.EAST;
|
||||
warzone.getWorld().getBlockAt(x, y, z-1).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x, y+1, z-1).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x, y+2, z-1).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x, y, z-1).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x, y+1, z-1).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x, y+2, z-1).setType(Material.FENCE);
|
||||
} else if (yaw >= 45 && yaw < 135) {
|
||||
facing = BlockFace.NORTH;
|
||||
opposite = BlockFace.SOUTH;
|
||||
warzone.getWorld().getBlockAt(x+1, y, z).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x+1, y+1, z).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x+1, y+2, z).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y, z).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y+1, z).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x+1, y+2, z).setType(Material.FENCE);
|
||||
} else if (yaw >= 135 && yaw < 225) {
|
||||
facing = BlockFace.EAST;
|
||||
opposite = BlockFace.WEST;
|
||||
warzone.getWorld().getBlockAt(x, y, z+1).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x, y+1, z+1).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x, y+2, z+1).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x, y, z+1).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x, y+1, z+1).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x, y+2, z+1).setType(Material.FENCE);
|
||||
} else if (yaw >= 225 && yaw < 315) {
|
||||
facing = BlockFace.SOUTH;
|
||||
opposite = BlockFace.NORTH;
|
||||
warzone.getWorld().getBlockAt(x-1, y, z).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x-1, y+1, z).setType(Material.FENCE);
|
||||
warzone.getWorld().getBlockAt(x-1, y+2, z).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y, z).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y+1, z).setType(Material.FENCE);
|
||||
this.warzone.getWorld().getBlockAt(x-1, y+2, z).setType(Material.FENCE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,27 +536,26 @@ public class Team {
|
||||
|
||||
// this resets the block to old state
|
||||
this.setFlagVolume();
|
||||
getFlagVolume().saveBlocks();
|
||||
this.getFlagVolume().saveBlocks();
|
||||
|
||||
initializeTeamFlag();
|
||||
this.initializeTeamFlag();
|
||||
}
|
||||
|
||||
public boolean isTeamFlagBlock(Block block) {
|
||||
if (teamFlag != null) {
|
||||
int flagX = teamFlag.getBlockX();
|
||||
int flagY = teamFlag.getBlockY() + 1;
|
||||
int flagZ = teamFlag.getBlockZ();
|
||||
if (this.teamFlag != null) {
|
||||
int flagX = this.teamFlag.getBlockX();
|
||||
int flagY = this.teamFlag.getBlockY() + 1;
|
||||
int flagZ = this.teamFlag.getBlockZ();
|
||||
if (block.getX() == flagX
|
||||
&& block.getY() == flagY
|
||||
&& block.getZ() == flagZ) {
|
||||
return true;
|
||||
}
|
||||
&& block.getZ() == flagZ)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Location getTeamFlag() {
|
||||
|
||||
return teamFlag;
|
||||
return this.teamFlag;
|
||||
}
|
||||
}
|
||||
|
@ -18,18 +18,18 @@ public class TeamKind {
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
return this.material;
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
return data;
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public String getDefaultName() {
|
||||
return defaultName;
|
||||
return this.defaultName;
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
return this.color;
|
||||
}
|
||||
}
|
||||
|
@ -15,36 +15,35 @@ public class TeamKinds {
|
||||
private static final List<TeamKind> teamKinds = new ArrayList<TeamKind>();
|
||||
|
||||
static {
|
||||
getTeamkinds().add(new TeamKind("white", Material.WOOL, (byte) 0, ChatColor.WHITE));
|
||||
getTeamkinds().add(new TeamKind("orange", Material.WOOL, (byte) 1, ChatColor.GOLD));
|
||||
getTeamkinds().add(new TeamKind("magenta", Material.WOOL, (byte) 2, ChatColor.LIGHT_PURPLE));
|
||||
getTeamkinds().add(new TeamKind("blue", Material.WOOL, (byte) 3, ChatColor.BLUE));
|
||||
getTeamkinds().add(new TeamKind("gold", Material.WOOL, (byte) 4, ChatColor.YELLOW)); // yellow = gold
|
||||
getTeamkinds().add(new TeamKind("green", Material.WOOL, (byte) 5, ChatColor.GREEN));
|
||||
getTeamkinds().add(new TeamKind("pink", Material.WOOL, (byte) 6, ChatColor.WHITE));
|
||||
getTeamkinds().add(new TeamKind("gray", Material.WOOL, (byte) 7, ChatColor.DARK_GRAY));
|
||||
getTeamkinds().add(new TeamKind("iron", Material.WOOL, (byte) 8, ChatColor.GRAY)); // lightgrey = iron
|
||||
getTeamkinds().add(new TeamKind("diamond", Material.WOOL, (byte) 9, ChatColor.DARK_AQUA)); // cyan = diamond
|
||||
getTeamkinds().add(new TeamKind("purple", Material.WOOL, (byte) 10, ChatColor.DARK_PURPLE));
|
||||
getTeamkinds().add(new TeamKind("navy", Material.WOOL, (byte) 11, ChatColor.DARK_BLUE));
|
||||
getTeamkinds().add(new TeamKind("brown", Material.WOOL, (byte) 12, ChatColor.DARK_RED));
|
||||
getTeamkinds().add(new TeamKind("darkgreen", Material.WOOL, (byte) 13, ChatColor.DARK_GREEN));
|
||||
getTeamkinds().add(new TeamKind("red", Material.WOOL, (byte) 14, ChatColor.RED));
|
||||
getTeamkinds().add(new TeamKind("black", Material.WOOL, (byte) 15, ChatColor.BLACK));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("white", Material.WOOL, (byte) 0, ChatColor.WHITE));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("orange", Material.WOOL, (byte) 1, ChatColor.GOLD));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("magenta", Material.WOOL, (byte) 2, ChatColor.LIGHT_PURPLE));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("blue", Material.WOOL, (byte) 3, ChatColor.BLUE));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("gold", Material.WOOL, (byte) 4, ChatColor.YELLOW)); // yellow = gold
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("green", Material.WOOL, (byte) 5, ChatColor.GREEN));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("pink", Material.WOOL, (byte) 6, ChatColor.WHITE));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("gray", Material.WOOL, (byte) 7, ChatColor.DARK_GRAY));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("iron", Material.WOOL, (byte) 8, ChatColor.GRAY)); // lightgrey = iron
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("diamond", Material.WOOL, (byte) 9, ChatColor.DARK_AQUA)); // cyan = diamond
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("purple", Material.WOOL, (byte) 10, ChatColor.DARK_PURPLE));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("navy", Material.WOOL, (byte) 11, ChatColor.DARK_BLUE));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("brown", Material.WOOL, (byte) 12, ChatColor.DARK_RED));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("darkgreen", Material.WOOL, (byte) 13, ChatColor.DARK_GREEN));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("red", Material.WOOL, (byte) 14, ChatColor.RED));
|
||||
TeamKinds.getTeamkinds().add(new TeamKind("black", Material.WOOL, (byte) 15, ChatColor.BLACK));
|
||||
}
|
||||
|
||||
public static TeamKind teamKindFromString(String str) {
|
||||
String lowered = str.toLowerCase();
|
||||
for (TeamKind kind : getTeamkinds()) {
|
||||
if (kind.getDefaultName().startsWith(lowered)) {
|
||||
return kind;
|
||||
}
|
||||
for (TeamKind kind : TeamKinds.getTeamkinds()) {
|
||||
if (kind.getDefaultName().startsWith(lowered))
|
||||
return kind;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<TeamKind> getTeamkinds() {
|
||||
return teamKinds;
|
||||
return TeamKinds.teamKinds;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class WarHub {
|
||||
}
|
||||
|
||||
public Volume getVolume() {
|
||||
return volume;
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
public void setLocation(Location loc) {
|
||||
@ -45,12 +45,12 @@ public class WarHub {
|
||||
|
||||
public Warzone getDestinationWarzoneForLocation(Location playerLocation) {
|
||||
Warzone zone = null;
|
||||
for (String zoneName : zoneGateBlocks.keySet()) {
|
||||
Block gate = zoneGateBlocks.get(zoneName);
|
||||
for (String zoneName : this.zoneGateBlocks.keySet()) {
|
||||
Block gate = this.zoneGateBlocks.get(zoneName);
|
||||
if (gate.getX() == playerLocation.getBlockX()
|
||||
&& gate.getY() == playerLocation.getBlockY()
|
||||
&& gate.getZ() == playerLocation.getBlockZ()) {
|
||||
zone = war.findWarzone(zoneName);
|
||||
zone = this.war.findWarzone(zoneName);
|
||||
}
|
||||
}
|
||||
return zone;
|
||||
@ -58,34 +58,36 @@ public class WarHub {
|
||||
|
||||
public void initialize() {
|
||||
// for now, draw the wall of gates to the west
|
||||
zoneGateBlocks.clear();
|
||||
this.zoneGateBlocks.clear();
|
||||
int disabled = 0;
|
||||
for (Warzone zone : war.getWarzones()) {
|
||||
if (zone.isDisabled()) disabled++;
|
||||
for (Warzone zone : this.war.getWarzones()) {
|
||||
if (zone.isDisabled()) {
|
||||
disabled++;
|
||||
}
|
||||
}
|
||||
int noOfWarzones = war.getWarzones().size() - disabled;
|
||||
int noOfWarzones = this.war.getWarzones().size() - disabled;
|
||||
if (noOfWarzones > 0) {
|
||||
int hubWidth = noOfWarzones * 4 + 2;
|
||||
int halfHubWidth = hubWidth / 2;
|
||||
int hubDepth = 6;
|
||||
int hubHeigth = 4;
|
||||
|
||||
Block locationBlock = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
volume.setCornerOne(locationBlock.getFace(BlockFace.EAST).getFace(BlockFace.SOUTH, halfHubWidth).getFace(BlockFace.DOWN));
|
||||
volume.setCornerTwo(locationBlock.getFace(BlockFace.NORTH, halfHubWidth).getFace(BlockFace.WEST, hubDepth).getFace(BlockFace.UP, hubHeigth));
|
||||
volume.saveBlocks();
|
||||
Block locationBlock = this.location.getWorld().getBlockAt(this.location.getBlockX(), this.location.getBlockY(), this.location.getBlockZ());
|
||||
this.volume.setCornerOne(locationBlock.getFace(BlockFace.EAST).getFace(BlockFace.SOUTH, halfHubWidth).getFace(BlockFace.DOWN));
|
||||
this.volume.setCornerTwo(locationBlock.getFace(BlockFace.NORTH, halfHubWidth).getFace(BlockFace.WEST, hubDepth).getFace(BlockFace.UP, hubHeigth));
|
||||
this.volume.saveBlocks();
|
||||
|
||||
// glass floor
|
||||
volume.clearBlocksThatDontFloat();
|
||||
volume.setToMaterial(Material.AIR);
|
||||
volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS);
|
||||
this.volume.clearBlocksThatDontFloat();
|
||||
this.volume.setToMaterial(Material.AIR);
|
||||
this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS);
|
||||
|
||||
// draw gates
|
||||
Block currentGateBlock = BlockInfo.getBlock(location.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.WEST, hubDepth).getFace(BlockFace.NORTH, 2);
|
||||
Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.WEST, hubDepth).getFace(BlockFace.NORTH, 2);
|
||||
|
||||
for (Warzone zone : war.getWarzones()) { // gonna use the index to find it again
|
||||
for (Warzone zone : this.war.getWarzones()) { // gonna use the index to find it again
|
||||
if (!zone.isDisabled()) {
|
||||
zoneGateBlocks.put(zone.getName(), currentGateBlock);
|
||||
this.zoneGateBlocks.put(zone.getName(), currentGateBlock);
|
||||
currentGateBlock.getFace(BlockFace.DOWN).setType(Material.GLOWSTONE);
|
||||
currentGateBlock.setType(Material.PORTAL);
|
||||
currentGateBlock.getFace(BlockFace.UP).setType(Material.PORTAL);
|
||||
@ -109,10 +111,10 @@ public class WarHub {
|
||||
lines[1] = "(/warhub)";
|
||||
lines[2] = "Pick your";
|
||||
lines[3] = "battle!";
|
||||
SignHelper.setToSign(war, signBlock, (byte)8, lines);
|
||||
SignHelper.setToSign(this.war, signBlock, (byte)8, lines);
|
||||
|
||||
// Warzone signs
|
||||
for (Warzone zone : war.getWarzones()) {
|
||||
for (Warzone zone : this.war.getWarzones()) {
|
||||
if (!zone.isDisabled() && zone.ready()) {
|
||||
this.resetZoneSign(zone);
|
||||
}
|
||||
@ -122,9 +124,11 @@ public class WarHub {
|
||||
|
||||
public void resetZoneSign(Warzone zone) {
|
||||
|
||||
Block zoneGate = zoneGateBlocks.get(zone.getName());
|
||||
Block zoneGate = this.zoneGateBlocks.get(zone.getName());
|
||||
Block block = zoneGate.getFace(BlockFace.SOUTH).getFace(BlockFace.EAST, 1);
|
||||
if (block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
if (block.getType() != Material.SIGN_POST) {
|
||||
block.setType(Material.SIGN_POST);
|
||||
}
|
||||
block.setData((byte)8);
|
||||
|
||||
int zoneCap = 0;
|
||||
@ -138,7 +142,7 @@ public class WarHub {
|
||||
lines[1] = zone.getName();
|
||||
lines[2] = zonePlayers + "/" + zoneCap + " players";
|
||||
lines[3] = zone.getTeams().size() + " teams";
|
||||
SignHelper.setToSign(war, block, (byte)8, lines);
|
||||
SignHelper.setToSign(this.war, block, (byte)8, lines);
|
||||
}
|
||||
|
||||
public void setVolume(Volume vol) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -49,9 +49,9 @@ public class ZoneLobby {
|
||||
this.war = war;
|
||||
this.warzone = warzone;
|
||||
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
||||
lobbyHalfSide = lobbyWidth / 2;
|
||||
if (lobbyHalfSide < 7) {
|
||||
lobbyHalfSide = 7;
|
||||
this.lobbyHalfSide = lobbyWidth / 2;
|
||||
if (this.lobbyHalfSide < 7) {
|
||||
this.lobbyHalfSide = 7;
|
||||
}
|
||||
this.setWall(wall);
|
||||
}
|
||||
@ -67,11 +67,11 @@ public class ZoneLobby {
|
||||
this.war = war;
|
||||
this.warzone = warzone;
|
||||
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
||||
lobbyHalfSide = lobbyWidth / 2;
|
||||
if (lobbyHalfSide < 7) {
|
||||
lobbyHalfSide = 7;
|
||||
this.lobbyHalfSide = lobbyWidth / 2;
|
||||
if (this.lobbyHalfSide < 7) {
|
||||
this.lobbyHalfSide = 7;
|
||||
}
|
||||
setLocation(playerLocation);
|
||||
this.setLocation(playerLocation);
|
||||
}
|
||||
|
||||
|
||||
@ -84,22 +84,22 @@ public class ZoneLobby {
|
||||
this.war = war;
|
||||
this.warzone = warzone;
|
||||
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
||||
lobbyHalfSide = lobbyWidth / 2;
|
||||
if (lobbyHalfSide < 7) {
|
||||
lobbyHalfSide = 7;
|
||||
this.lobbyHalfSide = lobbyWidth / 2;
|
||||
if (this.lobbyHalfSide < 7) {
|
||||
this.lobbyHalfSide = 7;
|
||||
}
|
||||
this.wall = wall;
|
||||
this.setVolume(volume);
|
||||
|
||||
// we're setting the zoneVolume directly, so we need to figure out the lobbyMiddleWallBlock on our own
|
||||
if (wall == BlockFace.NORTH) {
|
||||
lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.EAST, lobbyHalfSide));
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.EAST, this.lobbyHalfSide));
|
||||
} else if (wall == BlockFace.EAST){
|
||||
lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.SOUTH, lobbyHalfSide));
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.SOUTH, this.lobbyHalfSide));
|
||||
} else if (wall == BlockFace.SOUTH){
|
||||
lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.WEST, lobbyHalfSide));
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.WEST, this.lobbyHalfSide));
|
||||
} else if (wall == BlockFace.WEST){
|
||||
lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.NORTH, lobbyHalfSide));
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.NORTH, this.lobbyHalfSide));
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public class ZoneLobby {
|
||||
* @param playerLocation
|
||||
*/
|
||||
public void setLocation(Location playerLocation) {
|
||||
createVolumeOrReset();
|
||||
this.createVolumeOrReset();
|
||||
|
||||
// Lobby orientation
|
||||
int yaw = 0;
|
||||
@ -150,34 +150,34 @@ public class ZoneLobby {
|
||||
// }
|
||||
this.wall = opposite; // a player facing south places a lobby that looks just like a lobby stuck to the north wall
|
||||
|
||||
calculateLobbyWidth();
|
||||
lobbyMiddleWallBlock = new BlockInfo(warzone.getWorld().getBlockAt(playerLocation.getBlockX(),
|
||||
this.calculateLobbyWidth();
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(playerLocation.getBlockX(),
|
||||
playerLocation.getBlockY(),
|
||||
playerLocation.getBlockZ())
|
||||
.getFace(facing, 6));
|
||||
|
||||
Block corner1 = null;
|
||||
Block corner2 = null;
|
||||
int x = lobbyMiddleWallBlock.getX();
|
||||
int y = lobbyMiddleWallBlock.getY();
|
||||
int z = lobbyMiddleWallBlock.getZ();
|
||||
int x = this.lobbyMiddleWallBlock.getX();
|
||||
int y = this.lobbyMiddleWallBlock.getY();
|
||||
int z = this.lobbyMiddleWallBlock.getZ();
|
||||
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
//lobbyMiddleWallBlock = new BlockInfo(warzone.getWorld().getBlockAt(x, y, wallCenterPos));
|
||||
corner1 = warzone.getWorld().getBlockAt(x, y - 1, z + lobbyHalfSide);
|
||||
corner2 = warzone.getWorld().getBlockAt(x - lobbyDepth, y + 1 + lobbyHeight, z - lobbyHalfSide);
|
||||
} else if (wall == BlockFace.EAST){
|
||||
corner1 = warzone.getWorld().getBlockAt(x - lobbyHalfSide, y - 1, z);
|
||||
corner2 = warzone.getWorld().getBlockAt(x + lobbyHalfSide, y + 1 + lobbyHeight, z - lobbyDepth);
|
||||
} else if (wall == BlockFace.SOUTH){
|
||||
corner1 = warzone.getWorld().getBlockAt(x, y -1 , z - lobbyHalfSide);
|
||||
corner2 = warzone.getWorld().getBlockAt(x + lobbyDepth, y + 1 + lobbyHeight, z + lobbyHalfSide);
|
||||
} else if (wall == BlockFace.WEST){
|
||||
corner1 = warzone.getWorld().getBlockAt(x + lobbyHalfSide, y - 1, z);
|
||||
corner2 = warzone.getWorld().getBlockAt(x - lobbyHalfSide, y + 1 + lobbyHeight, z + lobbyDepth);
|
||||
corner1 = this.warzone.getWorld().getBlockAt(x, y - 1, z + this.lobbyHalfSide);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(x - this.lobbyDepth, y + 1 + this.lobbyHeight, z - this.lobbyHalfSide);
|
||||
} else if (this.wall == BlockFace.EAST){
|
||||
corner1 = this.warzone.getWorld().getBlockAt(x - this.lobbyHalfSide, y - 1, z);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(x + this.lobbyHalfSide, y + 1 + this.lobbyHeight, z - this.lobbyDepth);
|
||||
} else if (this.wall == BlockFace.SOUTH){
|
||||
corner1 = this.warzone.getWorld().getBlockAt(x, y -1 , z - this.lobbyHalfSide);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(x + this.lobbyDepth, y + 1 + this.lobbyHeight, z + this.lobbyHalfSide);
|
||||
} else if (this.wall == BlockFace.WEST){
|
||||
corner1 = this.warzone.getWorld().getBlockAt(x + this.lobbyHalfSide, y - 1, z);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(x - this.lobbyHalfSide, y + 1 + this.lobbyHeight, z + this.lobbyDepth);
|
||||
}
|
||||
|
||||
saveLobbyBlocks(corner1, corner2);
|
||||
this.saveLobbyBlocks(corner1, corner2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,76 +186,76 @@ public class ZoneLobby {
|
||||
* @param newWall
|
||||
*/
|
||||
public void setWall(BlockFace newWall) {
|
||||
createVolumeOrReset();
|
||||
this.createVolumeOrReset();
|
||||
this.wall = newWall;
|
||||
|
||||
ZoneVolume zoneVolume = warzone.getVolume();
|
||||
calculateLobbyWidth();
|
||||
ZoneVolume zoneVolume = this.warzone.getVolume();
|
||||
this.calculateLobbyWidth();
|
||||
|
||||
Block corner1 = null;
|
||||
Block corner2 = null;
|
||||
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
int wallStart = zoneVolume.getMinZ();
|
||||
int wallEnd = zoneVolume.getMaxZ();
|
||||
int x = zoneVolume.getMinX();
|
||||
int wallLength = wallEnd - wallStart + 1;
|
||||
int wallCenterPos = wallStart + wallLength / 2;
|
||||
int y = zoneVolume.getCenterY();
|
||||
lobbyMiddleWallBlock = new BlockInfo(warzone.getWorld().getBlockAt(x, y, wallCenterPos));
|
||||
corner1 = warzone.getWorld().getBlockAt(x, y - 1, wallCenterPos + lobbyHalfSide);
|
||||
corner2 = warzone.getWorld().getBlockAt(x - lobbyDepth, y + 1 + lobbyHeight, wallCenterPos - lobbyHalfSide);
|
||||
} else if (wall == BlockFace.EAST){
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(x, y, wallCenterPos));
|
||||
corner1 = this.warzone.getWorld().getBlockAt(x, y - 1, wallCenterPos + this.lobbyHalfSide);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(x - this.lobbyDepth, y + 1 + this.lobbyHeight, wallCenterPos - this.lobbyHalfSide);
|
||||
} else if (this.wall == BlockFace.EAST){
|
||||
int wallStart = zoneVolume.getMinX();
|
||||
int wallEnd = zoneVolume.getMaxX();
|
||||
int z = zoneVolume.getMinZ();
|
||||
int wallLength = wallEnd - wallStart + 1;
|
||||
int wallCenterPos = wallStart + wallLength / 2;
|
||||
int y = zoneVolume.getCenterY();
|
||||
lobbyMiddleWallBlock = new BlockInfo(warzone.getWorld().getBlockAt(wallCenterPos, y, z));
|
||||
corner1 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, y - 1, z);
|
||||
corner2 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide,
|
||||
y + 1 + lobbyHeight, z - lobbyDepth);
|
||||
} else if (wall == BlockFace.SOUTH){
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(wallCenterPos, y, z));
|
||||
corner1 = this.warzone.getWorld().getBlockAt(wallCenterPos - this.lobbyHalfSide, y - 1, z);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(wallCenterPos + this.lobbyHalfSide,
|
||||
y + 1 + this.lobbyHeight, z - this.lobbyDepth);
|
||||
} else if (this.wall == BlockFace.SOUTH){
|
||||
int wallStart = zoneVolume.getMinZ();
|
||||
int wallEnd = zoneVolume.getMaxZ();
|
||||
int x = zoneVolume.getMaxX();
|
||||
int wallLength = wallEnd - wallStart + 1;
|
||||
int wallCenterPos = wallStart + wallLength / 2;
|
||||
int y = zoneVolume.getCenterY();
|
||||
lobbyMiddleWallBlock = new BlockInfo(warzone.getWorld().getBlockAt(x, y, wallCenterPos));
|
||||
corner1 = warzone.getWorld().getBlockAt(x, y -1 , wallCenterPos - lobbyHalfSide);
|
||||
corner2 = warzone.getWorld().getBlockAt(x + lobbyDepth,
|
||||
y + 1 + lobbyHeight, wallCenterPos + lobbyHalfSide);
|
||||
} else if (wall == BlockFace.WEST){
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(x, y, wallCenterPos));
|
||||
corner1 = this.warzone.getWorld().getBlockAt(x, y -1 , wallCenterPos - this.lobbyHalfSide);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(x + this.lobbyDepth,
|
||||
y + 1 + this.lobbyHeight, wallCenterPos + this.lobbyHalfSide);
|
||||
} else if (this.wall == BlockFace.WEST){
|
||||
int wallStart = zoneVolume.getMinX();
|
||||
int wallEnd = zoneVolume.getMaxX();
|
||||
int z = zoneVolume.getMaxZ();
|
||||
int wallLength = wallEnd - wallStart + 1;
|
||||
int wallCenterPos = wallStart + wallLength / 2;
|
||||
int y = zoneVolume.getCenterY();
|
||||
lobbyMiddleWallBlock = new BlockInfo(warzone.getWorld().getBlockAt(wallCenterPos, y, z));
|
||||
corner1 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, y - 1, z);
|
||||
corner2 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, y + 1 + lobbyHeight, z + lobbyDepth);
|
||||
this.lobbyMiddleWallBlock = new BlockInfo(this.warzone.getWorld().getBlockAt(wallCenterPos, y, z));
|
||||
corner1 = this.warzone.getWorld().getBlockAt(wallCenterPos + this.lobbyHalfSide, y - 1, z);
|
||||
corner2 = this.warzone.getWorld().getBlockAt(wallCenterPos - this.lobbyHalfSide, y + 1 + this.lobbyHeight, z + this.lobbyDepth);
|
||||
}
|
||||
|
||||
saveLobbyBlocks(corner1, corner2);
|
||||
this.saveLobbyBlocks(corner1, corner2);
|
||||
}
|
||||
|
||||
private void createVolumeOrReset() {
|
||||
if (volume == null) {
|
||||
if (this.volume == null) {
|
||||
// no previous wall
|
||||
this.volume = new Volume("lobby", war, warzone.getWorld());
|
||||
} else if (volume.isSaved()) {
|
||||
volume.resetBlocks();
|
||||
this.volume = new Volume("lobby", this.war, this.warzone.getWorld());
|
||||
} else if (this.volume.isSaved()) {
|
||||
this.volume.resetBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateLobbyWidth() {
|
||||
int lobbyWidth = warzone.getTeams().size() * 4 + 5;
|
||||
lobbyHalfSide = lobbyWidth / 2;
|
||||
if (lobbyHalfSide < 7) {
|
||||
lobbyHalfSide = 7;
|
||||
int lobbyWidth = this.warzone.getTeams().size() * 4 + 5;
|
||||
this.lobbyHalfSide = lobbyWidth / 2;
|
||||
if (this.lobbyHalfSide < 7) {
|
||||
this.lobbyHalfSide = 7;
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,132 +270,132 @@ public class ZoneLobby {
|
||||
|
||||
public void initialize() {
|
||||
// maybe the number of teams change, now reset the gate positions
|
||||
if (lobbyMiddleWallBlock != null && volume != null /*&& volume.isSaved()*/) {
|
||||
setGatePositions(BlockInfo.getBlock(warzone.getWorld(), lobbyMiddleWallBlock));
|
||||
if (this.lobbyMiddleWallBlock != null && this.volume != null /*&& volume.isSaved()*/) {
|
||||
this.setGatePositions(BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock));
|
||||
// flatten the area (set all but floor to air, then replace any floor air blocks with glass)
|
||||
this.volume.clearBlocksThatDontFloat();
|
||||
this.volume.setToMaterial(Material.AIR);
|
||||
this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS); // beautiful
|
||||
|
||||
// add war hub link gate
|
||||
if (war.getWarHub() != null) {
|
||||
Block linkGateBlock = BlockInfo.getBlock(warzone.getWorld(), warHubLinkGate);
|
||||
placeGate(linkGateBlock, Material.OBSIDIAN);
|
||||
if (this.war.getWarHub() != null) {
|
||||
Block linkGateBlock = BlockInfo.getBlock(this.warzone.getWorld(), this.warHubLinkGate);
|
||||
this.placeGate(linkGateBlock, Material.OBSIDIAN);
|
||||
// add warhub sign
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "";
|
||||
lines[1] = "To War hub";
|
||||
lines[2] = "";
|
||||
lines[3] = "";
|
||||
resetGateSign(linkGateBlock, lines, false);
|
||||
this.resetGateSign(linkGateBlock, lines, false);
|
||||
}
|
||||
|
||||
// add team gates or single auto assign gate
|
||||
placeAutoAssignGate();
|
||||
for (String teamName : teamGateBlocks.keySet()) {
|
||||
BlockInfo gateInfo = teamGateBlocks.get(teamName);
|
||||
placeGate(BlockInfo.getBlock(warzone.getWorld(), gateInfo), TeamKinds.teamKindFromString(teamName));
|
||||
this.placeAutoAssignGate();
|
||||
for (String teamName : this.teamGateBlocks.keySet()) {
|
||||
BlockInfo gateInfo = this.teamGateBlocks.get(teamName);
|
||||
this.placeGate(BlockInfo.getBlock(this.warzone.getWorld(), gateInfo), TeamKinds.teamKindFromString(teamName));
|
||||
}
|
||||
for (Team t : warzone.getTeams()) {
|
||||
resetTeamGateSign(t);
|
||||
for (Team t : this.warzone.getTeams()) {
|
||||
this.resetTeamGateSign(t);
|
||||
}
|
||||
|
||||
// set zone tp
|
||||
zoneTeleportBlock = new BlockInfo(BlockInfo.getBlock(warzone.getWorld(), lobbyMiddleWallBlock).getFace(wall, 6));
|
||||
this.zoneTeleportBlock = new BlockInfo(BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(this.wall, 6));
|
||||
int yaw = 0;
|
||||
if (wall == BlockFace.WEST) {
|
||||
if (this.wall == BlockFace.WEST) {
|
||||
yaw = 180;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
yaw = 90;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
yaw = 0;
|
||||
} else if (wall == BlockFace.NORTH) {
|
||||
} else if (this.wall == BlockFace.NORTH) {
|
||||
yaw = 270;
|
||||
}
|
||||
warzone.setTeleport(new Location(warzone.getWorld(), zoneTeleportBlock.getX(), zoneTeleportBlock.getY(), zoneTeleportBlock.getZ(), yaw, 0));
|
||||
this.warzone.setTeleport(new Location(this.warzone.getWorld(), this.zoneTeleportBlock.getX(), this.zoneTeleportBlock.getY(), this.zoneTeleportBlock.getZ(), yaw, 0));
|
||||
|
||||
// set zone sign
|
||||
Block zoneSignBlock = BlockInfo.getBlock(warzone.getWorld(), lobbyMiddleWallBlock).getFace(wall, 4);
|
||||
Block zoneSignBlock = BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(this.wall, 4);
|
||||
byte data = 0;
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
data = (byte)4;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
data = (byte)8;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
data = (byte)12;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
data = (byte)0;
|
||||
}
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "Warzone";
|
||||
lines[1] = warzone.getName();
|
||||
if (autoAssignGate != null) {
|
||||
lines[1] = this.warzone.getName();
|
||||
if (this.autoAssignGate != null) {
|
||||
lines[2] = "Walk in the";
|
||||
lines[3] = "auto-assign gate.";
|
||||
} else {
|
||||
lines[2] = "";
|
||||
lines[3] = "Pick your team.";
|
||||
}
|
||||
SignHelper.setToSign(war, zoneSignBlock, data, lines);
|
||||
SignHelper.setToSign(this.war, zoneSignBlock, data, lines);
|
||||
|
||||
// lets get some light in here
|
||||
if (wall == BlockFace.NORTH || wall == BlockFace.SOUTH) {
|
||||
BlockInfo.getBlock(warzone.getWorld(), lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.WEST, lobbyHalfSide - 1).getFace(wall, 9).setType(Material.GLOWSTONE);
|
||||
BlockInfo.getBlock(warzone.getWorld(), lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.EAST, lobbyHalfSide - 1).getFace(wall, 9).setType(Material.GLOWSTONE);
|
||||
if (this.wall == BlockFace.NORTH || this.wall == BlockFace.SOUTH) {
|
||||
BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.WEST, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE);
|
||||
BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.EAST, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE);
|
||||
} else {
|
||||
BlockInfo.getBlock(warzone.getWorld(), lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.NORTH, lobbyHalfSide - 1).getFace(wall, 9).setType(Material.GLOWSTONE);
|
||||
BlockInfo.getBlock(warzone.getWorld(), lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.SOUTH, lobbyHalfSide - 1).getFace(wall, 9).setType(Material.GLOWSTONE);
|
||||
BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.NORTH, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE);
|
||||
BlockInfo.getBlock(this.warzone.getWorld(), this.lobbyMiddleWallBlock).getFace(BlockFace.DOWN).getFace(BlockFace.SOUTH, this.lobbyHalfSide - 1).getFace(this.wall, 9).setType(Material.GLOWSTONE);
|
||||
}
|
||||
} else {
|
||||
war.logWarn("Failed to initalize zone lobby for zone " + warzone.getName());
|
||||
this.war.logWarn("Failed to initalize zone lobby for zone " + this.warzone.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void setGatePositions(Block lobbyMiddleWallBlock) {
|
||||
BlockFace leftSide = null; // look at the zone
|
||||
BlockFace rightSide = null;
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
leftSide = BlockFace.EAST;
|
||||
rightSide = BlockFace.WEST;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
leftSide = BlockFace.SOUTH;
|
||||
rightSide = BlockFace.NORTH;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
leftSide = BlockFace.WEST;
|
||||
rightSide = BlockFace.EAST;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
leftSide = BlockFace.NORTH;
|
||||
rightSide = BlockFace.SOUTH;
|
||||
}
|
||||
teamGateBlocks.clear();
|
||||
if (warzone.getAutoAssignOnly()){
|
||||
autoAssignGate = new BlockInfo(lobbyMiddleWallBlock);
|
||||
this.teamGateBlocks.clear();
|
||||
if (this.warzone.getAutoAssignOnly()){
|
||||
this.autoAssignGate = new BlockInfo(lobbyMiddleWallBlock);
|
||||
} else {
|
||||
autoAssignGate = null;
|
||||
for (int doorIndex = 0; doorIndex < warzone.getTeams().size(); doorIndex++) {
|
||||
this.autoAssignGate = null;
|
||||
for (int doorIndex = 0; doorIndex < this.warzone.getTeams().size(); doorIndex++) {
|
||||
// 0 at center, 1 to the left, 2 to the right, 3 to the left, etc
|
||||
Team team = warzone.getTeams().get(doorIndex);
|
||||
if (warzone.getTeams().size() % 2 == 0) {
|
||||
Team team = this.warzone.getTeams().get(doorIndex);
|
||||
if (this.warzone.getTeams().size() % 2 == 0) {
|
||||
// even number of teams
|
||||
if (doorIndex % 2 == 0) {
|
||||
teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(rightSide, doorIndex * 2 + 2)));
|
||||
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(rightSide, doorIndex * 2 + 2)));
|
||||
} else {
|
||||
teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(leftSide, doorIndex * 2)));
|
||||
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(leftSide, doorIndex * 2)));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (doorIndex == 0) {
|
||||
teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock));
|
||||
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock));
|
||||
}
|
||||
else if (doorIndex % 2 == 0) {
|
||||
teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(rightSide, doorIndex * 2)));
|
||||
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(rightSide, doorIndex * 2)));
|
||||
} else {
|
||||
teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(leftSide, doorIndex * 2 + 2)));
|
||||
this.teamGateBlocks.put(team.getName(), new BlockInfo(lobbyMiddleWallBlock.getFace(leftSide, doorIndex * 2 + 2)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
warHubLinkGate = new BlockInfo(lobbyMiddleWallBlock.getFace(wall, 9));
|
||||
this.warHubLinkGate = new BlockInfo(lobbyMiddleWallBlock.getFace(this.wall, 9));
|
||||
}
|
||||
|
||||
private void placeGate(Block block,
|
||||
@ -403,27 +403,27 @@ public class ZoneLobby {
|
||||
if (block != null) {
|
||||
BlockFace leftSide = null; // look at the zone
|
||||
BlockFace rightSide = null;
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
leftSide = BlockFace.EAST;
|
||||
rightSide = BlockFace.WEST;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
leftSide = BlockFace.SOUTH;
|
||||
rightSide = BlockFace.NORTH;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
leftSide = BlockFace.WEST;
|
||||
rightSide = BlockFace.EAST;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
leftSide = BlockFace.NORTH;
|
||||
rightSide = BlockFace.SOUTH;
|
||||
}
|
||||
block.getFace(BlockFace.DOWN).setType(Material.GLOWSTONE);
|
||||
setBlock(block.getFace(leftSide), teamKind);
|
||||
setBlock(block.getFace(rightSide).getFace(BlockFace.UP), teamKind);
|
||||
setBlock(block.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP), teamKind);
|
||||
setBlock(block.getFace(rightSide), teamKind);
|
||||
setBlock(block.getFace(leftSide).getFace(BlockFace.UP), teamKind);
|
||||
setBlock(block.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP), teamKind);
|
||||
setBlock(block.getFace(BlockFace.UP).getFace(BlockFace.UP), teamKind);
|
||||
this.setBlock(block.getFace(leftSide), teamKind);
|
||||
this.setBlock(block.getFace(rightSide).getFace(BlockFace.UP), teamKind);
|
||||
this.setBlock(block.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP), teamKind);
|
||||
this.setBlock(block.getFace(rightSide), teamKind);
|
||||
this.setBlock(block.getFace(leftSide).getFace(BlockFace.UP), teamKind);
|
||||
this.setBlock(block.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP), teamKind);
|
||||
this.setBlock(block.getFace(BlockFace.UP).getFace(BlockFace.UP), teamKind);
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,27 +432,27 @@ public class ZoneLobby {
|
||||
if (block != null) {
|
||||
BlockFace leftSide = null; // look at the zone
|
||||
BlockFace rightSide = null;
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
leftSide = BlockFace.EAST;
|
||||
rightSide = BlockFace.WEST;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
leftSide = BlockFace.SOUTH;
|
||||
rightSide = BlockFace.NORTH;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
leftSide = BlockFace.WEST;
|
||||
rightSide = BlockFace.EAST;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
leftSide = BlockFace.NORTH;
|
||||
rightSide = BlockFace.SOUTH;
|
||||
}
|
||||
block.getFace(BlockFace.DOWN).setType(Material.GLOWSTONE);
|
||||
setBlock(block.getFace(leftSide), material);
|
||||
setBlock(block.getFace(rightSide).getFace(BlockFace.UP), material);
|
||||
setBlock(block.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP), material);
|
||||
setBlock(block.getFace(rightSide), material);
|
||||
setBlock(block.getFace(leftSide).getFace(BlockFace.UP), material);
|
||||
setBlock(block.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP), material);
|
||||
setBlock(block.getFace(BlockFace.UP).getFace(BlockFace.UP), material);
|
||||
this.setBlock(block.getFace(leftSide), material);
|
||||
this.setBlock(block.getFace(rightSide).getFace(BlockFace.UP), material);
|
||||
this.setBlock(block.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP), material);
|
||||
this.setBlock(block.getFace(rightSide), material);
|
||||
this.setBlock(block.getFace(leftSide).getFace(BlockFace.UP), material);
|
||||
this.setBlock(block.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP), material);
|
||||
this.setBlock(block.getFace(BlockFace.UP).getFace(BlockFace.UP), material);
|
||||
}
|
||||
}
|
||||
|
||||
@ -466,78 +466,96 @@ public class ZoneLobby {
|
||||
}
|
||||
|
||||
private void placeAutoAssignGate() {
|
||||
if (autoAssignGate != null) {
|
||||
if (this.autoAssignGate != null) {
|
||||
BlockFace leftSide = null; // look at the zone
|
||||
BlockFace rightSide = null;
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
leftSide = BlockFace.EAST;
|
||||
rightSide = BlockFace.WEST;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
leftSide = BlockFace.SOUTH;
|
||||
rightSide = BlockFace.NORTH;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
leftSide = BlockFace.WEST;
|
||||
rightSide = BlockFace.EAST;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
leftSide = BlockFace.NORTH;
|
||||
rightSide = BlockFace.SOUTH;
|
||||
}
|
||||
List<Team> teams = warzone.getTeams();
|
||||
Block autoAssignGateBlock = BlockInfo.getBlock(warzone.getWorld(), autoAssignGate);
|
||||
setBlock(autoAssignGateBlock.getFace(BlockFace.DOWN), (Material.GLOWSTONE));
|
||||
List<Team> teams = this.warzone.getTeams();
|
||||
Block autoAssignGateBlock = BlockInfo.getBlock(this.warzone.getWorld(), this.autoAssignGate);
|
||||
this.setBlock(autoAssignGateBlock.getFace(BlockFace.DOWN), (Material.GLOWSTONE));
|
||||
int size = teams.size();
|
||||
int index = 0;
|
||||
TeamKind kind = null;
|
||||
if (index >= size) kind = TeamKinds.teamKindFromString("diamond");
|
||||
else kind = teams.get(index).getKind();
|
||||
setBlock(autoAssignGateBlock.getFace(leftSide), kind);
|
||||
if (index >= size) {
|
||||
kind = TeamKinds.teamKindFromString("diamond");
|
||||
} else {
|
||||
kind = teams.get(index).getKind();
|
||||
}
|
||||
this.setBlock(autoAssignGateBlock.getFace(leftSide), kind);
|
||||
index++;
|
||||
if (index >= size) kind = TeamKinds.teamKindFromString("iron");
|
||||
else kind = teams.get(index).getKind();
|
||||
setBlock(autoAssignGateBlock.getFace(leftSide).getFace(BlockFace.UP), kind);
|
||||
if (index >= size) {
|
||||
kind = TeamKinds.teamKindFromString("iron");
|
||||
} else {
|
||||
kind = teams.get(index).getKind();
|
||||
}
|
||||
this.setBlock(autoAssignGateBlock.getFace(leftSide).getFace(BlockFace.UP), kind);
|
||||
index++;
|
||||
if (index >= size) kind = TeamKinds.teamKindFromString("gold");
|
||||
else kind = teams.get(index).getKind();
|
||||
setBlock(autoAssignGateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP), kind);
|
||||
if (index >= size) {
|
||||
kind = TeamKinds.teamKindFromString("gold");
|
||||
} else {
|
||||
kind = teams.get(index).getKind();
|
||||
}
|
||||
this.setBlock(autoAssignGateBlock.getFace(leftSide).getFace(BlockFace.UP).getFace(BlockFace.UP), kind);
|
||||
index++;
|
||||
if (index >= size) kind = TeamKinds.teamKindFromString("diamond");
|
||||
else kind = teams.get(index).getKind();
|
||||
setBlock(autoAssignGateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP), kind);
|
||||
if (index >= size) {
|
||||
kind = TeamKinds.teamKindFromString("diamond");
|
||||
} else {
|
||||
kind = teams.get(index).getKind();
|
||||
}
|
||||
this.setBlock(autoAssignGateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP), kind);
|
||||
index++;
|
||||
if (index >= size) kind = TeamKinds.teamKindFromString("iron");
|
||||
else kind = teams.get(index).getKind();
|
||||
setBlock(autoAssignGateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP), kind);
|
||||
if (index >= size) {
|
||||
kind = TeamKinds.teamKindFromString("iron");
|
||||
} else {
|
||||
kind = teams.get(index).getKind();
|
||||
}
|
||||
this.setBlock(autoAssignGateBlock.getFace(rightSide).getFace(BlockFace.UP).getFace(BlockFace.UP), kind);
|
||||
index++;
|
||||
if (index >= size) kind = TeamKinds.teamKindFromString("gold");
|
||||
else kind = teams.get(index).getKind();
|
||||
setBlock(autoAssignGateBlock.getFace(rightSide).getFace(BlockFace.UP), kind);
|
||||
if (index >= size) {
|
||||
kind = TeamKinds.teamKindFromString("gold");
|
||||
} else {
|
||||
kind = teams.get(index).getKind();
|
||||
}
|
||||
this.setBlock(autoAssignGateBlock.getFace(rightSide).getFace(BlockFace.UP), kind);
|
||||
index++;
|
||||
if (index >= size) kind = TeamKinds.teamKindFromString("diamond");
|
||||
else kind = teams.get(index).getKind();
|
||||
setBlock(autoAssignGateBlock.getFace(rightSide), kind);
|
||||
if (index >= size) {
|
||||
kind = TeamKinds.teamKindFromString("diamond");
|
||||
} else {
|
||||
kind = teams.get(index).getKind();
|
||||
}
|
||||
this.setBlock(autoAssignGateBlock.getFace(rightSide), kind);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInTeamGate(Team team, Location location) {
|
||||
BlockInfo info = teamGateBlocks.get(team.getName());
|
||||
BlockInfo info = this.teamGateBlocks.get(team.getName());
|
||||
if (info != null) {
|
||||
if (location.getBlockX() == info.getX()
|
||||
&& location.getBlockY() == info.getY()
|
||||
&& location.getBlockZ() == info.getZ()) {
|
||||
return true;
|
||||
}
|
||||
&& location.getBlockZ() == info.getZ())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAutoAssignGate(Location location) {
|
||||
if (autoAssignGate != null
|
||||
&& (location.getBlockX() == autoAssignGate.getX()
|
||||
&& location.getBlockY() == autoAssignGate.getY()
|
||||
&& location.getBlockZ() == autoAssignGate.getZ()) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (this.autoAssignGate != null
|
||||
&& (location.getBlockX() == this.autoAssignGate.getX()
|
||||
&& location.getBlockY() == this.autoAssignGate.getY()
|
||||
&& location.getBlockZ() == this.autoAssignGate.getZ()) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -551,31 +569,28 @@ public class ZoneLobby {
|
||||
|
||||
|
||||
public BlockFace getWall() {
|
||||
return wall;
|
||||
return this.wall;
|
||||
}
|
||||
|
||||
public boolean isInWarHubLinkGate(Location location) {
|
||||
if (warHubLinkGate != null
|
||||
&& location.getBlockX() == warHubLinkGate.getX()
|
||||
&& location.getBlockY() == warHubLinkGate.getY()
|
||||
&& location.getBlockZ() == warHubLinkGate.getZ()) {
|
||||
return true;
|
||||
}
|
||||
if (this.warHubLinkGate != null
|
||||
&& location.getBlockX() == this.warHubLinkGate.getX()
|
||||
&& location.getBlockY() == this.warHubLinkGate.getY()
|
||||
&& location.getBlockZ() == this.warHubLinkGate.getZ())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean blockIsAGateBlock(Block block, BlockFace blockWall) {
|
||||
if (blockWall == wall) {
|
||||
for (String teamName: teamGateBlocks.keySet()) {
|
||||
BlockInfo gateInfo = teamGateBlocks.get(teamName);
|
||||
if (isPartOfGate(BlockInfo.getBlock(warzone.getWorld(), gateInfo), block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (autoAssignGate != null && isPartOfGate(BlockInfo.getBlock(warzone.getWorld(), autoAssignGate), block)) {
|
||||
// auto assign
|
||||
return true;
|
||||
if (blockWall == this.wall) {
|
||||
for (String teamName: this.teamGateBlocks.keySet()) {
|
||||
BlockInfo gateInfo = this.teamGateBlocks.get(teamName);
|
||||
if (this.isPartOfGate(BlockInfo.getBlock(this.warzone.getWorld(), gateInfo), block))
|
||||
return true;
|
||||
}
|
||||
if (this.autoAssignGate != null && this.isPartOfGate(BlockInfo.getBlock(this.warzone.getWorld(), this.autoAssignGate), block))
|
||||
// auto assign
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -584,16 +599,16 @@ public class ZoneLobby {
|
||||
if (gateBlock != null) {
|
||||
BlockFace leftSide = null; // look at the zone
|
||||
BlockFace rightSide = null;
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
leftSide = BlockFace.EAST;
|
||||
rightSide = BlockFace.WEST;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
leftSide = BlockFace.SOUTH;
|
||||
rightSide = BlockFace.NORTH;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
leftSide = BlockFace.WEST;
|
||||
rightSide = BlockFace.EAST;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
leftSide = BlockFace.NORTH;
|
||||
rightSide = BlockFace.SOUTH;
|
||||
}
|
||||
@ -646,9 +661,9 @@ public class ZoneLobby {
|
||||
}
|
||||
|
||||
public void resetTeamGateSign(Team team) {
|
||||
BlockInfo info = teamGateBlocks.get(team.getName());
|
||||
BlockInfo info = this.teamGateBlocks.get(team.getName());
|
||||
if (info != null) {
|
||||
resetTeamGateSign(team, BlockInfo.getBlock(warzone.getWorld(), info));
|
||||
this.resetTeamGateSign(team, BlockInfo.getBlock(this.warzone.getWorld(), info));
|
||||
}
|
||||
}
|
||||
|
||||
@ -656,14 +671,14 @@ public class ZoneLobby {
|
||||
if (gate != null) {
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "Team " + team.getName();
|
||||
lines[1] = team.getPlayers().size() + "/" + warzone.getTeamCap() + " players";
|
||||
lines[2] = team.getPoints() + "/" + warzone.getScoreCap() + " pts";
|
||||
if (warzone.getLifePool() == -1) {
|
||||
lines[1] = team.getPlayers().size() + "/" + this.warzone.getTeamCap() + " players";
|
||||
lines[2] = team.getPoints() + "/" + this.warzone.getScoreCap() + " pts";
|
||||
if (this.warzone.getLifePool() == -1) {
|
||||
lines[3] = "unlimited lives";
|
||||
} else {
|
||||
lines[3] = team.getRemainingLifes() + "/" + warzone.getLifePool() + " lives left";
|
||||
lines[3] = team.getRemainingLifes() + "/" + this.warzone.getLifePool() + " lives left";
|
||||
}
|
||||
resetGateSign(gate, lines, true);
|
||||
this.resetGateSign(gate, lines, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -671,36 +686,48 @@ public class ZoneLobby {
|
||||
Block block = null;
|
||||
BlockFace direction = null;
|
||||
if (awayFromWall) {
|
||||
direction = wall;
|
||||
} else if (wall == BlockFace.NORTH) {
|
||||
direction = this.wall;
|
||||
} else if (this.wall == BlockFace.NORTH) {
|
||||
direction = BlockFace.SOUTH;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
direction = BlockFace.WEST;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
direction = BlockFace.NORTH;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
direction = BlockFace.EAST;
|
||||
}
|
||||
byte data = 0;
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.EAST);
|
||||
if (awayFromWall) data = (byte)4;
|
||||
else data = (byte)12;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
if (awayFromWall) {
|
||||
data = (byte)4;
|
||||
} else {
|
||||
data = (byte)12;
|
||||
}
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.SOUTH);
|
||||
if (awayFromWall) data = (byte)8;
|
||||
else data = (byte)0;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
if (awayFromWall) {
|
||||
data = (byte)8;
|
||||
} else {
|
||||
data = (byte)0;
|
||||
}
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.WEST);
|
||||
if (awayFromWall) data = (byte)12;
|
||||
else data = (byte)4;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
if (awayFromWall) {
|
||||
data = (byte)12;
|
||||
} else {
|
||||
data = (byte)4;
|
||||
}
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.NORTH);
|
||||
if (awayFromWall) data = (byte)0;
|
||||
else data = (byte)8;
|
||||
if (awayFromWall) {
|
||||
data = (byte)0;
|
||||
} else {
|
||||
data = (byte)8;
|
||||
}
|
||||
}
|
||||
|
||||
SignHelper.setToSign(war, block, data, lines);
|
||||
SignHelper.setToSign(this.war, block, data, lines);
|
||||
}
|
||||
|
||||
public boolean isLeavingZone(Location location) {
|
||||
@ -708,30 +735,30 @@ public class ZoneLobby {
|
||||
BlockFace inside = null;
|
||||
BlockFace left = null;
|
||||
BlockFace right = null;
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (this.wall == BlockFace.NORTH) {
|
||||
inside = BlockFace.SOUTH;
|
||||
left = BlockFace.WEST;
|
||||
right = BlockFace.EAST;
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
} else if (this.wall == BlockFace.EAST) {
|
||||
inside = BlockFace.WEST;
|
||||
left = BlockFace.NORTH;
|
||||
right = BlockFace.SOUTH;
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
} else if (this.wall == BlockFace.SOUTH) {
|
||||
inside = BlockFace.NORTH;
|
||||
left = BlockFace.EAST;
|
||||
right = BlockFace.WEST;
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
} else if (this.wall == BlockFace.WEST) {
|
||||
inside = BlockFace.EAST;
|
||||
left = BlockFace.SOUTH;
|
||||
right = BlockFace.NORTH;
|
||||
}
|
||||
if (autoAssignGate != null){
|
||||
if (leaving(location, BlockInfo.getBlock(warzone.getWorld(), autoAssignGate), inside, left, right)) return true;
|
||||
if (this.autoAssignGate != null){
|
||||
if (this.leaving(location, BlockInfo.getBlock(this.warzone.getWorld(), this.autoAssignGate), inside, left, right)) return true;
|
||||
}
|
||||
for (String teamName : teamGateBlocks.keySet()) {
|
||||
for (String teamName : this.teamGateBlocks.keySet()) {
|
||||
|
||||
BlockInfo info = teamGateBlocks.get(teamName);
|
||||
if (leaving(location, BlockInfo.getBlock(warzone.getWorld(), info), inside, left, right)) return true;
|
||||
BlockInfo info = this.teamGateBlocks.get(teamName);
|
||||
if (this.leaving(location, BlockInfo.getBlock(this.warzone.getWorld(), info), inside, left, right)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -743,14 +770,13 @@ public class ZoneLobby {
|
||||
// int z = location.getBlockZ();
|
||||
//
|
||||
// 3x4x1 deep
|
||||
Volume gateExitVolume = new Volume("tempGateExit", war, location.getWorld());
|
||||
Volume gateExitVolume = new Volume("tempGateExit", this.war, location.getWorld());
|
||||
Block out = gate.getFace(inside);
|
||||
gateExitVolume.setCornerOne(out.getFace(left).getFace(BlockFace.DOWN));
|
||||
gateExitVolume.setCornerTwo(gate.getFace(right, 1).getFace(BlockFace.UP, 3));
|
||||
|
||||
if (gateExitVolume.contains(location)) {
|
||||
return true;
|
||||
}
|
||||
if (gateExitVolume.contains(location))
|
||||
return true;
|
||||
|
||||
// 1 block thick arrow like detection grid:
|
||||
// Block out = gate.getFace(inside);
|
||||
|
@ -26,142 +26,164 @@ public class ZoneSetter {
|
||||
}
|
||||
|
||||
public void placeNorthwest() {
|
||||
Warzone warzone = war.findWarzone(zoneName);
|
||||
Block northwestBlock = player.getLocation().getWorld().getBlockAt(player.getLocation());
|
||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
||||
Block northwestBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
||||
StringBuilder msgString = new StringBuilder();
|
||||
try
|
||||
{
|
||||
if (warzone == null) {
|
||||
// create the warzone
|
||||
warzone = new Warzone(war, player.getLocation().getWorld(), zoneName);
|
||||
war.getIncompleteZones().add(warzone);
|
||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
||||
this.war.getIncompleteZones().add(warzone);
|
||||
warzone.getVolume().setNorthwest(northwestBlock);
|
||||
war.msg(player, "Warzone " + warzone.getName() + " created. Northwesternmost point set to x:"
|
||||
+ (int)warzone.getVolume().getNorthwestX() + " z:" + (int)warzone.getVolume().getNorthwestZ() + ". ");
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Northwesternmost point set to x:"
|
||||
+ warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
|
||||
} else {
|
||||
// change existing warzone
|
||||
resetWarzone(warzone, msgString);
|
||||
this.resetWarzone(warzone, msgString);
|
||||
warzone.getVolume().setNorthwest(northwestBlock);
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Northwesternmost point set to x:"
|
||||
+ (int)warzone.getVolume().getNorthwestX() + " z:" + (int)warzone.getVolume().getNorthwestZ() + ". ");
|
||||
+ warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
|
||||
}
|
||||
saveIfReady(warzone, msgString);
|
||||
this.saveIfReady(warzone, msgString);
|
||||
} catch (NotNorthwestException e) {
|
||||
war.badMsg(player, "The block you selected is not to the northwest of the existing southeasternmost block.");
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone(); // was reset before changing
|
||||
this.war.badMsg(this.player, "The block you selected is not to the northwest of the existing southeasternmost block.");
|
||||
if (warzone.getVolume().isSaved())
|
||||
{
|
||||
warzone.initializeZone(); // was reset before changing
|
||||
}
|
||||
} catch (TooSmallException e) {
|
||||
handleTooSmall();
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone();
|
||||
this.handleTooSmall();
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone();
|
||||
}
|
||||
} catch (TooBigException e) {
|
||||
handleTooBig();
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone();
|
||||
this.handleTooBig();
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void placeSoutheast() {
|
||||
Warzone warzone = war.findWarzone(zoneName);
|
||||
Block southeastBlock = player.getLocation().getWorld().getBlockAt(player.getLocation());
|
||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
||||
Block southeastBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
||||
StringBuilder msgString = new StringBuilder();
|
||||
try
|
||||
{
|
||||
if (warzone == null) {
|
||||
// create the warzone
|
||||
warzone = new Warzone(war, player.getLocation().getWorld(), zoneName);
|
||||
war.getIncompleteZones().add(warzone);
|
||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
||||
this.war.getIncompleteZones().add(warzone);
|
||||
warzone.getVolume().setSoutheast(southeastBlock);
|
||||
war.msg(player, "Warzone " + warzone.getName() + " created. Southeasternmost point set to x:"
|
||||
+ (int)warzone.getVolume().getSoutheastX() + " z:" + (int)warzone.getVolume().getSoutheastZ() + ". ");
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Southeasternmost point set to x:"
|
||||
+ warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
|
||||
} else {
|
||||
// change existing warzone
|
||||
resetWarzone(warzone, msgString);
|
||||
this.resetWarzone(warzone, msgString);
|
||||
warzone.getVolume().setSoutheast(southeastBlock);
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Southeasternmost point set to x:"
|
||||
+ (int)warzone.getVolume().getSoutheastX() + " z:" + (int)warzone.getVolume().getSoutheastZ() + ". ");
|
||||
+ warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
|
||||
}
|
||||
saveIfReady(warzone, msgString);
|
||||
this.saveIfReady(warzone, msgString);
|
||||
} catch (NotSoutheastException e) {
|
||||
war.badMsg(player, "The block you selected is not to the southeast of the existing northwestnmost block.");
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone(); // was reset before changing
|
||||
this.war.badMsg(this.player, "The block you selected is not to the southeast of the existing northwestnmost block.");
|
||||
if (warzone.getVolume().isSaved())
|
||||
{
|
||||
warzone.initializeZone(); // was reset before changing
|
||||
}
|
||||
} catch (TooSmallException e) {
|
||||
handleTooSmall();
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone();
|
||||
this.handleTooSmall();
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone();
|
||||
}
|
||||
} catch (TooBigException e) {
|
||||
handleTooBig();
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone();
|
||||
this.handleTooBig();
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void placeCorner1() {
|
||||
Block corner1Block = player.getLocation().getWorld().getBlockAt(player.getLocation());
|
||||
placeCorner1(corner1Block);
|
||||
Block corner1Block = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
||||
this.placeCorner1(corner1Block);
|
||||
}
|
||||
|
||||
public void placeCorner1(Block corner1Block) {
|
||||
Warzone warzone = war.findWarzone(zoneName);
|
||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
||||
StringBuilder msgString = new StringBuilder();
|
||||
try
|
||||
{
|
||||
if (warzone == null) {
|
||||
// create the warzone
|
||||
warzone = new Warzone(war, player.getLocation().getWorld(), zoneName);
|
||||
war.getIncompleteZones().add(warzone);
|
||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
||||
this.war.getIncompleteZones().add(warzone);
|
||||
warzone.getVolume().setZoneCornerOne(corner1Block);
|
||||
war.msg(player, "Warzone " + warzone.getName() + " created. Corner 1 set to x:"
|
||||
+ (int)corner1Block.getX() + " y:" + (int)corner1Block.getY() + " z:" + (int)corner1Block.getZ() + ". ");
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 1 set to x:"
|
||||
+ corner1Block.getX() + " y:" + corner1Block.getY() + " z:" + corner1Block.getZ() + ". ");
|
||||
} else {
|
||||
// change existing warzone
|
||||
resetWarzone(warzone, msgString);
|
||||
this.resetWarzone(warzone, msgString);
|
||||
warzone.getVolume().setZoneCornerOne(corner1Block);
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Corner 1 set to x:"
|
||||
+ (int)corner1Block.getX() + " y:" + (int)corner1Block.getY() + " z:" + (int)corner1Block.getZ() + ". ");
|
||||
+ corner1Block.getX() + " y:" + corner1Block.getY() + " z:" + corner1Block.getZ() + ". ");
|
||||
}
|
||||
saveIfReady(warzone, msgString);
|
||||
this.saveIfReady(warzone, msgString);
|
||||
} catch (TooSmallException e) {
|
||||
handleTooSmall();
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone();
|
||||
this.handleTooSmall();
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone();
|
||||
}
|
||||
} catch (TooBigException e) {
|
||||
handleTooBig();
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone();
|
||||
this.handleTooBig();
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void placeCorner2() {
|
||||
Block corner2Block = player.getLocation().getWorld().getBlockAt(player.getLocation());
|
||||
placeCorner2(corner2Block);
|
||||
Block corner2Block = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
|
||||
this.placeCorner2(corner2Block);
|
||||
}
|
||||
|
||||
public void placeCorner2(Block corner2Block) {
|
||||
Warzone warzone = war.findWarzone(zoneName);
|
||||
Warzone warzone = this.war.findWarzone(this.zoneName);
|
||||
StringBuilder msgString = new StringBuilder();
|
||||
try
|
||||
{
|
||||
if (warzone == null) {
|
||||
// create the warzone
|
||||
warzone = new Warzone(war, player.getLocation().getWorld(), zoneName);
|
||||
war.getIncompleteZones().add(warzone);
|
||||
warzone = new Warzone(this.war, this.player.getLocation().getWorld(), this.zoneName);
|
||||
this.war.getIncompleteZones().add(warzone);
|
||||
warzone.getVolume().setZoneCornerTwo(corner2Block);
|
||||
war.msg(player, "Warzone " + warzone.getName() + " created. Corner 2 set to x:"
|
||||
+ (int)corner2Block.getX() + " y:" + (int)corner2Block.getY() + " z:" + (int)corner2Block.getZ() + ". ");
|
||||
this.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 2 set to x:"
|
||||
+ corner2Block.getX() + " y:" + corner2Block.getY() + " z:" + corner2Block.getZ() + ". ");
|
||||
} else {
|
||||
// change existing warzone
|
||||
resetWarzone(warzone, msgString);
|
||||
this.resetWarzone(warzone, msgString);
|
||||
warzone.getVolume().setZoneCornerTwo(corner2Block);
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Corner 2 set to x:"
|
||||
+ (int)corner2Block.getX() + " y:" + (int)corner2Block.getY() + " z:" + (int)corner2Block.getZ() + ". ");
|
||||
+ corner2Block.getX() + " y:" + corner2Block.getY() + " z:" + corner2Block.getZ() + ". ");
|
||||
}
|
||||
saveIfReady(warzone, msgString);
|
||||
this.saveIfReady(warzone, msgString);
|
||||
} catch (TooSmallException e) {
|
||||
handleTooSmall();
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone();
|
||||
this.handleTooSmall();
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone();
|
||||
}
|
||||
} catch (TooBigException e) {
|
||||
handleTooBig();
|
||||
if (warzone.getVolume().isSaved()) warzone.initializeZone();
|
||||
this.handleTooBig();
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
warzone.initializeZone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetWarzone(Warzone warzone, StringBuilder msgString) {
|
||||
if (warzone.getVolume().isSaved()) {
|
||||
war.msg(player, "Resetting " + warzone.getName() + " blocks.");
|
||||
this.war.msg(this.player, "Resetting " + warzone.getName() + " blocks.");
|
||||
if (warzone.getLobby() != null && warzone.getLobby().getVolume() != null) {
|
||||
warzone.getLobby().getVolume().resetBlocks();
|
||||
}
|
||||
@ -171,48 +193,48 @@ public class ZoneSetter {
|
||||
}
|
||||
|
||||
private void handleTooSmall() {
|
||||
war.badMsg(player, "That would make the " + zoneName + " warzone too small. Sides must be at least 10 blocks and all existing structures (spawns, flags, etc) must fit inside.");
|
||||
this.war.badMsg(this.player, "That would make the " + this.zoneName + " warzone too small. Sides must be at least 10 blocks and all existing structures (spawns, flags, etc) must fit inside.");
|
||||
}
|
||||
|
||||
private void handleTooBig() {
|
||||
war.badMsg(player, "That would make the " + zoneName + " warzone too big. Sides must be less than 750 blocks.");
|
||||
this.war.badMsg(this.player, "That would make the " + this.zoneName + " warzone too big. Sides must be less than 750 blocks.");
|
||||
}
|
||||
|
||||
private void saveIfReady(Warzone warzone, StringBuilder msgString) {
|
||||
if (warzone.ready()) {
|
||||
if (!war.getWarzones().contains(warzone)) {
|
||||
war.addWarzone(warzone);
|
||||
if (!this.war.getWarzones().contains(warzone)) {
|
||||
this.war.addWarzone(warzone);
|
||||
}
|
||||
if (war.getIncompleteZones().contains(warzone)) {
|
||||
war.getIncompleteZones().remove(warzone);
|
||||
if (this.war.getIncompleteZones().contains(warzone)) {
|
||||
this.war.getIncompleteZones().remove(warzone);
|
||||
}
|
||||
WarMapper.save(war);
|
||||
WarMapper.save(this.war);
|
||||
msgString.append("Saving new warzone blocks...");
|
||||
war.msg(player, msgString.toString());
|
||||
this.war.msg(this.player, msgString.toString());
|
||||
warzone.saveState(false); // we just changed the volume, cant reset walls
|
||||
if (warzone.getLobby() == null) {
|
||||
// Set default lobby on south side
|
||||
ZoneLobby lobby = new ZoneLobby(war, warzone, BlockFace.SOUTH);
|
||||
ZoneLobby lobby = new ZoneLobby(this.war, warzone, BlockFace.SOUTH);
|
||||
warzone.setLobby(lobby);
|
||||
if (war.getWarHub() != null) { // warhub has to change
|
||||
war.getWarHub().getVolume().resetBlocks();
|
||||
war.getWarHub().initialize();
|
||||
if (this.war.getWarHub() != null) { // warhub has to change
|
||||
this.war.getWarHub().getVolume().resetBlocks();
|
||||
this.war.getWarHub().initialize();
|
||||
}
|
||||
war.msg(player, "Default lobby created on south side of zone. Use /setzonelobby <n/s/e/w> to change its position.");
|
||||
this.war.msg(this.player, "Default lobby created on south side of zone. Use /setzonelobby <n/s/e/w> to change its position.");
|
||||
} //else {
|
||||
// gotta move the lobby (or dont because zone.initzon does it for you)
|
||||
//warzone.getLobby().changeWall(warzone.getLobby().getWall());
|
||||
//}
|
||||
warzone.initializeZone();
|
||||
WarzoneMapper.save(war, warzone, true);
|
||||
war.msg(player, "Warzone saved.");
|
||||
WarzoneMapper.save(this.war, warzone, true);
|
||||
this.war.msg(this.player, "Warzone saved.");
|
||||
} else {
|
||||
if (warzone.getVolume().getCornerOne() == null) {
|
||||
msgString.append("Still missing corner 1.");
|
||||
} else if (warzone.getVolume().getCornerTwo() == null) {
|
||||
msgString.append("Still missing corner 2.");
|
||||
}
|
||||
war.msg(player, msgString.toString());
|
||||
this.war.msg(this.player, msgString.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,127 +34,127 @@ public class ZoneWallGuard {
|
||||
}
|
||||
|
||||
private void activate() {
|
||||
List<Block> nearestWallBlocks = warzone.getNearestWallBlocks(playerLocation);
|
||||
List<Block> nearestWallBlocks = this.warzone.getNearestWallBlocks(this.playerLocation);
|
||||
|
||||
// add wall guard blocks
|
||||
for (Block block : nearestWallBlocks) {
|
||||
glassify(block, wall);
|
||||
this.glassify(block, this.wall);
|
||||
if (this.wall != BlockFace.UP && this.wall != BlockFace.DOWN) {
|
||||
glassify(block.getFace(BlockFace.UP), wall);
|
||||
glassify(block.getFace(BlockFace.UP, 2), wall);
|
||||
glassify(block.getFace(BlockFace.DOWN), wall);
|
||||
glassify(block.getFace(BlockFace.DOWN, 2), wall);
|
||||
this.glassify(block.getFace(BlockFace.UP), this.wall);
|
||||
this.glassify(block.getFace(BlockFace.UP, 2), this.wall);
|
||||
this.glassify(block.getFace(BlockFace.DOWN), this.wall);
|
||||
this.glassify(block.getFace(BlockFace.DOWN, 2), this.wall);
|
||||
}
|
||||
if (this.wall == BlockFace.NORTH && warzone.getVolume().isNorthWallBlock(block)) {
|
||||
glassify(block.getFace(BlockFace.EAST), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.EAST, 2), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.UP), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.DOWN), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP, 2), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN, 2), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.WEST), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.WEST, 2), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.UP), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.DOWN), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP, 2), BlockFace.NORTH);
|
||||
glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN, 2), BlockFace.NORTH);
|
||||
} else if (this.wall == BlockFace.SOUTH && warzone.getVolume().isSouthWallBlock(block)) {
|
||||
glassify(block.getFace(BlockFace.EAST), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.EAST, 2), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.UP), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.DOWN), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP, 2), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN, 2), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.WEST), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.WEST, 2), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.UP), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.DOWN), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP, 2), BlockFace.SOUTH);
|
||||
glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN, 2), BlockFace.SOUTH);
|
||||
} else if (this.wall == BlockFace.EAST && warzone.getVolume().isEastWallBlock(block)) {
|
||||
glassify(block.getFace(BlockFace.NORTH), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.UP), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.DOWN), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP, 2), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN, 2), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.SOUTH), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.UP), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.DOWN), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP, 2), BlockFace.EAST);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.EAST);
|
||||
} else if (this.wall == BlockFace.WEST && warzone.getVolume().isWestWallBlock(block)) {
|
||||
glassify(block.getFace(BlockFace.NORTH), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.UP), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.DOWN), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP, 2), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN, 2), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.SOUTH), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.UP), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.DOWN), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP, 2), BlockFace.WEST);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.WEST);
|
||||
} else if (this.wall == BlockFace.UP && warzone.getVolume().isUpWallBlock(block)) {
|
||||
glassify(block.getFace(BlockFace.EAST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.EAST, 2), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.WEST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.WEST, 2), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.NORTH), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.EAST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST, 2), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST, 2), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.SOUTH), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.EAST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.WEST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.EAST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP, 2), BlockFace.UP);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.UP);
|
||||
} else if (this.wall == BlockFace.DOWN && warzone.getVolume().isDownWallBlock(block)) {
|
||||
glassify(block.getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.EAST, 2), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.WEST, 2), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.NORTH), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST, 2), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST, 2), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.SOUTH), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.DOWN);
|
||||
glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.DOWN);
|
||||
if (this.wall == BlockFace.NORTH && this.warzone.getVolume().isNorthWallBlock(block)) {
|
||||
this.glassify(block.getFace(BlockFace.EAST), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST, 2), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.UP), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.DOWN), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP, 2), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN, 2), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST, 2), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.UP), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.DOWN), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP, 2), BlockFace.NORTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN, 2), BlockFace.NORTH);
|
||||
} else if (this.wall == BlockFace.SOUTH && this.warzone.getVolume().isSouthWallBlock(block)) {
|
||||
this.glassify(block.getFace(BlockFace.EAST), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST, 2), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.UP), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST, 2).getFace(BlockFace.DOWN), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.UP, 2), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.EAST).getFace(BlockFace.DOWN, 2), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST, 2), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.UP), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST, 2).getFace(BlockFace.DOWN), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.UP, 2), BlockFace.SOUTH);
|
||||
this.glassify(block.getFace(BlockFace.WEST).getFace(BlockFace.DOWN, 2), BlockFace.SOUTH);
|
||||
} else if (this.wall == BlockFace.EAST && this.warzone.getVolume().isEastWallBlock(block)) {
|
||||
this.glassify(block.getFace(BlockFace.NORTH), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.UP), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.DOWN), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP, 2), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN, 2), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.UP), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.DOWN), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP, 2), BlockFace.EAST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.EAST);
|
||||
} else if (this.wall == BlockFace.WEST && this.warzone.getVolume().isWestWallBlock(block)) {
|
||||
this.glassify(block.getFace(BlockFace.NORTH), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.UP), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.DOWN), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.UP, 2), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.DOWN, 2), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.UP), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.DOWN), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP, 2), BlockFace.WEST);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.WEST);
|
||||
} else if (this.wall == BlockFace.UP && this.warzone.getVolume().isUpWallBlock(block)) {
|
||||
this.glassify(block.getFace(BlockFace.EAST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.EAST, 2), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.WEST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.WEST, 2), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.NORTH), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.EAST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST, 2), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST, 2), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.EAST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.WEST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.EAST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.UP, 2), BlockFace.UP);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.UP);
|
||||
} else if (this.wall == BlockFace.DOWN && this.warzone.getVolume().isDownWallBlock(block)) {
|
||||
this.glassify(block.getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.EAST, 2), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.WEST, 2), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.NORTH), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.EAST, 2), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.NORTH).getFace(BlockFace.WEST, 2), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.EAST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.DOWN);
|
||||
this.glassify(block.getFace(BlockFace.SOUTH).getFace(BlockFace.DOWN, 2), BlockFace.DOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,35 +163,35 @@ public class ZoneWallGuard {
|
||||
// face here means which wall we are working on
|
||||
|
||||
if ((block.getTypeId() == Material.AIR.getId() || block.getTypeId() == Material.WATER.getId()) &&
|
||||
(warzone.getLobby() == null || (warzone.getLobby() != null && !warzone.getLobby().blockIsAGateBlock(block, wall)))){
|
||||
(this.warzone.getLobby() == null || (this.warzone.getLobby() != null && !this.warzone.getLobby().blockIsAGateBlock(block, wall)))){
|
||||
if (wall == BlockFace.NORTH) {
|
||||
if (warzone.getVolume().isNorthWallBlock(block)) {
|
||||
glassified.add(new BlockInfo(block));
|
||||
if (this.warzone.getVolume().isNorthWallBlock(block)) {
|
||||
this.glassified.add(new BlockInfo(block));
|
||||
block.setType(Material.GLASS);
|
||||
}
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
if (warzone.getVolume().isSouthWallBlock(block)) {
|
||||
glassified.add(new BlockInfo(block));
|
||||
if (this.warzone.getVolume().isSouthWallBlock(block)) {
|
||||
this.glassified.add(new BlockInfo(block));
|
||||
block.setType(Material.GLASS);
|
||||
}
|
||||
} else if (wall == BlockFace.EAST) {
|
||||
if (warzone.getVolume().isEastWallBlock(block)) {
|
||||
glassified.add(new BlockInfo(block));
|
||||
if (this.warzone.getVolume().isEastWallBlock(block)) {
|
||||
this.glassified.add(new BlockInfo(block));
|
||||
block.setType(Material.GLASS);
|
||||
}
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
if (warzone.getVolume().isWestWallBlock(block)) {
|
||||
glassified.add(new BlockInfo(block));
|
||||
if (this.warzone.getVolume().isWestWallBlock(block)) {
|
||||
this.glassified.add(new BlockInfo(block));
|
||||
block.setType(Material.GLASS);
|
||||
}
|
||||
} else if (wall == BlockFace.UP) {
|
||||
if (warzone.getVolume().isUpWallBlock(block)) {
|
||||
glassified.add(new BlockInfo(block));
|
||||
if (this.warzone.getVolume().isUpWallBlock(block)) {
|
||||
this.glassified.add(new BlockInfo(block));
|
||||
block.setType(Material.GLASS);
|
||||
}
|
||||
} else if (wall == BlockFace.DOWN) {
|
||||
if (warzone.getVolume().isDownWallBlock(block)) {
|
||||
glassified.add(new BlockInfo(block));
|
||||
if (this.warzone.getVolume().isDownWallBlock(block)) {
|
||||
this.glassified.add(new BlockInfo(block));
|
||||
block.setType(Material.GLASS);
|
||||
}
|
||||
}
|
||||
@ -199,27 +199,27 @@ public class ZoneWallGuard {
|
||||
}
|
||||
|
||||
public void updatePlayerPosition(Location location) {
|
||||
if (warzone.isNearWall(location)) {
|
||||
if (this.warzone.isNearWall(location)) {
|
||||
this.playerLocation = location;
|
||||
deactivate();
|
||||
activate();
|
||||
this.deactivate();
|
||||
this.activate();
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivate() {
|
||||
for (BlockInfo oldBlock : glassified) {
|
||||
for (BlockInfo oldBlock : this.glassified) {
|
||||
// return to original
|
||||
Block glassifiedBlock = warzone.getWorld().getBlockAt(oldBlock.getX(), oldBlock.getY(), oldBlock.getZ());
|
||||
Block glassifiedBlock = this.warzone.getWorld().getBlockAt(oldBlock.getX(), oldBlock.getY(), oldBlock.getZ());
|
||||
glassifiedBlock.setTypeId(oldBlock.getTypeId());
|
||||
glassifiedBlock.setData(oldBlock.getData());
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public BlockFace getWall() {
|
||||
return wall;
|
||||
return this.wall;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class BlockResetJob implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
volume.resetBlocks();
|
||||
this.volume.resetBlocks();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,17 +22,17 @@ public class DeferredBlockResetsJob implements Runnable {
|
||||
}
|
||||
|
||||
public void add(DeferredBlockReset pleaseResetLater) {
|
||||
deferred.add(pleaseResetLater);
|
||||
this.deferred.add(pleaseResetLater);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return deferred.isEmpty();
|
||||
return this.deferred.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
for (DeferredBlockReset reset : deferred) {
|
||||
Block worldBlock = world.getBlockAt(reset.getX(), reset.getY(), reset.getZ());
|
||||
for (DeferredBlockReset reset : this.deferred) {
|
||||
Block worldBlock = this.world.getBlockAt(reset.getX(), reset.getY(), reset.getZ());
|
||||
worldBlock.setType(Material.getMaterial(reset.getBlockType()));
|
||||
|
||||
if (reset.getBlockType() == Material.SIGN_POST.getId()) {
|
||||
@ -42,10 +42,18 @@ public class DeferredBlockResetsJob implements Runnable {
|
||||
Sign sign = (Sign)state;
|
||||
//String[] lines = this.getSignLines().get("sign-" + i + "-" + j + "-" + k);
|
||||
if (reset.getLines() != null && sign.getLines() != null) {
|
||||
if (reset.getLines().length>0)sign.setLine(0, reset.getLines()[0]);
|
||||
if (reset.getLines().length>1)sign.setLine(1, reset.getLines()[1]);
|
||||
if (reset.getLines().length>2)sign.setLine(2, reset.getLines()[2]);
|
||||
if (reset.getLines().length>3)sign.setLine(3, reset.getLines()[3]);
|
||||
if (reset.getLines().length>0) {
|
||||
sign.setLine(0, reset.getLines()[0]);
|
||||
}
|
||||
if (reset.getLines().length>1) {
|
||||
sign.setLine(1, reset.getLines()[1]);
|
||||
}
|
||||
if (reset.getLines().length>2) {
|
||||
sign.setLine(2, reset.getLines()[2]);
|
||||
}
|
||||
if (reset.getLines().length>3) {
|
||||
sign.setLine(3, reset.getLines()[3]);
|
||||
}
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
|
@ -11,16 +11,16 @@ public class InitZoneJob implements Runnable {
|
||||
|
||||
public InitZoneJob(Warzone zone) {
|
||||
this.zone = zone;
|
||||
respawnExempted = null;
|
||||
this.respawnExempted = null;
|
||||
}
|
||||
|
||||
public InitZoneJob(Warzone warzone, Player respawnExempted) {
|
||||
zone = warzone;
|
||||
this.zone = warzone;
|
||||
this.respawnExempted = respawnExempted;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
zone.initializeZone(respawnExempted);
|
||||
this.zone.initializeZone(this.respawnExempted);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class LoadoutResetJob implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
zone.resetInventory(team, player);
|
||||
this.zone.resetInventory(this.team, this.player);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ public class LootDropperTask implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
for (ItemStack item : drop) {
|
||||
for (ItemStack item : this.drop) {
|
||||
if (item != null) {
|
||||
location.getWorld().dropItemNaturally(location, item);
|
||||
this.location.getWorld().dropItemNaturally(this.location, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,20 +19,20 @@ public class ResetCursorJob implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (isSoutheast) {
|
||||
cornerBlock.setType(originalCursorBlocks[0].getType());
|
||||
cornerBlock.setData(originalCursorBlocks[0].getData());
|
||||
cornerBlock.getFace(BlockFace.WEST).setType(originalCursorBlocks[1].getType());
|
||||
cornerBlock.getFace(BlockFace.WEST).setData(originalCursorBlocks[1].getData());
|
||||
cornerBlock.getFace(BlockFace.NORTH).setType(originalCursorBlocks[2].getType());
|
||||
cornerBlock.getFace(BlockFace.NORTH).setData(originalCursorBlocks[2].getData());
|
||||
if (this.isSoutheast) {
|
||||
this.cornerBlock.setType(this.originalCursorBlocks[0].getType());
|
||||
this.cornerBlock.setData(this.originalCursorBlocks[0].getData());
|
||||
this.cornerBlock.getFace(BlockFace.WEST).setType(this.originalCursorBlocks[1].getType());
|
||||
this.cornerBlock.getFace(BlockFace.WEST).setData(this.originalCursorBlocks[1].getData());
|
||||
this.cornerBlock.getFace(BlockFace.NORTH).setType(this.originalCursorBlocks[2].getType());
|
||||
this.cornerBlock.getFace(BlockFace.NORTH).setData(this.originalCursorBlocks[2].getData());
|
||||
} else {
|
||||
cornerBlock.setType(originalCursorBlocks[0].getType());
|
||||
cornerBlock.setData(originalCursorBlocks[0].getData());
|
||||
cornerBlock.getFace(BlockFace.EAST).setType(originalCursorBlocks[1].getType());
|
||||
cornerBlock.getFace(BlockFace.EAST).setData(originalCursorBlocks[1].getData());
|
||||
cornerBlock.getFace(BlockFace.SOUTH).setType(originalCursorBlocks[2].getType());
|
||||
cornerBlock.getFace(BlockFace.SOUTH).setData(originalCursorBlocks[2].getData());
|
||||
this.cornerBlock.setType(this.originalCursorBlocks[0].getType());
|
||||
this.cornerBlock.setData(this.originalCursorBlocks[0].getData());
|
||||
this.cornerBlock.getFace(BlockFace.EAST).setType(this.originalCursorBlocks[1].getType());
|
||||
this.cornerBlock.getFace(BlockFace.EAST).setData(this.originalCursorBlocks[1].getData());
|
||||
this.cornerBlock.getFace(BlockFace.SOUTH).setType(this.originalCursorBlocks[2].getType());
|
||||
this.cornerBlock.getFace(BlockFace.SOUTH).setData(this.originalCursorBlocks[2].getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ public class RespawnPlayerJob implements Runnable {
|
||||
public RespawnPlayerJob(Warzone zone, Team playerTeam, Player player) {
|
||||
this.zone = zone;
|
||||
// TODO Auto-generated constructor stub
|
||||
team = playerTeam;
|
||||
this.team = playerTeam;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
zone.respawnPlayer(team, player);
|
||||
this.zone.respawnPlayer(this.team, this.player);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class RestoreDeadmanInventoryJob implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
zone.restoreDeadmanInventory(player);
|
||||
player.teleport(zone.getTeleport());
|
||||
this.zone.restoreDeadmanInventory(this.player);
|
||||
this.player.teleport(this.zone.getTeleport());
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class RestoreWarhubJob implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
String[] hubStrSplit = hubStr.split(",");
|
||||
String[] hubStrSplit = this.hubStr.split(",");
|
||||
|
||||
int hubX = Integer.parseInt(hubStrSplit[0]);
|
||||
int hubY = Integer.parseInt(hubStrSplit[1]);
|
||||
@ -30,30 +30,30 @@ public class RestoreWarhubJob implements Runnable {
|
||||
String worldName;
|
||||
if (hubStrSplit.length > 3) {
|
||||
worldName = hubStrSplit[3];
|
||||
world = war.getServer().getWorld(worldName);
|
||||
world = this.war.getServer().getWorld(worldName);
|
||||
} else {
|
||||
worldName = "DEFAULT";
|
||||
world = war.getServer().getWorlds().get(0); // default to first world
|
||||
world = this.war.getServer().getWorlds().get(0); // default to first world
|
||||
}
|
||||
if (world != null) {
|
||||
Location hubLocation = new Location(world, hubX, hubY, hubZ);
|
||||
WarHub hub = new WarHub(war, hubLocation);
|
||||
war.setWarHub(hub);
|
||||
Volume vol = VolumeMapper.loadVolume("warhub", "", war, world);
|
||||
WarHub hub = new WarHub(this.war, hubLocation);
|
||||
this.war.setWarHub(hub);
|
||||
Volume vol = VolumeMapper.loadVolume("warhub", "", this.war, world);
|
||||
hub.setVolume(vol);
|
||||
hub.getVolume().resetBlocks();
|
||||
hub.initialize();
|
||||
|
||||
// In the previous job started by the mapper, warzones were created, but their lobbies are missing the war hub gate (because it didn't exist yet)
|
||||
for (Warzone zone : war.getWarzones()) {
|
||||
for (Warzone zone : this.war.getWarzones()) {
|
||||
if (zone.getLobby() != null) {
|
||||
zone.getLobby().getVolume().resetBlocks();
|
||||
zone.getLobby().initialize();
|
||||
}
|
||||
}
|
||||
war.logInfo("Warhub ready.");
|
||||
this.war.logInfo("Warhub ready.");
|
||||
} else {
|
||||
war.logWarn("Failed to restore warhub. The specified world (name: " + worldName + ") does not exist!");
|
||||
this.war.logWarn("Failed to restore warhub. The specified world (name: " + worldName + ") does not exist!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,14 +18,14 @@ public class RestoreWarzonesJob implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
String[] warzoneSplit = warzonesStr.split(",");
|
||||
war.getWarzones().clear();
|
||||
String[] warzoneSplit = this.warzonesStr.split(",");
|
||||
this.war.getWarzones().clear();
|
||||
for (String warzoneName : warzoneSplit) {
|
||||
if (warzoneName != null && !warzoneName.equals("")){
|
||||
war.logInfo("Loading zone " + warzoneName + "...");
|
||||
Warzone zone = WarzoneMapper.load(war, warzoneName, !newWarInstall);
|
||||
this.war.logInfo("Loading zone " + warzoneName + "...");
|
||||
Warzone zone = WarzoneMapper.load(this.war, warzoneName, !this.newWarInstall);
|
||||
if (zone != null) { // could have failed, would've been logged already
|
||||
war.getWarzones().add(zone);
|
||||
this.war.getWarzones().add(zone);
|
||||
//zone.getVolume().loadCorners();
|
||||
zone.getVolume().loadCorners();
|
||||
if (zone.getLobby() != null) {
|
||||
@ -38,8 +38,8 @@ public class RestoreWarzonesJob implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (war.getWarzones().size() > 0) {
|
||||
war.logInfo("Warzones ready.");
|
||||
if (this.war.getWarzones().size() > 0) {
|
||||
this.war.logInfo("Warzones ready.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,21 +17,24 @@ public class ScoreCapReachedJob implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
for (Team t : zone.getTeams()) {
|
||||
t.teamcast(winnersStr);
|
||||
for (Team t : this.zone.getTeams()) {
|
||||
t.teamcast(this.winnersStr);
|
||||
for (Player tp : t.getPlayers()) {
|
||||
// Send everyone to rally point (or zone lobby if not rally point)
|
||||
if (zone.getRallyPoint() != null) tp.teleport(zone.getRallyPoint());
|
||||
else tp.teleport(zone.getTeleport());
|
||||
if (this.zone.getRallyPoint() != null) {
|
||||
tp.teleport(this.zone.getRallyPoint());
|
||||
} else {
|
||||
tp.teleport(this.zone.getTeleport());
|
||||
}
|
||||
tp.setFireTicks(0);
|
||||
tp.setRemainingAir(300);
|
||||
if (zone.hasPlayerInventory(tp.getName())){
|
||||
zone.restorePlayerInventory(tp);
|
||||
if (this.zone.hasPlayerInventory(tp.getName())){
|
||||
this.zone.restorePlayerInventory(tp);
|
||||
}
|
||||
if (winnersStr.contains(t.getName())) {
|
||||
if (this.winnersStr.contains(t.getName())) {
|
||||
// give reward
|
||||
for (Integer slot : zone.getReward().keySet()){
|
||||
ItemStack item = zone.getReward().get(slot);
|
||||
for (Integer slot : this.zone.getReward().keySet()){
|
||||
ItemStack item = this.zone.getReward().get(slot);
|
||||
if (item != null) {
|
||||
tp.getInventory().addItem(item);
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ public class ZoneVolumeSaveJob extends Thread {
|
||||
this.zoneName = zoneName;
|
||||
this.war = war;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
ZoneVolumeMapper.save(volume, zoneName, war);
|
||||
ZoneVolumeMapper.save(this.volume, this.zoneName, this.war);
|
||||
}
|
||||
}
|
||||
|
@ -146,10 +146,18 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
if (state instanceof Sign) {
|
||||
Sign sign = (Sign)state;
|
||||
if (lines != null && sign.getLines() != null) {
|
||||
if (lines.length>0)sign.setLine(0, lines[0]);
|
||||
if (lines.length>1)sign.setLine(1, lines[1]);
|
||||
if (lines.length>2)sign.setLine(2, lines[2]);
|
||||
if (lines.length>3)sign.setLine(3, lines[3]);
|
||||
if (lines.length>0) {
|
||||
sign.setLine(0, lines[0]);
|
||||
}
|
||||
if (lines.length>1) {
|
||||
sign.setLine(1, lines[1]);
|
||||
}
|
||||
if (lines.length>2) {
|
||||
sign.setLine(2, lines[2]);
|
||||
}
|
||||
if (lines.length>3) {
|
||||
sign.setLine(3, lines[3]);
|
||||
}
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
@ -160,7 +168,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
List<ItemStack> items = null;
|
||||
if (blockSplit.length > 2) {
|
||||
String itemsStr = blockSplit[2];
|
||||
items = readInventoryString(itemsStr);
|
||||
items = PreDeGaulleZoneVolumeMapper.readInventoryString(itemsStr);
|
||||
}
|
||||
|
||||
// Chests set
|
||||
@ -187,7 +195,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
if (blockSplit.length > 2) {
|
||||
String itemsStr = blockSplit[2];
|
||||
//String itemsStr = lineScanner.nextLine();
|
||||
items = readInventoryString(itemsStr);
|
||||
items = PreDeGaulleZoneVolumeMapper.readInventoryString(itemsStr);
|
||||
}
|
||||
|
||||
// Dispensers set
|
||||
@ -285,18 +293,19 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (in != null)
|
||||
//if (scanner != null)
|
||||
try {
|
||||
in.close();
|
||||
in = null;
|
||||
//scanner.close();
|
||||
//scanner = null;
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file reader for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (in != null) {
|
||||
//if (scanner != null)
|
||||
try {
|
||||
in.close();
|
||||
in = null;
|
||||
//scanner.close();
|
||||
//scanner = null;
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file reader for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return noOfResetBlocks;
|
||||
}
|
||||
@ -307,9 +316,12 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
BufferedWriter out = null;
|
||||
try {
|
||||
(new File(war.getDataFolder().getPath() +"/dat/warzone-"+zoneName)).mkdir();
|
||||
if (zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||
else out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
||||
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
if (zoneName.equals("")) {
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||
} else {
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
||||
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
}
|
||||
|
||||
out.write("corner1"); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
||||
@ -372,8 +384,9 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null)
|
||||
extra += ";" + item.getData().getData() ;
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData() ;
|
||||
}
|
||||
extra += ";;";
|
||||
}
|
||||
}
|
||||
@ -398,8 +411,9 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null)
|
||||
extra += ";" + item.getData().getData() ;
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData() ;
|
||||
}
|
||||
extra += ";;";
|
||||
}
|
||||
}
|
||||
@ -432,14 +446,15 @@ public class PreDeGaulleZoneVolumeMapper {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (out != null)
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return noOfSavedBlocks;
|
||||
|
@ -37,12 +37,12 @@ public final class PropertiesFile {
|
||||
|
||||
try {
|
||||
if (file.exists()) {
|
||||
load();
|
||||
this.load();
|
||||
} else {
|
||||
save();
|
||||
this.save();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
log.severe("[PropertiesFile] Unable to load " + fileName + "!");
|
||||
PropertiesFile.log.severe("[PropertiesFile] Unable to load " + fileName + "!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ public final class PropertiesFile {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void load() throws IOException {
|
||||
inputStream = new FileInputStream(fileName);
|
||||
props.load(inputStream);
|
||||
this.inputStream = new FileInputStream(this.fileName);
|
||||
this.props.load(this.inputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,25 +63,25 @@ public final class PropertiesFile {
|
||||
*/
|
||||
public void save() {
|
||||
try {
|
||||
outputStream = new FileOutputStream(fileName);
|
||||
props.store(outputStream, null);
|
||||
this.outputStream = new FileOutputStream(this.fileName);
|
||||
this.props.store(this.outputStream, null);
|
||||
}catch(IOException ex) {
|
||||
log.severe("[PropertiesFile] Unable to save " + fileName + "!");
|
||||
PropertiesFile.log.severe("[PropertiesFile] Unable to save " + this.fileName + "!");
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (outputStream != null) {
|
||||
if (this.outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
this.outputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.severe("[PropertiesFile] Failed to close " + fileName + " writer!");
|
||||
PropertiesFile.log.severe("[PropertiesFile] Failed to close " + this.fileName + " writer!");
|
||||
}
|
||||
} else if (inputStream != null) {
|
||||
} else if (this.inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
this.inputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.severe("[PropertiesFile] Failed to close " + fileName + " reader!");
|
||||
PropertiesFile.log.severe("[PropertiesFile] Failed to close " + this.fileName + " reader!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ public final class PropertiesFile {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String> returnMap() throws Exception {
|
||||
return (Map<String, String>) props.clone();
|
||||
return (Map<String, String>) this.props.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ public final class PropertiesFile {
|
||||
* @return <code>Boolean</code> - True if the <code>key</code> exists, false if it cannot be found.
|
||||
*/
|
||||
public boolean containsKey(String var) {
|
||||
return props.containsKey(var);
|
||||
return this.props.containsKey(var);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,7 +126,7 @@ public final class PropertiesFile {
|
||||
* @return <code>java.lang.String</code> - True if the <code>key</code> exists, false if it cannot be found.
|
||||
*/
|
||||
public String getProperty(String var) {
|
||||
return (String)props.getProperty(var);
|
||||
return this.props.getProperty(var);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,7 +139,7 @@ public final class PropertiesFile {
|
||||
public void removeKey(String var) {
|
||||
if (this.props.containsKey(var)) {
|
||||
this.props.remove(var);
|
||||
save();
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ public final class PropertiesFile {
|
||||
* @return <code>Boolean</code> - True for existance, false for <code>key</code> found.
|
||||
*/
|
||||
public boolean keyExists(String key) {
|
||||
return containsKey(key);
|
||||
return this.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,9 +162,8 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to "" or empty.
|
||||
*/
|
||||
public String getString(String key) {
|
||||
if (this.containsKey(key)) {
|
||||
return this.getProperty(key);
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return this.getProperty(key);
|
||||
|
||||
return "";
|
||||
}
|
||||
@ -180,11 +179,10 @@ public final class PropertiesFile {
|
||||
* @return java.lang.String Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public String getString(String key, String value) {
|
||||
if (this.containsKey(key)) {
|
||||
return this.getProperty(key);
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return this.getProperty(key);
|
||||
|
||||
setString(key, value);
|
||||
this.setString(key, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -196,8 +194,8 @@ public final class PropertiesFile {
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setString(String key, String value) {
|
||||
props.put(key, value);
|
||||
save();
|
||||
this.props.put(key, value);
|
||||
this.save();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,9 +206,8 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0
|
||||
*/
|
||||
public int getInt(String key) {
|
||||
if (this.containsKey(key)) {
|
||||
return Integer.parseInt(this.getProperty(key));
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return Integer.parseInt(this.getProperty(key));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -224,11 +221,10 @@ public final class PropertiesFile {
|
||||
* @return <code>Integer</code> - Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public int getInt(String key, int value) {
|
||||
if (this.containsKey(key)) {
|
||||
return Integer.parseInt(this.getProperty(key));
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return Integer.parseInt(this.getProperty(key));
|
||||
|
||||
setInt(key, value);
|
||||
this.setInt(key, value);
|
||||
return value;
|
||||
|
||||
}
|
||||
@ -241,9 +237,9 @@ public final class PropertiesFile {
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setInt(String key, int value) {
|
||||
props.put(key, String.valueOf(value));
|
||||
this.props.put(key, String.valueOf(value));
|
||||
|
||||
save();
|
||||
this.save();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -254,9 +250,8 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0.0
|
||||
*/
|
||||
public double getDouble(String key) {
|
||||
if (this.containsKey(key)) {
|
||||
return Double.parseDouble(this.getProperty(key));
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return Double.parseDouble(this.getProperty(key));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -270,11 +265,10 @@ public final class PropertiesFile {
|
||||
* @return <code>Double</code> - Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public double getDouble(String key, double value) {
|
||||
if (this.containsKey(key)) {
|
||||
return Double.parseDouble(this.getProperty(key));
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return Double.parseDouble(this.getProperty(key));
|
||||
|
||||
setDouble(key, value);
|
||||
this.setDouble(key, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -286,9 +280,9 @@ public final class PropertiesFile {
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setDouble(String key, double value) {
|
||||
props.put(key, String.valueOf(value));
|
||||
this.props.put(key, String.valueOf(value));
|
||||
|
||||
save();
|
||||
this.save();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -299,9 +293,8 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to 0L
|
||||
*/
|
||||
public long getLong(String key) {
|
||||
if (this.containsKey(key)) {
|
||||
return Long.parseLong(this.getProperty(key));
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return Long.parseLong(this.getProperty(key));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -315,11 +308,10 @@ public final class PropertiesFile {
|
||||
* @return <code>Long</code> - Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public long getLong(String key, long value) {
|
||||
if (this.containsKey(key)) {
|
||||
return Long.parseLong(this.getProperty(key));
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return Long.parseLong(this.getProperty(key));
|
||||
|
||||
setLong(key, value);
|
||||
this.setLong(key, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -331,9 +323,9 @@ public final class PropertiesFile {
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setLong(String key, long value) {
|
||||
props.put(key, String.valueOf(value));
|
||||
this.props.put(key, String.valueOf(value));
|
||||
|
||||
save();
|
||||
this.save();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -344,9 +336,8 @@ public final class PropertiesFile {
|
||||
* @param key The <code>key</code> we will retrieve the property from, if no <code>key</code> is found default to false
|
||||
*/
|
||||
public boolean getBoolean(String key) {
|
||||
if (this.containsKey(key)) {
|
||||
return Boolean.parseBoolean(this.getProperty(key));
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return Boolean.parseBoolean(this.getProperty(key));
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -360,11 +351,10 @@ public final class PropertiesFile {
|
||||
* @return <code>Boolean</code> - Either we will return the default value or a prior existing value depending on existance.
|
||||
*/
|
||||
public boolean getBoolean(String key, boolean value) {
|
||||
if (this.containsKey(key)) {
|
||||
return Boolean.parseBoolean(this.getProperty(key));
|
||||
}
|
||||
if (this.containsKey(key))
|
||||
return Boolean.parseBoolean(this.getProperty(key));
|
||||
|
||||
setBoolean(key, value);
|
||||
this.setBoolean(key, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -376,8 +366,8 @@ public final class PropertiesFile {
|
||||
* @param value The <code>value</code> we will be setting inside the <code>.[properties]</code> file.
|
||||
*/
|
||||
public void setBoolean(String key, boolean value) {
|
||||
props.put(key, String.valueOf(value));
|
||||
this.props.put(key, String.valueOf(value));
|
||||
|
||||
save();
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class VolumeMapper {
|
||||
public static Volume loadVolume(String volumeName, String zoneName,
|
||||
War war, World world) {
|
||||
Volume volume = new Volume(volumeName, war, world);
|
||||
load(volume, zoneName, war, world);
|
||||
VolumeMapper.load(volume, zoneName, war, world);
|
||||
return volume;
|
||||
}
|
||||
|
||||
@ -42,9 +42,12 @@ public class VolumeMapper {
|
||||
public static void load(Volume volume, String zoneName, War war, World world) {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
if (zoneName.equals("")) in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() +
|
||||
"/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
|
||||
else in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
if (zoneName.equals("")) {
|
||||
in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() +
|
||||
"/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
|
||||
} else {
|
||||
in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
}
|
||||
String firstLine = in.readLine();
|
||||
if (firstLine != null && !firstLine.equals("")) {
|
||||
boolean height129Fix = false;
|
||||
@ -179,14 +182,15 @@ public class VolumeMapper {
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (in != null)
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file reader for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file reader for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,9 +198,12 @@ public class VolumeMapper {
|
||||
if (volume.hasTwoCorners()) {
|
||||
BufferedWriter out = null;
|
||||
try {
|
||||
if (zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||
else out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
||||
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
if (zoneName.equals("")) {
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||
} else {
|
||||
out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
||||
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||
}
|
||||
|
||||
out.write("corner1"); out.newLine();
|
||||
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
||||
@ -235,8 +242,9 @@ public class VolumeMapper {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null)
|
||||
extra += ";" + item.getData().getData() ;
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData() ;
|
||||
}
|
||||
extra += ";;";
|
||||
}
|
||||
}
|
||||
@ -252,8 +260,9 @@ public class VolumeMapper {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null)
|
||||
extra += ";" + item.getData().getData() ;
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData() ;
|
||||
}
|
||||
extra += ";;";
|
||||
}
|
||||
}
|
||||
@ -281,14 +290,15 @@ public class VolumeMapper {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
if (out != null)
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,17 +134,25 @@ public class ZoneVolumeMapper {
|
||||
if (state instanceof Sign) {
|
||||
Sign sign = (Sign)state;
|
||||
if (lines != null && sign.getLines() != null) {
|
||||
if (lines.length>0)sign.setLine(0, lines[0]);
|
||||
if (lines.length>1)sign.setLine(1, lines[1]);
|
||||
if (lines.length>2)sign.setLine(2, lines[2]);
|
||||
if (lines.length>3)sign.setLine(3, lines[3]);
|
||||
if (lines.length>0) {
|
||||
sign.setLine(0, lines[0]);
|
||||
}
|
||||
if (lines.length>1) {
|
||||
sign.setLine(1, lines[1]);
|
||||
}
|
||||
if (lines.length>2) {
|
||||
sign.setLine(2, lines[2]);
|
||||
}
|
||||
if (lines.length>3) {
|
||||
sign.setLine(3, lines[3]);
|
||||
}
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (diskBlockType == Material.CHEST.getId()) {
|
||||
// Chests read
|
||||
List<ItemStack> items = readInventoryString(invsReader.readLine());
|
||||
List<ItemStack> items = ZoneVolumeMapper.readInventoryString(invsReader.readLine());
|
||||
|
||||
// Chests set
|
||||
worldBlock.setType(Material.getMaterial(diskBlockType));
|
||||
@ -166,7 +174,7 @@ public class ZoneVolumeMapper {
|
||||
}
|
||||
} else if (diskBlockType == Material.DISPENSER.getId()) {
|
||||
// Dispensers read
|
||||
List<ItemStack> items = readInventoryString(invsReader.readLine());
|
||||
List<ItemStack> items = ZoneVolumeMapper.readInventoryString(invsReader.readLine());
|
||||
|
||||
// Dispensers set
|
||||
worldBlock.setType(Material.getMaterial(diskBlockType));
|
||||
@ -255,10 +263,18 @@ public class ZoneVolumeMapper {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (cornersReader != null) cornersReader.close();
|
||||
if (blocksStream != null) blocksStream.close();
|
||||
if (signsReader != null) signsReader.close();
|
||||
if (invsReader != null) invsReader.close();
|
||||
if (cornersReader != null) {
|
||||
cornersReader.close();
|
||||
}
|
||||
if (blocksStream != null) {
|
||||
blocksStream.close();
|
||||
}
|
||||
if (signsReader != null) {
|
||||
signsReader.close();
|
||||
}
|
||||
if (invsReader != null) {
|
||||
invsReader.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
@ -374,8 +390,9 @@ public class ZoneVolumeMapper {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null)
|
||||
extra += ";" + item.getData().getData() ;
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData() ;
|
||||
}
|
||||
extra += ";;";
|
||||
}
|
||||
}
|
||||
@ -401,8 +418,9 @@ public class ZoneVolumeMapper {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null)
|
||||
extra += ";" + item.getData().getData() ;
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData() ;
|
||||
}
|
||||
extra += ";;";
|
||||
}
|
||||
}
|
||||
@ -436,10 +454,18 @@ public class ZoneVolumeMapper {
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (cornersWriter != null) cornersWriter.close();
|
||||
if (blocksOutput != null) blocksOutput.close();
|
||||
if (signsWriter != null) signsWriter.close();
|
||||
if (invsWriter != null) invsWriter.close();
|
||||
if (cornersWriter != null) {
|
||||
cornersWriter.close();
|
||||
}
|
||||
if (blocksOutput != null) {
|
||||
blocksOutput.close();
|
||||
}
|
||||
if (signsWriter != null) {
|
||||
signsWriter.close();
|
||||
}
|
||||
if (invsWriter != null) {
|
||||
invsWriter.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to close volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
@ -456,11 +482,11 @@ public class ZoneVolumeMapper {
|
||||
}
|
||||
|
||||
public static void delete(Volume volume, War war) {
|
||||
deleteFile("War/dat/volume-" + volume.getName() + ".dat", war);
|
||||
deleteFile("War/dat/volume-" + volume.getName() + ".corners", war);
|
||||
deleteFile("War/dat/volume-" + volume.getName() + ".blocks", war);
|
||||
deleteFile("War/dat/volume-" + volume.getName() + ".signs", war);
|
||||
deleteFile("War/dat/volume-" + volume.getName() + ".invs", war);
|
||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".dat", war);
|
||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".corners", war);
|
||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".blocks", war);
|
||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".signs", war);
|
||||
ZoneVolumeMapper.deleteFile("War/dat/volume-" + volume.getName() + ".invs", war);
|
||||
}
|
||||
|
||||
private static void deleteFile(String path, War war) {
|
||||
|
@ -64,7 +64,7 @@ public class ChatFixUtil {
|
||||
*/
|
||||
public static ArrayList<String> fix(String msg) {
|
||||
// Make sure the end of msg is good
|
||||
msg = cleanMsgEnding(msg);
|
||||
msg = ChatFixUtil.cleanMsgEnding(msg);
|
||||
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
int displen = 0; // The number of displayed chars in row so far.
|
||||
@ -72,20 +72,20 @@ public class ChatFixUtil {
|
||||
String latestColor = null;
|
||||
|
||||
for (int i = 0; i < msg.length(); i++) {
|
||||
if (displen == lineLength) {
|
||||
if (displen == ChatFixUtil.lineLength) {
|
||||
// it is time to start on the next row!
|
||||
ret.add(row);
|
||||
displen = 0;
|
||||
row = "";
|
||||
if (latestColor != null) {
|
||||
row += deg+latestColor;
|
||||
row += ChatFixUtil.deg+latestColor;
|
||||
}
|
||||
}
|
||||
char c = msg.charAt(i);
|
||||
|
||||
if (c == deg) {
|
||||
if (c == ChatFixUtil.deg) {
|
||||
latestColor = String.valueOf(msg.charAt(i+1));
|
||||
row += deg+latestColor;
|
||||
row += ChatFixUtil.deg+latestColor;
|
||||
i++;
|
||||
} else {
|
||||
displen += 1;
|
||||
@ -99,7 +99,7 @@ public class ChatFixUtil {
|
||||
public static ArrayList<String> fix(List<String> messages) {
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
for (String message : messages) {
|
||||
ret.addAll(fix(message));
|
||||
ret.addAll(ChatFixUtil.fix(message));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -112,9 +112,9 @@ public class ChatFixUtil {
|
||||
protected static String cleanMsgEnding (String msg) {
|
||||
|
||||
while (msg.length() > 0) {
|
||||
if (msg.endsWith(String.valueOf(deg)) || msg.endsWith(" ")) {
|
||||
if (msg.endsWith(String.valueOf(ChatFixUtil.deg)) || msg.endsWith(" ")) {
|
||||
msg = msg.substring(0, msg.length()-1);
|
||||
} else if (msg.length() >= 2 && msg.charAt(msg.length() - 2) == deg) {
|
||||
} else if (msg.length() >= 2 && msg.charAt(msg.length() - 2) == ChatFixUtil.deg) {
|
||||
msg = msg.substring(0, msg.length()-2);
|
||||
} else {
|
||||
break;
|
||||
@ -130,19 +130,18 @@ public class ChatFixUtil {
|
||||
*/
|
||||
public static String thisMsgWouldCrashClient(String str) {
|
||||
// There would always be crash if we end with deg or deg+'anychar'
|
||||
if (str.length() >= 1 && str.charAt(str.length() - 1) == deg) {
|
||||
return "Crash: The str ends with deg.";
|
||||
} else if (str.length() >= 2 && str.charAt(str.length() - 2) == deg) {
|
||||
return "Crash: The str ends with deg+'anychar'.";
|
||||
}
|
||||
if (str.length() >= 1 && str.charAt(str.length() - 1) == ChatFixUtil.deg)
|
||||
return "Crash: The str ends with deg.";
|
||||
else if (str.length() >= 2 && str.charAt(str.length() - 2) == ChatFixUtil.deg)
|
||||
return "Crash: The str ends with deg+'anychar'.";
|
||||
|
||||
int displayedChars = 0;
|
||||
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char c = str.charAt(i);
|
||||
if (c == deg && displayedChars == lineLength) {
|
||||
return "Crash: Deg as fiftyforth \"displayed\" char";
|
||||
} else if (c == deg) {
|
||||
if (c == ChatFixUtil.deg && displayedChars == ChatFixUtil.lineLength)
|
||||
return "Crash: Deg as fiftyforth \"displayed\" char";
|
||||
else if (c == ChatFixUtil.deg) {
|
||||
i++; // this and next: they are not displayed... skip them...
|
||||
} else {
|
||||
displayedChars += 1;
|
||||
@ -160,7 +159,7 @@ public class ChatFixUtil {
|
||||
public static void sendMessage(Player player, String message, boolean fix) {
|
||||
if (fix) {
|
||||
List<String> messages = ChatFixUtil.fix(message);
|
||||
sendMessage(player, messages, false);
|
||||
ChatFixUtil.sendMessage(player, messages, false);
|
||||
} else {
|
||||
if (player != null) {
|
||||
player.sendMessage(message);
|
||||
@ -172,14 +171,14 @@ public class ChatFixUtil {
|
||||
messages = ChatFixUtil.fix(messages);
|
||||
}
|
||||
for (String message : messages) {
|
||||
sendMessage(player, message, false);
|
||||
ChatFixUtil.sendMessage(player, message, false);
|
||||
}
|
||||
}
|
||||
public static void sendMessage(Player player, String message) {
|
||||
sendMessage(player, message, true);
|
||||
ChatFixUtil.sendMessage(player, message, true);
|
||||
}
|
||||
public static void sendMessage(Player player, List<String> messages) {
|
||||
sendMessage(player, messages, true);
|
||||
ChatFixUtil.sendMessage(player, messages, true);
|
||||
}
|
||||
//----------------------------------------------//
|
||||
// Many Players
|
||||
@ -187,10 +186,10 @@ public class ChatFixUtil {
|
||||
public static void sendMessage(Collection<Player> players, String message, boolean fix) {
|
||||
if (fix) {
|
||||
List<String> messages = ChatFixUtil.fix(message);
|
||||
sendMessage(players, messages, false);
|
||||
ChatFixUtil.sendMessage(players, messages, false);
|
||||
} else {
|
||||
for (Player player : players) {
|
||||
sendMessage(player, message, false);
|
||||
ChatFixUtil.sendMessage(player, message, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -200,13 +199,13 @@ public class ChatFixUtil {
|
||||
}
|
||||
|
||||
for (String message : messages) {
|
||||
sendMessage(players, message, false);
|
||||
ChatFixUtil.sendMessage(players, message, false);
|
||||
}
|
||||
}
|
||||
public static void sendMessage(Collection<Player> players, String message) {
|
||||
sendMessage(players, message, true);
|
||||
ChatFixUtil.sendMessage(players, message, true);
|
||||
}
|
||||
public static void sendMessage(Collection<Player> players, List<String> messages) {
|
||||
sendMessage(players, messages, true);
|
||||
ChatFixUtil.sendMessage(players, messages, true);
|
||||
}
|
||||
}
|
||||
|
@ -24,30 +24,30 @@ public class DeferredBlockReset {
|
||||
this.z = z;
|
||||
this.blockType = blockType;
|
||||
this.blockData = blockData;
|
||||
lines = signLines;
|
||||
this.lines = signLines;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public int getBlockType() {
|
||||
return blockType;
|
||||
return this.blockType;
|
||||
}
|
||||
|
||||
public byte getBlockData() {
|
||||
return blockData;
|
||||
return this.blockData;
|
||||
}
|
||||
|
||||
public String[] getLines() {
|
||||
return lines;
|
||||
return this.lines;
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class InventoryStash {
|
||||
}
|
||||
|
||||
public ItemStack[] getContents() {
|
||||
return contents;
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public void setHelmet(ItemStack helmet) {
|
||||
@ -36,7 +36,7 @@ public class InventoryStash {
|
||||
}
|
||||
|
||||
public ItemStack getHelmet() {
|
||||
return helmet;
|
||||
return this.helmet;
|
||||
}
|
||||
|
||||
public void setChest(ItemStack chest) {
|
||||
@ -44,7 +44,7 @@ public class InventoryStash {
|
||||
}
|
||||
|
||||
public ItemStack getChest() {
|
||||
return chest;
|
||||
return this.chest;
|
||||
}
|
||||
|
||||
public void setLegs(ItemStack legs) {
|
||||
@ -52,7 +52,7 @@ public class InventoryStash {
|
||||
}
|
||||
|
||||
public ItemStack getLegs() {
|
||||
return legs;
|
||||
return this.legs;
|
||||
}
|
||||
|
||||
public void setFeet(ItemStack feet) {
|
||||
@ -60,7 +60,7 @@ public class InventoryStash {
|
||||
}
|
||||
|
||||
public ItemStack getFeet() {
|
||||
return feet;
|
||||
return this.feet;
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,15 +61,15 @@ public class BlockInfo {
|
||||
// }
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
return this.z;
|
||||
}
|
||||
|
||||
// letting us mutate the BlockInfos might be a bad idea; use setters with care
|
||||
@ -86,19 +86,19 @@ public class BlockInfo {
|
||||
}
|
||||
|
||||
public int getTypeId() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Material getType() {
|
||||
return Material.getMaterial(type);
|
||||
return Material.getMaterial(this.type);
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
return data;
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public boolean is(Material material) {
|
||||
return getType() == material;
|
||||
return this.getType() == material;
|
||||
}
|
||||
|
||||
// public String[] getSignLines() {
|
||||
|
@ -23,12 +23,12 @@ public class CenteredVolume extends Volume {
|
||||
public CenteredVolume(String name, Block center, int sideSize, War war, World world) {
|
||||
super(name, war, world);
|
||||
this.world = world;
|
||||
setCenter(center);
|
||||
setSideSize(sideSize);
|
||||
this.setCenter(center);
|
||||
this.setSideSize(sideSize);
|
||||
}
|
||||
|
||||
public void changeCenter(Location newCenter) {
|
||||
changeCenter(world.getBlockAt(newCenter.getBlockX(),
|
||||
this.changeCenter(this.world.getBlockAt(newCenter.getBlockX(),
|
||||
newCenter.getBlockY(),
|
||||
newCenter.getBlockZ()),
|
||||
this.sideSize);
|
||||
@ -46,27 +46,27 @@ public class CenteredVolume extends Volume {
|
||||
}
|
||||
|
||||
public void calculateCorners() {
|
||||
int topHalfOfSide = sideSize / 2;
|
||||
int topHalfOfSide = this.sideSize / 2;
|
||||
|
||||
int x = center.getX() + topHalfOfSide;
|
||||
int y = center.getY() + topHalfOfSide;
|
||||
int z = center.getZ() + topHalfOfSide;
|
||||
Block cornerOne = world.getBlockAt(x, y, z);
|
||||
setCornerOne(cornerOne);
|
||||
int x = this.center.getX() + topHalfOfSide;
|
||||
int y = this.center.getY() + topHalfOfSide;
|
||||
int z = this.center.getZ() + topHalfOfSide;
|
||||
Block cornerOne = this.world.getBlockAt(x, y, z);
|
||||
this.setCornerOne(cornerOne);
|
||||
|
||||
if (sideSize % 2 == 0) { // not a real center, bottom half is larger by 1
|
||||
int bottomHalfOfSide = sideSize - topHalfOfSide;
|
||||
x = center.getX() - bottomHalfOfSide;
|
||||
y = center.getY() - bottomHalfOfSide;
|
||||
z = center.getZ() - bottomHalfOfSide;
|
||||
Block cornerTwo = world.getBlockAt(x, y, z);
|
||||
setCornerTwo(cornerTwo);
|
||||
if (this.sideSize % 2 == 0) { // not a real center, bottom half is larger by 1
|
||||
int bottomHalfOfSide = this.sideSize - topHalfOfSide;
|
||||
x = this.center.getX() - bottomHalfOfSide;
|
||||
y = this.center.getY() - bottomHalfOfSide;
|
||||
z = this.center.getZ() - bottomHalfOfSide;
|
||||
Block cornerTwo = this.world.getBlockAt(x, y, z);
|
||||
this.setCornerTwo(cornerTwo);
|
||||
} else {
|
||||
x = center.getX() - topHalfOfSide;
|
||||
y = center.getY() - topHalfOfSide;
|
||||
z = center.getZ() - topHalfOfSide;
|
||||
Block cornerTwo = world.getBlockAt(x, y, z);
|
||||
setCornerTwo(cornerTwo);
|
||||
x = this.center.getX() - topHalfOfSide;
|
||||
y = this.center.getY() - topHalfOfSide;
|
||||
z = this.center.getZ() - topHalfOfSide;
|
||||
Block cornerTwo = this.world.getBlockAt(x, y, z);
|
||||
this.setCornerTwo(cornerTwo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,72 +23,68 @@ public class VerticalVolume extends Volume{
|
||||
@Override
|
||||
public void setCornerOne(Block block){
|
||||
// corner one defaults to topmost corner
|
||||
Block topBlock = getWorld().getBlockAt(block.getX(), 127, block.getZ());
|
||||
Block topBlock = this.getWorld().getBlockAt(block.getX(), 127, block.getZ());
|
||||
super.setCornerOne(topBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCornerTwo(Block block){
|
||||
// corner two defaults to bottom most corner
|
||||
Block bottomBlock = getWorld().getBlockAt(block.getX(), 0, block.getZ());
|
||||
Block bottomBlock = this.getWorld().getBlockAt(block.getX(), 0, block.getZ());
|
||||
super.setCornerTwo(bottomBlock);
|
||||
}
|
||||
|
||||
public boolean isWallBlock(Block block){
|
||||
return isEastWallBlock(block) || isNorthWallBlock(block) || isSouthWallBlock(block) || isWestWallBlock(block);
|
||||
return this.isEastWallBlock(block) || this.isNorthWallBlock(block) || this.isSouthWallBlock(block) || this.isWestWallBlock(block);
|
||||
}
|
||||
|
||||
public boolean isEastWallBlock(Block block) {
|
||||
if (getMinZ() == block.getZ()
|
||||
&& block.getX() <= getMaxX()
|
||||
&& block.getX() >= getMinX()) {
|
||||
return true; // east wall
|
||||
}
|
||||
if (this.getMinZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX())
|
||||
return true; // east wall
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSouthWallBlock(Block block) {
|
||||
if (getMaxX() == block.getX()
|
||||
&& block.getZ() <= getMaxZ()
|
||||
&& block.getZ() >= getMinZ()) {
|
||||
return true; // south wall
|
||||
}
|
||||
if (this.getMaxX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ())
|
||||
return true; // south wall
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNorthWallBlock(Block block) {
|
||||
if (getMinX() == block.getX()
|
||||
&& block.getZ() <= getMaxZ()
|
||||
&& block.getZ() >= getMinZ()) {
|
||||
return true; // north wall
|
||||
}
|
||||
if (this.getMinX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ())
|
||||
return true; // north wall
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isWestWallBlock(Block block) {
|
||||
if (getMaxZ() == block.getZ()
|
||||
&& block.getX() <= getMaxX()
|
||||
&& block.getX() >= getMinX()) {
|
||||
return true; // west wall
|
||||
}
|
||||
if (this.getMaxZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX())
|
||||
return true; // west wall
|
||||
return false;
|
||||
}
|
||||
|
||||
public int resetWallBlocks(BlockFace wall) {
|
||||
int noOfResetBlocks = 0;
|
||||
try {
|
||||
if (hasTwoCorners() && getBlockTypes() != null) {
|
||||
if (this.hasTwoCorners() && this.getBlockTypes() != null) {
|
||||
if (wall == BlockFace.EAST) {
|
||||
int z = getMinZ();
|
||||
int z = this.getMinZ();
|
||||
int k = 0;
|
||||
int y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++) {
|
||||
int x = getMinX();
|
||||
for (int i = 0; i < getSizeX(); i++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
int y = this.getMinY();
|
||||
for (int j = 0; j < this.getSizeY(); j++) {
|
||||
int x = this.getMinX();
|
||||
for (int i = 0; i < this.getSizeX(); i++) {
|
||||
int oldBlockType = this.getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = this.getBlockDatas()[i][j][k];
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
if (this.resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
x++;
|
||||
@ -96,16 +92,16 @@ public class VerticalVolume extends Volume{
|
||||
y++;
|
||||
}
|
||||
} else if (wall == BlockFace.WEST) {
|
||||
int z = getMaxZ();
|
||||
int k = getSizeZ()-1;
|
||||
int y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++) {
|
||||
int x = getMinX();
|
||||
for (int i = 0; i < getSizeX(); i++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
int z = this.getMaxZ();
|
||||
int k = this.getSizeZ()-1;
|
||||
int y = this.getMinY();
|
||||
for (int j = 0; j < this.getSizeY(); j++) {
|
||||
int x = this.getMinX();
|
||||
for (int i = 0; i < this.getSizeX(); i++) {
|
||||
int oldBlockType = this.getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = this.getBlockDatas()[i][j][k];
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
if (this.resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
x++;
|
||||
@ -113,16 +109,16 @@ public class VerticalVolume extends Volume{
|
||||
y++;
|
||||
}
|
||||
} else if (wall == BlockFace.NORTH) {
|
||||
int x = getMinX();
|
||||
int x = this.getMinX();
|
||||
int i = 0;
|
||||
int y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++) {
|
||||
int z = getMinZ();
|
||||
for (int k = 0; k < getSizeZ(); k++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
int y = this.getMinY();
|
||||
for (int j = 0; j < this.getSizeY(); j++) {
|
||||
int z = this.getMinZ();
|
||||
for (int k = 0; k < this.getSizeZ(); k++) {
|
||||
int oldBlockType = this.getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = this.getBlockDatas()[i][j][k];
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
if (this.resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
z++;
|
||||
@ -130,16 +126,16 @@ public class VerticalVolume extends Volume{
|
||||
y++;
|
||||
}
|
||||
} else if (wall == BlockFace.SOUTH) {
|
||||
int x = getMaxX();
|
||||
int i = getSizeX()-1;
|
||||
int y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++) {
|
||||
int z = getMinZ();
|
||||
for (int k = 0; k < getSizeZ(); k++) {
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
int x = this.getMaxX();
|
||||
int i = this.getSizeX()-1;
|
||||
int y = this.getMinY();
|
||||
for (int j = 0; j < this.getSizeY(); j++) {
|
||||
int z = this.getMinZ();
|
||||
for (int k = 0; k < this.getSizeZ(); k++) {
|
||||
int oldBlockType = this.getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = this.getBlockDatas()[i][j][k];
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
if (this.resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
z++;
|
||||
@ -149,7 +145,7 @@ public class VerticalVolume extends Volume{
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().logWarn("Failed to reset wall " + wall + " in volume " + getName() + ". " + e.getClass().toString() + " " + e.getMessage());
|
||||
this.getWar().logWarn("Failed to reset wall " + wall + " in volume " + this.getName() + ". " + e.getClass().toString() + " " + e.getMessage());
|
||||
}
|
||||
return noOfResetBlocks;
|
||||
}
|
||||
|
@ -44,11 +44,11 @@ public class Volume {
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
return this.world;
|
||||
}
|
||||
|
||||
public boolean hasTwoCorners() {
|
||||
return cornerOne != null && cornerTwo != null;
|
||||
return this.cornerOne != null && this.cornerTwo != null;
|
||||
}
|
||||
|
||||
public void setCornerOne(Block block) {
|
||||
@ -68,19 +68,19 @@ public class Volume {
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
try {
|
||||
if (hasTwoCorners()) {
|
||||
this.setBlockTypes(new int[getSizeX()][getSizeY()][getSizeZ()]);
|
||||
this.setBlockDatas(new byte[getSizeX()][getSizeY()][getSizeZ()]);
|
||||
if (this.hasTwoCorners()) {
|
||||
this.setBlockTypes(new int[this.getSizeX()][this.getSizeY()][this.getSizeZ()]);
|
||||
this.setBlockDatas(new byte[this.getSizeX()][this.getSizeY()][this.getSizeZ()]);
|
||||
this.getSignLines().clear();
|
||||
this.getInvBlockContents().clear();
|
||||
x = getMinX();
|
||||
for (int i = 0; i < getSizeX(); i++){
|
||||
y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++){
|
||||
z = getMinZ();
|
||||
for (int k = 0;k < getSizeZ(); k++) {
|
||||
x = this.getMinX();
|
||||
for (int i = 0; i < this.getSizeX(); i++){
|
||||
y = this.getMinY();
|
||||
for (int j = 0; j < this.getSizeY(); j++){
|
||||
z = this.getMinZ();
|
||||
for (int k = 0;k < this.getSizeZ(); k++) {
|
||||
try {
|
||||
Block block = getWorld().getBlockAt(x, y, z);
|
||||
Block block = this.getWorld().getBlockAt(x, y, z);
|
||||
this.getBlockTypes()[i][j][k] = block.getTypeId();
|
||||
this.getBlockDatas()[i][j][k] = block.getData();
|
||||
BlockState state = block.getState();
|
||||
@ -121,7 +121,7 @@ public class Volume {
|
||||
|
||||
noOfSavedBlocks++;
|
||||
} catch (Exception e) {
|
||||
this.getWar().getLogger().warning("Failed to save block in volume " + getName() + ". Saved blocks so far:" + noOfSavedBlocks
|
||||
this.getWar().getLogger().warning("Failed to save block in volume " + this.getName() + ". Saved blocks so far:" + noOfSavedBlocks
|
||||
+ ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@ -134,7 +134,7 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().getLogger().warning("Failed to save volume " + getName() + " blocks. Saved blocks:" + noOfSavedBlocks
|
||||
this.getWar().getLogger().warning("Failed to save volume " + this.getName() + " blocks. Saved blocks:" + noOfSavedBlocks
|
||||
+ ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " "+ e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -143,26 +143,26 @@ public class Volume {
|
||||
|
||||
public void resetBlocksAsJob() {
|
||||
BlockResetJob job = new BlockResetJob(this);
|
||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, job);
|
||||
this.war.getServer().getScheduler().scheduleSyncDelayedTask(this.war, job);
|
||||
}
|
||||
|
||||
public int resetBlocks() {
|
||||
int visitedBlocks = 0, noOfResetBlocks = 0, x = 0, y = 0, z = 0;
|
||||
int currentBlockId = 0;
|
||||
int oldBlockType = 0;
|
||||
clearBlocksThatDontFloat();
|
||||
this.clearBlocksThatDontFloat();
|
||||
try {
|
||||
if (hasTwoCorners() && isSaved()) {
|
||||
x = getMinX();
|
||||
for (int i = 0; i < getSizeX(); i++){
|
||||
y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++){
|
||||
z = getMinZ();
|
||||
for (int k = 0;k < getSizeZ(); k++) {
|
||||
if (this.hasTwoCorners() && this.isSaved()) {
|
||||
x = this.getMinX();
|
||||
for (int i = 0; i < this.getSizeX(); i++){
|
||||
y = this.getMinY();
|
||||
for (int j = 0; j < this.getSizeY(); j++){
|
||||
z = this.getMinZ();
|
||||
for (int k = 0;k < this.getSizeZ(); k++) {
|
||||
try {
|
||||
oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
oldBlockType = this.getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = this.getBlockDatas()[i][j][k];
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
currentBlockId = currentBlock.getTypeId();
|
||||
if (currentBlockId != oldBlockType ||
|
||||
(currentBlockId == oldBlockType && currentBlock.getData() != oldBlockData ) ||
|
||||
@ -175,10 +175,10 @@ public class Volume {
|
||||
|| oldBlockType == Material.SIGN_POST.getId()) {
|
||||
// Signs
|
||||
if (oldBlockType == Material.SIGN_POST.getId() && ((oldBlockData & 0x04) == 0x04)
|
||||
&& i+1 != getSizeX()) {
|
||||
&& i+1 != this.getSizeX()) {
|
||||
Block southBlock = currentBlock.getFace(BlockFace.SOUTH);
|
||||
int oldSouthBlockType = getBlockTypes()[i+1][j][k];
|
||||
byte oldSouthBlockData = getBlockDatas()[i+1][j][k];
|
||||
int oldSouthBlockType = this.getBlockTypes()[i+1][j][k];
|
||||
byte oldSouthBlockData = this.getBlockDatas()[i+1][j][k];
|
||||
if (southBlock.getTypeId() != oldSouthBlockType) {
|
||||
southBlock.setTypeId(oldSouthBlockType);
|
||||
southBlock.setData(oldSouthBlockData);
|
||||
@ -191,10 +191,18 @@ public class Volume {
|
||||
Sign sign = (Sign)state;
|
||||
String[] lines = this.getSignLines().get("sign-" + i + "-" + j + "-" + k);
|
||||
if (lines != null && sign.getLines() != null) {
|
||||
if (lines.length>0)sign.setLine(0, lines[0]);
|
||||
if (lines.length>1)sign.setLine(1, lines[1]);
|
||||
if (lines.length>2)sign.setLine(2, lines[2]);
|
||||
if (lines.length>3)sign.setLine(3, lines[3]);
|
||||
if (lines.length>0) {
|
||||
sign.setLine(0, lines[0]);
|
||||
}
|
||||
if (lines.length>1) {
|
||||
sign.setLine(1, lines[1]);
|
||||
}
|
||||
if (lines.length>2) {
|
||||
sign.setLine(2, lines[2]);
|
||||
}
|
||||
if (lines.length>3) {
|
||||
sign.setLine(3, lines[3]);
|
||||
}
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
@ -242,13 +250,13 @@ public class Volume {
|
||||
// Door blocks
|
||||
|
||||
// Check if is bottom door block
|
||||
if (j+1 < getSizeY() && getBlockTypes()[i][j+1][k] == oldBlockType) {
|
||||
if (j+1 < this.getSizeY() && this.getBlockTypes()[i][j+1][k] == oldBlockType) {
|
||||
// set both door blocks right away
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
Block blockAbove = getWorld().getBlockAt(x, y+1, z);
|
||||
Block blockAbove = this.getWorld().getBlockAt(x, y+1, z);
|
||||
blockAbove.setType(Material.getMaterial(oldBlockType));
|
||||
blockAbove.setData(getBlockDatas()[i][j+1][k]);
|
||||
blockAbove.setData(this.getBlockDatas()[i][j+1][k]);
|
||||
}
|
||||
} else if (((oldBlockType == Material.TORCH.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
@ -257,11 +265,11 @@ public class Volume {
|
||||
|| (oldBlockType == Material.STONE_BUTTON.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.LADDER.getId() && ((oldBlockData & 0x04) == 0x04))
|
||||
|| (oldBlockType == Material.RAILS.getId() && ((oldBlockData & 0x02) == 0x02)))
|
||||
&& i+1 != getSizeX()){
|
||||
&& i+1 != this.getSizeX()){
|
||||
// Blocks that hang on a block south of themselves need to make sure that block is there before placing themselves... lol
|
||||
Block southBlock = currentBlock.getFace(BlockFace.SOUTH);
|
||||
int oldSouthBlockType = getBlockTypes()[i+1][j][k];
|
||||
byte oldSouthBlockData = getBlockDatas()[i+1][j][k];
|
||||
int oldSouthBlockType = this.getBlockTypes()[i+1][j][k];
|
||||
byte oldSouthBlockData = this.getBlockDatas()[i+1][j][k];
|
||||
if (southBlock.getTypeId() != oldSouthBlockType) {
|
||||
southBlock.setTypeId(oldSouthBlockType);
|
||||
southBlock.setData(oldSouthBlockData);
|
||||
@ -278,7 +286,7 @@ public class Volume {
|
||||
}
|
||||
visitedBlocks++;
|
||||
} catch (Exception e) {
|
||||
this.getWar().getLogger().warning("Failed to reset block in volume " + getName() + ". Visited blocks so far:" + visitedBlocks
|
||||
this.getWar().getLogger().warning("Failed to reset block in volume " + this.getName() + ". Visited blocks so far:" + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks +
|
||||
". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
@ -292,7 +300,7 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().logWarn("Failed to reset volume " + getName() + " blocks. Blocks visited: " + visitedBlocks
|
||||
this.getWar().logWarn("Failed to reset volume " + this.getName() + " blocks. Blocks visited: " + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks + ". Error at x:" + x + " y:" + y + " z:" + z
|
||||
+ ". Current block: " + currentBlockId + ". Old block: " + oldBlockType + ". Exception: " + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
@ -319,107 +327,107 @@ public class Volume {
|
||||
}
|
||||
|
||||
public BlockInfo getMinXBlock() {
|
||||
if (cornerOne.getX() < cornerTwo.getX()) return cornerOne;
|
||||
return cornerTwo;
|
||||
if (this.cornerOne.getX() < this.cornerTwo.getX()) return this.cornerOne;
|
||||
return this.cornerTwo;
|
||||
}
|
||||
|
||||
public BlockInfo getMinYBlock() {
|
||||
if (cornerOne.getY() < cornerTwo.getY()) return cornerOne;
|
||||
return cornerTwo;
|
||||
if (this.cornerOne.getY() < this.cornerTwo.getY()) return this.cornerOne;
|
||||
return this.cornerTwo;
|
||||
}
|
||||
|
||||
public BlockInfo getMinZBlock() {
|
||||
if (cornerOne.getZ() < cornerTwo.getZ()) return cornerOne;
|
||||
return cornerTwo;
|
||||
if (this.cornerOne.getZ() < this.cornerTwo.getZ()) return this.cornerOne;
|
||||
return this.cornerTwo;
|
||||
}
|
||||
|
||||
public int getMinX() {
|
||||
return getMinXBlock().getX();
|
||||
return this.getMinXBlock().getX();
|
||||
}
|
||||
|
||||
public int getMinY() {
|
||||
return getMinYBlock().getY();
|
||||
return this.getMinYBlock().getY();
|
||||
}
|
||||
|
||||
public int getMinZ() {
|
||||
return getMinZBlock().getZ();
|
||||
return this.getMinZBlock().getZ();
|
||||
}
|
||||
|
||||
public BlockInfo getMaxXBlock() {
|
||||
if (cornerOne.getX() < cornerTwo.getX()) return cornerTwo;
|
||||
return cornerOne;
|
||||
if (this.cornerOne.getX() < this.cornerTwo.getX()) return this.cornerTwo;
|
||||
return this.cornerOne;
|
||||
}
|
||||
|
||||
public BlockInfo getMaxYBlock() {
|
||||
if (cornerOne.getY() < cornerTwo.getY()) return cornerTwo;
|
||||
return cornerOne;
|
||||
if (this.cornerOne.getY() < this.cornerTwo.getY()) return this.cornerTwo;
|
||||
return this.cornerOne;
|
||||
}
|
||||
|
||||
public BlockInfo getMaxZBlock() {
|
||||
if (cornerOne.getZ() < cornerTwo.getZ()) return cornerTwo;
|
||||
return cornerOne;
|
||||
if (this.cornerOne.getZ() < this.cornerTwo.getZ()) return this.cornerTwo;
|
||||
return this.cornerOne;
|
||||
}
|
||||
|
||||
public int getMaxX() {
|
||||
return getMaxXBlock().getX();
|
||||
return this.getMaxXBlock().getX();
|
||||
}
|
||||
|
||||
public int getMaxY() {
|
||||
return getMaxYBlock().getY();
|
||||
return this.getMaxYBlock().getY();
|
||||
}
|
||||
|
||||
public int getMaxZ() {
|
||||
return getMaxZBlock().getZ();
|
||||
return this.getMaxZBlock().getZ();
|
||||
}
|
||||
|
||||
public int getSizeX() {
|
||||
return getMaxX() - getMinX() + 1;
|
||||
return this.getMaxX() - this.getMinX() + 1;
|
||||
}
|
||||
|
||||
public int getSizeY() {
|
||||
return getMaxY() - getMinY() + 1;
|
||||
return this.getMaxY() - this.getMinY() + 1;
|
||||
}
|
||||
|
||||
public int getSizeZ() {
|
||||
return getMaxZ() - getMinZ() + 1;
|
||||
return this.getMaxZ() - this.getMinZ() + 1;
|
||||
}
|
||||
|
||||
public boolean isSaved() {
|
||||
return getBlockTypes() != null;
|
||||
return this.getBlockTypes() != null;
|
||||
}
|
||||
|
||||
public int[][][] getBlockTypes() {
|
||||
return blockTypes;
|
||||
return this.blockTypes;
|
||||
}
|
||||
|
||||
public BlockInfo getCornerOne() {
|
||||
return cornerOne;
|
||||
return this.cornerOne;
|
||||
}
|
||||
|
||||
public BlockInfo getCornerTwo() {
|
||||
return cornerTwo;
|
||||
return this.cornerTwo;
|
||||
}
|
||||
|
||||
public boolean contains(Location location) {
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
return hasTwoCorners() &&
|
||||
location.getWorld().getName().equals(world.getName()) &&
|
||||
x <= getMaxX() && x >= getMinX() &&
|
||||
y <= getMaxY() && y >= getMinY() &&
|
||||
z <= getMaxZ() && z >= getMinZ();
|
||||
return this.hasTwoCorners() &&
|
||||
location.getWorld().getName().equals(this.world.getName()) &&
|
||||
x <= this.getMaxX() && x >= this.getMinX() &&
|
||||
y <= this.getMaxY() && y >= this.getMinY() &&
|
||||
z <= this.getMaxZ() && z >= this.getMinZ();
|
||||
}
|
||||
|
||||
public boolean contains(Block block) {
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
return hasTwoCorners() &&
|
||||
block.getWorld().getName().equals(world.getName()) &&
|
||||
x <= getMaxX() && x >= getMinX() &&
|
||||
y <= getMaxY() && y >= getMinY() &&
|
||||
z <= getMaxZ() && z >= getMinZ();
|
||||
return this.hasTwoCorners() &&
|
||||
block.getWorld().getName().equals(this.world.getName()) &&
|
||||
x <= this.getMaxX() && x >= this.getMinX() &&
|
||||
y <= this.getMaxY() && y >= this.getMinY() &&
|
||||
z <= this.getMaxZ() && z >= this.getMinZ();
|
||||
}
|
||||
|
||||
public void setBlockTypes(int[][][] blockTypes) {
|
||||
@ -427,23 +435,23 @@ public class Volume {
|
||||
}
|
||||
|
||||
public War getWar() {
|
||||
return war;
|
||||
return this.war;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setToMaterial(Material material) {
|
||||
try {
|
||||
if (hasTwoCorners() && isSaved()) {
|
||||
int x = getMinX();
|
||||
for (int i = 0; i < getSizeX(); i++){
|
||||
int y = getMaxY();
|
||||
for (int j = getSizeY(); j > 0; j--){
|
||||
int z = getMinZ();
|
||||
for (int k = 0;k < getSizeZ(); k++) {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (this.hasTwoCorners() && this.isSaved()) {
|
||||
int x = this.getMinX();
|
||||
for (int i = 0; i < this.getSizeX(); i++){
|
||||
int y = this.getMaxY();
|
||||
for (int j = this.getSizeY(); j > 0; j--){
|
||||
int z = this.getMinZ();
|
||||
for (int k = 0;k < this.getSizeZ(); k++) {
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
currentBlock.setType(material);
|
||||
z++;
|
||||
}
|
||||
@ -453,26 +461,26 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().logWarn("Failed to set block to " + material + "in volume " + name + "." + e.getClass().toString() + " " + e.getMessage());
|
||||
this.getWar().logWarn("Failed to set block to " + material + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setFaceMaterial(BlockFace face, Material material) {
|
||||
try {
|
||||
if (hasTwoCorners() && isSaved()) {
|
||||
int x = getMinX();
|
||||
for (int i = 0; i < getSizeX(); i++){
|
||||
int y = getMinY();
|
||||
for (int j = 0; j < getSizeY(); j++){
|
||||
int z = getMinZ();
|
||||
for (int k = 0;k < getSizeZ(); k++) {
|
||||
if ((face == BlockFace.DOWN && y == getMinY())
|
||||
|| (face == BlockFace.UP && y == getMaxY())
|
||||
|| (face == BlockFace.NORTH && x == getMinX())
|
||||
|| (face == BlockFace.EAST && z == getMinZ())
|
||||
|| (face == BlockFace.SOUTH && x == getMaxX())
|
||||
|| (face == BlockFace.WEST && z == getMaxZ())) {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (this.hasTwoCorners() && this.isSaved()) {
|
||||
int x = this.getMinX();
|
||||
for (int i = 0; i < this.getSizeX(); i++){
|
||||
int y = this.getMinY();
|
||||
for (int j = 0; j < this.getSizeY(); j++){
|
||||
int z = this.getMinZ();
|
||||
for (int k = 0;k < this.getSizeZ(); k++) {
|
||||
if ((face == BlockFace.DOWN && y == this.getMinY())
|
||||
|| (face == BlockFace.UP && y == this.getMaxY())
|
||||
|| (face == BlockFace.NORTH && x == this.getMinX())
|
||||
|| (face == BlockFace.EAST && z == this.getMinZ())
|
||||
|| (face == BlockFace.SOUTH && x == this.getMaxX())
|
||||
|| (face == BlockFace.WEST && z == this.getMaxZ())) {
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
currentBlock.setType(material);
|
||||
}
|
||||
z++;
|
||||
@ -483,7 +491,7 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().logWarn("Failed to set block to " + material + "in volume " + name + "." + e.getClass().toString() + " " + e.getMessage());
|
||||
this.getWar().logWarn("Failed to set block to " + material + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,14 +500,14 @@ public class Volume {
|
||||
int i = 0, j = 0, k = 0;
|
||||
int x, y, z;
|
||||
Block currentBlock = null;
|
||||
if (hasTwoCorners() && isSaved()) {
|
||||
x = getMinX();
|
||||
for (i = 0; i < getSizeX(); i++){
|
||||
y = getMaxY();
|
||||
for (j = getSizeY(); j > 0; j--){
|
||||
z = getMinZ();
|
||||
for (k = 0;k < getSizeZ(); k++) {
|
||||
currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (this.hasTwoCorners() && this.isSaved()) {
|
||||
x = this.getMinX();
|
||||
for (i = 0; i < this.getSizeX(); i++){
|
||||
y = this.getMaxY();
|
||||
for (j = this.getSizeY(); j > 0; j--){
|
||||
z = this.getMinZ();
|
||||
for (k = 0;k < this.getSizeZ(); k++) {
|
||||
currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
for (Material oldType : oldTypes) {
|
||||
if (currentBlock.getType().getId() == oldType.getId()) {
|
||||
currentBlock.setType(newType);
|
||||
@ -518,7 +526,7 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().logWarn("Failed to switch block to " + newType + "in volume " + name + "." + e.getClass().toString() + " " + e.getMessage());
|
||||
this.getWar().logWarn("Failed to switch block to " + newType + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,7 +554,7 @@ public class Volume {
|
||||
toAirMaterials[19] = Material.CACTUS;
|
||||
toAirMaterials[20] = Material.SNOW;
|
||||
toAirMaterials[21] = Material.ICE;
|
||||
switchMaterials(toAirMaterials, Material.AIR);
|
||||
this.switchMaterials(toAirMaterials, Material.AIR);
|
||||
}
|
||||
|
||||
public void setSignLines(HashMap<String, String[]> signLines) {
|
||||
@ -554,7 +562,7 @@ public class Volume {
|
||||
}
|
||||
|
||||
public HashMap<String, String[]> getSignLines() {
|
||||
return signLines;
|
||||
return this.signLines;
|
||||
}
|
||||
|
||||
public void setInvBlockContents(HashMap<String, List<ItemStack>> invBlockContents) {
|
||||
@ -562,9 +570,10 @@ public class Volume {
|
||||
}
|
||||
|
||||
public HashMap<String, List<ItemStack>> getInvBlockContents() {
|
||||
return invBlockContents;
|
||||
return this.invBlockContents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalize() {
|
||||
this.blockDatas = null;
|
||||
this.blockTypes = null;
|
||||
|
@ -28,28 +28,28 @@ public class ZoneVolume extends Volume {
|
||||
@Override
|
||||
public int saveBlocks() {
|
||||
// Save blocks directly to disk (i.e. don't put everything in memory)
|
||||
int saved = ZoneVolumeMapper.save(this, zone.getName(), this.getWar());
|
||||
getWar().logInfo("Saved " + saved + " blocks in warzone " + zone.getName() + ".");
|
||||
isSaved = true;
|
||||
int saved = ZoneVolumeMapper.save(this, this.zone.getName(), this.getWar());
|
||||
this.getWar().logInfo("Saved " + saved + " blocks in warzone " + this.zone.getName() + ".");
|
||||
this.isSaved = true;
|
||||
return saved;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaved() {
|
||||
return isSaved;
|
||||
return this.isSaved;
|
||||
}
|
||||
|
||||
public void loadCorners() {
|
||||
ZoneVolumeMapper.load(this, zone.getName(), this.getWar(), this.getWorld(), true);
|
||||
isSaved = true;
|
||||
ZoneVolumeMapper.load(this, this.zone.getName(), this.getWar(), this.getWorld(), true);
|
||||
this.isSaved = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resetBlocks() {
|
||||
// Load blocks directly from disk and onto the map (i.e. no more in-memory warzone blocks)
|
||||
int reset = ZoneVolumeMapper.load(this, zone.getName(), this.getWar(), this.getWorld(), false);
|
||||
getWar().logInfo("Reset " + reset + " blocks in warzone " + zone.getName() + ".");
|
||||
isSaved = true;
|
||||
int reset = ZoneVolumeMapper.load(this, this.zone.getName(), this.getWar(), this.getWorld(), false);
|
||||
this.getWar().logInfo("Reset " + reset + " blocks in warzone " + this.zone.getName() + ".");
|
||||
this.isSaved = true;
|
||||
return reset;
|
||||
}
|
||||
|
||||
@ -66,40 +66,38 @@ public class ZoneVolume extends Volume {
|
||||
public void setNorthwest(Block block) throws NotNorthwestException, TooSmallException, TooBigException {
|
||||
// northwest defaults to top block
|
||||
BlockInfo topBlock = new BlockInfo(block.getX(), 127, block.getZ(), block.getTypeId(), block.getData());
|
||||
BlockInfo oldCornerOne = getCornerOne();
|
||||
BlockInfo oldCornerTwo = getCornerTwo();
|
||||
if (getCornerOne() == null)
|
||||
BlockInfo oldCornerOne = this.getCornerOne();
|
||||
BlockInfo oldCornerTwo = this.getCornerTwo();
|
||||
if (this.getCornerOne() == null)
|
||||
{
|
||||
if (getCornerTwo() == null) {
|
||||
if (this.getCornerTwo() == null) {
|
||||
// northwest defaults to corner 1
|
||||
super.setCornerOne(topBlock);
|
||||
} else if (getCornerTwo().getX() <= block.getX() || getCornerTwo().getZ() >= block.getZ()) {
|
||||
throw new NotNorthwestException();
|
||||
} else {
|
||||
} else if (this.getCornerTwo().getX() <= block.getX() || this.getCornerTwo().getZ() >= block.getZ())
|
||||
throw new NotNorthwestException();
|
||||
else {
|
||||
// corner 2 already set, but we're sure we're located at the northwest of it
|
||||
super.setCornerOne(topBlock);
|
||||
}
|
||||
} else if (getCornerTwo() == null){
|
||||
} else if (this.getCornerTwo() == null){
|
||||
// corner 1 already exists, set northwest as corner 2 (only if it's at the northwest of corner 1)
|
||||
if (getCornerOne().getX() <= block.getX() || getCornerOne().getZ() >= block.getZ()) {
|
||||
throw new NotNorthwestException();
|
||||
}
|
||||
if (this.getCornerOne().getX() <= block.getX() || this.getCornerOne().getZ() >= block.getZ())
|
||||
throw new NotNorthwestException();
|
||||
super.setCornerTwo(topBlock);
|
||||
} else {
|
||||
// both corners already set: we are resizing (only if the new block is northwest relative to the southeasternmost block)
|
||||
if (getSoutheastX() <= block.getX() || getSoutheastZ() >= block.getZ()) {
|
||||
throw new NotNorthwestException();
|
||||
}
|
||||
BlockInfo minXBlock = getMinXBlock(); // north means min X
|
||||
if (this.getSoutheastX() <= block.getX() || this.getSoutheastZ() >= block.getZ())
|
||||
throw new NotNorthwestException();
|
||||
BlockInfo minXBlock = this.getMinXBlock(); // north means min X
|
||||
minXBlock.setX(block.getX()); // mutating, argh!
|
||||
BlockInfo maxZBlock = getMaxZBlock(); // west means max Z
|
||||
BlockInfo maxZBlock = this.getMaxZBlock(); // west means max Z
|
||||
maxZBlock.setZ(block.getZ());
|
||||
}
|
||||
if (tooSmall() || zoneStructuresAreOutside()) {
|
||||
if (this.tooSmall() || this.zoneStructuresAreOutside()) {
|
||||
super.setCornerOne(oldCornerOne);
|
||||
super.setCornerTwo(oldCornerTwo);
|
||||
throw new TooSmallException();
|
||||
} else if (tooBig()) {
|
||||
} else if (this.tooBig()) {
|
||||
super.setCornerOne(oldCornerOne);
|
||||
super.setCornerTwo(oldCornerTwo);
|
||||
throw new TooBigException();
|
||||
@ -107,56 +105,54 @@ public class ZoneVolume extends Volume {
|
||||
}
|
||||
|
||||
public int getNorthwestX() {
|
||||
if (!hasTwoCorners())
|
||||
if (!this.hasTwoCorners())
|
||||
return 0;
|
||||
else
|
||||
return getMinX();
|
||||
return this.getMinX();
|
||||
}
|
||||
|
||||
public int getNorthwestZ() {
|
||||
if (!hasTwoCorners())
|
||||
if (!this.hasTwoCorners())
|
||||
return 0;
|
||||
else
|
||||
return getMaxZ();
|
||||
return this.getMaxZ();
|
||||
}
|
||||
|
||||
public void setSoutheast(Block block) throws NotSoutheastException, TooSmallException, TooBigException {
|
||||
// southeast defaults to bottom block
|
||||
BlockInfo bottomBlock = new BlockInfo(block.getX(), 0, block.getZ(), block.getTypeId(), block.getData());
|
||||
BlockInfo oldCornerOne = getCornerOne();
|
||||
BlockInfo oldCornerTwo = getCornerTwo();
|
||||
if (getCornerTwo() == null)
|
||||
BlockInfo oldCornerOne = this.getCornerOne();
|
||||
BlockInfo oldCornerTwo = this.getCornerTwo();
|
||||
if (this.getCornerTwo() == null)
|
||||
{
|
||||
if (getCornerOne() == null) {
|
||||
if (this.getCornerOne() == null) {
|
||||
// southeast defaults to corner 2
|
||||
super.setCornerTwo(bottomBlock);
|
||||
} else if (getCornerOne().getX() >= block.getX() || getCornerOne().getZ() <= block.getZ()) {
|
||||
throw new NotSoutheastException();
|
||||
} else {
|
||||
} else if (this.getCornerOne().getX() >= block.getX() || this.getCornerOne().getZ() <= block.getZ())
|
||||
throw new NotSoutheastException();
|
||||
else {
|
||||
// corner 1 already set, but we're sure we're located at the southeast of it
|
||||
super.setCornerTwo(bottomBlock);
|
||||
}
|
||||
} else if (getCornerOne() == null){
|
||||
} else if (this.getCornerOne() == null){
|
||||
// corner 2 already exists, set northwest as corner 1 (only if it's at the southeast of corner 2)
|
||||
if (getCornerTwo().getX() >= block.getX() || getCornerTwo().getZ() <= block.getZ()) {
|
||||
throw new NotSoutheastException();
|
||||
}
|
||||
if (this.getCornerTwo().getX() >= block.getX() || this.getCornerTwo().getZ() <= block.getZ())
|
||||
throw new NotSoutheastException();
|
||||
super.setCornerOne(bottomBlock);
|
||||
} else {
|
||||
// both corners already set: we are resizing (only if the new block is southeast relative to the northwesternmost block)
|
||||
if (getNorthwestX() >= block.getX() || getNorthwestZ() <= block.getZ()) {
|
||||
throw new NotSoutheastException();
|
||||
}
|
||||
BlockInfo maxXBlock = getMaxXBlock(); // south means max X
|
||||
if (this.getNorthwestX() >= block.getX() || this.getNorthwestZ() <= block.getZ())
|
||||
throw new NotSoutheastException();
|
||||
BlockInfo maxXBlock = this.getMaxXBlock(); // south means max X
|
||||
maxXBlock.setX(block.getX()); // mutating, argh!
|
||||
BlockInfo minZBlock = getMinZBlock(); // east means min Z
|
||||
BlockInfo minZBlock = this.getMinZBlock(); // east means min Z
|
||||
minZBlock.setZ(block.getZ());
|
||||
}
|
||||
if (tooSmall() || zoneStructuresAreOutside()) {
|
||||
if (this.tooSmall() || this.zoneStructuresAreOutside()) {
|
||||
super.setCornerOne(oldCornerOne);
|
||||
super.setCornerTwo(oldCornerTwo);
|
||||
throw new TooSmallException();
|
||||
} else if (tooBig()) {
|
||||
} else if (this.tooBig()) {
|
||||
super.setCornerOne(oldCornerOne);
|
||||
super.setCornerTwo(oldCornerTwo);
|
||||
throw new TooBigException();
|
||||
@ -165,169 +161,160 @@ public class ZoneVolume extends Volume {
|
||||
}
|
||||
|
||||
public int getSoutheastX() {
|
||||
if (!hasTwoCorners())
|
||||
if (!this.hasTwoCorners())
|
||||
return 0;
|
||||
else
|
||||
return getMaxX();
|
||||
return this.getMaxX();
|
||||
}
|
||||
|
||||
public int getSoutheastZ() {
|
||||
if (!hasTwoCorners())
|
||||
if (!this.hasTwoCorners())
|
||||
return 0;
|
||||
else
|
||||
return getMinZ();
|
||||
return this.getMinZ();
|
||||
}
|
||||
|
||||
public int getCenterY() {
|
||||
if (!hasTwoCorners())
|
||||
if (!this.hasTwoCorners())
|
||||
return 0;
|
||||
else
|
||||
return getMinY() + (getMaxY() - getMinY())/2;
|
||||
return this.getMinY() + (this.getMaxY() - this.getMinY())/2;
|
||||
}
|
||||
|
||||
public void setZoneCornerOne(Block block) throws TooSmallException, TooBigException {
|
||||
BlockInfo oldCornerOne = getCornerOne();
|
||||
BlockInfo oldCornerOne = this.getCornerOne();
|
||||
super.setCornerOne(block);
|
||||
if (tooSmall() || zoneStructuresAreOutside()) {
|
||||
if (this.tooSmall() || this.zoneStructuresAreOutside()) {
|
||||
super.setCornerOne(oldCornerOne);
|
||||
throw new TooSmallException();
|
||||
} else if (tooBig()) {
|
||||
} else if (this.tooBig()) {
|
||||
super.setCornerOne(oldCornerOne);
|
||||
throw new TooBigException();
|
||||
}
|
||||
}
|
||||
|
||||
public void setZoneCornerTwo(Block block) throws TooSmallException, TooBigException {
|
||||
BlockInfo oldCornerTwo = getCornerTwo();
|
||||
BlockInfo oldCornerTwo = this.getCornerTwo();
|
||||
super.setCornerTwo(block);
|
||||
if (tooSmall() || zoneStructuresAreOutside()) {
|
||||
if (this.tooSmall() || this.zoneStructuresAreOutside()) {
|
||||
super.setCornerTwo(oldCornerTwo);
|
||||
throw new TooSmallException();
|
||||
} else if (tooBig()) {
|
||||
} else if (this.tooBig()) {
|
||||
super.setCornerTwo(oldCornerTwo);
|
||||
throw new TooBigException();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean tooSmall() {
|
||||
if (hasTwoCorners() && ((getMaxX() - getMinX() < 10)
|
||||
|| (getMaxY() - getMinY() < 10)
|
||||
|| (getMaxZ() - getMinZ() < 10))) return true;
|
||||
if (this.hasTwoCorners() && ((this.getMaxX() - this.getMinX() < 10)
|
||||
|| (this.getMaxY() - this.getMinY() < 10)
|
||||
|| (this.getMaxZ() - this.getMinZ() < 10))) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean tooBig() {
|
||||
if (hasTwoCorners() && ((getMaxX() - getMinX() > 750)
|
||||
|| (getMaxY() - getMinY() > 750)
|
||||
|| (getMaxZ() - getMinZ() > 750))) return true;
|
||||
if (this.hasTwoCorners() && ((this.getMaxX() - this.getMinX() > 750)
|
||||
|| (this.getMaxY() - this.getMinY() > 750)
|
||||
|| (this.getMaxZ() - this.getMinZ() > 750))) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean zoneStructuresAreOutside() {
|
||||
// check team spawns & flags
|
||||
for (Team team : zone.getTeams()) {
|
||||
for (Team team : this.zone.getTeams()) {
|
||||
if (team.getTeamSpawn() != null) {
|
||||
if (!isInside(team.getSpawnVolume().getCornerOne())
|
||||
|| !isInside(team.getSpawnVolume().getCornerTwo())) {
|
||||
return true;
|
||||
}
|
||||
if (!this.isInside(team.getSpawnVolume().getCornerOne())
|
||||
|| !this.isInside(team.getSpawnVolume().getCornerTwo()))
|
||||
return true;
|
||||
}
|
||||
if (team.getTeamFlag() != null) {
|
||||
if (!isInside(team.getFlagVolume().getCornerOne())
|
||||
|| !isInside(team.getFlagVolume().getCornerTwo())) {
|
||||
return true;
|
||||
}
|
||||
if (!this.isInside(team.getFlagVolume().getCornerOne())
|
||||
|| !this.isInside(team.getFlagVolume().getCornerTwo()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// check monuments
|
||||
for (Monument monument : zone.getMonuments()) {
|
||||
for (Monument monument : this.zone.getMonuments()) {
|
||||
if (monument.getVolume() != null) {
|
||||
if (!isInside(monument.getVolume().getCornerOne())
|
||||
|| !isInside(monument.getVolume().getCornerTwo())) {
|
||||
return true;
|
||||
}
|
||||
if (!this.isInside(monument.getVolume().getCornerOne())
|
||||
|| !this.isInside(monument.getVolume().getCornerTwo()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isInside(BlockInfo info) {
|
||||
if (info.getX() <= getMaxX() && info.getX() >= getMinX() &&
|
||||
info.getY() <= getMaxY() && info.getY() >= getMinY() &&
|
||||
info.getZ() <= getMaxZ() && info.getZ() >= getMinZ())
|
||||
if (info.getX() <= this.getMaxX() && info.getX() >= this.getMinX() &&
|
||||
info.getY() <= this.getMaxY() && info.getY() >= this.getMinY() &&
|
||||
info.getZ() <= this.getMaxZ() && info.getZ() >= this.getMinZ())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isWallBlock(Block block){
|
||||
return isEastWallBlock(block) || isNorthWallBlock(block)
|
||||
|| isSouthWallBlock(block) || isWestWallBlock(block)
|
||||
|| isUpWallBlock(block) || isDownWallBlock(block);
|
||||
return this.isEastWallBlock(block) || this.isNorthWallBlock(block)
|
||||
|| this.isSouthWallBlock(block) || this.isWestWallBlock(block)
|
||||
|| this.isUpWallBlock(block) || this.isDownWallBlock(block);
|
||||
}
|
||||
|
||||
public boolean isEastWallBlock(Block block) {
|
||||
if (getMinZ() == block.getZ()
|
||||
&& block.getX() <= getMaxX()
|
||||
&& block.getX() >= getMinX()
|
||||
&& block.getY() >= getMinY()
|
||||
&& block.getY() <= getMaxY()) {
|
||||
return true; // east wall
|
||||
}
|
||||
if (this.getMinZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
return true; // east wall
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSouthWallBlock(Block block) {
|
||||
if (getMaxX() == block.getX()
|
||||
&& block.getZ() <= getMaxZ()
|
||||
&& block.getZ() >= getMinZ()
|
||||
&& block.getY() >= getMinY()
|
||||
&& block.getY() <= getMaxY()) {
|
||||
return true; // south wall
|
||||
}
|
||||
if (this.getMaxX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
return true; // south wall
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNorthWallBlock(Block block) {
|
||||
if (getMinX() == block.getX()
|
||||
&& block.getZ() <= getMaxZ()
|
||||
&& block.getZ() >= getMinZ()
|
||||
&& block.getY() >= getMinY()
|
||||
&& block.getY() <= getMaxY()) {
|
||||
return true; // north wall
|
||||
}
|
||||
if (this.getMinX() == block.getX()
|
||||
&& block.getZ() <= this.getMaxZ()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
return true; // north wall
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isWestWallBlock(Block block) {
|
||||
if (getMaxZ() == block.getZ()
|
||||
&& block.getX() <= getMaxX()
|
||||
&& block.getX() >= getMinX()
|
||||
&& block.getY() >= getMinY()
|
||||
&& block.getY() <= getMaxY()) {
|
||||
return true; // west wall
|
||||
}
|
||||
if (this.getMaxZ() == block.getZ()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getY() >= this.getMinY()
|
||||
&& block.getY() <= this.getMaxY())
|
||||
return true; // west wall
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isUpWallBlock(Block block) {
|
||||
if (getMaxY() == block.getY()
|
||||
&& block.getX() <= getMaxX()
|
||||
&& block.getX() >= getMinX()
|
||||
&& block.getZ() >= getMinZ()
|
||||
&& block.getZ() <= getMaxZ()) {
|
||||
return true; // top wall
|
||||
}
|
||||
if (this.getMaxY() == block.getY()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getZ() <= this.getMaxZ())
|
||||
return true; // top wall
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDownWallBlock(Block block) {
|
||||
if (getMinY() == block.getY()
|
||||
&& block.getX() <= getMaxX()
|
||||
&& block.getX() >= getMinX()
|
||||
&& block.getZ() >= getMinZ()
|
||||
&& block.getZ() <= getMaxZ()) {
|
||||
return true; // bottom wall
|
||||
}
|
||||
if (this.getMinY() == block.getY()
|
||||
&& block.getX() <= this.getMaxX()
|
||||
&& block.getX() >= this.getMinX()
|
||||
&& block.getZ() >= this.getMinZ()
|
||||
&& block.getZ() <= this.getMaxZ())
|
||||
return true; // bottom wall
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user