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 x = location.getBlockX();
int y = location.getBlockY(); int y = location.getBlockY();
int z = location.getBlockZ(); int z = location.getBlockZ();
volume = new CenteredVolume("name", location, war, warzone); volume = new CenteredVolume("name", location, 5, war, warzone);
volume.setSideSize(5);
volume.saveBlocks(); volume.saveBlocks();
this.addMonumentBlocks(); this.addMonumentBlocks();

View File

@ -1,21 +1,22 @@
package com.tommytony.war; 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.BlockState;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import com.tommytony.war.volumes.CenteredVolume; import com.tommytony.war.volumes.CenteredVolume;
import com.tommytony.war.volumes.Volume;
import java.util.ArrayList;
import java.util.List;
public class Team { public class Team {
private List<Player> players = new ArrayList<Player>(); private List<Player> players = new ArrayList<Player>();
private Location teamSpawn = null; private Location teamSpawn = null;
private String name; private String name;
private int remainingTickets; private int remainingTickets;
private int startTickets;
private int points = 0; private int points = 0;
private CenteredVolume volume; private CenteredVolume volume;
private final War war; private final War war;
@ -26,14 +27,16 @@ public class Team {
this.warzone = warzone; this.warzone = warzone;
this.setName(name); this.setName(name);
this.teamSpawn = teamSpawn; 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) { public void setTeamSpawn(Location teamSpawn) {
if(teamSpawn != null) volume.resetBlocks();
this.teamSpawn = teamSpawn; 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(); volume.saveBlocks();
// Set the spawn // Set the spawn

View File

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

View File

@ -74,7 +74,7 @@ public class WarPlayerListener extends PlayerListener {
} else { } else {
boolean warped = false; boolean warped = false;
for(Warzone warzone : war.getWarzones()) { for(Warzone warzone : war.getWarzones()) {
if(warzone.getName().equals(split[1])){ if(warzone.getName().equals(split[1]) && warzone.getTeleport() != null){
player.teleportTo(warzone.getTeleport()); player.teleportTo(warzone.getTeleport());
warped = true; warped = true;
player.sendMessage(war.str("You've landed in warzone " + warzone.getName() + player.sendMessage(war.str("You've landed in warzone " + warzone.getName() +
@ -232,8 +232,6 @@ public class WarPlayerListener extends PlayerListener {
} }
} }
if(team != null) { if(team != null) {
team.getVolume().resetBlocks();
team.setTeamSpawn(player.getLocation());
team.setTeamSpawn(player.getLocation()); team.setTeamSpawn(player.getLocation());
player.sendMessage(war.str("Team " + team.getName() + " spawn relocated.")); player.sendMessage(war.str("Team " + team.getName() + " spawn relocated."));
} else { } else {
@ -463,6 +461,7 @@ public class WarPlayerListener extends PlayerListener {
Location to = event.getTo(); Location to = event.getTo();
Warzone playerWarzone = war.getPlayerWarzone(player.getName()); Warzone playerWarzone = war.getPlayerWarzone(player.getName());
if(playerWarzone != null) {
Team playerTeam = war.getPlayerTeam(player.getName()); Team playerTeam = war.getPlayerTeam(player.getName());
if(player != null && from != null && to != null && if(player != null && from != null && to != null &&
playerTeam != null && !playerWarzone.getVolume().contains(to)) { playerTeam != null && !playerWarzone.getVolume().contains(to)) {
@ -501,6 +500,7 @@ public class WarPlayerListener extends PlayerListener {
player.setHealth(20); player.setHealth(20);
player.sendMessage(war.str("Your dance pleases the monument's voodoo. You gain full health!")); 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; 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.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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 { public class Warzone {
private String name; private String name;
private VerticalVolume volume; private VerticalVolume volume;
@ -34,6 +39,7 @@ public class Warzone {
this.friendlyFire = war.getDefaultFriendlyFire(); this.friendlyFire = war.getDefaultFriendlyFire();
this.setLifePool(war.getDefaultLifepool()); this.setLifePool(war.getDefaultLifepool());
this.setLoadout(war.getDefaultLoadout()); this.setLoadout(war.getDefaultLoadout());
this.volume = new VerticalVolume(name, war, this);
} }
public boolean ready() { public boolean ready() {
@ -90,11 +96,13 @@ public class Warzone {
block.setType(Material.SignPost); block.setType(Material.SignPost);
block.setData((byte)10); // towards southeast block.setData((byte)10); // towards southeast
Sign sign = (Sign)block; BlockState state = block.getState();
Sign sign = (Sign)state;
sign.setLine(0, "Northwest"); sign.setLine(0, "Northwest");
sign.setLine(1, "corner of"); sign.setLine(1, "corner of");
sign.setLine(2, "warzone"); sign.setLine(2, "warzone");
sign.setLine(3, name); sign.setLine(3, name);
state.update();
saveState(); saveState();
} }
@ -116,7 +124,7 @@ public class Warzone {
removeSoutheast(); removeSoutheast();
} }
this.southeast = southeast; 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 // add sign
int x = southeast.getBlockX(); int x = southeast.getBlockX();
int y = southeast.getBlockY(); int y = southeast.getBlockY();
@ -125,11 +133,13 @@ public class Warzone {
block.setType(Material.SignPost); block.setType(Material.SignPost);
block.setData((byte)2);; block.setData((byte)2);;
Sign sign = (Sign)block; BlockState state = block.getState();
Sign sign = (Sign)state;
sign.setLine(0, "Southeast"); sign.setLine(0, "Southeast");
sign.setLine(1, "corner of"); sign.setLine(1, "corner of");
sign.setLine(2, "warzone"); sign.setLine(2, "warzone");
sign.setLine(3, name); sign.setLine(3, name);
state.update();
saveState(); saveState();
} }
@ -175,6 +185,7 @@ public class Warzone {
respawnPlayer(team, player); respawnPlayer(team, player);
} }
team.setRemainingTickets(lifePool); team.setRemainingTickets(lifePool);
team.getVolume().resetBlocks();
team.resetSign(); team.resetSign();
} }

View File

@ -11,9 +11,10 @@ public class CenteredVolume extends Volume {
private Block center; private Block center;
private int sideSize = -1; 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); super(name, war, warzone);
setCenter(warzone.getWorld().getBlockAt(center.getBlockX(), center.getBlockY(), center.getBlockZ())); setCenter(warzone.getWorld().getBlockAt(center.getBlockX(), center.getBlockY(), center.getBlockZ()));
setSideSize(sideSize);
} }
public void setCenter(Block block) { public void setCenter(Block block) {

View File

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