Playtesting v0.3. Bugs everywhere getting fixed. No more spamming anything. Weird crash occured twice. Scary. Otherwise monuments work great and its a lot of fun.

This commit is contained in:
taoneill 2011-01-17 22:58:46 -05:00
parent 6cc5ee64bc
commit 6dfb261c05
9 changed files with 122 additions and 70 deletions

View File

@ -71,7 +71,7 @@ public class War extends JavaPlugin {
if(warHub != null) { if(warHub != null) {
warHub.getVolume().resetBlocks(); warHub.getVolume().resetBlocks();
} }
Logger.getLogger("Minecraft").info("All warzone blocks reset. War v" + version + " disabled."); Logger.getLogger("Minecraft").info("All War blocks reset. War v" + version + " disabled.");
} }
public void onEnable() { public void onEnable() {
@ -82,9 +82,9 @@ public class War extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Highest, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this); //pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
@ -574,13 +574,14 @@ public class War extends JavaPlugin {
Team newTeam = new Team(name, teamMaterial, player.getLocation(), this, warzone); Team newTeam = new Team(name, teamMaterial, player.getLocation(), this, warzone);
newTeam.setRemainingTickets(warzone.getLifePool()); newTeam.setRemainingTickets(warzone.getLifePool());
warzone.getTeams().add(newTeam); warzone.getTeams().add(newTeam);
newTeam.setTeamSpawn(player.getLocation());
if(warzone.getLobby() != null) { if(warzone.getLobby() != null) {
warzone.getLobby().getVolume().resetBlocks(); warzone.getLobby().getVolume().resetBlocks();
warzone.getVolume().resetWallBlocks(warzone.getLobby().getWall()); warzone.getVolume().resetWallBlocks(warzone.getLobby().getWall());
warzone.addZoneOutline(warzone.getLobby().getWall()); warzone.addZoneOutline(warzone.getLobby().getWall());
warzone.getLobby().initialize(); warzone.getLobby().initialize();
} }
newTeam.setTeamSpawn(player.getLocation());
player.sendMessage(this.str("Team " + name + " created with spawn here.")); player.sendMessage(this.str("Team " + name + " created with spawn here."));
} }

View File

@ -29,6 +29,7 @@ public class WarBlockListener extends BlockListener {
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Block block = event.getBlock(); Block block = event.getBlock();
boolean captured = false;
if(player != null) { if(player != null) {
Team team = war.getPlayerTeam(player.getName()); Team team = war.getPlayerTeam(player.getName());
Warzone zone = war.getPlayerWarzone(player.getName()); Warzone zone = war.getPlayerWarzone(player.getName());
@ -43,25 +44,28 @@ public class WarBlockListener extends BlockListener {
for(Team t : teams) { for(Team t : teams) {
t.teamcast(war.str("Monument " + monument.getName() + " has been captured by team " + team.getName() + ".")); t.teamcast(war.str("Monument " + monument.getName() + " has been captured by team " + team.getName() + "."));
} }
return; // important otherwise cancelled down a few line by isImportantblock
captured = true; // important otherwise cancelled down a few line by isImportantblock
} else { } else {
player.sendMessage(war.str("You can't capture a monument without a block of your team's material. Get one from your team spawn.")); player.sendMessage(war.str("You can't capture a monument without a block of your team's material. Get one from your team spawn."));
event.setCancelled(true); event.setCancelled(true);
} }
} }
if(zone != null && zone.isImportantBlock(block) && !isZoneMaker){ if(!captured) {
player.sendMessage(war.str("Can't build here.")); if(zone != null && zone.isImportantBlock(block) && !isZoneMaker){
event.setCancelled(true); player.sendMessage(war.str("Can't build here."));
} event.setCancelled(true);
// protect warzone lobbies }
if(block != null) { // protect warzone lobbies
for(Warzone wz: war.getWarzones()) { if(block != null) {
if(wz.getLobby() != null && wz.getLobby().getVolume().contains(block) && !isZoneMaker) { for(Warzone wz: war.getWarzones()) {
player.sendMessage(war.str("Can't build here.")); if(wz.getLobby() != null && wz.getLobby().getVolume().contains(block) && !isZoneMaker) {
event.setCancelled(true); player.sendMessage(war.str("Can't build here."));
} event.setCancelled(true);
}
}
} }
} }
} }
} }
@ -77,7 +81,18 @@ public class WarBlockListener extends BlockListener {
// can't actually destroy blocks in a warzone if not part of a team // can't actually destroy blocks in a warzone if not part of a team
player.sendMessage(war.str("Can't destroy part of a warzone if you're not in a team.")); player.sendMessage(war.str("Can't destroy part of a warzone if you're not in a team."));
event.setCancelled(true); event.setCancelled(true);
} else if(warzone != null && warzone.isImportantBlock(block) && !isZoneMaker) { } else if(team != null && block != null && warzone != null
&& warzone.isMonumentCenterBlock(block)){
Monument monument = warzone.getMonumentFromCenterBlock(block);
if(monument.hasOwner()) {
List<Team> teams = warzone.getTeams();
for(Team t : teams) {
t.teamcast(war.str("Team " + monument.getOwnerTeam().getName() + " loses control of monument " + monument.getName()));
}
monument.uncapture();
}
}else if(warzone != null && warzone.isImportantBlock(block) && !isZoneMaker) {
if(team != null && team.getVolume().contains(block)) { if(team != null && team.getVolume().contains(block)) {
if(player.getInventory().contains(team.getMaterial())) { if(player.getInventory().contains(team.getMaterial())) {
player.sendMessage(war.str("You already have a " + team.getName() + " block.")); player.sendMessage(war.str("You already have a " + team.getName() + " block."));
@ -88,18 +103,7 @@ public class WarBlockListener extends BlockListener {
player.sendMessage(war.str("Can't destroy this.")); player.sendMessage(war.str("Can't destroy this."));
event.setCancelled(true); event.setCancelled(true);
} }
} else if(team != null && block != null && warzone != null }
&& warzone.isMonumentCenterBlock(block)
){
Monument monument = warzone.getMonumentFromCenterBlock(block);
if(monument.hasOwner()) {
monument.uncapture();
List<Team> teams = warzone.getTeams();
for(Team t : teams) {
t.teamcast(war.str("Team " + team.getName() + " loses control of monument " + monument.getName()));
}
}
}
// protect warzone lobbies // protect warzone lobbies
if(block != null) { if(block != null) {

View File

@ -24,7 +24,7 @@ public class WarEntityListener extends EntityListener {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
public void onEntityDamage(EntityDamageEvent event) { //public void onEntityDamage(EntityDamageEvent event) {
// // BUKKIT !! // // BUKKIT !!
// //Entity attacker = event.getDamager(); // //Entity attacker = event.getDamager();
// Entity defender = event.getEntity(); // Entity defender = event.getEntity();
@ -76,7 +76,7 @@ public class WarEntityListener extends EntityListener {
// event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team // event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team
// } // }
// } // }
} //}
// public void onEntityDamaged(EntityDamagedEvent event) { // public void onEntityDamaged(EntityDamagedEvent event) {
// Entity damaged = event.getEntity(); // Entity damaged = event.getEntity();

View File

@ -5,22 +5,16 @@ import java.util.Random;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import com.tommytony.war.Monument;
import com.tommytony.war.Team; import com.tommytony.war.Team;
import com.tommytony.war.TeamMaterials; import com.tommytony.war.TeamMaterials;
import com.tommytony.war.WarHub; import com.tommytony.war.WarHub;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby; import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarMapper;
import com.tommytony.war.mappers.WarzoneMapper;
/** /**
@ -86,7 +80,7 @@ public class WarPlayerListener extends PlayerListener {
List<Team> teams = playerWarzone.getTeams(); List<Team> teams = playerWarzone.getTeams();
for(Team t : teams) { for(Team t : teams) {
t.teamcast(war.str("The battle is over. Team " + team.getName() + " lost: " t.teamcast(war.str("The battle is over. Team " + team.getName() + " lost: "
+ player.getName() + " hit the bottom of their life pool." )); + player.getName() + " died and there were no lives left in their life pool." ));
if(!t.getName().equals(team.getName())) { if(!t.getName().equals(team.getName())) {
// all other teams get a point // all other teams get a point

View File

@ -4,6 +4,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.HumanEntity;
import bukkit.tommytony.war.War; import bukkit.tommytony.war.War;
@ -34,6 +35,8 @@ public class Monument {
} }
public void addMonumentBlocks() { public void addMonumentBlocks() {
this.volume.setToMaterial(Material.AIR);
this.ownerTeam = null; this.ownerTeam = null;
int x = location.getBlockX(); int x = location.getBlockX();
int y = location.getBlockY(); int y = location.getBlockY();
@ -120,12 +123,12 @@ public class Monument {
public void capture(Team team) { public void capture(Team team) {
ownerTeam = team; ownerTeam = team;
warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(team.getMaterial()); //warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(team.getMaterial());
} }
public void uncapture() { public void uncapture() {
ownerTeam = null; ownerTeam = null;
warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(Material.OBSIDIAN); //warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(Material.OBSIDIAN);
} }
@ -158,5 +161,10 @@ public class Monument {
public void setVolume(Volume newVolume) { public void setVolume(Volume newVolume) {
this.volume = newVolume; this.volume = newVolume;
}
public Team getOwnerTeam() {
return ownerTeam;
} }
} }

View File

@ -54,6 +54,9 @@ public class Team {
} }
private void initializeTeamSpawn(Location teamSpawn) { private void initializeTeamSpawn(Location teamSpawn) {
// make air
this.volume.setToMaterial(Material.AIR);
// Set the spawn // Set the spawn
int x = teamSpawn.getBlockX(); int x = teamSpawn.getBlockX();
int y = teamSpawn.getBlockY(); int y = teamSpawn.getBlockY();
@ -208,12 +211,14 @@ public class Team {
block.setData((byte)6); block.setData((byte)6);
BlockState state = block.getState(); BlockState state = block.getState();
Sign sign = (Sign) state; if(state instanceof Sign) {
sign.setLine(0, "Team " + name); Sign sign = (Sign) state;
sign.setLine(1, remainingTickets + "/" + warzone.getLifePool() + " lives left"); sign.setLine(0, "Team " + name);
sign.setLine(2, points + "/" + warzone.getScoreCap() + " pts"); sign.setLine(1, remainingTickets + "/" + warzone.getLifePool() + " lives left");
sign.setLine(3, players.size() + "/" + warzone.getTeamCap() + " players"); sign.setLine(2, points + "/" + warzone.getScoreCap() + " pts");
state.update(true); sign.setLine(3, players.size() + "/" + warzone.getTeamCap() + " players");
state.update(true);
}
if(warzone.getLobby() != null) { if(warzone.getLobby() != null) {
warzone.getLobby().resetTeamGateSign(this); warzone.getLobby().resetTeamGateSign(this);

View File

@ -98,12 +98,21 @@ public class WarHub {
if(signBlock.getType() != Material.SIGN_POST) signBlock.setType(Material.SIGN_POST); if(signBlock.getType() != Material.SIGN_POST) signBlock.setType(Material.SIGN_POST);
signBlock.setData((byte)8); signBlock.setData((byte)8);
BlockState state = signBlock.getState(); BlockState state = signBlock.getState();
Sign sign = (Sign) state; if(state instanceof Sign) {
sign.setLine(0, "War hub"); Sign sign = (Sign) state;
sign.setLine(1, ""); sign.setLine(0, "War hub");
sign.setLine(2, "Pick you battle!"); sign.setLine(1, "");
sign.setLine(3, ""); sign.setLine(2, "Pick you battle!");
state.update(true); sign.setLine(3, "");
state.update(true);
}
// Warzone signs
for(Warzone zone : war.getWarzones()) {
if(zone.ready()) {
war.getWarHub().resetZoneSign(zone);
}
}
} }
} }
@ -126,12 +135,14 @@ public class WarHub {
} }
BlockState state = block.getState(); BlockState state = block.getState();
Sign sign = (Sign) state; if(state instanceof Sign) {
sign.setLine(0, "Warzone"); Sign sign = (Sign) state;
sign.setLine(1, zone.getName()); sign.setLine(0, "Warzone");
sign.setLine(2, zonePlayers + "/" + zoneCap + " players"); sign.setLine(1, zone.getName());
sign.setLine(3, zone.getTeams().size() + " teams"); sign.setLine(2, zonePlayers + "/" + zoneCap + " players");
state.update(true); sign.setLine(3, zone.getTeams().size() + " teams");
state.update(true);
}
} }
public void setVolume(Volume vol) { public void setVolume(Volume vol) {

View File

@ -145,6 +145,7 @@ public class ZoneLobby {
if(lobbyMiddleWallBlock != null && volume != null && volume.isSaved()) { if(lobbyMiddleWallBlock != null && volume != null && volume.isSaved()) {
// flatten the area (set all but floor to air, then replace any floor air blocks with glass) // 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.setToMaterial(Material.AIR);
this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS); // beautiful this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS); // beautiful
@ -154,7 +155,7 @@ public class ZoneLobby {
// add warhub sign // add warhub sign
String[] lines = new String[4]; String[] lines = new String[4];
lines[0] = ""; lines[0] = "";
lines[1] = "War hub"; lines[1] = "To War hub";
lines[2] = ""; lines[2] = "";
lines[3] = ""; lines[3] = "";
resetGateSign(warHubLinkGate, lines, false); resetGateSign(warHubLinkGate, lines, false);
@ -516,12 +517,15 @@ public class ZoneLobby {
if(awayFromWall) block.setData((byte)0); if(awayFromWall) block.setData((byte)0);
else block.setData((byte)8); else block.setData((byte)8);
} }
BlockState state = block.getState(); BlockState state = block.getState();
Sign sign = (Sign) state; if(state instanceof Sign) {
sign.setLine(0, lines[0]); Sign sign = (Sign) state;
sign.setLine(1, lines[1]); sign.setLine(0, lines[0]);
sign.setLine(2, lines[2]); sign.setLine(1, lines[1]);
sign.setLine(3, lines[3]); sign.setLine(2, lines[2]);
state.update(true); sign.setLine(3, lines[3]);
state.update(true);
}
} }
} }

View File

@ -70,9 +70,7 @@ public class Volume {
public int resetBlocks() { public int resetBlocks() {
int noOfResetBlocks = 0; int noOfResetBlocks = 0;
Material[] toAirMaterials = new Material[1]; clearBlocksThatDontFloat();
toAirMaterials[0] = Material.SIGN_POST;
switchMaterials(toAirMaterials, Material.AIR);
try { try {
if(hasTwoCorners() && getBlockInfos() != null) { if(hasTwoCorners() && getBlockInfos() != null) {
int x = getMinX(); int x = getMinX();
@ -295,7 +293,7 @@ public class Volume {
for(int k = 0;k < getSizeZ(); k++) { for(int k = 0;k < getSizeZ(); k++) {
Block currentBlock = getWorld().getBlockAt(x, y, z); Block currentBlock = getWorld().getBlockAt(x, y, z);
for(Material oldType : oldTypes) { for(Material oldType : oldTypes) {
if(currentBlock.getType() == oldType) { if(currentBlock.getType().getId() == oldType.getId()) {
currentBlock.setType(newType); currentBlock.setType(newType);
} }
} }
@ -311,4 +309,31 @@ public class Volume {
} }
} }
public void clearBlocksThatDontFloat() {
Material[] toAirMaterials = new Material[22];
toAirMaterials[0] = Material.SIGN_POST;
toAirMaterials[1] = Material.SIGN;
toAirMaterials[2] = Material.IRON_DOOR_BLOCK;
toAirMaterials[3] = Material.WOOD_DOOR;
toAirMaterials[4] = Material.LADDER;
toAirMaterials[5] = Material.YELLOW_FLOWER;
toAirMaterials[6] = Material.RED_ROSE;
toAirMaterials[7] = Material.RED_MUSHROOM;
toAirMaterials[8] = Material.BROWN_MUSHROOM;
toAirMaterials[9] = Material.SAPLING;
toAirMaterials[10] = Material.TORCH;
toAirMaterials[11] = Material.RAILS;
toAirMaterials[12] = Material.STONE_BUTTON;
toAirMaterials[13] = Material.STONE_PLATE;
toAirMaterials[14] = Material.WOOD_PLATE;
toAirMaterials[15] = Material.LEVER;
toAirMaterials[16] = Material.REDSTONE;
toAirMaterials[17] = Material.REDSTONE_TORCH_ON;
toAirMaterials[18] = Material.REDSTONE_TORCH_OFF;
toAirMaterials[19] = Material.CACTUS;
toAirMaterials[20] = Material.SNOW;
toAirMaterials[21] = Material.ICE;
switchMaterials(toAirMaterials, Material.AIR);
}
} }