Can't get rid of block freeze bug. Going back to CB 432 (RB2) from CB 439 didnt help. Swallowing sign exceptions until I figure out how to do it properly. I need you guy's help to find a way to reproduc ethe block freeze bug. :(

This commit is contained in:
taoneill 2011-02-25 10:26:53 -05:00
parent 58e59c75c2
commit aba1e25569
14 changed files with 97 additions and 104 deletions

View File

@ -27,7 +27,6 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import com.nijikokun.bukkit.Permissions.Permissions;
import com.tommytony.war.ChatFixUtil;
import com.tommytony.war.Monument;
import com.tommytony.war.Team;
import com.tommytony.war.TeamChatColors;
@ -39,6 +38,7 @@ import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.VolumeMapper;
import com.tommytony.war.mappers.WarMapper;
import com.tommytony.war.mappers.WarzoneMapper;
import com.tommytony.war.utils.ChatFixUtil;
/**
*

View File

@ -19,9 +19,9 @@ import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerMoveEvent;
import com.tommytony.war.LootDropperTask;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.jobs.LootDropperTask;
/**
*

View File

@ -18,13 +18,13 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.tommytony.war.InventoryStash;
import com.tommytony.war.RestoreDeadmanInventoryJob;
import com.tommytony.war.Team;
import com.tommytony.war.TeamMaterials;
import com.tommytony.war.WarHub;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.jobs.RestoreDeadmanInventoryJob;
import com.tommytony.war.utils.InventoryStash;
/**

View File

@ -14,6 +14,7 @@ import org.bukkit.material.MaterialData;
import bukkit.tommytony.war.War;
import com.tommytony.war.utils.SignHelper;
import com.tommytony.war.volumes.Volume;
/**
@ -275,22 +276,12 @@ public class Team {
// signBlock.setType(Material.SIGN_POST);
// }
if(signBlock.getType() != Material.SIGN_POST) {
signBlock.setType(Material.SIGN_POST);
}
signBlock.setData((byte)signData);
BlockState state = signBlock.getState();
if(state instanceof Sign) {
Sign sign = (Sign) state;
if(sign.getLines() != null) {
sign.setLine(0, "Team " + name);
sign.setLine(1, remainingLives + "/" + warzone.getLifePool() + " lives left");
sign.setLine(2, points + "/" + warzone.getScoreCap() + " pts");
sign.setLine(3, players.size() + "/" + warzone.getTeamCap() + " players");
sign.update(true);
}
}
String[] lines = new String[4];
lines[0] = "Team " + name;
lines[1] = remainingLives + "/" + warzone.getLifePool() + " lives left";
lines[2] = points + "/" + warzone.getScoreCap() + " pts";
lines[3] = players.size() + "/" + warzone.getTeamCap() + " players";
SignHelper.setToSign(signBlock, (byte)signData, lines);
}
}

View File

@ -15,6 +15,7 @@ import org.bukkit.material.MaterialData;
import bukkit.tommytony.war.War;
import com.tommytony.war.utils.SignHelper;
import com.tommytony.war.volumes.Volume;
/**
@ -107,21 +108,12 @@ public class WarHub {
// War hub sign
Block signBlock = locationBlock.getFace(BlockFace.WEST);
if(signBlock.getType() != Material.SIGN_POST) {
signBlock.setType(Material.SIGN_POST);
}
signBlock.setData((byte)8);
BlockState state = signBlock.getState();
if(state instanceof Sign) {
Sign sign = (Sign) state;
if(sign.getLines() != null) {
sign.setLine(0, "War hub");
sign.setLine(1, "");
sign.setLine(2, "Pick your battle!");
sign.setLine(3, "");
sign.update(true);
}
}
String[] lines = new String[4];
lines[0] = "War hub";
lines[1] = "";
lines[2] = "Pick your battle!";
lines[3] = "";
SignHelper.setToSign(signBlock, (byte)8, lines);
// Warzone signs
for(Warzone zone : war.getWarzones()) {
@ -145,22 +137,12 @@ public class WarHub {
zonePlayers += t.getPlayers().size();
zoneCap += zone.getTeamCap();
}
if(block.getType() != Material.SIGN_POST) {
block.setType(Material.SIGN_POST);
}
block.setData((byte)8);
BlockState state = block.getState();
if(state instanceof Sign) {
Sign sign = (Sign) state;
if(sign.getLines() != null) {
sign.setLine(0, "Warzone");
sign.setLine(1, zone.getName());
sign.setLine(2, zonePlayers + "/" + zoneCap + " players");
sign.setLine(3, zone.getTeams().size() + " teams");
sign.update(true);
}
}
String[] lines = new String[4];
lines[0] = "Warzone";
lines[1] = zone.getName();
lines[2] = zonePlayers + "/" + zoneCap + " players";
lines[3] = zone.getTeams().size() + " teams";
SignHelper.setToSign(block, (byte)8, lines);
}
public void setVolume(Volume vol) {

View File

@ -18,6 +18,8 @@ import org.bukkit.inventory.PlayerInventory;
import bukkit.tommytony.war.War;
import com.tommytony.war.jobs.ResetCursorJob;
import com.tommytony.war.utils.InventoryStash;
import com.tommytony.war.volumes.VerticalVolume;
/**

View File

@ -11,6 +11,7 @@ import org.bukkit.material.MaterialData;
import bukkit.tommytony.war.War;
import com.tommytony.war.mappers.VolumeMapper;
import com.tommytony.war.utils.SignHelper;
import com.tommytony.war.volumes.VerticalVolume;
import com.tommytony.war.volumes.Volume;
@ -181,35 +182,27 @@ public class ZoneLobby {
// set zone sign
Block zoneSignBlock = lobbyMiddleWallBlock.getFace(wall, 4);
if(zoneSignBlock.getType() != Material.SIGN_POST) {
zoneSignBlock.setType(Material.SIGN_POST);
}
byte data = 0;
if(wall == BlockFace.NORTH) {
zoneSignBlock.setData((byte)4);
data = (byte)4;
} else if(wall == BlockFace.EAST) {
zoneSignBlock.setData((byte)8);
data = (byte)8;
} else if(wall == BlockFace.SOUTH) {
zoneSignBlock.setData((byte)12);
data = (byte)12;
} else if(wall == BlockFace.WEST) {
zoneSignBlock.setData((byte)0);
data = (byte)0;
}
BlockState state = zoneSignBlock.getState();
if(state instanceof Sign) {
Sign sign = (Sign) state;
if(sign.getLines() != null) {
sign.setLine(0, "Warzone");
sign.setLine(1, warzone.getName());
if(autoAssignGate != null) {
sign.setLine(2, "Walk in the");
sign.setLine(3, "auto-assign gate.");
} else {
sign.setLine(2, "");
sign.setLine(3, "Pick your team.");
}
sign.update(true);
}
String[] lines = new String[4];
lines[0] = "Warzone";
lines[1] = warzone.getName();
if(autoAssignGate != null) {
lines[2] = "Walk in the";
lines[3] = "auto-assign gate.";
} else {
lines[2] = "";
lines[3] = "Pick your team.";
}
SignHelper.setToSign(zoneSignBlock, data, lines);
// lets get some light in here
if(wall == BlockFace.NORTH || wall == BlockFace.SOUTH) {
@ -573,39 +566,26 @@ public class ZoneLobby {
} else if (wall == BlockFace.WEST) {
direction = BlockFace.EAST;
}
byte data = 0;
if(wall == BlockFace.NORTH) {
block = gate.getFace(direction).getFace(BlockFace.EAST);
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
if(awayFromWall) block.setData((byte)4);
else block.setData((byte)12);
if(awayFromWall) data = (byte)4;
else data = (byte)12;
} else if(wall == BlockFace.EAST) {
block = gate.getFace(direction).getFace(BlockFace.SOUTH);
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
if(awayFromWall) block.setData((byte)8);
else block.setData((byte)0);
if(awayFromWall) data = (byte)8;
else data = (byte)0;
} else if(wall == BlockFace.SOUTH) {
block = gate.getFace(direction).getFace(BlockFace.WEST);
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
if(awayFromWall) block.setData((byte)12);
else block.setData((byte)4);
if(awayFromWall) data = (byte)12;
else data = (byte)4;
} else if(wall == BlockFace.WEST) {
block = gate.getFace(direction).getFace(BlockFace.NORTH);
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
if(awayFromWall) block.setData((byte)0);
else block.setData((byte)8);
if(awayFromWall) data = (byte)0;
else data = (byte)8;
}
BlockState state = block.getState();
if(state instanceof Sign) {
Sign sign = (Sign) state;
if(sign.getLines() != null) {
sign.setLine(0, lines[0]);
sign.setLine(1, lines[1]);
sign.setLine(2, lines[2]);
sign.setLine(3, lines[3]);
sign.update(true);
}
}
SignHelper.setToSign(block, data, lines);
}
public boolean isLeavingZone(Location location) {

View File

@ -1,4 +1,4 @@
package com.tommytony.war;
package com.tommytony.war.jobs;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.tommytony.war;
package com.tommytony.war.jobs;
import org.bukkit.Material;
import org.bukkit.block.Block;

View File

@ -1,7 +1,9 @@
package com.tommytony.war;
package com.tommytony.war.jobs;
import org.bukkit.entity.Player;
import com.tommytony.war.Warzone;
public class RestoreDeadmanInventoryJob implements Runnable {
private final Player player;

View File

@ -1,7 +1,9 @@
package com.tommytony.war;
package com.tommytony.war.jobs;
import org.bukkit.entity.Player;
import com.tommytony.war.Warzone;
public class ScoreCapReachedJob implements Runnable {
private final Player player;

View File

@ -1,4 +1,4 @@
package com.tommytony.war;
package com.tommytony.war.utils;
import java.util.*;

View File

@ -1,4 +1,4 @@
package com.tommytony.war;
package com.tommytony.war.utils;
import org.bukkit.inventory.ItemStack;

View File

@ -0,0 +1,34 @@
package com.tommytony.war.utils;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import bukkit.tommytony.war.War;
public class SignHelper {
public static void setToSign(Block block, byte data, String[] lines) {
if(block.getType() != Material.SIGN_POST) {
block.setType(Material.SIGN_POST);
}
block.setData(data);
BlockState state = block.getState();
if(state instanceof Sign) {
Sign sign = (Sign) state;
try {
if(sign.getLines() != null) {
sign.setLine(0, lines[0]);
sign.setLine(1, lines[1]);
sign.setLine(2, lines[2]);
sign.setLine(3, lines[3]);
sign.update(true);
}
} catch (Exception e) {
// just can't stand this anymore
}
}
}
}