Customizable warzone structure materials

Change flag, monument, bomb, cake and spawn look by typing "/zonecfg
material:<main/stand/light>" while holding the block of your choosing.
Complements the lobbymaterial and warhubmaterial settings.

Brought back synchronization.
This commit is contained in:
taoneill 2012-06-18 23:36:06 -04:00
parent 9f657c4a59
commit 60e4eafc13
11 changed files with 572 additions and 108 deletions

View File

@ -23,6 +23,7 @@ import com.tommytony.war.config.TeamSpawnStyle;
import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake;
import com.tommytony.war.utility.SignHelper;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
/**
@ -94,25 +95,45 @@ public class Team {
@SuppressWarnings("unused")
public void initializeTeamSpawn() {
// make air
this.spawnVolume.setToMaterial(Material.AIR);
// make air (old two-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld());
airGap.setCornerOne(new BlockInfo(
this.spawnVolume.getCornerOne().getX(),
this.spawnVolume.getCornerOne().getY() + 1,
this.spawnVolume.getCornerOne().getZ(),
0,
(byte)0));
airGap.setCornerTwo(new BlockInfo(
this.spawnVolume.getCornerTwo().getX(),
this.spawnVolume.getCornerOne().getY() + 2,
this.spawnVolume.getCornerTwo().getZ(),
0,
(byte)0));
airGap.setToMaterial(Material.AIR);
// Set the spawn
int x = this.teamSpawn.getBlockX();
int y = this.teamSpawn.getBlockY();
int z = this.teamSpawn.getBlockZ();
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
TeamSpawnStyle style = this.getTeamConfig().resolveSpawnStyle();
if (style.equals(TeamSpawnStyle.INVISIBLE)) {
// nothing but glowstone
this.warzone.getWorld().getBlockAt(x, y - 1, z).setType(Material.GLOWSTONE);
Block lightBlock = this.warzone.getWorld().getBlockAt(x, y - 1, z);
lightBlock.setType(light);
lightBlock.setData(lightData);
} else {
// first ring
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);
Block lightBlock = this.warzone.getWorld().getBlockAt(x, y - 1, z);
lightBlock.setType(light);
lightBlock.setData(lightData);
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);
@ -508,29 +529,66 @@ public class Team {
@SuppressWarnings("unused")
public void initializeTeamFlag() {
// make air
this.flagVolume.setToMaterial(Material.AIR);
// make air (old two-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld());
airGap.setCornerOne(new BlockInfo(
this.flagVolume.getCornerOne().getX(),
this.flagVolume.getCornerOne().getY() + 1,
this.flagVolume.getCornerOne().getZ(),
0,
(byte)0));
airGap.setCornerTwo(new BlockInfo(
this.flagVolume.getCornerTwo().getX(),
this.flagVolume.getCornerOne().getY() + 2,
this.flagVolume.getCornerTwo().getZ(),
0,
(byte)0));
airGap.setToMaterial(Material.AIR);
// Set the flag blocks
int x = this.teamFlag.getBlockX();
int y = this.teamFlag.getBlockY();
int z = this.teamFlag.getBlockZ();
Material main = Material.getMaterial(this.warzone.getWarzoneMaterials().getMainId());
byte mainData = this.warzone.getWarzoneMaterials().getMainData();
Material stand = Material.getMaterial(this.warzone.getWarzoneMaterials().getStandId());
byte standData = this.warzone.getWarzoneMaterials().getStandData();
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
// first ring
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);
Block current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
current.setType(light);
current.setData(lightData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
// flag
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;
@ -544,27 +602,39 @@ public class Team {
if ((yaw >= 0 && yaw < 45) || (yaw >= 315 && yaw <= 360)) {
facing = BlockFace.WEST;
opposite = BlockFace.EAST;
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);
current = this.warzone.getWorld().getBlockAt(x, y, z - 1);
current.setType(stand);
current.setData(standData);
current = this.warzone.getWorld().getBlockAt(x, y + 1, z - 1);
current.setType(stand);
current.setData(standData);
} else if (yaw >= 45 && yaw < 135) {
facing = BlockFace.NORTH;
opposite = BlockFace.SOUTH;
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);
current = this.warzone.getWorld().getBlockAt(x + 1, y, z);
current.setType(stand);
current.setData(standData);
current = this.warzone.getWorld().getBlockAt(x + 1, y + 1, z);
current.setType(stand);
current.setData(standData);
} else if (yaw >= 135 && yaw < 225) {
facing = BlockFace.EAST;
opposite = BlockFace.WEST;
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);
current = this.warzone.getWorld().getBlockAt(x, y, z + 1);
current.setType(stand);
current.setData(standData);
current = this.warzone.getWorld().getBlockAt(x, y + 1, z + 1);
current.setType(stand);
current.setData(standData);;
} else if (yaw >= 225 && yaw < 315) {
facing = BlockFace.SOUTH;
opposite = BlockFace.NORTH;
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);
current = this.warzone.getWorld().getBlockAt(x - 1, y, z);
current.setType(stand);
current.setData(standData);
current = this.warzone.getWorld().getBlockAt(x - 1, y + 1, z);
current.setType(stand);
current.setData(standData);
}
}

View File

@ -44,6 +44,9 @@ import com.tommytony.war.job.SpoutFadeOutMessageJob;
import com.tommytony.war.mapper.WarYmlMapper;
import com.tommytony.war.mapper.WarzoneYmlMapper;
import com.tommytony.war.spout.SpoutDisplayer;
import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake;
import com.tommytony.war.structure.Monument;
import com.tommytony.war.structure.WarHub;
import com.tommytony.war.structure.HubLobbyMaterials;
import com.tommytony.war.structure.ZoneLobby;
@ -523,6 +526,62 @@ public class War extends JavaPlugin {
}
}
}
if (namedParams.containsKey("material")) {
String whichBlocks = namedParams.get("material");
ItemStack blockInHand = player.getItemInHand();
boolean updatedMaterials = false;
int id = blockInHand.getTypeId();
byte data = (byte)0;
if (blockInHand.getData() != null) {
data = blockInHand.getData().getData();
}
if (!blockInHand.getType().isBlock()) {
this.badMsg(player, "Can only use blocks as material.");
} else {
if (whichBlocks.equals("main")) {
warzone.getWarzoneMaterials().setMainId(id);
warzone.getWarzoneMaterials().setMainData(data);
returnMessage.append(" main material set to id:" + id + " data:" + data + ".");
updatedMaterials = true;
} else if (whichBlocks.equals("stand")) {
warzone.getWarzoneMaterials().setStandId(id);
warzone.getWarzoneMaterials().setStandData(data);
returnMessage.append(" stand material set to id:" + id + " data:" + data + ".");
updatedMaterials = true;
} else if (whichBlocks.equals("light")) {
warzone.getWarzoneMaterials().setLightId(id);
warzone.getWarzoneMaterials().setLightData(data);
returnMessage.append(" light material set to id:" + id + " data:" + data + ".");
updatedMaterials = true;
}
if (updatedMaterials) {
// reset all structures
for (Monument monument : warzone.getMonuments()) {
monument.getVolume().resetBlocks();
monument.addMonumentBlocks();
}
for (Cake cake : warzone.getCakes()) {
cake.getVolume().resetBlocks();
cake.addCakeBlocks();
}
for (Bomb bomb : warzone.getBombs()) {
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
}
for (Team team : warzone.getTeams()) {
team.getSpawnVolume().resetBlocks();
team.initializeTeamSpawn();
if (team.getTeamFlag() != null) {
team.getFlagVolume().resetBlocks();
team.initializeTeamFlag();
}
}
}
}
}
}
return returnMessage.toString();

View File

@ -37,6 +37,7 @@ import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake;
import com.tommytony.war.structure.Monument;
import com.tommytony.war.structure.HubLobbyMaterials;
import com.tommytony.war.structure.WarzoneMaterials;
import com.tommytony.war.structure.ZoneLobby;
import com.tommytony.war.structure.ZoneWallGuard;
import com.tommytony.war.utility.LoadoutSelection;
@ -81,6 +82,7 @@ public class Warzone {
private InventoryBag defaultInventories = new InventoryBag();
private HubLobbyMaterials lobbyMaterials = null;
private WarzoneMaterials warzoneMaterials = new WarzoneMaterials(49, (byte)0, 85, (byte)0, 89, (byte)0); // default main obsidian, stand ladder, light glowstone
private boolean isEndOfGame = false;
private boolean isReinitializing = false;
@ -852,7 +854,7 @@ public class Warzone {
//
// Concurrent execution of these events could cause the inventory reset of the last players to die to fail as
// they get tp'ed back to the lobby, or perhaps kills to bleed into the next round.
//synchronized (this.getGameEndLock()) {
synchronized (this.getGameEndLock()) {
Team playerTeam = Team.getTeamByPlayerName(player.getName());
// Make sure the player that died is still part of a team, game may have ended while waiting on synchronized.
@ -1026,7 +1028,7 @@ public class Warzone {
}
playerTeam.resetSign();
}
//}
}
}
public void reinitialize() {
@ -1393,9 +1395,9 @@ public class Warzone {
return this.isReinitializing;
}
// public Object getGameEndLock() {
// return gameEndLock;
// }
public Object getGameEndLock() {
return gameEndLock;
}
public void setName(String newName) {
this.name = newName;
@ -1424,4 +1426,12 @@ public class Warzone {
}
return false;
}
public void setWarzoneMaterials(WarzoneMaterials warzoneMaterials) {
this.warzoneMaterials = warzoneMaterials;
}
public WarzoneMaterials getWarzoneMaterials() {
return warzoneMaterials;
}
}

View File

@ -484,7 +484,7 @@ public class WarPlayerListener implements Listener {
// Make sure game ends can't occur simultaneously.
// See Warzone.handleDeath() for details.
//synchronized (playerWarzone.getGameEndLock()) {
synchronized (playerWarzone.getGameEndLock()) {
boolean inSpawn = playerTeam.getSpawnVolume().contains(player.getLocation());
boolean inFlag = (playerTeam.getFlagVolume() != null && playerTeam.getFlagVolume().contains(player.getLocation()));
@ -568,7 +568,7 @@ public class WarPlayerListener implements Listener {
}
return;
//}
}
}
// Bomb detonation
@ -578,7 +578,7 @@ public class WarPlayerListener implements Listener {
// Make sure game ends can't occur simultaneously.
// See Warzone.handleDeath() for details.
//synchronized (playerWarzone.getGameEndLock()) {
synchronized (playerWarzone.getGameEndLock()) {
boolean inEnemySpawn = false;
Team victim = null;
@ -657,7 +657,7 @@ public class WarPlayerListener implements Listener {
}
return;
//}
}
}
// Cake retrieval
@ -669,7 +669,7 @@ public class WarPlayerListener implements Listener {
// Make sure game ends can't occur simultaneously.
// See Warzone.handleDeath() for details.
//synchronized (playerWarzone.getGameEndLock()) {
synchronized (playerWarzone.getGameEndLock()) {
boolean inSpawn = playerTeam.getSpawnVolume().contains(player.getLocation());
if (inSpawn && playerTeam.getPlayers().contains(player)) {
@ -740,7 +740,7 @@ public class WarPlayerListener implements Listener {
}
return;
//}
}
}
// Class selection lock

View File

@ -24,6 +24,7 @@ import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake;
import com.tommytony.war.structure.HubLobbyMaterials;
import com.tommytony.war.structure.Monument;
import com.tommytony.war.structure.WarzoneMaterials;
import com.tommytony.war.structure.ZoneLobby;
import com.tommytony.war.volume.Volume;
import com.tommytony.war.volume.ZoneVolume;
@ -322,15 +323,15 @@ public class WarzoneYmlMapper {
gateData = gateMaterialSection.getInt("data");
}
int lightId = War.war.getWarhubMaterials().getLightId();
int lightData = War.war.getWarhubMaterials().getLightData();
ConfigurationSection lightMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.light");
if (lightMaterialSection != null) {
lightId = lightMaterialSection.getInt("id");
lightData = lightMaterialSection.getInt("data");
int lobbyLightId = War.war.getWarhubMaterials().getLightId();
int lobbyLightData = War.war.getWarhubMaterials().getLightData();
ConfigurationSection lobbyLightMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.light");
if (lobbyLightMaterialSection != null) {
lobbyLightId = lobbyLightMaterialSection.getInt("id");
lobbyLightData = lobbyLightMaterialSection.getInt("data");
}
warzone.setLobbyMaterials(new HubLobbyMaterials(floorId, (byte)floorData, outlineId, (byte)outlineData, gateId, (byte)gateData, lightId, (byte)lightData));
warzone.setLobbyMaterials(new HubLobbyMaterials(floorId, (byte)floorData, outlineId, (byte)outlineData, gateId, (byte)gateData, lobbyLightId, (byte)lobbyLightData));
// lobby world
String lobbyWorldName = warzoneRootSection.getString(lobbyPrefix + "world");
@ -340,7 +341,34 @@ public class WarzoneYmlMapper {
Volume lobbyVolume = VolumeMapper.loadVolume("lobby", warzone.getName(), lobbyWorld);
ZoneLobby lobby = new ZoneLobby(warzone, lobbyFace, lobbyVolume);
warzone.setLobby(lobby);
// warzone materials
int mainId = warzone.getWarzoneMaterials().getMainId();
int mainData = warzone.getWarzoneMaterials().getMainData();
ConfigurationSection mainMaterialSection = warzoneRootSection.getConfigurationSection(zoneInfoPrefix + "materials.main");
if (mainMaterialSection != null) {
mainId = mainMaterialSection.getInt("id");
mainData = mainMaterialSection.getInt("data");
}
int standId = warzone.getWarzoneMaterials().getStandId();
int standData = warzone.getWarzoneMaterials().getStandData();
ConfigurationSection standMaterialSection = warzoneRootSection.getConfigurationSection(zoneInfoPrefix + "materials.stand");
if (standMaterialSection != null) {
standId = standMaterialSection.getInt("id");
standData = standMaterialSection.getInt("data");
}
int lightId = warzone.getWarzoneMaterials().getLightId();
int lightData = warzone.getWarzoneMaterials().getLightData();
ConfigurationSection lightMaterialSection = warzoneRootSection.getConfigurationSection(zoneInfoPrefix + "materials.light");
if (lightMaterialSection != null) {
lightId = lightMaterialSection.getInt("id");
lightData = lightMaterialSection.getInt("data");
}
warzone.setWarzoneMaterials(new WarzoneMaterials(mainId, (byte)mainData, standId, (byte)standData, lightId, (byte)lightData));
return warzone;
}
@ -405,6 +433,19 @@ public class WarzoneYmlMapper {
lightSection.set("id", warzone.getLobbyMaterials().getLightId());
lightSection.set("data", warzone.getLobbyMaterials().getLightData());
}
// materials
if (warzone.getLobby() != null) {
ConfigurationSection mainSection = warzoneInfoSection.createSection("materials.main");
mainSection.set("id", warzone.getWarzoneMaterials().getMainId());
mainSection.set("data", warzone.getWarzoneMaterials().getMainData());
ConfigurationSection standSection = warzoneInfoSection.createSection("materials.stand");
standSection.set("id", warzone.getWarzoneMaterials().getStandId());
standSection.set("data", warzone.getWarzoneMaterials().getStandData());
ConfigurationSection lightSection = warzoneInfoSection.createSection("materials.light");
lightSection.set("id", warzone.getWarzoneMaterials().getLightId());
lightSection.set("data", warzone.getWarzoneMaterials().getLightData());
}
// rallyPoint
if (warzone.getRallyPoint() != null) {

View File

@ -7,6 +7,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.tommytony.war.Warzone;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
/**
@ -31,30 +32,73 @@ public class Bomb {
}
public void addBombBlocks() {
this.volume.setToMaterial(Material.AIR);
// make air (old two-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld());
airGap.setCornerOne(new BlockInfo(
this.volume.getCornerOne().getX(),
this.volume.getCornerOne().getY() + 1,
this.volume.getCornerOne().getZ(),
0,
(byte)0));
airGap.setCornerTwo(new BlockInfo(
this.volume.getCornerTwo().getX(),
this.volume.getCornerOne().getY() + 3,
this.volume.getCornerTwo().getZ(),
0,
(byte)0));
airGap.setToMaterial(Material.AIR);
int x = this.location.getBlockX();
int y = this.location.getBlockY();
int z = this.location.getBlockZ();
Material main = Material.getMaterial(this.warzone.getWarzoneMaterials().getMainId());
byte mainData = this.warzone.getWarzoneMaterials().getMainData();
Material stand = Material.getMaterial(this.warzone.getWarzoneMaterials().getStandId());
byte standData = this.warzone.getWarzoneMaterials().getStandData();
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
// center
this.warzone.getWorld().getBlockAt(x, y - 1, z).getState().setType(Material.OBSIDIAN);
Block current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
current.setType(main);
current.setData(mainData);
// inner ring
this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1).setType(Material.GLOWSTONE);
this.warzone.getWorld().getBlockAt(x + 1, y - 1, z).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1).setType(Material.GLOWSTONE);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1);
current.setType(light);
current.setData(lightData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
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);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
current.setType(light);
current.setData(lightData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1).setType(Material.GLOWSTONE);
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).setType(Material.GLOWSTONE);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1);
current.setType(light);
current.setData(lightData);
// block holder
this.warzone.getWorld().getBlockAt(x, y, z).setType(Material.OBSIDIAN);
current = this.warzone.getWorld().getBlockAt(x, y, z);
current.setType(stand);
current.setData(standData);
Block tntBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z);
tntBlock.setType(Material.TNT);
}

View File

@ -7,6 +7,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.tommytony.war.Warzone;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
/**
@ -31,30 +32,74 @@ public class Cake {
}
public void addCakeBlocks() {
this.volume.setToMaterial(Material.AIR);
// make air (old two-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld());
airGap.setCornerOne(new BlockInfo(
this.volume.getCornerOne().getX(),
this.volume.getCornerOne().getY() + 1,
this.volume.getCornerOne().getZ(),
0,
(byte)0));
airGap.setCornerTwo(new BlockInfo(
this.volume.getCornerTwo().getX(),
this.volume.getCornerOne().getY() + 2,
this.volume.getCornerTwo().getZ(),
0,
(byte)0));
airGap.setToMaterial(Material.AIR);
int x = this.location.getBlockX();
int y = this.location.getBlockY();
int z = this.location.getBlockZ();
Material main = Material.getMaterial(this.warzone.getWarzoneMaterials().getMainId());
byte mainData = this.warzone.getWarzoneMaterials().getMainData();
Material stand = Material.getMaterial(this.warzone.getWarzoneMaterials().getStandId());
byte standData = this.warzone.getWarzoneMaterials().getStandData();
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
// center
this.warzone.getWorld().getBlockAt(x, y - 1, z).getState().setType(Material.OBSIDIAN);
Block current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
current.setType(main);
current.setData(mainData);
// inner ring
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);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1);
current.setType(light);
current.setData(lightData);
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);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
current.setType(light);
current.setData(lightData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
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);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1);
current.setType(light);
current.setData(lightData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
// block holder
this.warzone.getWorld().getBlockAt(x, y, z).setType(Material.GLASS);
current = this.warzone.getWorld().getBlockAt(x, y, z);
current.setType(stand);
current.setData(standData);
Block cakeBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z);
cakeBlock.setType(Material.CAKE_BLOCK);
}

View File

@ -7,6 +7,7 @@ import org.bukkit.block.BlockFace;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume;
/**
@ -31,61 +32,146 @@ public class Monument {
}
public void addMonumentBlocks() {
this.volume.setToMaterial(Material.AIR);
// make air (old three-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld());
airGap.setCornerOne(new BlockInfo(
this.volume.getCornerOne().getX(),
this.volume.getCornerOne().getY() + 1,
this.volume.getCornerOne().getZ(),
0,
(byte)0));
airGap.setCornerTwo(new BlockInfo(
this.volume.getCornerTwo().getX(),
this.volume.getCornerOne().getY() + 3,
this.volume.getCornerTwo().getZ(),
0,
(byte)0));
airGap.setToMaterial(Material.AIR);
this.ownerTeam = null;
int x = this.location.getBlockX();
int y = this.location.getBlockY();
int z = this.location.getBlockZ();
Material main = Material.getMaterial(this.warzone.getWarzoneMaterials().getMainId());
byte mainData = this.warzone.getWarzoneMaterials().getMainData();
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
// center
this.warzone.getWorld().getBlockAt(x, y - 1, z).getState().setType(Material.OBSIDIAN);
Block current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
current.setType(main);
current.setData(mainData);
// inner ring
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);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
this.warzone.getWorld().getBlockAt(x, y - 1, z + 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x, y - 1, z - 1).setType(Material.OBSIDIAN);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
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);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
// outer ring
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);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 2);
current.setType(light);
current.setData(lightData);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z - 2);
current.setType(light);
current.setData(lightData);
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);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 2);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 2);
current.setType(main);
current.setData(mainData);
this.warzone.getWorld().getBlockAt(x, y - 1, z + 2).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x, y - 1, z - 2).setType(Material.OBSIDIAN);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 2);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 2);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 2);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 2);
current.setType(main);
current.setData(mainData);
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);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z + 2);
current.setType(light);
current.setData(lightData);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z + 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z - 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z - 2);
current.setType(light);
current.setData(lightData);
// block holder
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);
current = this.warzone.getWorld().getBlockAt(x, y, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y, z - 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y, z + 1);
current.setType(main);
current.setData(mainData);
this.warzone.getWorld().getBlockAt(x, y + 1, z - 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x, y + 1, z + 1).setType(Material.OBSIDIAN);
current = this.warzone.getWorld().getBlockAt(x, y + 1, z - 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y + 1, z + 1);
current.setType(main);
current.setData(mainData);
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);
current = this.warzone.getWorld().getBlockAt(x, y + 2, z);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y + 2, z - 1);
current.setType(main);
current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y + 2, z + 1);
current.setType(main);
current.setData(mainData);
}

View File

@ -0,0 +1,104 @@
package com.tommytony.war.structure;
import java.util.logging.Level;
import org.bukkit.Material;
import com.tommytony.war.War;
public class WarzoneMaterials {
private int mainId;
private byte mainData;
private int standId;
private byte standData;
private int lightId;
private byte lightData;
public WarzoneMaterials(int mainId, byte mainData, int standId, byte standData, int lightId, byte lightData) {
// Make sure we are using legal blocks or AIR as material
if (isBlockOrAir(mainId)) {
this.setMainId(mainId);
this.setMainData(mainData);
} else {
this.setMainId(49); // default obsidian
this.setMainData((byte)0);
}
if (isBlockOrAir(standId)) {
this.setStandId(standId);
this.setStandData(standData);
} else {
this.setStandId(85); // default ladder
this.setStandData((byte)0);
}
if (isBlockOrAir(lightId)) {
this.setLightId(lightId);
this.setLightData(lightData);
} else {
this.setLightId(89); // default glowstone
this.setLightData((byte)0);
}
}
private boolean isBlockOrAir(int itemId) {
Material material = Material.getMaterial(itemId);
if (material.isBlock() || material.equals(Material.AIR)) {
return true;
} else {
War.war.log("Can't use item with id:" + itemId + " as warzone material.", Level.WARNING);
return false;
}
}
public int getMainId() {
return mainId;
}
public byte getMainData() {
return mainData;
}
public int getLightId() {
return lightId;
}
public byte getLightData() {
return lightData;
}
public int getStandId() {
return standId;
}
public byte getStandData() {
return standData;
}
public void setMainId(int mainId) {
this.mainId = mainId;
}
public void setMainData(byte mainData) {
this.mainData = mainData;
}
public void setStandId(int standId) {
this.standId = standId;
}
public void setStandData(byte standData) {
this.standData = standData;
}
public void setLightId(int lightId) {
this.lightId = lightId;
}
public void setLightData(byte lightData) {
this.lightData = lightData;
}
}

View File

@ -427,7 +427,7 @@ public class Volume {
public void setToMaterial(Material material) {
try {
if (this.hasTwoCorners() && this.isSaved()) {
if (this.hasTwoCorners()) {
int x = this.getMinX();
for (int i = 0; i < this.getSizeX(); i++) {
int y = this.getMaxY();

View File

@ -115,6 +115,7 @@ commands:
/savezone [zone-name] reward:default => sets the winner's reward to your current items.
/savezone [zone-name] author:tommytony,someguy => adds these players as authors of the warzone, allowing them to edit it.
/savezone [zone-name] deleteauthor:tommytony,someguy => removes these players from the warzone authors.
/savezone [zone-name] warhubmaterial:<floor/outline/gate/light> => while holding block, changes look for different parts of warhub.
setzonelobby:
description: War> Creates or changes the position of the warzone lobby.
usage: Creates or changes the position of the warzone lobby.
@ -202,6 +203,8 @@ commands:
/setzoneconfig [zone-name] reward:default => sets the winner's reward to your current items.
/setzoneconfig [zone-name] author:tommytony,someguy => adds these players as authors of the warzone, allowing them to edit it.
/setzoneconfig [zone-name] deleteauthor:tommytony,someguy => removes these players from the warzone authors.
/setzoneconfig [zone-name] material:<main/stand/light> => while holding block, changes look for structures like flag stands and monuments.
/setzoneconfig [zone-name] lobbymaterial:<floor/outline/gate/light> => while holding block, changes look for different parts of lobby.
zonecfg:
description: War> Alias for /setzoneconfig
usage: Use named parameters to change the configuration of the warzone and default team settings. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.
@ -214,6 +217,8 @@ commands:
/zonecfg [zone-name] reward:default => sets the winner's reward to your current items.
/zonecfg [zone-name] author:tommytony,someguy => adds these players as authors of the warzone, allowing them to edit it.
/zonecfg [zone-name] deleteauthor:tommytony,someguy => removes these players from the warzone authors.
/zonecfg [zone-name] material:<main/stand/light> => while holding block, changes look for structures like flag stands and monuments.
/zonecfg [zone-name] lobbymaterial:<floor/outline/gate/light> => while holding block, changes look for different parts of lobby.
setteamconfig:
description: War> Use named parameters to change team-specific settings. Resets warzone blocks like /nextbattle. Does not save zone blocks like /savezone.
usage: Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.