Lots of bugs in my volumes stuff. Still somewhat broken.

This commit is contained in:
taoneill 2011-01-09 02:15:51 -05:00
parent 9204df2dc2
commit 07b3b21077
7 changed files with 83 additions and 66 deletions

View File

@ -21,8 +21,7 @@ public class Monument {
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
volume = new CenteredVolume("name", location, war, warzone);
volume.setSideSize(5);
volume = new CenteredVolume("name", location, 5, war, warzone);
volume.saveBlocks();
this.addMonumentBlocks();

View File

@ -1,21 +1,22 @@
package com.tommytony.war;
import org.bukkit.*;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Block;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Player;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import com.tommytony.war.volumes.CenteredVolume;
import com.tommytony.war.volumes.Volume;
import java.util.ArrayList;
import java.util.List;
public class Team {
private List<Player> players = new ArrayList<Player>();
private Location teamSpawn = null;
private String name;
private int remainingTickets;
private int startTickets;
private int points = 0;
private CenteredVolume volume;
private final War war;
@ -26,14 +27,16 @@ public class Team {
this.warzone = warzone;
this.setName(name);
this.teamSpawn = teamSpawn;
this.volume = new CenteredVolume(name, teamSpawn, war, warzone);
this.volume = new CenteredVolume(name, teamSpawn, 5, war, warzone);
}
public void setTeamSpawn(Location teamSpawn) {
if(teamSpawn != null) volume.resetBlocks();
this.teamSpawn = teamSpawn;
Volume newTeamSpawn = new CenteredVolume(name, teamSpawn, war, warzone);
// this resets the block to old state
volume.setCenter(warzone.getWorld().getBlockAt(teamSpawn.getBlockX(), teamSpawn.getBlockY(), teamSpawn.getBlockZ()));
volume.setSideSize(5);
volume.saveBlocks();
// Set the spawn

View File

@ -105,7 +105,7 @@ public class War extends JavaPlugin {
public Warzone warzone(Location location) {
for(Warzone warzone : warzones) {
if(warzone.getVolume().contains(location)) return warzone;
if(warzone.getVolume() != null && warzone.getVolume().contains(location)) return warzone;
}
return null;
}

View File

@ -74,7 +74,7 @@ public class WarPlayerListener extends PlayerListener {
} else {
boolean warped = false;
for(Warzone warzone : war.getWarzones()) {
if(warzone.getName().equals(split[1])){
if(warzone.getName().equals(split[1]) && warzone.getTeleport() != null){
player.teleportTo(warzone.getTeleport());
warped = true;
player.sendMessage(war.str("You've landed in warzone " + warzone.getName() +
@ -232,8 +232,6 @@ public class WarPlayerListener extends PlayerListener {
}
}
if(team != null) {
team.getVolume().resetBlocks();
team.setTeamSpawn(player.getLocation());
team.setTeamSpawn(player.getLocation());
player.sendMessage(war.str("Team " + team.getName() + " spawn relocated."));
} else {
@ -463,6 +461,7 @@ public class WarPlayerListener extends PlayerListener {
Location to = event.getTo();
Warzone playerWarzone = war.getPlayerWarzone(player.getName());
if(playerWarzone != null) {
Team playerTeam = war.getPlayerTeam(player.getName());
if(player != null && from != null && to != null &&
playerTeam != null && !playerWarzone.getVolume().contains(to)) {
@ -501,6 +500,7 @@ public class WarPlayerListener extends PlayerListener {
player.setHealth(20);
player.sendMessage(war.str("Your dance pleases the monument's voodoo. You gain full health!"));
}
}
}

View File

@ -1,15 +1,20 @@
package com.tommytony.war;
import org.bukkit.*;
import org.bukkit.block.Sign;
import com.tommytony.war.volumes.CenteredVolume;
import com.tommytony.war.volumes.VerticalVolume;
import com.tommytony.war.volumes.Volume;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Block;
import org.bukkit.ItemStack;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Player;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import com.tommytony.war.volumes.VerticalVolume;
import com.tommytony.war.volumes.Volume;
public class Warzone {
private String name;
private VerticalVolume volume;
@ -34,6 +39,7 @@ public class Warzone {
this.friendlyFire = war.getDefaultFriendlyFire();
this.setLifePool(war.getDefaultLifepool());
this.setLoadout(war.getDefaultLoadout());
this.volume = new VerticalVolume(name, war, this);
}
public boolean ready() {
@ -90,11 +96,13 @@ public class Warzone {
block.setType(Material.SignPost);
block.setData((byte)10); // towards southeast
Sign sign = (Sign)block;
BlockState state = block.getState();
Sign sign = (Sign)state;
sign.setLine(0, "Northwest");
sign.setLine(1, "corner of");
sign.setLine(2, "warzone");
sign.setLine(3, name);
state.update();
saveState();
}
@ -116,7 +124,7 @@ public class Warzone {
removeSoutheast();
}
this.southeast = southeast;
this.volume.setCornerOne(world.getBlockAt(southeast.getBlockX(), southeast.getBlockY(), southeast.getBlockZ()));
this.volume.setCornerTwo(world.getBlockAt(southeast.getBlockX(), southeast.getBlockY(), southeast.getBlockZ()));
// add sign
int x = southeast.getBlockX();
int y = southeast.getBlockY();
@ -125,11 +133,13 @@ public class Warzone {
block.setType(Material.SignPost);
block.setData((byte)2);;
Sign sign = (Sign)block;
BlockState state = block.getState();
Sign sign = (Sign)state;
sign.setLine(0, "Southeast");
sign.setLine(1, "corner of");
sign.setLine(2, "warzone");
sign.setLine(3, name);
state.update();
saveState();
}
@ -175,6 +185,7 @@ public class Warzone {
respawnPlayer(team, player);
}
team.setRemainingTickets(lifePool);
team.getVolume().resetBlocks();
team.resetSign();
}

View File

@ -11,9 +11,10 @@ public class CenteredVolume extends Volume {
private Block center;
private int sideSize = -1;
public CenteredVolume(String name, Location center, War war, Warzone warzone) {
public CenteredVolume(String name, Location center, int sideSize, War war, Warzone warzone) {
super(name, war, warzone);
setCenter(warzone.getWorld().getBlockAt(center.getBlockX(), center.getBlockY(), center.getBlockZ()));
setSideSize(sideSize);
}
public void setCenter(Block block) {

View File

@ -6,6 +6,7 @@ import org.bukkit.Block;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import com.tommytony.war.War;
@ -86,11 +87,13 @@ public class Volume {
currentBlock.setType(oldBlockInfo.getType());
currentBlock.setData(oldBlockInfo.getData());
if(oldBlockInfo.is(Material.Sign) || oldBlockInfo.is(Material.SignPost)) {
Sign currentSign = (Sign) currentBlock;
BlockState state = currentBlock.getState();
Sign currentSign = (Sign) state;
currentSign.setLine(0, oldBlockInfo.getSignLines()[0]);
currentSign.setLine(1, oldBlockInfo.getSignLines()[0]);
currentSign.setLine(2, oldBlockInfo.getSignLines()[0]);
currentSign.setLine(3, oldBlockInfo.getSignLines()[0]);
state.update();
}
noOfResetBlocks++;
}
@ -258,7 +261,7 @@ public class Volume {
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
return x <= getMaxX() && x >= getMinX() &&
return hasTwoCorners() && x <= getMaxX() && x >= getMinX() &&
y <= getMaxY() && y >= getMinY() &&
z <= getMaxZ() && z >= getMinZ();
}
@ -267,7 +270,7 @@ public class Volume {
int x = block.getX();
int y = block.getY();
int z = block.getZ();
return x <= getMaxX() && x >= getMinX() &&
return hasTwoCorners() && x <= getMaxX() && x >= getMinX() &&
y <= getMaxY() && y >= getMinY() &&
z <= getMaxZ() && z >= getMinZ();
}