mirror of
https://github.com/taoneill/war.git
synced 2024-11-13 05:54:31 +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
@ -17,7 +17,7 @@ import com.tommytony.war.Team;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -28,15 +28,16 @@ public class WarBlockListener extends BlockListener {
|
||||
public WarBlockListener(War war) {
|
||||
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());
|
||||
if (team != null && block != null && zone != null
|
||||
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()
|
||||
&& block.getData() == team.getKind().getData()) {
|
||||
@ -50,98 +51,99 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// unbreakableZoneBlocks
|
||||
if (zone != null && zone.isUnbreakableZoneBlocks()
|
||||
if (zone != null && zone.isUnbreakableZoneBlocks()
|
||||
&& (!isZoneMaker
|
||||
|| (isZoneMaker && team != null))
|
||||
|| (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public void onBlockDamage(BlockDamageEvent event) {
|
||||
// Player player = event.getPlayer();
|
||||
// Block block = event.getBlock();
|
||||
// if (player != null && block != null && event.getDamageLevel() == BlockDamageLevel.BROKEN) {
|
||||
// handleBreakOrDamage(player,block, event);
|
||||
//
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
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
|
||||
} else if (team != null && block != null && warzone != null
|
||||
&& warzone.isMonumentCenterBlock(block)){
|
||||
Monument monument = warzone.getMonumentFromCenterBlock(block);
|
||||
if (monument.hasOwner()) {
|
||||
@ -155,11 +157,11 @@ public class WarBlockListener extends BlockListener {
|
||||
event.setCancelled(false);
|
||||
return;
|
||||
}else if (warzone != null && warzone.isImportantBlock(block) && (!isZoneMaker || (isZoneMaker && team != null))) {
|
||||
|
||||
|
||||
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) {
|
||||
@ -180,63 +182,63 @@ public class WarBlockListener extends BlockListener {
|
||||
player.getInventory().addItem(teamKindBlock);
|
||||
warzone.addFlagThief(lostFlagTeam, player.getName());
|
||||
block.setType(Material.AIR);
|
||||
|
||||
|
||||
for (Team t : warzone.getTeams()) {
|
||||
t.teamcast(player.getName() + " stole team " + lostFlagTeam.getName() + "'s flag.");
|
||||
if (t.getName().equals(lostFlagTeam.getName())){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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()));
|
||||
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.");
|
||||
Warzone blockZone = this.war.warzone(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
|
||||
if (blockZone == 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;
|
||||
}
|
||||
|
||||
|
||||
// unbreakableZoneBlocks
|
||||
if (blockZone != null && blockZone.isUnbreakableZoneBlocks()
|
||||
if (blockZone != null && blockZone.isUnbreakableZoneBlocks()
|
||||
&& (!isZoneMaker
|
||||
|| (isZoneMaker && team != null))
|
||||
|| (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;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import com.tommytony.war.Team;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -33,105 +33,106 @@ public class WarEntityListener extends EntityListener {
|
||||
public WarEntityListener(War war) {
|
||||
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,
|
||||
// new LootDropperTask(player.getLocation(), event.getDrops()),
|
||||
// war.getServer().getScheduler().scheduleAsyncDelayedTask(war,
|
||||
// new LootDropperTask(player.getLocation(), event.getDrops()),
|
||||
// 750);
|
||||
// }
|
||||
// }
|
||||
event.getDrops().clear(); // no loot
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void handlerAttackDefend(EntityDamageByEntityEvent event) {
|
||||
Entity attacker = event.getDamager();
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
|
||||
if (attacker != null && defender != null && attacker instanceof Player && defender instanceof Player) {
|
||||
// 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());
|
||||
if (attackerTeam != null && defenderTeam != null
|
||||
&& attackerTeam != defenderTeam
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
} else if (attackerTeam != null && defenderTeam != null
|
||||
&& attackerTeam == defenderTeam
|
||||
} else if (attackerTeam != null && defenderTeam != null
|
||||
&& attackerTeam == defenderTeam
|
||||
&& attackerWarzone == defenderWarzone
|
||||
&& 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
|
||||
}
|
||||
|
||||
|
||||
} else if (defender instanceof Player && event instanceof EntityDamageByProjectileEvent) {
|
||||
// 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,46 +140,48 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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 ||
|
||||
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!)
|
||||
@ -201,30 +205,32 @@ public class WarEntityListener extends EntityListener {
|
||||
net.minecraft.server.Entity playerEntity = ((CraftPlayer)player).getHandle();
|
||||
playerEntity.fireTicks = 0;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@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 {
|
||||
|
@ -10,156 +10,154 @@ import bukkit.tommytony.war.War;
|
||||
import com.tommytony.war.volumes.Volume;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
public class Monument {
|
||||
private Location location;
|
||||
private Volume volume;
|
||||
|
||||
|
||||
private Team ownerTeam = null;
|
||||
private final String name;
|
||||
private Warzone warzone;
|
||||
|
||||
|
||||
public Monument(String name, War war, Warzone warzone, Location location) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
public void addMonumentBlocks() {
|
||||
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);
|
||||
|
||||
warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
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-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);
|
||||
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
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);
|
||||
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
this.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+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-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);
|
||||
|
||||
warzone.getWorld().getBlockAt(x, y+1, z-1).setType(Material.OBSIDIAN);
|
||||
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, 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);
|
||||
|
||||
this.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+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) {
|
||||
this.ownerTeam = team;
|
||||
|
||||
|
||||
}
|
||||
|
||||
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();
|
||||
public void setLocation(Location location) {
|
||||
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) {
|
||||
this.volume = newVolume;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Team getOwnerTeam() {
|
||||
|
||||
return ownerTeam;
|
||||
}
|
||||
|
||||
return this.ownerTeam;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import com.tommytony.war.utils.SignHelper;
|
||||
import com.tommytony.war.volumes.Volume;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -31,7 +31,7 @@ public class Team {
|
||||
private final Warzone warzone;
|
||||
private TeamKind kind;
|
||||
private War war;
|
||||
|
||||
|
||||
public Team(String name, TeamKind kind, Location teamSpawn, War war, Warzone warzone) {
|
||||
this.warzone = warzone;
|
||||
this.setName(name);
|
||||
@ -41,69 +41,71 @@ public class Team {
|
||||
this.kind = kind;
|
||||
this.setFlagVolume(null); // no flag at the start
|
||||
}
|
||||
|
||||
public TeamKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
private void setSpawnVolume() {
|
||||
if (spawnVolume.isSaved()) spawnVolume.resetBlocks();
|
||||
int x = teamSpawn.getBlockX();
|
||||
int y = teamSpawn.getBlockY();
|
||||
int z = 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));
|
||||
public TeamKind getKind() {
|
||||
return this.kind;
|
||||
}
|
||||
|
||||
private void setSpawnVolume() {
|
||||
if (this.spawnVolume.isSaved()) {
|
||||
this.spawnVolume.resetBlocks();
|
||||
}
|
||||
int x = this.teamSpawn.getBlockX();
|
||||
int y = this.teamSpawn.getBlockY();
|
||||
int z = this.teamSpawn.getBlockZ();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void initializeTeamSpawn() {
|
||||
// make air
|
||||
this.spawnVolume.setToMaterial(Material.AIR);
|
||||
|
||||
// Set the spawn
|
||||
int x = teamSpawn.getBlockX();
|
||||
int y = teamSpawn.getBlockY();
|
||||
int z = teamSpawn.getBlockZ();
|
||||
|
||||
if (warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
|
||||
|
||||
// Set the spawn
|
||||
int x = this.teamSpawn.getBlockX();
|
||||
int y = this.teamSpawn.getBlockY();
|
||||
int z = this.teamSpawn.getBlockZ();
|
||||
|
||||
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,234 +115,234 @@ 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);
|
||||
|
||||
setBlock(x-1, y-1, z+2, kind);
|
||||
setBlock(x-1, y-1, z-2, kind);
|
||||
|
||||
setBlock(x, y-1, z+2, kind);
|
||||
setBlock(x, y-1, z-2, kind);
|
||||
|
||||
setBlock(x+1, 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);
|
||||
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);
|
||||
|
||||
this.setBlock(x-1, 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);
|
||||
this.setBlock(x, y-1, z-2, this.kind);
|
||||
|
||||
this.setBlock(x+1, 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);
|
||||
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;
|
||||
if (yaw >= 0 && yaw < 90) {
|
||||
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);
|
||||
|
||||
if (warzone.getSpawnStyle().equals(TeamSpawnStyles.BIG)) {
|
||||
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.NORTH, 2).getFace(BlockFace.WEST, 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);
|
||||
|
||||
setBlock(x+1, y+2, z-2, kind);
|
||||
setBlock(x+2, y+2, z-2, kind);
|
||||
setBlock(x+2, y+2, z-1, kind);
|
||||
|
||||
setBlock(x+2, y+3, z-2, 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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
setBlock(x+2, y+2, z+1, kind);
|
||||
setBlock(x+2, y+2, z+2, kind);
|
||||
setBlock(x+1, y+2, z+2, kind);
|
||||
|
||||
setBlock(x+2, y+3, 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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
setBlock(x-1, y+2, z+2, kind);
|
||||
setBlock(x-2, y+2, z+2, kind);
|
||||
setBlock(x-2, y+2, z+1, kind);
|
||||
|
||||
setBlock(x-2, y+3, z+2, 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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
setBlock(x-2, y+2, z-1, kind);
|
||||
setBlock(x-2, y+2, z-2, kind);
|
||||
setBlock(x-1, y+2, z-2, kind);
|
||||
|
||||
setBlock(x-2, y+3, 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);
|
||||
|
||||
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);
|
||||
|
||||
this.setBlock(x-2, y+3, z-2, this.kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (signBlock != null) {
|
||||
// if (signBlock.getType() != Material.SIGN_POST) {
|
||||
// if (signBlock.getType() != Material.SIGN_POST) {
|
||||
// signBlock.setType(Material.SIGN_POST);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// // already a signpost, gotta delete it and create a new one
|
||||
// signBlock.setType(Material.AIR);
|
||||
// signBlock.setType(Material.SIGN_POST);
|
||||
// }
|
||||
|
||||
|
||||
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());
|
||||
block.setData(kind.getData());
|
||||
}
|
||||
|
||||
|
||||
public void setTeamSpawn(Location teamSpawn) {
|
||||
|
||||
|
||||
this.teamSpawn = teamSpawn;
|
||||
|
||||
|
||||
// this resets the block to old state
|
||||
this.setSpawnVolume();
|
||||
getSpawnVolume().saveBlocks();
|
||||
|
||||
initializeTeamSpawn();
|
||||
this.getSpawnVolume().saveBlocks();
|
||||
|
||||
this.initializeTeamSpawn();
|
||||
}
|
||||
|
||||
|
||||
public Location getTeamSpawn() {
|
||||
return teamSpawn;
|
||||
return this.teamSpawn;
|
||||
}
|
||||
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
this.players.add(player);
|
||||
}
|
||||
|
||||
|
||||
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,76 +351,76 @@ 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;
|
||||
thePlayer = player;
|
||||
}
|
||||
}
|
||||
if (thePlayer != null) {
|
||||
players.remove(thePlayer);
|
||||
this.players.remove(thePlayer);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setRemainingLives(int remainingLives) {
|
||||
this.remainingLives = remainingLives;
|
||||
this.remainingLives = remainingLives;
|
||||
}
|
||||
|
||||
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++;
|
||||
if (atLeastOnePlayerOnTeam && atLeastOnePlayerOnOtherTeam) {
|
||||
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(){
|
||||
this.getSpawnVolume().resetBlocks();
|
||||
this.initializeTeamSpawn(); // reset everything instead of just sign
|
||||
|
||||
|
||||
// BUKKIT
|
||||
// int x = teamSpawn.getBlockX();
|
||||
// int y = teamSpawn.getBlockY();
|
||||
// int z = teamSpawn.getBlockZ();
|
||||
//
|
||||
//
|
||||
// Block block = warzone.getWorld().getBlockAt(x, y, z).getFace(BlockFace.SOUTH, 2).getFace(BlockFace.WEST, 2);
|
||||
// if (block.getType() != Material.SIGN_POST) {
|
||||
// if (block.getType() != Material.SIGN_POST) {
|
||||
// block.setType(Material.SIGN_POST);
|
||||
// }
|
||||
// }
|
||||
//// else {
|
||||
//// // already a signpost, gotta delete it and create a new one
|
||||
//// block.setType(Material.AIR);
|
||||
//// block.setType(Material.SIGN_POST);
|
||||
//// }
|
||||
//// block.setData((byte)6);
|
||||
//
|
||||
//
|
||||
// BlockState state = block.getState();
|
||||
// if (state instanceof Sign) {
|
||||
// Sign sign = (Sign) state;
|
||||
@ -430,9 +432,9 @@ public class Team {
|
||||
// sign.setLine(3, players.size() + "/" + warzone.getTeamCap() + " players");
|
||||
// state.update(true);
|
||||
// }
|
||||
|
||||
if (warzone.getLobby() != null) {
|
||||
warzone.getLobby().resetTeamGateSign(this);
|
||||
|
||||
if (this.warzone.getLobby() != null) {
|
||||
this.warzone.getLobby().resetTeamGateSign(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,108 +451,111 @@ 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")
|
||||
public void initializeTeamFlag() {
|
||||
// make air
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setTeamFlag(Location teamFlag) {
|
||||
|
||||
|
||||
this.teamFlag = teamFlag;
|
||||
|
||||
|
||||
// this resets the block to old state
|
||||
this.setFlagVolume();
|
||||
getFlagVolume().saveBlocks();
|
||||
|
||||
initializeTeamFlag();
|
||||
this.getFlagVolume().saveBlocks();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -14,22 +14,22 @@ public class TeamKind {
|
||||
this.material = material;
|
||||
this.data = data;
|
||||
this.color = color;
|
||||
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -7,44 +7,43 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
public class TeamKinds {
|
||||
private static final List<TeamKind> teamKinds = new ArrayList<TeamKind>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.tommytony.war;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ import com.tommytony.war.volumes.BlockInfo;
|
||||
import com.tommytony.war.volumes.Volume;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -24,7 +24,7 @@ public class WarHub {
|
||||
private Location location;
|
||||
private Volume volume;
|
||||
private Map<String, Block> zoneGateBlocks = new HashMap<String, Block>();
|
||||
|
||||
|
||||
public WarHub(War war, Location location) {
|
||||
this.war = war;
|
||||
this.location = location;
|
||||
@ -32,25 +32,25 @@ public class WarHub {
|
||||
}
|
||||
|
||||
public Volume getVolume() {
|
||||
return volume;
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
public void setLocation(Location loc) {
|
||||
this.location = loc;
|
||||
}
|
||||
|
||||
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
for (Warzone zone : war.getWarzones()) { // gonna use the index to find it again
|
||||
Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getFace(BlockFace.UP).getFace(BlockFace.WEST, hubDepth).getFace(BlockFace.NORTH, 2);
|
||||
|
||||
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);
|
||||
@ -97,36 +99,38 @@ public class WarHub {
|
||||
currentGateBlock.getFace(BlockFace.NORTH).getFace(BlockFace.UP).getFace(BlockFace.UP).setType(Material.OBSIDIAN);
|
||||
currentGateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).setType(Material.OBSIDIAN);
|
||||
currentGateBlock = currentGateBlock.getFace(BlockFace.NORTH, 4);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// War hub sign
|
||||
Block signBlock = locationBlock.getFace(BlockFace.WEST);
|
||||
|
||||
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "War hub";
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
int zonePlayers = 0;
|
||||
for (Team t : zone.getTeams()) {
|
||||
@ -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
@ -17,7 +17,7 @@ import com.tommytony.war.volumes.Volume;
|
||||
import com.tommytony.war.volumes.ZoneVolume;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -27,18 +27,18 @@ public class ZoneLobby {
|
||||
private BlockFace wall;
|
||||
private Volume volume;
|
||||
BlockInfo lobbyMiddleWallBlock = null; // on the zone wall, one above the zone lobby floor
|
||||
|
||||
|
||||
BlockInfo warHubLinkGate = null;
|
||||
|
||||
Map<String, BlockInfo> teamGateBlocks = new HashMap<String, BlockInfo>();
|
||||
|
||||
Map<String, BlockInfo> teamGateBlocks = new HashMap<String, BlockInfo>();
|
||||
BlockInfo autoAssignGate = null;
|
||||
|
||||
|
||||
BlockInfo zoneTeleportBlock = null;
|
||||
|
||||
|
||||
private final int lobbyHeight = 3;
|
||||
private int lobbyHalfSide;
|
||||
private final int lobbyDepth = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Use this constructor with /setzonelobby <n/s/e/w>
|
||||
* @param war
|
||||
@ -49,13 +49,13 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Use this constructor with /setzonelobby <zonename>.
|
||||
* Makes sure the lobby is not sticking inside the zone.
|
||||
@ -67,50 +67,50 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience ctor when loading form disk.
|
||||
* This figures out the middle wall block of the lobby from the volume instead
|
||||
* This figures out the middle wall block of the lobby from the volume instead
|
||||
* of the other way around.
|
||||
*/
|
||||
public ZoneLobby(War war, Warzone warzone, BlockFace wall, Volume volume) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Changes the lobby's position. Orientation is determined from the player location.
|
||||
* Creates volume or resets. Saves new lobby blocks.
|
||||
* @param playerLocation
|
||||
*/
|
||||
public void setLocation(Location playerLocation) {
|
||||
createVolumeOrReset();
|
||||
|
||||
this.createVolumeOrReset();
|
||||
|
||||
// Lobby orientation
|
||||
int yaw = 0;
|
||||
if (playerLocation.getYaw() >= 0){
|
||||
@ -133,7 +133,7 @@ public class ZoneLobby {
|
||||
facing = BlockFace.SOUTH;
|
||||
opposite = BlockFace.NORTH;
|
||||
}
|
||||
|
||||
|
||||
// float yaw = playerLocation.getYaw() % 360;
|
||||
// if (yaw >= 45 && yaw < 135) {
|
||||
// facing = BlockFace.NORTH;
|
||||
@ -147,118 +147,118 @@ public class ZoneLobby {
|
||||
// } else if (yaw >= 315 || yaw < 45) {
|
||||
// facing = BlockFace.WEST;
|
||||
// opposite = BlockFace.EAST;
|
||||
// }
|
||||
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(),
|
||||
playerLocation.getBlockY(),
|
||||
// }
|
||||
this.wall = opposite; // a player facing south places a lobby that looks just like a lobby stuck to the north wall
|
||||
|
||||
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();
|
||||
|
||||
if (wall == BlockFace.NORTH) {
|
||||
int x = this.lobbyMiddleWallBlock.getX();
|
||||
int y = this.lobbyMiddleWallBlock.getY();
|
||||
int z = this.lobbyMiddleWallBlock.getZ();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Classic way of creating a lobby. Lobby position goes to middle of zone wall.
|
||||
* Creates volume or resets. Saves new lobby blocks.
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void saveLobbyBlocks(Block corner1, Block corner2) {
|
||||
if (corner1 != null && corner2 != null) {
|
||||
// save the blocks, wide enough for three team gates, 3+1 high and 10 deep, extruding out from the zone wall.
|
||||
@ -267,135 +267,135 @@ public class ZoneLobby {
|
||||
this.volume.saveBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
|
||||
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,179 +403,194 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void placeGate(Block block,
|
||||
Material material) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setBlock(Block block, TeamKind kind) {
|
||||
block.setType(kind.getMaterial());
|
||||
block.setData(kind.getData());
|
||||
}
|
||||
|
||||
|
||||
private void setBlock(Block block, Material material) {
|
||||
block.setType(material);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
TeamKind kind = null;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public Volume getVolume() {
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
|
||||
public void setVolume(Volume volume) {
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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,82 +671,94 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void resetGateSign(Block gate, String[] lines, boolean awayFromWall) {
|
||||
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;
|
||||
}
|
||||
|
||||
SignHelper.setToSign(war, block, data, lines);
|
||||
if (awayFromWall) {
|
||||
data = (byte)0;
|
||||
} else {
|
||||
data = (byte)8;
|
||||
}
|
||||
}
|
||||
|
||||
SignHelper.setToSign(this.war, block, data, lines);
|
||||
}
|
||||
|
||||
|
||||
public boolean isLeavingZone(Location location) {
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
for (String teamName : teamGateBlocks.keySet()) {
|
||||
|
||||
BlockInfo info = teamGateBlocks.get(teamName);
|
||||
if (leaving(location, BlockInfo.getBlock(warzone.getWorld(), info), 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 : this.teamGateBlocks.keySet()) {
|
||||
|
||||
BlockInfo info = this.teamGateBlocks.get(teamName);
|
||||
if (this.leaving(location, BlockInfo.getBlock(this.warzone.getWorld(), info), inside, left, right)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -741,17 +768,16 @@ public class ZoneLobby {
|
||||
// int x = location.getBlockX();
|
||||
// int y = location.getBlockY();
|
||||
// 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);
|
||||
// Block outL = out.getFace(left);
|
||||
|
@ -24,144 +24,166 @@ public class ZoneSetter {
|
||||
this.player = player;
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
|
||||
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() + ". ");
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Northwesternmost point set to x:"
|
||||
+ 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() + ". ");
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Southeasternmost point set to x:"
|
||||
+ 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() + ". ");
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Corner 1 set to x:"
|
||||
+ 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() + ". ");
|
||||
msgString.append("Warzone " + warzone.getName() + " modified. Corner 2 set to x:"
|
||||
+ 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();
|
||||
}
|
||||
@ -169,51 +191,51 @@ public class ZoneSetter {
|
||||
msgString.append(reset + " blocks reset. ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
warzone.saveState(false); // we just changed the volume, cant reset walls
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import com.tommytony.war.volumes.BlockInfo;
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -22,9 +22,9 @@ public class ZoneWallGuard {
|
||||
private Player player;
|
||||
private Warzone warzone;
|
||||
private Location playerLocation;
|
||||
private BlockFace wall;
|
||||
private List<BlockInfo> glassified = new ArrayList<BlockInfo>();
|
||||
|
||||
private BlockFace wall;
|
||||
private List<BlockInfo> glassified = new ArrayList<BlockInfo>();
|
||||
|
||||
public ZoneWallGuard(Player player, War war, Warzone warzone, BlockFace wall) {
|
||||
this.player = player;
|
||||
this.wall = wall;
|
||||
@ -32,194 +32,194 @@ public class ZoneWallGuard {
|
||||
this.warzone = warzone;
|
||||
this.activate();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void glassify(Block block, BlockFace wall) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ public class BlockResetJob implements Runnable {
|
||||
public BlockResetJob(Volume volume) {
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ public class LootDropperTask implements Runnable {
|
||||
this.location = location;
|
||||
this.drop = drop;
|
||||
}
|
||||
|
||||
|
||||
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,8 +21,8 @@ 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]);
|
||||
int hubZ = Integer.parseInt(hubStrSplit[2]);
|
||||
@ -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);
|
||||
if (zone != null) { // could have failed, would've been logged already
|
||||
war.getWarzones().add(zone);
|
||||
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
|
||||
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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,7 +93,7 @@ public final class PropertiesFile {
|
||||
* <blockquote><pre>
|
||||
* PropertiesFile settings = new PropertiesFile("settings.properties");
|
||||
* Map<String, String> mappedSettings;
|
||||
*
|
||||
*
|
||||
* try {
|
||||
* mappedSettings = settings.returnMap();
|
||||
* } catch (Exception ex) {
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ import com.tommytony.war.jobs.RestoreWarhubJob;
|
||||
import com.tommytony.war.jobs.RestoreWarzonesJob;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
public class WarMapper {
|
||||
|
||||
|
||||
public static void load(War war) {
|
||||
//war.getLogger().info("Loading war config...");
|
||||
(war.getDataFolder()).mkdir();
|
||||
@ -31,7 +31,7 @@ public class WarMapper {
|
||||
war.logWarn("Failed to load war.txt file.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// Create file if need be
|
||||
boolean newWar = false;
|
||||
if (!warConfig.containsKey("warzones")) {
|
||||
@ -45,14 +45,14 @@ public class WarMapper {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// warzones
|
||||
String warzonesStr = warConfig.getString("warzones");
|
||||
RestoreWarzonesJob restoreWarzones = new RestoreWarzonesJob(war, warzonesStr, newWar);
|
||||
if (war.getServer().getScheduler().scheduleSyncDelayedTask(war, restoreWarzones) == -1) {
|
||||
war.logWarn("Failed to schedule warzone-restore job. No warzone was loaded.");
|
||||
}
|
||||
|
||||
|
||||
// zone makers
|
||||
String makersStr = warConfig.getString("zoneMakers");
|
||||
String[] makersSplit = makersStr.split(",");
|
||||
@ -62,7 +62,7 @@ public class WarMapper {
|
||||
war.getZoneMakerNames().add(makerName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// defaultLoadout
|
||||
String defaultLoadoutStr = warConfig.getString("defaultLoadout");
|
||||
String[] defaultLoadoutSplit = defaultLoadoutStr.split(";");
|
||||
@ -75,37 +75,37 @@ public class WarMapper {
|
||||
war.getDefaultLoadout().put(Integer.parseInt(itemStrSplit[2]), item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// defaultLifePool
|
||||
war.setDefaultLifepool(warConfig.getInt("defaultLifePool"));
|
||||
|
||||
|
||||
// defaultMonumentHeal
|
||||
war.setDefaultMonumentHeal(warConfig.getInt("defaultMonumentHeal"));
|
||||
|
||||
|
||||
// defaultFriendlyFire
|
||||
war.setDefaultFriendlyFire(warConfig.getBoolean("defaultFriendlyFire"));
|
||||
|
||||
|
||||
// defaultAutoAssignOnly
|
||||
war.setDefaultAutoAssignOnly(warConfig.getBoolean("defaultAutoAssignOnly"));
|
||||
|
||||
|
||||
// defaultTeamCap
|
||||
war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap"));
|
||||
|
||||
|
||||
// defaultScoreCap
|
||||
war.setDefaultScoreCap(warConfig.getInt("defaultScoreCap"));
|
||||
|
||||
// pvpInZonesOnly
|
||||
war.setPvpInZonesOnly(warConfig.getBoolean("pvpInZonesOnly"));
|
||||
|
||||
|
||||
// defaultBlockHeads
|
||||
war.setDefaultBlockHeads(warConfig.getBoolean("defaultBlockHeads"));
|
||||
|
||||
|
||||
// buildInZonesOnly
|
||||
war.setBuildInZonesOnly(warConfig.getBoolean("buildInZonesOnly"));
|
||||
|
||||
|
||||
// disablePVPMessage
|
||||
war.setDisablePvpMessage(warConfig.getBoolean("disablePvpMessage"));
|
||||
|
||||
|
||||
// defaultSpawnStyle
|
||||
String spawnStyle = warConfig.getString("defaultspawnStyle");
|
||||
if (spawnStyle != null && !spawnStyle.equals("")){
|
||||
@ -117,9 +117,9 @@ public class WarMapper {
|
||||
} else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)){
|
||||
war.setDefaultSpawnStyle(spawnStyle);
|
||||
}
|
||||
// default is already initialized to BIG (see Warzone)
|
||||
// default is already initialized to BIG (see Warzone)
|
||||
}
|
||||
|
||||
|
||||
// defaultReward
|
||||
String defaultRewardStr = warConfig.getString("defaultReward");
|
||||
if (defaultRewardStr != null && !defaultRewardStr.equals("")) {
|
||||
@ -134,25 +134,25 @@ public class WarMapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// defaultUnbreakableZoneBlocks
|
||||
war.setDefaultUnbreakableZoneBlocks(warConfig.getBoolean("defaultUnbreakableZoneBlocks"));
|
||||
|
||||
|
||||
// defaultNoCreatures
|
||||
war.setDefaultNoCreatures(warConfig.getBoolean("defaultNoCreatures"));
|
||||
|
||||
|
||||
// defaultDropLootOnDeath
|
||||
//war.setDefaultDropLootOnDeath(warConfig.getBoolean("defaultDropLootOnDeath"));
|
||||
|
||||
|
||||
// defaultResetOnEmpty
|
||||
war.setDefaultResetOnEmpty(warConfig.getBoolean("defaultResetOnEmpty"));
|
||||
|
||||
// defaultResetOnLoad
|
||||
war.setDefaultResetOnLoad(warConfig.getBoolean("defaultResetOnLoad"));
|
||||
|
||||
|
||||
// defaultResetOnUnload
|
||||
war.setDefaultResetOnUnload(warConfig.getBoolean("defaultResetOnUnload"));
|
||||
|
||||
|
||||
// warhub
|
||||
String hubStr = warConfig.getString("warhub");
|
||||
if (hubStr != null && !hubStr.equals("")) {
|
||||
@ -161,27 +161,27 @@ public class WarMapper {
|
||||
war.logWarn("Failed to schedule warhub-restore job. War hub was not loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
warConfig.close();
|
||||
}
|
||||
|
||||
|
||||
public static void save(War war) {
|
||||
PropertiesFile warConfig = new PropertiesFile(war.getDataFolder().getPath() + "/war.txt");
|
||||
String warzonesStr = "";
|
||||
|
||||
|
||||
// warzones
|
||||
for (Warzone zone : war.getWarzones()) {
|
||||
warzonesStr += zone.getName() + ",";
|
||||
}
|
||||
warConfig.setString("warzones", warzonesStr);
|
||||
|
||||
|
||||
// zone makers: default is none and it means everyone can use /setzone
|
||||
String makersStr = ""; // everyone
|
||||
for (String name : war.getZoneMakerNames()) {
|
||||
makersStr += name + ",";
|
||||
}
|
||||
warConfig.setString("zoneMakers", makersStr);
|
||||
|
||||
|
||||
// defaultLoadout
|
||||
String defaultLoadoutStr = "";
|
||||
HashMap<Integer, ItemStack> items = war.getDefaultLoadout();
|
||||
@ -192,40 +192,40 @@ public class WarMapper {
|
||||
}
|
||||
}
|
||||
warConfig.setString("defaultLoadout", defaultLoadoutStr);
|
||||
|
||||
|
||||
// defaultLifepool
|
||||
warConfig.setInt("defaultLifePool", war.getDefaultLifepool());
|
||||
|
||||
|
||||
// defaultMonumentHeal
|
||||
warConfig.setInt("defaultMonumentHeal", war.getDefaultMonumentHeal());
|
||||
|
||||
|
||||
// defaultFriendlyFire
|
||||
warConfig.setBoolean("defaultFriendlyFire", war.getDefaultFriendlyFire());
|
||||
|
||||
|
||||
// defaultAutoAssignOnly
|
||||
warConfig.setBoolean("defaultAutoAssignOnly", war.getDefaultAutoAssignOnly());
|
||||
|
||||
|
||||
// defaultTeamCap
|
||||
warConfig.setInt("defaultTeamCap", war.getDefaultTeamCap());
|
||||
|
||||
|
||||
// defaultScoreCap
|
||||
warConfig.setInt("defaultScoreCap", war.getDefaultScoreCap());
|
||||
|
||||
// pvpInZonesOnly
|
||||
warConfig.setBoolean("pvpInZonesOnly", war.isPvpInZonesOnly());
|
||||
|
||||
|
||||
// defaultBlockHeads
|
||||
warConfig.setBoolean("defaultBlockHeads", war.isDefaultBlockHeads());
|
||||
|
||||
|
||||
// buildInZonesOnly
|
||||
warConfig.setBoolean("buildInZonesOnly", war.isBuildInZonesOnly());
|
||||
|
||||
|
||||
// disablePVPMessage
|
||||
warConfig.setBoolean("disablePvpMessage", war.isDisablePvpMessage());
|
||||
|
||||
|
||||
// spawnStyle
|
||||
warConfig.setString("spawnStyle", war.getDefaultSpawnStyle());
|
||||
|
||||
|
||||
// defaultReward
|
||||
String defaultRewardStr = "";
|
||||
HashMap<Integer, ItemStack> rewardItems = war.getDefaultReward();
|
||||
@ -239,32 +239,32 @@ public class WarMapper {
|
||||
|
||||
// defaultUnbreakableZoneBlocks
|
||||
warConfig.setBoolean("defaultUnbreakableZoneBlocks", war.isDefaultUnbreakableZoneBlocks());
|
||||
|
||||
|
||||
// defaultNoCreatures
|
||||
warConfig.setBoolean("defaultNoCreatures", war.isDefaultNoCreatures());
|
||||
|
||||
|
||||
// defaultResetOnEmpty
|
||||
warConfig.setBoolean("defaultResetOnEmpty", war.isDefaultResetOnEmpty());
|
||||
|
||||
|
||||
// defaultResetOnLoad
|
||||
warConfig.setBoolean("defaultResetOnLoad", war.isDefaultResetOnLoad());
|
||||
|
||||
|
||||
// defaultResetOnUnload
|
||||
warConfig.setBoolean("defaultResetOnUnload", war.isDefaultResetOnUnload());
|
||||
|
||||
|
||||
// defaultDropLootOnDeath
|
||||
//warConfig.setBoolean("defaultDropLootOnDeath", war.isDefaultDropLootOnDeath());
|
||||
|
||||
|
||||
// warhub
|
||||
String hubStr = "";
|
||||
WarHub hub = war.getWarHub();
|
||||
if (hub != null) {
|
||||
hubStr = hub.getLocation().getBlockX() + "," + hub.getLocation().getBlockY() + "," + hub.getLocation().getBlockZ() + ","
|
||||
hubStr = hub.getLocation().getBlockX() + "," + hub.getLocation().getBlockY() + "," + hub.getLocation().getBlockZ() + ","
|
||||
+ hub.getLocation().getWorld().getName();
|
||||
VolumeMapper.save(hub.getVolume(), "", war);
|
||||
}
|
||||
warConfig.setString("warhub", hubStr);
|
||||
|
||||
|
||||
warConfig.save();
|
||||
warConfig.close();
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import com.tommytony.war.volumes.Volume;
|
||||
import com.tommytony.war.volumes.ZoneVolume;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -37,7 +37,7 @@ public class WarzoneMapper {
|
||||
war.getLogger().info("Failed to load warzone-" + name + ".txt file.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// world
|
||||
String worldStr = warzoneConfig.getProperty("world");
|
||||
World world = null;
|
||||
@ -46,14 +46,14 @@ public class WarzoneMapper {
|
||||
} else {
|
||||
world = war.getServer().getWorld(worldStr);
|
||||
}
|
||||
|
||||
|
||||
if (world == null) {
|
||||
war.logWarn("Failed to restore warzone " + name + ". The specified world (name: " + worldStr + ") does not exist!");
|
||||
} else {
|
||||
// Create the zone
|
||||
// Create the zone
|
||||
Warzone warzone = new Warzone(war, world, name);
|
||||
|
||||
// Create file if needed
|
||||
|
||||
// Create file if needed
|
||||
if (!warzoneConfig.containsKey("name")) {
|
||||
WarzoneMapper.save(war, warzone, false);
|
||||
war.getLogger().info("Warzone " + name + " config file created.");
|
||||
@ -64,7 +64,7 @@ public class WarzoneMapper {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// teleport
|
||||
String teleportStr = warzoneConfig.getString("teleport");
|
||||
if (teleportStr != null && !teleportStr.equals("")) {
|
||||
@ -75,7 +75,7 @@ public class WarzoneMapper {
|
||||
int yaw = Integer.parseInt(teleportSplit[3]);
|
||||
warzone.setTeleport(new Location(world, teleX, teleY, teleZ, yaw, 0));
|
||||
}
|
||||
|
||||
|
||||
// teams
|
||||
String teamsStr = warzoneConfig.getString("teams");
|
||||
if (teamsStr != null && !teamsStr.equals("")) {
|
||||
@ -92,7 +92,7 @@ public class WarzoneMapper {
|
||||
int yaw = Integer.parseInt(teamStrSplit[4]);
|
||||
teamLocation.setYaw(yaw);
|
||||
}
|
||||
Team team = new Team(teamStrSplit[0],
|
||||
Team team = new Team(teamStrSplit[0],
|
||||
TeamKinds.teamKindFromString(teamStrSplit[0]),
|
||||
teamLocation,
|
||||
war, warzone );
|
||||
@ -101,7 +101,7 @@ public class WarzoneMapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// teamFlags
|
||||
String teamFlagsStr = warzoneConfig.getString("teamFlags");
|
||||
if (teamFlagsStr != null && !teamFlagsStr.equals("")) {
|
||||
@ -124,10 +124,10 @@ public class WarzoneMapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ff
|
||||
warzone.setFriendlyFire(warzoneConfig.getBoolean("friendlyFire"));
|
||||
|
||||
|
||||
// loadout
|
||||
String loadoutStr = warzoneConfig.getString("loadout");
|
||||
if (loadoutStr != null && !loadoutStr.equals("")) {
|
||||
@ -142,25 +142,25 @@ public class WarzoneMapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// life pool (always set after teams, so the teams' remaining lives get initialized properly by this setter)
|
||||
warzone.setLifePool(warzoneConfig.getInt("lifePool"));
|
||||
|
||||
|
||||
// monument heal
|
||||
warzone.setMonumentHeal(warzoneConfig.getInt("monumentHeal"));
|
||||
|
||||
|
||||
// autoAssignOnly
|
||||
warzone.setAutoAssignOnly(warzoneConfig.getBoolean("autoAssignOnly"));
|
||||
|
||||
|
||||
// team cap
|
||||
warzone.setTeamCap(warzoneConfig.getInt("teamCap"));
|
||||
|
||||
|
||||
// score cap
|
||||
warzone.setScoreCap(warzoneConfig.getInt("scoreCap"));
|
||||
|
||||
|
||||
// blockHeads
|
||||
warzone.setBlockHeads(warzoneConfig.getBoolean("blockHeads"));
|
||||
|
||||
|
||||
// spawnStyle
|
||||
String spawnStyle = warzoneConfig.getString("spawnStyle");
|
||||
if (spawnStyle != null && !spawnStyle.equals("")){
|
||||
@ -172,9 +172,9 @@ public class WarzoneMapper {
|
||||
} else if (spawnStyle.equals(TeamSpawnStyles.INVISIBLE)){
|
||||
warzone.setSpawnStyle(spawnStyle);
|
||||
}
|
||||
// default is already initialized to BIG (see Warzone)
|
||||
// default is already initialized to BIG (see Warzone)
|
||||
}
|
||||
|
||||
|
||||
// reward
|
||||
String rewardStr = warzoneConfig.getString("reward");
|
||||
if (rewardStr != null && !rewardStr.equals("")) {
|
||||
@ -189,40 +189,40 @@ public class WarzoneMapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// unbreakableZoneBlocks
|
||||
warzone.setUnbreakableZoneBlocks(warzoneConfig.getBoolean("unbreakableZoneBlocks"));
|
||||
|
||||
|
||||
// disabled
|
||||
warzone.setDisabled(warzoneConfig.getBoolean("disabled"));
|
||||
|
||||
|
||||
// defaultNoCreatures
|
||||
warzone.setNoCreatures(warzoneConfig.getBoolean("noCreatures"));
|
||||
|
||||
|
||||
// resetOnEmpty
|
||||
warzone.setResetOnEmpty(warzoneConfig.getBoolean("resetOnEmpty"));
|
||||
|
||||
// resetOnLoad
|
||||
warzone.setResetOnLoad(warzoneConfig.getBoolean("resetOnLoad"));
|
||||
|
||||
|
||||
// resetOnUnload
|
||||
warzone.setResetOnUnload(warzoneConfig.getBoolean("resetOnUnload"));
|
||||
|
||||
|
||||
// rallyPoint
|
||||
String rallyPointStr = warzoneConfig.getString("rallyPoint");
|
||||
if (rallyPointStr != null && !rallyPointStr.equals("")) {
|
||||
String[] rallyPointStrSplit = rallyPointStr.split(",");
|
||||
|
||||
|
||||
int rpX = Integer.parseInt(rallyPointStrSplit[0]);
|
||||
int rpY = Integer.parseInt(rallyPointStrSplit[1]);
|
||||
int rpZ = Integer.parseInt(rallyPointStrSplit[2]);
|
||||
Location rallyPoint = new Location(world, rpX, rpY, rpZ);
|
||||
warzone.setRallyPoint(rallyPoint);
|
||||
}
|
||||
|
||||
|
||||
// dropLootOnDeath
|
||||
//warzone.setDropLootOnDeath(warzoneConfig.getBoolean("dropLootOnDeath"));
|
||||
|
||||
|
||||
// monuments
|
||||
String monumentsStr = warzoneConfig.getString("monuments");
|
||||
if (monumentsStr != null && !monumentsStr.equals("")) {
|
||||
@ -234,28 +234,28 @@ public class WarzoneMapper {
|
||||
int monumentX = Integer.parseInt(monumentStrSplit[1]);
|
||||
int monumentY = Integer.parseInt(monumentStrSplit[2]);
|
||||
int monumentZ = Integer.parseInt(monumentStrSplit[3]);
|
||||
Monument monument = new Monument(monumentStrSplit[0], war, warzone,
|
||||
Monument monument = new Monument(monumentStrSplit[0], war, warzone,
|
||||
new Location(world, monumentX, monumentY, monumentZ));
|
||||
warzone.getMonuments().add(monument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// lobby
|
||||
String lobbyStr = warzoneConfig.getString("lobby");
|
||||
|
||||
|
||||
warzoneConfig.close();
|
||||
|
||||
|
||||
if (createNewVolume) {
|
||||
ZoneVolume zoneVolume = new ZoneVolume(warzone.getName(), war, world, warzone); //VolumeMapper.loadZoneVolume(warzone.getName(), warzone.getName(), war, warzone.getWorld(), warzone);
|
||||
warzone.setVolume(zoneVolume);
|
||||
}
|
||||
|
||||
|
||||
// monument blocks
|
||||
for (Monument monument: warzone.getMonuments()) {
|
||||
monument.setVolume(VolumeMapper.loadVolume(monument.getName(),warzone.getName(), war, world));
|
||||
}
|
||||
|
||||
|
||||
// team spawn blocks
|
||||
for (Team team : warzone.getTeams()) {
|
||||
team.setSpawnVolume(VolumeMapper.loadVolume(team.getName(), warzone.getName(), war, world));
|
||||
@ -263,7 +263,7 @@ public class WarzoneMapper {
|
||||
team.setFlagVolume(VolumeMapper.loadVolume(team.getName()+"flag", warzone.getName(), war, world));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// lobby
|
||||
BlockFace lobbyFace = null;
|
||||
if (lobbyStr != null && !lobbyStr.equals("")){
|
||||
@ -280,23 +280,23 @@ public class WarzoneMapper {
|
||||
ZoneLobby lobby = new ZoneLobby(war, warzone, lobbyFace, lobbyVolume);
|
||||
warzone.setLobby(lobby);
|
||||
}
|
||||
|
||||
|
||||
return warzone;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static void save(War war, Warzone warzone, boolean saveAllBlocks) {
|
||||
(new File(war.getDataFolder().getPath() +"/dat/warzone-"+warzone.getName())).mkdir();
|
||||
PropertiesFile warzoneConfig = new PropertiesFile(war.getDataFolder().getPath() + "/warzone-" + warzone.getName() + ".txt");
|
||||
//war.getLogger().info("Saving warzone " + warzone.getName() + "...");
|
||||
|
||||
|
||||
// name
|
||||
warzoneConfig.setString("name", warzone.getName());
|
||||
|
||||
|
||||
// world
|
||||
warzoneConfig.setString("world", warzone.getWorld().getName()); // default for now
|
||||
|
||||
|
||||
// teleport
|
||||
String teleportStr = "";
|
||||
Location tele = warzone.getTeleport();
|
||||
@ -310,7 +310,7 @@ public class WarzoneMapper {
|
||||
teleportStr = tele.getBlockX() + "," + tele.getBlockY() + "," + tele.getBlockZ() + "," + intYaw;
|
||||
}
|
||||
warzoneConfig.setString("teleport", teleportStr);
|
||||
|
||||
|
||||
// teams
|
||||
String teamsStr = "";
|
||||
List<Team> teams = warzone.getTeams();
|
||||
@ -325,7 +325,7 @@ public class WarzoneMapper {
|
||||
teamsStr += team.getName() + "," + spawn.getBlockX() + "," + spawn.getBlockY() + "," + spawn.getBlockZ() + "," + intYaw + ";";
|
||||
}
|
||||
warzoneConfig.setString("teams", teamsStr);
|
||||
|
||||
|
||||
// team flags
|
||||
String teamFlagsStr = "";;
|
||||
for (Team team : teams) {
|
||||
@ -341,10 +341,10 @@ public class WarzoneMapper {
|
||||
}
|
||||
}
|
||||
warzoneConfig.setString("teamFlags", teamFlagsStr);
|
||||
|
||||
|
||||
// ff
|
||||
warzoneConfig.setBoolean("friendlyFire", warzone.getFriendlyFire());
|
||||
|
||||
|
||||
// loadout
|
||||
String loadoutStr = "";
|
||||
HashMap<Integer, ItemStack> items = warzone.getLoadout();
|
||||
@ -355,28 +355,28 @@ public class WarzoneMapper {
|
||||
}
|
||||
}
|
||||
warzoneConfig.setString("loadout", loadoutStr);
|
||||
|
||||
|
||||
// life pool
|
||||
warzoneConfig.setInt("lifePool", warzone.getLifePool());
|
||||
|
||||
|
||||
// monument heal
|
||||
warzoneConfig.setInt("monumentHeal", warzone.getMonumentHeal());
|
||||
|
||||
// autoAssignOnly
|
||||
warzoneConfig.setBoolean("autoAssignOnly", warzone.isAutoAssignOnly());
|
||||
|
||||
|
||||
// team cap
|
||||
warzoneConfig.setInt("teamCap", warzone.getTeamCap());
|
||||
|
||||
|
||||
// score cap
|
||||
warzoneConfig.setInt("scoreCap", warzone.getScoreCap());
|
||||
|
||||
|
||||
// blockHeads
|
||||
warzoneConfig.setBoolean("blockHeads", warzone.isBlockHeads());
|
||||
|
||||
|
||||
// spawnStyle
|
||||
warzoneConfig.setString("spawnStyle", warzone.getSpawnStyle());
|
||||
|
||||
|
||||
// reward
|
||||
String rewardStr = "";
|
||||
HashMap<Integer, ItemStack> rewardItems = warzone.getReward();
|
||||
@ -387,25 +387,25 @@ public class WarzoneMapper {
|
||||
}
|
||||
}
|
||||
warzoneConfig.setString("reward", rewardStr);
|
||||
|
||||
|
||||
// unbreakableZoneBlocks
|
||||
warzoneConfig.setBoolean("unbreakableZoneBlocks", warzone.isUnbreakableZoneBlocks());
|
||||
|
||||
|
||||
// disabled
|
||||
warzoneConfig.setBoolean("disabled", warzone.isDisabled());
|
||||
|
||||
|
||||
// noCreatures
|
||||
warzoneConfig.setBoolean("noCreatures", warzone.isNoCreatures());
|
||||
|
||||
|
||||
// resetOnEmpty
|
||||
warzoneConfig.setBoolean("resetOnEmpty", warzone.isResetOnEmpty());
|
||||
|
||||
|
||||
// resetOnLoad
|
||||
warzoneConfig.setBoolean("resetOnLoad", warzone.isResetOnLoad());
|
||||
|
||||
|
||||
// resetOnUnload
|
||||
warzoneConfig.setBoolean("resetOnUnload", warzone.isResetOnUnload());
|
||||
|
||||
|
||||
// rallyPoint
|
||||
String rpStr = "";
|
||||
Location rp = warzone.getRallyPoint();
|
||||
@ -413,10 +413,10 @@ public class WarzoneMapper {
|
||||
rpStr = rp.getBlockX() + "," + rp.getBlockY() + "," + rp.getBlockZ();
|
||||
}
|
||||
warzoneConfig.setString("rallyPoint", rpStr);
|
||||
|
||||
|
||||
// defaultDropLootOnDeath
|
||||
//warzoneConfig.setBoolean("dropLootOnDeath", warzone.isDropLootOnDeath());
|
||||
|
||||
|
||||
// monuments
|
||||
String monumentsStr = "";
|
||||
List<Monument> monuments = warzone.getMonuments();
|
||||
@ -425,7 +425,7 @@ public class WarzoneMapper {
|
||||
monumentsStr += monument.getName() + "," + monumentLoc.getBlockX() + "," + monumentLoc.getBlockY() + "," + monumentLoc.getBlockZ() + ";";
|
||||
}
|
||||
warzoneConfig.setString("monuments", monumentsStr);
|
||||
|
||||
|
||||
// lobby
|
||||
String lobbyStr = "";
|
||||
if (warzone.getLobby() != null) {
|
||||
@ -437,42 +437,42 @@ public class WarzoneMapper {
|
||||
lobbyStr = "north";
|
||||
} else if (BlockFace.WEST == warzone.getLobby().getWall()) {
|
||||
lobbyStr = "west";
|
||||
}
|
||||
}
|
||||
}
|
||||
warzoneConfig.setString("lobby", lobbyStr);
|
||||
|
||||
|
||||
warzoneConfig.save();
|
||||
warzoneConfig.close();
|
||||
|
||||
|
||||
if (saveAllBlocks) {
|
||||
// zone blocks
|
||||
//VolumeMapper.save(warzone.getVolume(), warzone.getName(), war);
|
||||
}
|
||||
|
||||
|
||||
// monument blocks
|
||||
for (Monument monument: monuments) {
|
||||
VolumeMapper.save(monument.getVolume(), warzone.getName(), war);
|
||||
}
|
||||
|
||||
|
||||
// team spawn & flag blocks
|
||||
for (Team team : teams) {
|
||||
VolumeMapper.save(team.getSpawnVolume(), warzone.getName(), war);
|
||||
if (team.getFlagVolume() != null) {
|
||||
VolumeMapper.save(team.getFlagVolume(), warzone.getName(), war);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (warzone.getLobby() != null) {
|
||||
VolumeMapper.save(warzone.getLobby().getVolume(), warzone.getName(), war);
|
||||
}
|
||||
|
||||
|
||||
// if (saveBlocks) {
|
||||
// war.getLogger().info("Saved warzone " + warzone.getName() + " config and blocks.");
|
||||
// } else {
|
||||
// war.getLogger().info("Saved warzone " + warzone.getName() + " config.");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
public static void delete(War war, String name) {
|
||||
File zoneFolder = new File(war.getDataFolder().getPath() + "/dat/warzone-" + name);
|
||||
File[] files = zoneFolder.listFiles();
|
||||
|
@ -34,12 +34,12 @@ import com.tommytony.war.volumes.ZoneVolume;
|
||||
/**
|
||||
* The ZoneVolumeMapper take the blocks from disk and sets them in the worlds, since
|
||||
* the ZoneVolume doesn't hold its blocks in memory like regular Volumes.
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
public class ZoneVolumeMapper {
|
||||
|
||||
|
||||
public static int load(ZoneVolume volume, String zoneName, War war, World world, boolean onlyLoadCorners) {
|
||||
File cornersFile = new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".corners");
|
||||
File blocksFile = new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".blocks");
|
||||
@ -50,12 +50,12 @@ public class ZoneVolumeMapper {
|
||||
// The post 1.6 formatted files haven't been created yet so
|
||||
// we need to use the old load.
|
||||
noOfResetBlocks = PreDeGaulleZoneVolumeMapper.load(volume, zoneName, war, world, onlyLoadCorners);
|
||||
|
||||
|
||||
// The new 1.6 files aren't created yet. We just reset the zone (except deferred blocks which will soon execute on main thread ),
|
||||
// so let's save to the new format as soon as the zone is fully reset.
|
||||
ZoneVolumeMapper.saveAsJob(volume, zoneName, war, 2);
|
||||
war.logInfo("Warzone " + zoneName + " file converted!");
|
||||
|
||||
|
||||
return noOfResetBlocks;
|
||||
} else {
|
||||
// 1.6 file exist, so go ahead with reset
|
||||
@ -68,7 +68,7 @@ public class ZoneVolumeMapper {
|
||||
blocksStream = new FileInputStream(blocksFile);
|
||||
signsReader = new BufferedReader(new FileReader(signsFile));
|
||||
invsReader = new BufferedReader(new FileReader(invsFile));
|
||||
|
||||
|
||||
// Get the corners
|
||||
cornersReader.readLine();
|
||||
int x1 = Integer.parseInt(cornersReader.readLine());
|
||||
@ -78,16 +78,16 @@ public class ZoneVolumeMapper {
|
||||
int x2 = Integer.parseInt(cornersReader.readLine());
|
||||
int y2 = Integer.parseInt(cornersReader.readLine());
|
||||
int z2 = Integer.parseInt(cornersReader.readLine());
|
||||
|
||||
|
||||
volume.setCornerOne(world.getBlockAt(x1, y1, z1));
|
||||
volume.setCornerTwo(world.getBlockAt(x2, y2, z2));
|
||||
|
||||
volume.setCornerTwo(world.getBlockAt(x2, y2, z2));
|
||||
|
||||
// Allocate block byte arrays
|
||||
int noOfBlocks = volume.getSizeX()*volume.getSizeY()*volume.getSizeZ();
|
||||
byte[] blockBytes = new byte[noOfBlocks*2]; // one byte for type, one for data
|
||||
|
||||
|
||||
blocksStream.read(blockBytes); // read it all
|
||||
|
||||
|
||||
// Now use the block bytes to reset the world blocks
|
||||
if (!onlyLoadCorners) {
|
||||
DeferredBlockResetsJob deferred = new DeferredBlockResetsJob(world);
|
||||
@ -99,24 +99,24 @@ public class ZoneVolumeMapper {
|
||||
volume.clearBlocksThatDontFloat();
|
||||
x = volume.getMinX();
|
||||
for (i = 0; i < volume.getSizeX(); i++){
|
||||
y = volume.getMinY();
|
||||
y = volume.getMinY();
|
||||
for (j = 0; j < volume.getSizeY(); j++) {
|
||||
z = volume.getMinZ();
|
||||
for (k = 0; k < volume.getSizeZ(); k++) {
|
||||
try {
|
||||
diskBlockType = blockBytes[visitedBlocks*2];
|
||||
diskBlockData = blockBytes[visitedBlocks*2+1];
|
||||
|
||||
|
||||
worldBlock = volume.getWorld().getBlockAt(x, y, z);
|
||||
worldBlockId = worldBlock.getTypeId();
|
||||
if (worldBlockId != diskBlockType ||
|
||||
(worldBlockId == diskBlockType && worldBlock.getData() != diskBlockData ) ||
|
||||
(worldBlockId == diskBlockType && worldBlock.getData() == diskBlockData &&
|
||||
(diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId()
|
||||
(diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId()
|
||||
|| diskBlockType == Material.CHEST.getId() || diskBlockType == Material.DISPENSER.getId())
|
||||
)
|
||||
) {
|
||||
if (diskBlockType == Material.WALL_SIGN.getId()
|
||||
if (diskBlockType == Material.WALL_SIGN.getId()
|
||||
|| diskBlockType == Material.SIGN_POST.getId()) {
|
||||
// Signs read
|
||||
String linesStr = signsReader.readLine();
|
||||
@ -134,18 +134,26 @@ 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));
|
||||
worldBlock.setData(diskBlockData);
|
||||
@ -166,8 +174,8 @@ 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));
|
||||
worldBlock.setData(diskBlockData);
|
||||
@ -188,7 +196,7 @@ public class ZoneVolumeMapper {
|
||||
}
|
||||
} else if (diskBlockType == Material.WOODEN_DOOR.getId() || diskBlockType == Material.IRON_DOOR_BLOCK.getId()){
|
||||
// Door blocks
|
||||
|
||||
|
||||
if (j-1 > 0) {
|
||||
Block blockBelow = world.getBlockAt(x, y-1, z);
|
||||
boolean belowIsGlass = blockBelow.getTypeId() == Material.GLASS.getId();
|
||||
@ -204,7 +212,7 @@ public class ZoneVolumeMapper {
|
||||
worldBlock.setType(Material.GLASS);
|
||||
}
|
||||
}
|
||||
} else if (((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
} else if (((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
|| (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||
@ -223,14 +231,14 @@ public class ZoneVolumeMapper {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
visitedBlocks++;
|
||||
|
||||
|
||||
blockReads++;
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
volume.getWar().getLogger().warning("Failed to reset block in zone volume " + volume.getName() + ". "
|
||||
+ "Blocks read: " + blockReads
|
||||
+ ". Visited blocks so far:" + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks +
|
||||
volume.getWar().getLogger().warning("Failed to reset block in zone volume " + volume.getName() + ". "
|
||||
+ "Blocks read: " + blockReads
|
||||
+ ". Visited blocks so far:" + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks +
|
||||
". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@ -244,31 +252,39 @@ public class ZoneVolumeMapper {
|
||||
if (!deferred.isEmpty()) {
|
||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, deferred, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
war.logWarn("Failed to find volume file " + volume.getName() +
|
||||
war.logWarn("Failed to find volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to read volume file " + volume.getName() +
|
||||
war.logWarn("Failed to read volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
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() +
|
||||
war.logWarn("Failed to close volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return noOfResetBlocks;
|
||||
return noOfResetBlocks;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static List<ItemStack> readInventoryString(String invString) {
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
if (invString != null && !invString.equals("")) {
|
||||
@ -311,7 +327,7 @@ public class ZoneVolumeMapper {
|
||||
blocksOutput = new FileOutputStream(new File(path + ".blocks"));
|
||||
signsWriter = new BufferedWriter(new FileWriter(new File(path + ".signs")));
|
||||
invsWriter = new BufferedWriter(new FileWriter(new File(path + ".invs")));
|
||||
|
||||
|
||||
cornersWriter.write("corner1"); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerOne().getX())); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerOne().getY())); cornersWriter.newLine();
|
||||
@ -320,7 +336,7 @@ public class ZoneVolumeMapper {
|
||||
cornersWriter.write(Integer.toString(volume.getCornerTwo().getX())); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerTwo().getY())); cornersWriter.newLine();
|
||||
cornersWriter.write(Integer.toString(volume.getCornerTwo().getZ())); cornersWriter.newLine();
|
||||
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
@ -328,7 +344,7 @@ public class ZoneVolumeMapper {
|
||||
int typeId;
|
||||
byte data;
|
||||
BlockState state;
|
||||
|
||||
|
||||
x = volume.getMinX();
|
||||
for (int i = 0; i < volume.getSizeX(); i++){
|
||||
y = volume.getMinY();
|
||||
@ -340,10 +356,10 @@ public class ZoneVolumeMapper {
|
||||
typeId = block.getTypeId();
|
||||
data = block.getData();
|
||||
state = block.getState();
|
||||
|
||||
|
||||
blocksOutput.write((byte)typeId);
|
||||
blocksOutput.write(data);
|
||||
|
||||
|
||||
if (state instanceof Sign) {
|
||||
// Signs
|
||||
String extra = "";
|
||||
@ -371,11 +387,12 @@ public class ZoneVolumeMapper {
|
||||
if (items != null) {
|
||||
for (ItemStack item : items) {
|
||||
if (item != null) {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null)
|
||||
extra += ";" + item.getData().getData() ;
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData() ;
|
||||
}
|
||||
extra += ";;";
|
||||
}
|
||||
}
|
||||
@ -383,7 +400,7 @@ public class ZoneVolumeMapper {
|
||||
invsWriter.newLine();
|
||||
}
|
||||
} else if (state instanceof Dispenser) {
|
||||
// Dispensers
|
||||
// Dispensers
|
||||
Dispenser dispenser = (Dispenser)state;
|
||||
Inventory inv = dispenser.getInventory();
|
||||
int size = inv.getSize();
|
||||
@ -398,11 +415,12 @@ public class ZoneVolumeMapper {
|
||||
if (items != null) {
|
||||
for (ItemStack item : items) {
|
||||
if (item != null) {
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null)
|
||||
extra += ";" + item.getData().getData() ;
|
||||
extra += item.getTypeId() + ";"
|
||||
+ item.getAmount() + ";"
|
||||
+ item.getDurability();
|
||||
if (item.getData() != null) {
|
||||
extra += ";" + item.getData().getData() ;
|
||||
}
|
||||
extra += ";;";
|
||||
}
|
||||
}
|
||||
@ -414,7 +432,7 @@ public class ZoneVolumeMapper {
|
||||
}
|
||||
catch (Exception e) {
|
||||
war.logWarn("Unexpected error while saving a block to " +
|
||||
" file for zone " + zoneName + ". Blocks saved so far: " + noOfSavedBlocks
|
||||
" file for zone " + zoneName + ". Blocks saved so far: " + noOfSavedBlocks
|
||||
+ "Position: x:" + x + " y:" + y + " z:" + z + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@ -426,22 +444,30 @@ public class ZoneVolumeMapper {
|
||||
x++;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
war.logWarn("Failed to write volume file " + zoneName +
|
||||
war.logWarn("Failed to write volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName +
|
||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName +
|
||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
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() +
|
||||
war.logWarn("Failed to close volume file " + volume.getName() +
|
||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -454,15 +480,15 @@ public class ZoneVolumeMapper {
|
||||
ZoneVolumeSaveJob job = new ZoneVolumeSaveJob(volume, zoneName, war);
|
||||
war.getServer().getScheduler().scheduleSyncDelayedTask(war, job, tickDelay);
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
File volFile= new File(path);
|
||||
if (volFile.exists()) {
|
||||
|
@ -8,30 +8,30 @@ import org.bukkit.entity.Player;
|
||||
* The purpose of this tool is twofold:
|
||||
* 1: Avoid client crashes due to bad color formating.
|
||||
* 2: Make color continue on word wrapping
|
||||
*
|
||||
*
|
||||
* In minecraft the degree sign is used as a prefix to another char to create a color.
|
||||
* For example the code for white is "\u00A7f".
|
||||
* For example the code for white is "\u00A7f".
|
||||
* The "\u00A7" is the unicode notation for the degree sign and the "f" means white.
|
||||
*
|
||||
*
|
||||
* When does minecraft wrap the text? After how many chars?
|
||||
* Answer:
|
||||
* Answer:
|
||||
* Because the font isn't monospace this differs depending on what you write.
|
||||
* However we can fit 53 "M" without wrapping and the 54th char would then wrap (be at the beginning of the next line instead)
|
||||
* As there is no broader char than "M" we can know for sure the minimum line length is 53.
|
||||
* Note that this means the number of DISPLAYED chars per row is 53.
|
||||
* A degree sign and the char after will NOT count, as they will not be displayed as chars.
|
||||
*
|
||||
*
|
||||
* Good to know: Numbers have the same font width as an M.
|
||||
*
|
||||
*
|
||||
* When does the client crash?
|
||||
* Answer:
|
||||
* Answer:
|
||||
* When a row ends with a degree char and optionally another sign after.
|
||||
* Another way to say the same: When a line ends with either a broken or valid color notation.
|
||||
* AND
|
||||
* The client will ALWAYS crash if the sign after the last displayed char in a row is a degree char.
|
||||
* A goofy way to explatin it:
|
||||
* For a line with only "M" and numbers, the fiftyfourth "displayed char" musn't be a degree sign.
|
||||
*
|
||||
*
|
||||
* WARNING:
|
||||
* Above is a hypothesis I have created based on what my experiments have shown.
|
||||
* I am fairly sure it is correct but please help me test it further.
|
||||
@ -39,53 +39,53 @@ import org.bukkit.entity.Player;
|
||||
public class ChatFixUtil {
|
||||
public final static char deg = '\u00A7';
|
||||
public final static int lineLength = 53;
|
||||
|
||||
|
||||
/**
|
||||
* This method wraps the msg for you at row lengths of 53,
|
||||
* avoids client crash scenarios and makes the previous color continue on
|
||||
* the next line.
|
||||
*
|
||||
* The upsides with filtering your messages through this method are:
|
||||
*
|
||||
* The upsides with filtering your messages through this method are:
|
||||
* - No client crashes.
|
||||
* - Line wrapping with preserved color.
|
||||
*
|
||||
*
|
||||
* The downsides are:
|
||||
* - The width of the chat window will not be used to it's fullest.
|
||||
* For example you can fit more that 53 commas (,) in a chatwindow row
|
||||
* but the line would break after 53 displayed chars.
|
||||
*
|
||||
*
|
||||
* Suggested usage:
|
||||
* NO NEED TO USE the fix method for static help pages in your plugin.
|
||||
* As the text is static you can make sure there is no client crash yourself
|
||||
* and be able to use the full line length.
|
||||
*
|
||||
*
|
||||
* DO USE in cases like where you output colored messages with playernames in your
|
||||
* plugin. As the player names have different length there is potential for client crash.
|
||||
*/
|
||||
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.
|
||||
String row = "";
|
||||
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;
|
||||
@ -95,26 +95,26 @@ public class ChatFixUtil {
|
||||
ret.add(row);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Removes the ending chars as long as they are deg or deg+'anychar' or a space
|
||||
* As I see it we would never want those chars at the end of a msg.
|
||||
*/
|
||||
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;
|
||||
@ -122,7 +122,7 @@ public class ChatFixUtil {
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This test util assumes line break after 53 displayed chars.
|
||||
* The fix method above breaks like that so this method should
|
||||
@ -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;
|
||||
@ -150,7 +149,7 @@ public class ChatFixUtil {
|
||||
}
|
||||
return "all ok";
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------//
|
||||
// Methods for effectively sending messages
|
||||
//----------------------------------------------//
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -198,15 +197,15 @@ public class ChatFixUtil {
|
||||
if (fix) {
|
||||
messages = ChatFixUtil.fix(messages);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -11,16 +11,16 @@ public class InventoryStash {
|
||||
|
||||
public InventoryStash(ItemStack[] contents) {
|
||||
this.setContents(contents);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public InventoryStash(ItemStack[] contents, ItemStack helmet, ItemStack chest, ItemStack legs, ItemStack feet) {
|
||||
this.setContents(contents);
|
||||
this.setHelmet(helmet);
|
||||
this.setChest(chest);
|
||||
this.setLegs(legs);
|
||||
this.setFeet(feet);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setContents(ItemStack[] contents) {
|
||||
@ -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,8 +60,8 @@ public class InventoryStash {
|
||||
}
|
||||
|
||||
public ItemStack getFeet() {
|
||||
return feet;
|
||||
return this.feet;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -30,5 +30,5 @@ public class SignHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -20,7 +20,7 @@ public class BlockInfo {
|
||||
public static Block getBlock(World world, BlockInfo info) {
|
||||
return world.getBlockAt(info.getX(), info.getY(), info.getZ());
|
||||
}
|
||||
|
||||
|
||||
public BlockInfo(int x, int y, int z, int type, byte data)
|
||||
{
|
||||
this.x = x;
|
||||
@ -29,7 +29,7 @@ public class BlockInfo {
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
public BlockInfo(Block block) {
|
||||
this.x = block.getX();
|
||||
this.y = block.getY();
|
||||
@ -41,7 +41,7 @@ public class BlockInfo {
|
||||
// this.signLines = sign.getLines();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// public BlockInfo(BlockState blockState) {
|
||||
// this.x = blockState.getX();
|
||||
// this.y = blockState.getY();
|
||||
@ -53,7 +53,7 @@ public class BlockInfo {
|
||||
//// this.signLines = sign.getLines();
|
||||
//// }
|
||||
// }
|
||||
|
||||
|
||||
// public BlockInfo(int typeID, byte data, String[] lines) {
|
||||
// type = typeID;
|
||||
// this.data = data;
|
||||
@ -61,46 +61,46 @@ 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
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
|
||||
public void setZ(int z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
|
||||
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() {
|
||||
// if (is(Material.SIGN) || is(Material.SIGN_POST)){
|
||||
// return new String[4] {"", ""};
|
||||
|
@ -7,9 +7,9 @@ import org.bukkit.block.Block;
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*
|
||||
* Broken, don't use.
|
||||
*
|
||||
*/
|
||||
@ -23,50 +23,50 @@ 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(),
|
||||
newCenter.getBlockY(),
|
||||
newCenter.getBlockZ()),
|
||||
this.changeCenter(this.world.getBlockAt(newCenter.getBlockX(),
|
||||
newCenter.getBlockY(),
|
||||
newCenter.getBlockZ()),
|
||||
this.sideSize);
|
||||
}
|
||||
|
||||
|
||||
public void changeCenter(Block newCenter, int sideSize) {
|
||||
this.resetBlocks();
|
||||
this.center = newCenter;
|
||||
this.sideSize = sideSize;
|
||||
this.calculateCorners();
|
||||
}
|
||||
|
||||
|
||||
public void setCenter(Block block) {
|
||||
this.center = block;
|
||||
}
|
||||
|
||||
|
||||
public void calculateCorners() {
|
||||
int topHalfOfSide = 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);
|
||||
|
||||
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);
|
||||
int topHalfOfSide = this.sideSize / 2;
|
||||
|
||||
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 (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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,5 @@ public class NotNorthwestException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -5736463256274556866L;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.tommytony.war.volumes;
|
||||
public class NotSoutheastException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4347064837067648341L;
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.tommytony.war.volumes;
|
||||
public class TooBigException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 61793179891881015L;
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.tommytony.war.volumes;
|
||||
public class TooSmallException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1641366536434076088L;
|
||||
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.block.BlockFace;
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -19,93 +19,89 @@ public class VerticalVolume extends Volume{
|
||||
super(name, war, world);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@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++;
|
||||
}
|
||||
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++;
|
||||
@ -147,13 +143,13 @@ public class VerticalVolume extends Volume{
|
||||
y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
private boolean resetBlock(int oldBlockType, byte oldBlockData, Block currentBlock) {
|
||||
if (currentBlock.getTypeId() != oldBlockType ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() != oldBlockData) ||
|
||||
@ -176,5 +172,5 @@ public class VerticalVolume extends Volume{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import bukkit.tommytony.war.War;
|
||||
import com.tommytony.war.jobs.BlockResetJob;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -35,30 +35,30 @@ public class Volume {
|
||||
private byte[][][] blockDatas = null;
|
||||
private HashMap<String, String[]> signLines = new HashMap<String, String[]>();
|
||||
private HashMap<String, List<ItemStack>> invBlockContents = new HashMap<String, List<ItemStack>>();
|
||||
private War war;
|
||||
private War war;
|
||||
|
||||
public Volume(String name, War war, World world) {
|
||||
this.name = name;
|
||||
this.war = war;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
this.cornerOne = new BlockInfo(block);
|
||||
}
|
||||
|
||||
|
||||
public void setCornerOne(BlockInfo blockInfo) {
|
||||
this.cornerOne = blockInfo;
|
||||
}
|
||||
|
||||
|
||||
public int saveBlocks() {
|
||||
// BlockSaveJob job = new BlockSaveJob(this);
|
||||
// war.getServer().getScheduler().scheduleSyncDelayedTask(war, job);
|
||||
@ -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();
|
||||
@ -90,7 +90,7 @@ public class Volume {
|
||||
if (sign.getLines() != null) {
|
||||
this.getSignLines().put("sign-" + i + "-" + j + "-" + k, sign.getLines());
|
||||
}
|
||||
|
||||
|
||||
} else if (state instanceof Chest) {
|
||||
// Chests
|
||||
Chest chest = (Chest)state;
|
||||
@ -105,7 +105,7 @@ public class Volume {
|
||||
}
|
||||
this.getInvBlockContents().put("chest-" + i + "-" + j + "-" + k, items);
|
||||
} else if (state instanceof Dispenser) {
|
||||
// Dispensers
|
||||
// Dispensers
|
||||
Dispenser dispenser = (Dispenser)state;
|
||||
Inventory inv = dispenser.getInventory();
|
||||
int size = inv.getSize();
|
||||
@ -118,10 +118,10 @@ public class Volume {
|
||||
}
|
||||
this.getInvBlockContents().put("dispenser-" + i + "-" + j + "-" + k, items);
|
||||
}
|
||||
|
||||
|
||||
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 {
|
||||
@ -132,53 +132,53 @@ public class Volume {
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
return noOfSavedBlocks;
|
||||
}
|
||||
|
||||
|
||||
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 ) ||
|
||||
(currentBlockId == oldBlockType && currentBlock.getData() == oldBlockData &&
|
||||
(oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId()
|
||||
(oldBlockType == Material.WALL_SIGN.getId() || oldBlockType == Material.SIGN_POST.getId()
|
||||
|| oldBlockType == Material.CHEST.getId() || oldBlockType == Material.DISPENSER.getId())
|
||||
)
|
||||
) {
|
||||
if (oldBlockType == Material.WALL_SIGN.getId()
|
||||
if (oldBlockType == Material.WALL_SIGN.getId()
|
||||
|| 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);
|
||||
}
|
||||
}
|
||||
@ -219,7 +227,7 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
} else if (oldBlockType == Material.DISPENSER.getId()) {
|
||||
// Dispensers
|
||||
// Dispensers
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
BlockState state = currentBlock.getState();
|
||||
@ -240,28 +248,28 @@ public class Volume {
|
||||
}
|
||||
} else if (oldBlockType == Material.WOODEN_DOOR.getId() || oldBlockType == Material.IRON_DOOR_BLOCK.getId()){
|
||||
// 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))
|
||||
} else if (((oldBlockType == Material.TORCH.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.REDSTONE_TORCH_ON.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (oldBlockType == Material.LEVER.getId() && ((oldBlockData & 0x02) == 0x02))
|
||||
|| (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,8 +286,8 @@ public class Volume {
|
||||
}
|
||||
visitedBlocks++;
|
||||
} catch (Exception e) {
|
||||
this.getWar().getLogger().warning("Failed to reset block in volume " + getName() + ". Visited blocks so far:" + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks +
|
||||
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();
|
||||
} finally {
|
||||
@ -290,10 +298,10 @@ public class Volume {
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().logWarn("Failed to reset volume " + getName() + " blocks. Blocks visited: " + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks + ". Error at x:" + x + " y:" + y + " z:" + z
|
||||
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();
|
||||
}
|
||||
@ -304,122 +312,122 @@ public class Volume {
|
||||
// TODO Auto-generated method stub
|
||||
return this.blockDatas;
|
||||
}
|
||||
|
||||
|
||||
public void setBlockDatas(byte[][][] data) {
|
||||
this.blockDatas = data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setCornerTwo(Block block) {
|
||||
this.cornerTwo = new BlockInfo(block);
|
||||
}
|
||||
|
||||
|
||||
public void setCornerTwo(BlockInfo blockInfo) {
|
||||
this.cornerTwo = blockInfo;
|
||||
}
|
||||
|
||||
|
||||
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++;
|
||||
}
|
||||
@ -451,28 +459,28 @@ public class Volume {
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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++;
|
||||
@ -481,25 +489,25 @@ public class Volume {
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void switchMaterials(Material[] oldTypes, Material newType) {
|
||||
try {
|
||||
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);
|
||||
@ -516,9 +524,9 @@ public class Volume {
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
|
@ -11,7 +11,7 @@ import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.mappers.ZoneVolumeMapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author tommytony
|
||||
*
|
||||
*/
|
||||
@ -24,40 +24,40 @@ public class ZoneVolume extends Volume {
|
||||
super(name, war, world);
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBlockTypes(int[][][] blockTypes) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBlockDatas(byte[][][] blockData) {
|
||||
return;
|
||||
@ -66,268 +66,255 @@ 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) {
|
||||
// northwest defaults to corner 1
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
// southeast defaults to corner 2
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -347,7 +334,7 @@ public class ZoneVolume extends Volume {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
}
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
@ -415,7 +402,7 @@ public class ZoneVolume extends Volume {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
}
|
||||
z++;
|
||||
}
|
||||
x++;
|
||||
@ -432,20 +419,20 @@ public class ZoneVolume extends Volume {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if (resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
}
|
||||
z++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.getWar().logWarn("Failed to reset wall " + wall + " in volume " + getName() + ". " + e.getClass().toString() + " " + e.getMessage());
|
||||
}
|
||||
return noOfResetBlocks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean resetBlock(int oldBlockType, byte oldBlockData, Block currentBlock) {
|
||||
if (currentBlock.getTypeId() != oldBlockType ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() != oldBlockData) ||
|
||||
|
Loading…
Reference in New Issue
Block a user