Using more bukkit interfaces rather than IDs

Item/damage/anything ID's have now become deprecated in bukkit presumedly
in preparation for any sort of official server modding API. This switches
war from using IDs in most cases to bukkit-provided classes such as
ItemStack.
This commit is contained in:
cmastudios 2013-09-27 18:11:09 -05:00
parent e38b2aa62b
commit 39b0ead3bd
26 changed files with 841 additions and 1194 deletions

View File

@ -81,7 +81,7 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>1.6.2-R0.1</version> <version>1.6.2-R1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.kitteh</groupId> <groupId>org.kitteh</groupId>

View File

@ -1,6 +1,7 @@
package com.tommytony.war; package com.tommytony.war;
import java.io.File; import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -16,7 +17,10 @@ import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Sign;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Objective;
import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.SpoutManager;
@ -32,7 +36,6 @@ import com.tommytony.war.config.TeamSpawnStyle;
import com.tommytony.war.structure.Bomb; import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake; import com.tommytony.war.structure.Cake;
import com.tommytony.war.utility.Direction; import com.tommytony.war.utility.Direction;
import com.tommytony.war.utility.SignHelper;
import com.tommytony.war.volume.BlockInfo; import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume; import com.tommytony.war.volume.Volume;
@ -118,8 +121,7 @@ public class Team {
int y = teamSpawn.getBlockY(); int y = teamSpawn.getBlockY();
int z = teamSpawn.getBlockZ(); int z = teamSpawn.getBlockZ();
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId()); ItemStack light = this.warzone.getWarzoneMaterials().getLightBlock();
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
TeamSpawnStyle style = this.getTeamConfig().resolveSpawnStyle(); TeamSpawnStyle style = this.getTeamConfig().resolveSpawnStyle();
if (!style.equals(TeamSpawnStyle.INVISIBLE)) { if (!style.equals(TeamSpawnStyle.INVISIBLE)) {
@ -128,9 +130,10 @@ public class Team {
this.setBlock(x + 1, y - 1, z, this.kind); this.setBlock(x + 1, y - 1, z, this.kind);
this.setBlock(x + 1, y - 1, z - 1, this.kind); this.setBlock(x + 1, y - 1, z - 1, this.kind);
this.setBlock(x, y - 1, z + 1, this.kind); this.setBlock(x, y - 1, z + 1, this.kind);
Block lightBlock = this.warzone.getWorld().getBlockAt(x, y - 1, z); BlockState lightBlock = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
lightBlock.setType(light); lightBlock.setType(light.getType());
lightBlock.setData(lightData); lightBlock.setData(light.getData());
lightBlock.update(true);
this.setBlock(x, y - 1, z - 1, this.kind); 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 + 1, this.kind);
this.setBlock(x - 1, y - 1, z, this.kind); this.setBlock(x - 1, y - 1, z, this.kind);
@ -145,21 +148,21 @@ public class Team {
yaw = (int) (360 + (teamSpawn.getYaw() % 360)); yaw = (int) (360 + (teamSpawn.getYaw() % 360));
} }
Block signBlock = null; Block signBlock = null;
int signData = 0; BlockFace signDirection = null;
if (style.equals(TeamSpawnStyle.SMALL)) { if (style.equals(TeamSpawnStyle.SMALL)) {
// SMALL style // SMALL style
if (yaw >= 0 && yaw < 90) { if (yaw >= 0 && yaw < 90) {
signData = 10; signDirection = BlockFace.SOUTH_WEST.getOppositeFace();
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH()).getRelative(Direction.WEST()); signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH()).getRelative(Direction.WEST());
} else if (yaw >= 90 && yaw <= 180) { } else if (yaw >= 90 && yaw <= 180) {
signData = 14; signDirection = BlockFace.NORTH_WEST.getOppositeFace();
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH()).getRelative(Direction.EAST()); signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH()).getRelative(Direction.EAST());
} else if (yaw >= 180 && yaw < 270) { } else if (yaw >= 180 && yaw < 270) {
signData = 2; signDirection = BlockFace.NORTH_EAST.getOppositeFace();
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH()).getRelative(Direction.EAST()); signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH()).getRelative(Direction.EAST());
} else if (yaw >= 270 && yaw <= 360) { } else if (yaw >= 270 && yaw <= 360) {
signData = 6; signDirection = BlockFace.SOUTH_EAST.getOppositeFace();
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH()).getRelative(Direction.WEST()); signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH()).getRelative(Direction.WEST());
} }
} else if (!style.equals(TeamSpawnStyle.INVISIBLE)) { } else if (!style.equals(TeamSpawnStyle.INVISIBLE)) {
@ -186,7 +189,7 @@ public class Team {
this.setBlock(x - 2, y - 1, z - 2, this.kind); this.setBlock(x - 2, y - 1, z - 2, this.kind);
if (yaw >= 0 && yaw < 90) { if (yaw >= 0 && yaw < 90) {
signData = 10; signDirection = BlockFace.SOUTH_WEST.getOppositeFace();
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH(), 2).getRelative(Direction.WEST(), 2); signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH(), 2).getRelative(Direction.WEST(), 2);
if (style.equals(TeamSpawnStyle.BIG)) { if (style.equals(TeamSpawnStyle.BIG)) {
@ -217,7 +220,7 @@ public class Team {
this.setBlock(x + 2, y + 3, z - 2, this.kind); this.setBlock(x + 2, y + 3, z - 2, this.kind);
} }
} else if (yaw >= 90 && yaw <= 180) { } else if (yaw >= 90 && yaw <= 180) {
signData = 14; signDirection = BlockFace.NORTH_WEST.getOppositeFace();
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH(), 2).getRelative(Direction.EAST(), 2); signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH(), 2).getRelative(Direction.EAST(), 2);
if (style.equals(TeamSpawnStyle.BIG)) { if (style.equals(TeamSpawnStyle.BIG)) {
// rim // rim
@ -247,7 +250,7 @@ public class Team {
this.setBlock(x + 2, y + 3, z + 2, this.kind); this.setBlock(x + 2, y + 3, z + 2, this.kind);
} }
} else if (yaw >= 180 && yaw < 270) { } else if (yaw >= 180 && yaw < 270) {
signData = 2; signDirection = BlockFace.NORTH_EAST.getOppositeFace();
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH(), 2).getRelative(Direction.EAST(), 2); signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH(), 2).getRelative(Direction.EAST(), 2);
if (style.equals(TeamSpawnStyle.BIG)) { if (style.equals(TeamSpawnStyle.BIG)) {
// rim // rim
@ -277,7 +280,7 @@ public class Team {
this.setBlock(x - 2, y + 3, z + 2, this.kind); this.setBlock(x - 2, y + 3, z + 2, this.kind);
} }
} else if (yaw >= 270 && yaw <= 360) { } else if (yaw >= 270 && yaw <= 360) {
signData = 6; signDirection = BlockFace.SOUTH_EAST.getOppositeFace();
signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH(), 2).getRelative(Direction.WEST(), 2); signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH(), 2).getRelative(Direction.WEST(), 2);
if (style.equals(TeamSpawnStyle.BIG)) { if (style.equals(TeamSpawnStyle.BIG)) {
// rim // rim
@ -310,17 +313,41 @@ public class Team {
} }
if (signBlock != null) { if (signBlock != null) {
String[] lines = new String[4]; String[] lines;
lines[0] = "Team " + this.name;
lines[1] = this.players.size() + "/" + this.getTeamConfig().resolveInt(TeamConfig.TEAMSIZE) + " players";
lines[2] = this.points + "/" + this.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)+ " pts";
if (this.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL) == -1) { if (this.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL) == -1) {
lines[3] = "unlimited lives"; lines = MessageFormat
.format("Team {0}\n{1}/{2} players\n{3}/{4} pts\nunlimited lives",
this.name,
this.players.size(),
this.getTeamConfig().resolveInt(
TeamConfig.TEAMSIZE),
this.points,
this.getTeamConfig().resolveInt(
TeamConfig.MAXSCORE)).split("\n");
} else { } else {
lines[3] = this.remainingLives + "/" + this.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL) + " lives left"; lines = MessageFormat
.format("Team {0}\n{1}/{2} players\n{3}/{4} pts\n{5} lives left",
this.name,
this.players.size(),
this.getTeamConfig().resolveInt(
TeamConfig.TEAMSIZE),
this.points,
this.getTeamConfig().resolveInt(
TeamConfig.MAXSCORE),
this.remainingLives,
this.getTeamConfig().resolveInt(
TeamConfig.LIFEPOOL)).split("\n");
} }
signBlock.setType(Material.SIGN_POST);
SignHelper.setToSign(War.war, signBlock, (byte) signData, lines); org.bukkit.block.Sign block = (org.bukkit.block.Sign) signBlock
.getState();
org.bukkit.material.Sign data = (Sign) block.getData();
data.setFacingDirection(signDirection);
block.setData(data);
for (int i = 0; i < 4; i++) {
block.setLine(i, lines[i]);
}
block.update(true);
} }
if (War.war.isSpoutServer()) { if (War.war.isSpoutServer()) {
@ -329,9 +356,10 @@ public class Team {
} }
private void setBlock(int x, int y, int z, TeamKind kind) { private void setBlock(int x, int y, int z, TeamKind kind) {
Block block = this.warzone.getWorld().getBlockAt(x, y, z); BlockState block = this.warzone.getWorld().getBlockAt(x, y, z).getState();
block.setType(kind.getMaterial()); block.setType(kind.getMaterial());
block.setData(kind.getData()); block.setData(kind.getBlockData());
block.update(true);
} }
public void addTeamSpawn(Location teamSpawn) { public void addTeamSpawn(Location teamSpawn) {
@ -535,7 +563,6 @@ public class Team {
this.flagVolume.setCornerTwo(this.warzone.getWorld().getBlockAt(x + 1, y + 3, z + 1)); this.flagVolume.setCornerTwo(this.warzone.getWorld().getBlockAt(x + 1, y + 3, z + 1));
} }
@SuppressWarnings("unused")
public void initializeTeamFlag() { public void initializeTeamFlag() {
// make air (old two-high above floor) // make air (old two-high above floor)
Volume airGap = new Volume("airgap", this.warzone.getWorld()); Volume airGap = new Volume("airgap", this.warzone.getWorld());
@ -557,46 +584,50 @@ public class Team {
int x = this.teamFlag.getBlockX(); int x = this.teamFlag.getBlockX();
int y = this.teamFlag.getBlockY(); int y = this.teamFlag.getBlockY();
int z = this.teamFlag.getBlockZ(); 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 // first ring
Block current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1); BlockState current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1).getState();
current.setType(main); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(mainData); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z); current.update(true);
current.setType(main); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z).getState();
current.setData(mainData); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.setType(main); current.update(true);
current.setData(mainData); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1).getState();
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setType(main); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.setData(mainData); current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z); current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1).getState();
current.setType(light); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(lightData); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1); current.update(true);
current.setType(main); current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
current.setData(mainData); current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1); current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
current.setType(main); current.update(true);
current.setData(mainData); current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1).getState();
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setType(main); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.setData(mainData); current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1); current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1).getState();
current.setType(main); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(mainData); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z).getState();
current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).getState();
current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.update(true);
// flag // flag
this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(this.kind.getMaterial()); BlockState flagBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z).getState();
this.warzone.getWorld().getBlockAt(x, y + 1, z).setData(this.kind.getData()); flagBlock.setType(this.kind.getMaterial());
flagBlock.setData(this.kind.getBlockData());
flagBlock.update(true);
// Flag post using Orientation // Flag post using Orientation
int yaw = 0; int yaw = 0;
@ -605,44 +636,42 @@ public class Team {
} else { } else {
yaw = (int) (360 + (this.teamFlag.getYaw() % 360)); yaw = (int) (360 + (this.teamFlag.getYaw() % 360));
} }
BlockFace facing = null;
BlockFace opposite = null;
if ((yaw >= 0 && yaw < 45) || (yaw >= 315 && yaw <= 360)) { if ((yaw >= 0 && yaw < 45) || (yaw >= 315 && yaw <= 360)) {
facing = Direction.WEST(); current = this.warzone.getWorld().getBlockAt(x, y, z - 1).getState();
opposite = Direction.EAST(); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current = this.warzone.getWorld().getBlockAt(x, y, z - 1); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
current.setType(stand); current.update(true);
current.setData(standData); current = this.warzone.getWorld().getBlockAt(x, y + 1, z - 1).getState();
current = this.warzone.getWorld().getBlockAt(x, y + 1, z - 1); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current.setType(stand); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
current.setData(standData); current.update(true);
} else if (yaw >= 45 && yaw < 135) { } else if (yaw >= 45 && yaw < 135) {
facing = Direction.NORTH(); current = this.warzone.getWorld().getBlockAt(x + 1, y, z).getState();
opposite = Direction.SOUTH(); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current = this.warzone.getWorld().getBlockAt(x + 1, y, z); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
current.setType(stand); current.update(true);
current.setData(standData); current = this.warzone.getWorld().getBlockAt(x + 1, y + 1, z).getState();
current = this.warzone.getWorld().getBlockAt(x + 1, y + 1, z); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current.setType(stand); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
current.setData(standData); current.update(true);
} else if (yaw >= 135 && yaw < 225) { } else if (yaw >= 135 && yaw < 225) {
facing = Direction.EAST(); current = this.warzone.getWorld().getBlockAt(x, y, z + 1).getState();
opposite = Direction.WEST(); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current = this.warzone.getWorld().getBlockAt(x, y, z + 1); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
current.setType(stand); current.update(true);
current.setData(standData); current = this.warzone.getWorld().getBlockAt(x, y + 1, z + 1).getState();
current = this.warzone.getWorld().getBlockAt(x, y + 1, z + 1); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current.setType(stand); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
current.setData(standData);; current.update(true);
} else if (yaw >= 225 && yaw < 315) { } else if (yaw >= 225 && yaw < 315) {
facing = Direction.SOUTH(); current = this.warzone.getWorld().getBlockAt(x - 1, y, z).getState();
opposite = Direction.NORTH(); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current = this.warzone.getWorld().getBlockAt(x - 1, y, z); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
current.setType(stand); current.update(true);
current.setData(standData); current = this.warzone.getWorld().getBlockAt(x - 1, y + 1, z).getState();
current = this.warzone.getWorld().getBlockAt(x - 1, y + 1, z); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current.setType(stand); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
current.setData(standData); current.update(true);
} }
} }

View File

@ -108,7 +108,9 @@ public class War extends JavaPlugin {
private Logger warLogger; private Logger warLogger;
private HubLobbyMaterials warhubMaterials = new HubLobbyMaterials(20, (byte)0, 5, (byte)0, 49, (byte)0, 89, (byte)0); // default floor glass, outline planks, gate obsidian, light glowstone private HubLobbyMaterials warhubMaterials = new HubLobbyMaterials(
new ItemStack(Material.GLASS), new ItemStack(Material.WOOD),
new ItemStack(Material.OBSIDIAN), new ItemStack(Material.GLOWSTONE));
public War() { public War() {
super(); super();
@ -355,22 +357,21 @@ public class War extends JavaPlugin {
int i = 0; int i = 0;
for (ItemStack stack : inv.getContents()) { for (ItemStack stack : inv.getContents()) {
if (stack != null && stack.getType() != Material.AIR) { if (stack != null && stack.getType() != Material.AIR) {
loadout.put(i, this.copyStack(stack)); loadout.put(i, stack.clone());
i++; i++;
} }
} }
if (inv.getBoots() != null && inv.getBoots().getType() != Material.AIR) { if (inv.getBoots() != null && inv.getBoots().getType() != Material.AIR) {
loadout.put(100, this.copyStack(inv.getBoots())); loadout.put(100, inv.getBoots().clone());
} }
if (inv.getLeggings() != null && inv.getLeggings().getType() != Material.AIR) { if (inv.getLeggings() != null && inv.getLeggings().getType() != Material.AIR) {
loadout.put(101, this.copyStack(inv.getLeggings())); loadout.put(101, inv.getLeggings().clone());
} }
if (inv.getChestplate() != null && inv.getChestplate().getType() != Material.AIR) { if (inv.getChestplate() != null && inv.getChestplate().getType() != Material.AIR) {
loadout.put(102, this.copyStack(inv.getChestplate())); loadout.put(102, inv.getChestplate().clone());
} }
if (inv.getHelmet() != null && inv.getHelmet().getType() != Material.AIR) { if (inv.getHelmet() != null && inv.getHelmet().getType() != Material.AIR) {
loadout.put(103, this.copyStack(inv.getHelmet())); loadout.put(103, inv.getHelmet().clone());
} }
} }
@ -379,22 +380,11 @@ public class War extends JavaPlugin {
return originalStack.clone(); return originalStack.clone();
} }
public void copyEnchantments(ItemStack originalStack, ItemStack copiedStack) {
for (Enchantment enchantment : originalStack.getEnchantments().keySet()) {
int level = originalStack.getEnchantments().get(enchantment);
safelyEnchant(copiedStack, enchantment, level);
}
}
public void safelyEnchant(ItemStack target, Enchantment enchantment, int level) { public void safelyEnchant(ItemStack target, Enchantment enchantment, int level) {
try { if (level > enchantment.getMaxLevel()) {
if (level > enchantment.getMaxLevel()) { target.addUnsafeEnchantment(enchantment, level);
target.addUnsafeEnchantment(Enchantment.getById(enchantment.getId()), level); } else {
} else { target.addEnchantment(enchantment, level);
target.addEnchantment(Enchantment.getById(enchantment.getId()), level);
}
} catch (Exception e) {
War.war.log("Failed to apply enchantment id:" + enchantment.getId() + " level:" + level, Level.WARNING);
} }
} }
@ -577,34 +567,24 @@ public class War extends JavaPlugin {
ItemStack blockInHand = player.getItemInHand(); ItemStack blockInHand = player.getItemInHand();
boolean updatedLobbyMaterials = false; boolean updatedLobbyMaterials = false;
int id = blockInHand.getTypeId();
byte data = (byte)0;
if (blockInHand.getData() != null) {
data = blockInHand.getData().getData();
}
if (!blockInHand.getType().isBlock() && !blockInHand.getType().equals(Material.AIR)) { if (!blockInHand.getType().isBlock() && !blockInHand.getType().equals(Material.AIR)) {
this.badMsg(player, "Can only use blocks or air as lobby material."); this.badMsg(player, "Can only use blocks or air as lobby material.");
} else { } else {
if (whichBlocks.equals("floor")) { if (whichBlocks.equals("floor")) {
warzone.getLobbyMaterials().setFloorId(id); warzone.getLobbyMaterials().setFloorBlock(blockInHand);
warzone.getLobbyMaterials().setFloorData(data); returnMessage.append(" lobby floor material set to " + blockInHand.getType());
returnMessage.append(" lobby floor material set to id:" + id + " data:" + data + ".");
updatedLobbyMaterials = true; updatedLobbyMaterials = true;
} else if (whichBlocks.equals("outline")) { } else if (whichBlocks.equals("outline")) {
warzone.getLobbyMaterials().setOutlineId(id); warzone.getLobbyMaterials().setOutlineBlock(blockInHand);
warzone.getLobbyMaterials().setOutlineData(data); returnMessage.append(" lobby outline material set to " + blockInHand.getType());
returnMessage.append(" lobby outline material set to id:" + id + " data:" + data + ".");
updatedLobbyMaterials = true; updatedLobbyMaterials = true;
} else if (whichBlocks.equals("gate")) { } else if (whichBlocks.equals("gate")) {
warzone.getLobbyMaterials().setGateId(id); warzone.getLobbyMaterials().setGateBlock(blockInHand);
warzone.getLobbyMaterials().setGateData(data); returnMessage.append(" lobby gate material set to " + blockInHand.getType());
returnMessage.append(" lobby gate material set to id:" + id + " data:" + data + ".");
updatedLobbyMaterials = true; updatedLobbyMaterials = true;
} else if (whichBlocks.equals("light")) { } else if (whichBlocks.equals("light")) {
warzone.getLobbyMaterials().setLightId(id); warzone.getLobbyMaterials().setLightBlock(blockInHand);
warzone.getLobbyMaterials().setLightData(data); returnMessage.append(" lobby light material set to " + blockInHand.getType());
returnMessage.append(" lobby light material set to id:" + id + " data:" + data + ".");
updatedLobbyMaterials = true; updatedLobbyMaterials = true;
} }
@ -619,29 +599,20 @@ public class War extends JavaPlugin {
ItemStack blockInHand = player.getItemInHand(); ItemStack blockInHand = player.getItemInHand();
boolean updatedMaterials = false; boolean updatedMaterials = false;
int id = blockInHand.getTypeId();
byte data = (byte)0;
if (blockInHand.getData() != null) {
data = blockInHand.getData().getData();
}
if (!blockInHand.getType().isBlock()) { if (!blockInHand.getType().isBlock()) {
this.badMsg(player, "Can only use blocks as material."); this.badMsg(player, "Can only use blocks as material.");
} else { } else {
if (whichBlocks.equals("main")) { if (whichBlocks.equals("main")) {
warzone.getWarzoneMaterials().setMainId(id); warzone.getWarzoneMaterials().setMainBlock(blockInHand);
warzone.getWarzoneMaterials().setMainData(data); returnMessage.append(" main material set to " + blockInHand.getType());
returnMessage.append(" main material set to id:" + id + " data:" + data + ".");
updatedMaterials = true; updatedMaterials = true;
} else if (whichBlocks.equals("stand")) { } else if (whichBlocks.equals("stand")) {
warzone.getWarzoneMaterials().setStandId(id); warzone.getWarzoneMaterials().setStandBlock(blockInHand);
warzone.getWarzoneMaterials().setStandData(data); returnMessage.append(" stand material set to " + blockInHand.getType());
returnMessage.append(" stand material set to id:" + id + " data:" + data + ".");
updatedMaterials = true; updatedMaterials = true;
} else if (whichBlocks.equals("light")) { } else if (whichBlocks.equals("light")) {
warzone.getWarzoneMaterials().setLightId(id); warzone.getWarzoneMaterials().setLightBlock(blockInHand);
warzone.getWarzoneMaterials().setLightData(data); returnMessage.append(" light material set to " + blockInHand.getType());
returnMessage.append(" light material set to id:" + id + " data:" + data + ".");
updatedMaterials = true; updatedMaterials = true;
} }
@ -752,34 +723,24 @@ public class War extends JavaPlugin {
ItemStack blockInHand = player.getItemInHand(); ItemStack blockInHand = player.getItemInHand();
boolean updatedWarhubMaterials = false; boolean updatedWarhubMaterials = false;
int id = blockInHand.getTypeId();
byte data = (byte)0;
if (blockInHand.getData() != null) {
data = blockInHand.getData().getData();
}
if (!blockInHand.getType().isBlock() && !blockInHand.getType().equals(Material.AIR)) { if (!blockInHand.getType().isBlock() && !blockInHand.getType().equals(Material.AIR)) {
this.badMsg(player, "Can only use blocks or air as warhub material."); this.badMsg(player, "Can only use blocks or air as warhub material.");
} else { } else {
if (whichBlocks.equals("floor")) { if (whichBlocks.equals("floor")) {
War.war.getWarhubMaterials().setFloorId(id); this.warhubMaterials.setFloorBlock(blockInHand);
War.war.getWarhubMaterials().setFloorData(data); returnMessage.append(" warhub floor material set to " + blockInHand.getType());
returnMessage.append(" warhub floor material set to id:" + id + " data:" + data + ".");
updatedWarhubMaterials = true; updatedWarhubMaterials = true;
} else if (whichBlocks.equals("outline")) { } else if (whichBlocks.equals("outline")) {
War.war.getWarhubMaterials().setOutlineId(id); this.warhubMaterials.setOutlineBlock(blockInHand);
War.war.getWarhubMaterials().setOutlineData(data); returnMessage.append(" warhub outline material set to " + blockInHand.getType());
returnMessage.append(" warhub outline material set to id:" + id + " data:" + data + ".");
updatedWarhubMaterials = true; updatedWarhubMaterials = true;
} else if (whichBlocks.equals("gate")) { } else if (whichBlocks.equals("gate")) {
War.war.getWarhubMaterials().setGateId(id); this.warhubMaterials.setGateBlock(blockInHand);
War.war.getWarhubMaterials().setGateData(data); returnMessage.append(" warhub gate material set to " + blockInHand.getType());
returnMessage.append(" warhub gate material set to id:" + id + " data:" + data + ".");
updatedWarhubMaterials = true; updatedWarhubMaterials = true;
} else if (whichBlocks.equals("light")) { } else if (whichBlocks.equals("light")) {
War.war.getWarhubMaterials().setLightId(id); this.warhubMaterials.setLightBlock(blockInHand);
War.war.getWarhubMaterials().setLightData(data); returnMessage.append(" warhub light material set to " + blockInHand.getType());
returnMessage.append(" warhub light material set to id:" + id + " data:" + data + ".");
updatedWarhubMaterials = true; updatedWarhubMaterials = true;
} }

View File

@ -37,7 +37,6 @@ import com.tommytony.war.config.TeamKind;
import com.tommytony.war.config.WarzoneConfig; import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.config.WarzoneConfigBag; import com.tommytony.war.config.WarzoneConfigBag;
import com.tommytony.war.event.WarBattleWinEvent; import com.tommytony.war.event.WarBattleWinEvent;
import com.tommytony.war.event.WarPlayerDeathEvent;
import com.tommytony.war.event.WarPlayerLeaveEvent; import com.tommytony.war.event.WarPlayerLeaveEvent;
import com.tommytony.war.event.WarPlayerThiefEvent; import com.tommytony.war.event.WarPlayerThiefEvent;
import com.tommytony.war.event.WarScoreCapEvent; import com.tommytony.war.event.WarScoreCapEvent;
@ -95,7 +94,7 @@ public class Warzone {
private final List<Player> respawn = new ArrayList<Player>(); private final List<Player> respawn = new ArrayList<Player>();
private final List<String> reallyDeadFighters = new ArrayList<String>(); private final List<String> reallyDeadFighters = new ArrayList<String>();
private List<LogKillsDeathsJob.KillsDeathsRecord> killsDeathsTracker = new ArrayList(); private List<LogKillsDeathsJob.KillsDeathsRecord> killsDeathsTracker = new ArrayList<KillsDeathsRecord>();
private final WarzoneConfigBag warzoneConfig; private final WarzoneConfigBag warzoneConfig;
private final TeamConfigBag teamDefaultConfig; private final TeamConfigBag teamDefaultConfig;
@ -104,7 +103,9 @@ public class Warzone {
private Scoreboard scoreboard; private Scoreboard scoreboard;
private HubLobbyMaterials lobbyMaterials = null; 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 WarzoneMaterials warzoneMaterials = new WarzoneMaterials(
new ItemStack(Material.OBSIDIAN), new ItemStack(Material.FENCE),
new ItemStack(Material.GLOWSTONE));
private boolean isEndOfGame = false; private boolean isEndOfGame = false;
private boolean isReinitializing = false; private boolean isReinitializing = false;
@ -116,16 +117,7 @@ public class Warzone {
this.warzoneConfig = new WarzoneConfigBag(this); this.warzoneConfig = new WarzoneConfigBag(this);
this.teamDefaultConfig = new TeamConfigBag(); // don't use ctor with Warzone, as this changes config resolution this.teamDefaultConfig = new TeamConfigBag(); // don't use ctor with Warzone, as this changes config resolution
this.volume = new ZoneVolume(name, this.getWorld(), this); this.volume = new ZoneVolume(name, this.getWorld(), this);
this.lobbyMaterials = new HubLobbyMaterials( this.lobbyMaterials = War.war.getWarhubMaterials().clone();
War.war.getWarhubMaterials().getFloorId(),
War.war.getWarhubMaterials().getFloorData(),
War.war.getWarhubMaterials().getOutlineId(),
War.war.getWarhubMaterials().getOutlineData(),
War.war.getWarhubMaterials().getGateId(),
War.war.getWarhubMaterials().getGateData(),
War.war.getWarhubMaterials().getLightId(),
War.war.getWarhubMaterials().getLightData()
);
} }
public static Warzone getZoneByName(String name) { public static Warzone getZoneByName(String name) {
@ -617,7 +609,7 @@ public class Warzone {
int invIndex = 0; int invIndex = 0;
for (ItemStack item : originalContents.getContents()) { for (ItemStack item : originalContents.getContents()) {
if (item != null && item.getTypeId() != 0) { if (item != null && item.getType() != Material.AIR) {
playerInv.setItem(invIndex, item); playerInv.setItem(invIndex, item);
} }
invIndex++; invIndex++;
@ -963,8 +955,7 @@ public class Warzone {
sp.sendNotification( sp.sendNotification(
SpoutDisplayer.cleanForNotification("Round over! " + playerTeam.getKind().getColor() + playerTeam.getName()), SpoutDisplayer.cleanForNotification("Round over! " + playerTeam.getKind().getColor() + playerTeam.getName()),
SpoutDisplayer.cleanForNotification("ran out of lives."), SpoutDisplayer.cleanForNotification("ran out of lives."),
playerTeam.getKind().getMaterial(), playerTeam.getKind().getBlockHead(),
playerTeam.getKind().getDyeColor().getWoolData(),
10000); 10000);
} }
} }
@ -1041,8 +1032,7 @@ public class Warzone {
sp.sendNotification( sp.sendNotification(
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"), SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "your flag."), SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "your flag."),
playerTeam.getKind().getMaterial(), playerTeam.getKind().getBlockHead(),
playerTeam.getKind().getDyeColor().getWoolData(),
5000); 5000);
} }
} }
@ -1484,7 +1474,7 @@ public class Warzone {
int invIndex = 0; int invIndex = 0;
playerItems = new HashMap<Integer, ItemStack>(); playerItems = new HashMap<Integer, ItemStack>();
for (ItemStack item : originalState.getContents()) { for (ItemStack item : originalState.getContents()) {
if (item != null && item.getTypeId() != 0) { if (item != null && item.getType() != Material.AIR) {
playerItems.put(invIndex, item); playerItems.put(invIndex, item);
} }
invIndex++; invIndex++;

View File

@ -1,15 +1,11 @@
package com.tommytony.war.command; package com.tommytony.war.command;
import java.util.List;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.tommytony.war.Team; import com.tommytony.war.Team;
import com.tommytony.war.War; import com.tommytony.war.War;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.TeamKind; import com.tommytony.war.config.TeamKind;
import com.tommytony.war.config.WarzoneConfig; import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.structure.ZoneLobby; import com.tommytony.war.structure.ZoneLobby;

View File

@ -60,7 +60,7 @@ public class KillstreakReward {
*/ */
public KillstreakReward(ConfigurationSection section) { public KillstreakReward(ConfigurationSection section) {
this.section = section; this.section = section;
this.airstrikePlayers = new HashSet(); this.airstrikePlayers = new HashSet<String>();
} }
/** /**

View File

@ -53,6 +53,7 @@ public enum TeamKind {
* *
* @return wool color data value * @return wool color data value
*/ */
@SuppressWarnings("deprecation")
public byte getData() { public byte getData() {
return this.dyeColor.getWoolData(); return this.dyeColor.getWoolData();
} }

View File

@ -55,7 +55,10 @@ public class WarBlockListener implements Listener {
Team team = Team.getTeamByPlayerName(player.getName()); Team team = Team.getTeamByPlayerName(player.getName());
Warzone zone = Warzone.getZoneByLocation(player); Warzone zone = Warzone.getZoneByLocation(player);
// Monument capturing // Monument capturing
if (team != null && block != null && zone != null && zone.isMonumentCenterBlock(block) && block.getType() == team.getKind().getMaterial() && block.getData() == team.getKind().getData()) { if (team != null && block != null && zone != null
&& zone.isMonumentCenterBlock(block)
&& block.getType() == team.getKind().getMaterial()
&& block.getState().getData() == team.getKind().getBlockData()) {
Monument monument = zone.getMonumentFromCenterBlock(block); Monument monument = zone.getMonumentFromCenterBlock(block);
if (monument != null && !monument.hasOwner()) { if (monument != null && !monument.hasOwner()) {
monument.capture(team); monument.capture(team);
@ -122,7 +125,7 @@ public class WarBlockListener implements Listener {
} }
// can't place a block of your team's color // can't place a block of your team's color
if (team != null && block.getType() == team.getKind().getMaterial() && block.getData() == team.getKind().getData()) { if (team != null && block.getType() == team.getKind().getMaterial() && block.getState().getData() == team.getKind().getBlockData()) {
War.war.badMsg(player, "You can only use your team's blocks to capture monuments."); War.war.badMsg(player, "You can only use your team's blocks to capture monuments.");
cancelAndKeepItem(event); cancelAndKeepItem(event);
return; return;

View File

@ -1,7 +1,6 @@
package com.tommytony.war.event; package com.tommytony.war.event;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@ -9,8 +8,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Location; 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.NoteBlock; import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,8 +27,6 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer; import org.getspout.spoutapi.player.SpoutPlayer;
@ -43,7 +39,6 @@ import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.job.DeferredBlockResetsJob; import com.tommytony.war.job.DeferredBlockResetsJob;
import com.tommytony.war.spout.SpoutDisplayer; import com.tommytony.war.spout.SpoutDisplayer;
import com.tommytony.war.structure.Bomb; import com.tommytony.war.structure.Bomb;
import com.tommytony.war.utility.DeferredBlockReset;
import com.tommytony.war.utility.LoadoutSelection; import com.tommytony.war.utility.LoadoutSelection;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -339,8 +334,10 @@ public class WarEntityListener implements Listener {
if (zone.isBombBlock(block)) { if (zone.isBombBlock(block)) {
// tnt doesn't get reset like normal blocks, gotta schedule a later reset just for the Bomb // tnt doesn't get reset like normal blocks, gotta schedule a later reset just for the Bomb
// structure's tnt block // structure's tnt block
DeferredBlockResetsJob job = new DeferredBlockResetsJob(block.getWorld()); DeferredBlockResetsJob job = new DeferredBlockResetsJob();
job.add(new DeferredBlockReset(block.getX(), block.getY(), block.getZ(), Material.TNT.getId(), (byte)0)); BlockState tnt = block.getState();
tnt.setType(Material.TNT);
job.add(tnt);
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job, 10); War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job, 10);
} }
inOneZone = true; inOneZone = true;
@ -364,37 +361,9 @@ public class WarEntityListener implements Listener {
int dontExplodeSize = dontExplode.size(); int dontExplodeSize = dontExplode.size();
if (dontExplode.size() > 0) { if (dontExplode.size() > 0) {
// Reset the exploded blocks that shouldn't have exploded (some of these are zone artifacts, if rollbackexplosion some may be outside-of-zone blocks // Reset the exploded blocks that shouldn't have exploded (some of these are zone artifacts, if rollbackexplosion some may be outside-of-zone blocks
DeferredBlockResetsJob job = new DeferredBlockResetsJob(dontExplode.get(0).getWorld()); DeferredBlockResetsJob job = new DeferredBlockResetsJob();
List<Block> doors = new ArrayList<Block>();
for (Block dont : dontExplode) { for (Block dont : dontExplode) {
DeferredBlockReset deferred = null; job.add(dont.getState());
if (dont.getState() instanceof Sign) {
String[] lines = ((Sign)dont.getState()).getLines();
deferred = new DeferredBlockReset(dont.getX(), dont.getY(), dont.getZ(), dont.getTypeId(), dont.getData(), lines);
} else if (dont.getState() instanceof InventoryHolder) {
ItemStack[] contents = ((InventoryHolder)dont.getState()).getInventory().getContents();
Block worldBlock = dont.getWorld().getBlockAt(dont.getLocation());
if (worldBlock.getState() instanceof InventoryHolder) {
((InventoryHolder)worldBlock.getState()).getInventory().clear();
}
deferred = new DeferredBlockReset(dont.getX(), dont.getY(), dont.getZ(), dont.getTypeId(), dont.getData(), copyItems(contents));
} else if (dont.getTypeId() == Material.NOTE_BLOCK.getId()) {
Block worldBlock = dont.getWorld().getBlockAt(dont.getLocation());
if (worldBlock.getState() instanceof NoteBlock) {
NoteBlock noteBlock = ((NoteBlock)worldBlock.getState());
if (noteBlock != null) {
deferred = new DeferredBlockReset(dont.getX(), dont.getY(), dont.getZ(), dont.getTypeId(), dont.getData(), noteBlock.getRawNote());
}
}
} else if (dont.getTypeId() != Material.TNT.getId()) {
deferred = new DeferredBlockReset(dont.getX(), dont.getY(), dont.getZ(), dont.getTypeId(), dont.getData());
if (dont.getTypeId() == Material.WOODEN_DOOR.getId() || dont.getTypeId() == Material.IRON_DOOR_BLOCK.getId()) {
doors.add(dont);
}
}
if (deferred != null) {
job.add(deferred);
}
} }
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job); War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
@ -407,10 +376,6 @@ public class WarEntityListener implements Listener {
} }
} }
private List<ItemStack> copyItems(ItemStack[] contents) {
return Arrays.asList(contents);
}
/** /**
* Handles damage on Players * Handles damage on Players
* *

View File

@ -104,7 +104,7 @@ public class WarPlayerListener implements Listener {
Item item = event.getItemDrop(); Item item = event.getItemDrop();
if (item != null) { if (item != null) {
ItemStack itemStack = item.getItemStack(); ItemStack itemStack = item.getItemStack();
if (itemStack != null && itemStack.getType() == team.getKind().getMaterial() && itemStack.getData().getData() == team.getKind().getData()) { if (itemStack != null && itemStack.getType() == team.getKind().getMaterial() && itemStack.getData() == team.getKind().getBlockData()) {
// Can't drop your team's kind block // Can't drop your team's kind block
War.war.badMsg(player, "Can't drop " + team.getName() + " blocks."); War.war.badMsg(player, "Can't drop " + team.getName() + " blocks.");
event.setCancelled(true); event.setCancelled(true);

View File

@ -3,167 +3,45 @@ package com.tommytony.war.job;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.NoteBlock;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import com.tommytony.war.utility.DeferredBlockReset; import com.tommytony.war.utility.DeferredBlockReset;
import com.tommytony.war.utility.Direction;
import com.tommytony.war.volume.Volume;
public class DeferredBlockResetsJob implements Runnable { public class DeferredBlockResetsJob implements Runnable {
List<DeferredBlockReset> deferred = new ArrayList<DeferredBlockReset>(); List<BlockState> deferred = new ArrayList<BlockState>();
private final World world;
public DeferredBlockResetsJob(World world) {
this.world = world;
public DeferredBlockResetsJob() {
} }
public void add(DeferredBlockReset pleaseResetLater) { @Deprecated
public DeferredBlockResetsJob(World humor) {
}
public void add(BlockState pleaseResetLater) {
this.deferred.add(pleaseResetLater); this.deferred.add(pleaseResetLater);
} }
@Deprecated
public void add(DeferredBlockReset humor) {
}
public boolean isEmpty() { public boolean isEmpty() {
return this.deferred.isEmpty(); return this.deferred.isEmpty();
} }
public void run() { public void run() {
ArrayList<DeferredBlockReset> doors = new ArrayList<DeferredBlockReset>(); for (BlockState reset : this.deferred) {
reset.update(true, false);
for (DeferredBlockReset reset : this.deferred) { for (Entity ent : reset.getWorld().getEntities()) {
if (this.world != null && reset != null) { if (ent instanceof Item
Block worldBlock = this.world.getBlockAt(reset.getX(), reset.getY(), reset.getZ()); && ent.getLocation().distance(reset.getLocation()) < 2) {
worldBlock.setType(Material.getMaterial(reset.getBlockType())); ent.remove();
if (reset.getBlockType() == Material.WALL_SIGN.getId() || reset.getBlockType() == Material.SIGN_POST.getId()) {
BlockState state = worldBlock.getState();
state.setData(new org.bukkit.material.Sign(reset.getBlockType(), reset.getBlockData()));
if (state instanceof Sign) {
Sign sign = (Sign) state;
if (reset.getLines() != null && sign.getLines() != null) {
if (reset.getLines().length > 0) {
sign.setLine(0, reset.getLines()[0]);
}
if (reset.getLines().length > 1) {
sign.setLine(1, reset.getLines()[1]);
}
if (reset.getLines().length > 2) {
sign.setLine(2, reset.getLines()[2]);
}
if (reset.getLines().length > 3) {
sign.setLine(3, reset.getLines()[3]);
}
sign.update(true);
}
}
} else if (reset.getBlockType() == Material.CHEST.getId()
|| reset.getBlockType() == Material.DISPENSER.getId()
|| reset.getBlockType() == Material.FURNACE.getId()
|| reset.getBlockType() == Material.BURNING_FURNACE.getId()) {
List<ItemStack> items = reset.getItems();
worldBlock.setType(Material.getMaterial(reset.getBlockType()));
worldBlock.setData(reset.getBlockData());
BlockState state = worldBlock.getState();
if (state instanceof InventoryHolder) {
InventoryHolder container = (InventoryHolder) state;
if (items != null) {
int ii = 0;
container.getInventory().clear();
for (ItemStack item : items) {
if (item != null) {
container.getInventory().setItem(ii, item);
ii++;
}
}
state.update(true);
items.clear();
}
} else {
// normal reset
worldBlock.setData(reset.getBlockData());
}
} else if (reset.getBlockType() == Material.NOTE_BLOCK.getId()) {
worldBlock.setType(Material.getMaterial(reset.getBlockType()));
worldBlock.setData(reset.getBlockData());
BlockState state = worldBlock.getState();
if (state instanceof NoteBlock && reset.getRawNote() != null) {
NoteBlock noteBlock = (NoteBlock) state;
noteBlock.setRawNote(reset.getRawNote());
noteBlock.update(true);
} else {
// normal reset
worldBlock.setData(reset.getBlockData());
}
} else if (reset.getBlockType() == Material.WOODEN_DOOR.getId() || reset.getBlockType() == Material.IRON_DOOR_BLOCK.getId()) {
// Door blocks
doors.add(reset);
} else {
// normal data reset
worldBlock.setData(reset.getBlockData());
}
}
}
// Take care of doors last
for (DeferredBlockReset doorBlock : doors) {
Block worldBlock = world.getBlockAt(doorBlock.getX(), doorBlock.getY(), doorBlock.getZ());
if (worldBlock.getTypeId() != doorBlock.getBlockType() || worldBlock.getData() != doorBlock.getBlockData()) {
// find its friend
for (DeferredBlockReset other : doors) {
if (other.getX() == doorBlock.getX()
&& other.getY() == doorBlock.getY() - 1
&& other.getZ() == doorBlock.getZ()) {
// doorBlock is above
Block above = worldBlock;
Block below = world.getBlockAt(other.getX(), other.getY(), other.getZ());
above.setTypeId(doorBlock.getBlockType());
above.setData(doorBlock.getBlockData());
below.setTypeId(other.getBlockType());
below.setData(other.getBlockData());
scrubDroppedDoors(below);
break;
} else if (other.getX() == doorBlock.getX()
&& other.getY() == doorBlock.getY() + 1
&& other.getZ() == doorBlock.getZ()) {
// doorBlock is below
Block above = world.getBlockAt(other.getX(), other.getY(), other.getZ());
Block below = worldBlock;
above.setTypeId(doorBlock.getBlockType());
above.setData(doorBlock.getBlockData());
below.setTypeId(other.getBlockType());
below.setData(other.getBlockData());
scrubDroppedDoors(below);
break;
}
} }
} }
} }
} }
private void scrubDroppedDoors(Block block) {
Chunk chunk = block.getWorld().getChunkAt(block);
Volume scrubVolume = new Volume("scrub", block.getWorld());
scrubVolume.setCornerOne(block.getRelative(BlockFace.DOWN).getRelative(Direction.EAST()).getRelative(Direction.NORTH()));
scrubVolume.setCornerTwo(block.getRelative(BlockFace.UP).getRelative(Direction.WEST()).getRelative(Direction.SOUTH()));
for (Entity entity : chunk.getEntities()) {
if ((entity instanceof Item && (((Item)entity).getItemStack().getTypeId() == Material.IRON_DOOR.getId()
|| ((Item)entity).getItemStack().getTypeId() == Material.WOOD_DOOR.getId()))
&& scrubVolume.contains(entity.getLocation())) {
entity.remove();
}
}
}
} }

View File

@ -47,7 +47,7 @@ public class HelmetProtectionTask implements Runnable {
int removed = 0; int removed = 0;
for (ItemStack item : playerInv.getContents()) { for (ItemStack item : playerInv.getContents()) {
// remove only same colored wool // remove only same colored wool
if (item != null && item.getType() == teamBlockMaterial && item.getData().getData() == team.getKind().getData()) { if (item != null && item.getType() == teamBlockMaterial && item.getData() == team.getKind().getBlockData()) {
playerInv.clear(i); playerInv.clear(i);
removed++; removed++;
} }

View File

@ -1,37 +0,0 @@
package com.tommytony.war.job;
import org.bukkit.block.Block;
import com.tommytony.war.utility.Direction;
import com.tommytony.war.volume.BlockInfo;
public class ResetCursorJob implements Runnable {
private final Block cornerBlock;
private final BlockInfo[] originalCursorBlocks;
private final boolean isSoutheast;
public ResetCursorJob(Block cornerBlock, BlockInfo[] originalCursorBlocks, boolean isSoutheast) {
this.cornerBlock = cornerBlock;
this.originalCursorBlocks = originalCursorBlocks;
this.isSoutheast = isSoutheast;
}
public void run() {
if (this.isSoutheast) {
this.cornerBlock.setType(this.originalCursorBlocks[0].getType());
this.cornerBlock.setData(this.originalCursorBlocks[0].getData());
this.cornerBlock.getRelative(Direction.WEST()).setType(this.originalCursorBlocks[1].getType());
this.cornerBlock.getRelative(Direction.WEST()).setData(this.originalCursorBlocks[1].getData());
this.cornerBlock.getRelative(Direction.NORTH()).setType(this.originalCursorBlocks[2].getType());
this.cornerBlock.getRelative(Direction.NORTH()).setData(this.originalCursorBlocks[2].getData());
} else {
this.cornerBlock.setType(this.originalCursorBlocks[0].getType());
this.cornerBlock.setData(this.originalCursorBlocks[0].getData());
this.cornerBlock.getRelative(Direction.EAST()).setType(this.originalCursorBlocks[1].getType());
this.cornerBlock.getRelative(Direction.EAST()).setData(this.originalCursorBlocks[1].getData());
this.cornerBlock.getRelative(Direction.SOUTH()).setType(this.originalCursorBlocks[2].getType());
this.cornerBlock.getRelative(Direction.SOUTH()).setData(this.originalCursorBlocks[2].getData());
}
}
}

View File

@ -5,12 +5,12 @@ import java.util.logging.Level;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.tommytony.war.War; import com.tommytony.war.War;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
import com.tommytony.war.mapper.VolumeMapper; import com.tommytony.war.mapper.VolumeMapper;
import com.tommytony.war.structure.WarHub; import com.tommytony.war.structure.WarHub;
import com.tommytony.war.structure.HubLobbyMaterials;
import com.tommytony.war.volume.Volume; import com.tommytony.war.volume.Volume;
public class RestoreYmlWarhubJob implements Runnable { public class RestoreYmlWarhubJob implements Runnable {
@ -21,6 +21,7 @@ public class RestoreYmlWarhubJob implements Runnable {
this.warhubConfig = warhubConfig; this.warhubConfig = warhubConfig;
} }
@SuppressWarnings("deprecation")
public void run() { public void run() {
int hubX = warhubConfig.getInt("x"); int hubX = warhubConfig.getInt("x");
int hubY = warhubConfig.getInt("y"); int hubY = warhubConfig.getInt("y");
@ -30,40 +31,54 @@ public class RestoreYmlWarhubJob implements Runnable {
String hubOrientation = warhubConfig.getString("orientation"); String hubOrientation = warhubConfig.getString("orientation");
// materials // materials
int floorId = 20; // default glass if (warhubConfig.isItemStack("materials.floor")) {
int floorData = 0; War.war.getWarhubMaterials().setFloorBlock(
ConfigurationSection floorMaterialSection = warhubConfig.getConfigurationSection("materials.floor"); warhubConfig.getItemStack("materials.floor"));
if (floorMaterialSection != null) { } else {
floorId = floorMaterialSection.getInt("id"); ConfigurationSection floorMaterialSection = warhubConfig
floorData = floorMaterialSection.getInt("data"); .getConfigurationSection("materials.floor");
if (floorMaterialSection != null) {
War.war.getWarhubMaterials().setFloorBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
if (warhubConfig.isItemStack("materials.outline")) {
int outlineId = 5; // default planks War.war.getWarhubMaterials().setOutlineBlock(
int outlineData = 0; warhubConfig.getItemStack("materials.outline"));
ConfigurationSection outlineMaterialSection = warhubConfig.getConfigurationSection("materials.outline"); } else {
if (outlineMaterialSection != null) { ConfigurationSection floorMaterialSection = warhubConfig
outlineId = outlineMaterialSection.getInt("id"); .getConfigurationSection("materials.outline");
outlineData = outlineMaterialSection.getInt("data"); if (floorMaterialSection != null) {
War.war.getWarhubMaterials().setOutlineBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
if (warhubConfig.isItemStack("materials.gate")) {
int gateId = 49; // default obsidian War.war.getWarhubMaterials().setGateBlock(
int gateData = 0; warhubConfig.getItemStack("materials.gate"));
ConfigurationSection gateMaterialSection = warhubConfig.getConfigurationSection("materials.gate"); } else {
if (gateMaterialSection != null) { ConfigurationSection floorMaterialSection = warhubConfig
gateId = gateMaterialSection.getInt("id"); .getConfigurationSection("materials.gate");
gateData = gateMaterialSection.getInt("data"); if (floorMaterialSection != null) {
War.war.getWarhubMaterials().setGateBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
if (warhubConfig.isItemStack("materials.light")) {
int lightId = 89; // default glowstone War.war.getWarhubMaterials().setLightBlock(
int lightData = 0; warhubConfig.getItemStack("materials.light"));
ConfigurationSection lightMaterialSection = warhubConfig.getConfigurationSection("materials.light"); } else {
if (lightMaterialSection != null) { ConfigurationSection floorMaterialSection = warhubConfig
lightId = lightMaterialSection.getInt("id"); .getConfigurationSection("materials.light");
lightData = lightMaterialSection.getInt("data"); if (floorMaterialSection != null) {
War.war.getWarhubMaterials().setLightBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
War.war.setWarhubMaterials(new HubLobbyMaterials(floorId, (byte)floorData, outlineId, (byte)outlineData, gateId, (byte)gateData, lightId, (byte)lightData));
World world = War.war.getServer().getWorld(worldName); World world = War.war.getServer().getWorld(worldName);
if (world != null) { if (world != null) {
Location hubLocation = new Location(world, hubX, hubY, hubZ); Location hubLocation = new Location(world, hubX, hubY, hubZ);

View File

@ -50,6 +50,7 @@ public class LoadoutYmlMapper {
* @param loadoutName The name of the loadout * @param loadoutName The name of the loadout
* @return new style loadout * @return new style loadout
*/ */
@SuppressWarnings("deprecation")
public static Loadout fromConfigToLoadout(ConfigurationSection config, HashMap<Integer, ItemStack> loadout, String loadoutName) { public static Loadout fromConfigToLoadout(ConfigurationSection config, HashMap<Integer, ItemStack> loadout, String loadoutName) {
List<Integer> slots = config.getIntegerList(loadoutName + ".slots"); List<Integer> slots = config.getIntegerList(loadoutName + ".slots");
for (Integer slot : slots) { for (Integer slot : slots) {

View File

@ -184,18 +184,10 @@ public class WarYmlMapper {
hubConfigSection.set("world", hub.getLocation().getWorld().getName()); hubConfigSection.set("world", hub.getLocation().getWorld().getName());
hubConfigSection.set("orientation", orientationStr); hubConfigSection.set("orientation", orientationStr);
ConfigurationSection floorSection = hubConfigSection.createSection("materials.floor"); hubConfigSection.set("materials.floor", War.war.getWarhubMaterials().getFloorBlock());
floorSection.set("id", War.war.getWarhubMaterials().getFloorId()); hubConfigSection.set("materials.outline", War.war.getWarhubMaterials().getOutlineBlock());
floorSection.set("data", War.war.getWarhubMaterials().getFloorData()); hubConfigSection.set("materials.gate", War.war.getWarhubMaterials().getGateBlock());
ConfigurationSection outlineSection = hubConfigSection.createSection("materials.outline"); hubConfigSection.set("materials.light", War.war.getWarhubMaterials().getLightBlock());
outlineSection.set("id", War.war.getWarhubMaterials().getOutlineId());
outlineSection.set("data", War.war.getWarhubMaterials().getOutlineData());
ConfigurationSection gateSection = hubConfigSection.createSection("materials.gate");
gateSection.set("id", War.war.getWarhubMaterials().getGateId());
gateSection.set("data", War.war.getWarhubMaterials().getGateData());
ConfigurationSection lightSection = hubConfigSection.createSection("materials.light");
lightSection.set("id", War.war.getWarhubMaterials().getLightId());
lightSection.set("data", War.war.getWarhubMaterials().getLightData());
VolumeMapper.save(hub.getVolume(), ""); VolumeMapper.save(hub.getVolume(), "");
} }

View File

@ -22,9 +22,7 @@ import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.TeamKind; import com.tommytony.war.config.TeamKind;
import com.tommytony.war.structure.Bomb; import com.tommytony.war.structure.Bomb;
import com.tommytony.war.structure.Cake; import com.tommytony.war.structure.Cake;
import com.tommytony.war.structure.HubLobbyMaterials;
import com.tommytony.war.structure.Monument; import com.tommytony.war.structure.Monument;
import com.tommytony.war.structure.WarzoneMaterials;
import com.tommytony.war.structure.ZoneLobby; import com.tommytony.war.structure.ZoneLobby;
import com.tommytony.war.utility.Direction; import com.tommytony.war.utility.Direction;
import com.tommytony.war.volume.Volume; import com.tommytony.war.volume.Volume;
@ -32,6 +30,7 @@ import com.tommytony.war.volume.ZoneVolume;
public class WarzoneYmlMapper { public class WarzoneYmlMapper {
@SuppressWarnings("deprecation")
public static Warzone load(String name, boolean createNewVolume) { public static Warzone load(String name, boolean createNewVolume) {
File warzoneTxtFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt"); File warzoneTxtFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
File warzoneYmlFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".yml"); File warzoneYmlFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".yml");
@ -323,40 +322,55 @@ public class WarzoneYmlMapper {
} }
// lobby materials // lobby materials
int floorId = War.war.getWarhubMaterials().getFloorId(); // default warhub if (warzoneRootSection.isItemStack(lobbyPrefix + "materials.floor")) {
int floorData = War.war.getWarhubMaterials().getFloorData(); warzone.getLobbyMaterials().setFloorBlock(
ConfigurationSection floorMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.floor"); warzoneRootSection.getItemStack(lobbyPrefix + "materials.floor"));
if (floorMaterialSection != null) { } else {
floorId = floorMaterialSection.getInt("id"); ConfigurationSection floorMaterialSection = warzoneRootSection
floorData = floorMaterialSection.getInt("data"); .getConfigurationSection(lobbyPrefix + "materials.floor");
if (floorMaterialSection != null) {
warzone.getLobbyMaterials().setFloorBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
if (warzoneRootSection.isItemStack(lobbyPrefix + "materials.outline")) {
int outlineId = War.war.getWarhubMaterials().getOutlineId(); warzone.getLobbyMaterials().setOutlineBlock(
int outlineData = War.war.getWarhubMaterials().getOutlineData(); warzoneRootSection.getItemStack(lobbyPrefix + "materials.outline"));
ConfigurationSection outlineMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.outline"); } else {
if (outlineMaterialSection != null) { ConfigurationSection floorMaterialSection = warzoneRootSection
outlineId = outlineMaterialSection.getInt("id"); .getConfigurationSection(lobbyPrefix + "materials.outline");
outlineData = outlineMaterialSection.getInt("data"); if (floorMaterialSection != null) {
warzone.getLobbyMaterials().setOutlineBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
if (warzoneRootSection.isItemStack(lobbyPrefix + "materials.gate")) {
int gateId = War.war.getWarhubMaterials().getGateId(); warzone.getLobbyMaterials().setGateBlock(
int gateData = War.war.getWarhubMaterials().getGateData();; warzoneRootSection.getItemStack(lobbyPrefix + "materials.gate"));
ConfigurationSection gateMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.gate"); } else {
if (gateMaterialSection != null) { ConfigurationSection floorMaterialSection = warzoneRootSection
gateId = gateMaterialSection.getInt("id"); .getConfigurationSection(lobbyPrefix + "materials.gate");
gateData = gateMaterialSection.getInt("data"); if (floorMaterialSection != null) {
warzone.getLobbyMaterials().setGateBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
if (warzoneRootSection.isItemStack(lobbyPrefix + "materials.light")) {
int lobbyLightId = War.war.getWarhubMaterials().getLightId(); warzone.getLobbyMaterials().setLightBlock(
int lobbyLightData = War.war.getWarhubMaterials().getLightData(); warzoneRootSection.getItemStack(lobbyPrefix + "materials.light"));
ConfigurationSection lobbyLightMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.light"); } else {
if (lobbyLightMaterialSection != null) { ConfigurationSection floorMaterialSection = warzoneRootSection
lobbyLightId = lobbyLightMaterialSection.getInt("id"); .getConfigurationSection(lobbyPrefix + "materials.light");
lobbyLightData = lobbyLightMaterialSection.getInt("data"); if (floorMaterialSection != null) {
warzone.getLobbyMaterials().setLightBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
warzone.setLobbyMaterials(new HubLobbyMaterials(floorId, (byte)floorData, outlineId, (byte)outlineData, gateId, (byte)gateData, lobbyLightId, (byte)lobbyLightData));
// lobby world // lobby world
String lobbyWorldName = warzoneRootSection.getString(lobbyPrefix + "world"); String lobbyWorldName = warzoneRootSection.getString(lobbyPrefix + "world");
World lobbyWorld = War.war.getServer().getWorld(lobbyWorldName); World lobbyWorld = War.war.getServer().getWorld(lobbyWorldName);
@ -367,32 +381,43 @@ public class WarzoneYmlMapper {
warzone.setLobby(lobby); warzone.setLobby(lobby);
// warzone materials // warzone materials
int mainId = warzone.getWarzoneMaterials().getMainId(); if (warzoneRootSection.isItemStack(zoneInfoPrefix + "materials.main")) {
int mainData = warzone.getWarzoneMaterials().getMainData(); warzone.getWarzoneMaterials().setMainBlock(
ConfigurationSection mainMaterialSection = warzoneRootSection.getConfigurationSection(zoneInfoPrefix + "materials.main"); warzoneRootSection.getItemStack(zoneInfoPrefix + "materials.main"));
if (mainMaterialSection != null) { } else {
mainId = mainMaterialSection.getInt("id"); ConfigurationSection floorMaterialSection = warzoneRootSection
mainData = mainMaterialSection.getInt("data"); .getConfigurationSection(zoneInfoPrefix + "materials.main");
if (floorMaterialSection != null) {
warzone.getWarzoneMaterials().setMainBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
if (warzoneRootSection.isItemStack(zoneInfoPrefix + "materials.stand")) {
int standId = warzone.getWarzoneMaterials().getStandId(); warzone.getWarzoneMaterials().setStandBlock(
int standData = warzone.getWarzoneMaterials().getStandData(); warzoneRootSection.getItemStack(zoneInfoPrefix + "materials.stand"));
ConfigurationSection standMaterialSection = warzoneRootSection.getConfigurationSection(zoneInfoPrefix + "materials.stand"); } else {
if (standMaterialSection != null) { ConfigurationSection floorMaterialSection = warzoneRootSection
standId = standMaterialSection.getInt("id"); .getConfigurationSection(zoneInfoPrefix + "materials.stand");
standData = standMaterialSection.getInt("data"); if (floorMaterialSection != null) {
warzone.getWarzoneMaterials().setStandBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
if (warzoneRootSection.isItemStack(zoneInfoPrefix + "materials.light")) {
int lightId = warzone.getWarzoneMaterials().getLightId(); warzone.getWarzoneMaterials().setLightBlock(
int lightData = warzone.getWarzoneMaterials().getLightData(); warzoneRootSection.getItemStack(zoneInfoPrefix + "materials.light"));
ConfigurationSection lightMaterialSection = warzoneRootSection.getConfigurationSection(zoneInfoPrefix + "materials.light"); } else {
if (lightMaterialSection != null) { ConfigurationSection floorMaterialSection = warzoneRootSection
lightId = lightMaterialSection.getInt("id"); .getConfigurationSection(zoneInfoPrefix + "materials.light");
lightData = lightMaterialSection.getInt("data"); if (floorMaterialSection != null) {
warzone.getWarzoneMaterials().setLightBlock(
new ItemStack(floorMaterialSection.getInt("id"), 1,
(short) floorMaterialSection.getInt("data")));
}
} }
warzone.setWarzoneMaterials(new WarzoneMaterials(mainId, (byte)mainData, standId, (byte)standData, lightId, (byte)lightData));
return warzone; return warzone;
} }
@ -444,31 +469,17 @@ public class WarzoneYmlMapper {
lobbySection.set("orientation", lobbyOrientation); lobbySection.set("orientation", lobbyOrientation);
lobbySection.set("world", warzone.getLobby().getVolume().getWorld().getName()); lobbySection.set("world", warzone.getLobby().getVolume().getWorld().getName());
ConfigurationSection floorSection = lobbySection.createSection("materials.floor"); lobbySection.set("materials.floor", warzone.getLobbyMaterials().getFloorBlock());
floorSection.set("id", warzone.getLobbyMaterials().getFloorId()); lobbySection.set("materials.outline", warzone.getLobbyMaterials().getOutlineBlock());
floorSection.set("data", warzone.getLobbyMaterials().getFloorData()); lobbySection.set("materials.gate", warzone.getLobbyMaterials().getGateBlock());
ConfigurationSection outlineSection = lobbySection.createSection("materials.outline"); lobbySection.set("materials.light", warzone.getLobbyMaterials().getLightBlock());
outlineSection.set("id", warzone.getLobbyMaterials().getOutlineId());
outlineSection.set("data", warzone.getLobbyMaterials().getOutlineData());
ConfigurationSection gateSection = lobbySection.createSection("materials.gate");
gateSection.set("id", warzone.getLobbyMaterials().getGateId());
gateSection.set("data", warzone.getLobbyMaterials().getGateData());
ConfigurationSection lightSection = lobbySection.createSection("materials.light");
lightSection.set("id", warzone.getLobbyMaterials().getLightId());
lightSection.set("data", warzone.getLobbyMaterials().getLightData());
} }
// materials // materials
if (warzone.getLobby() != null) { if (warzone.getLobby() != null) {
ConfigurationSection mainSection = warzoneInfoSection.createSection("materials.main"); warzoneInfoSection.set("materials.main", warzone.getWarzoneMaterials().getMainBlock());
mainSection.set("id", warzone.getWarzoneMaterials().getMainId()); warzoneInfoSection.set("materials.stand", warzone.getWarzoneMaterials().getStandBlock());
mainSection.set("data", warzone.getWarzoneMaterials().getMainData()); warzoneInfoSection.set("materials.light", warzone.getWarzoneMaterials().getLightBlock());
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 // rallyPoint

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.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
@ -53,55 +54,58 @@ public class Bomb {
int y = this.location.getBlockY(); int y = this.location.getBlockY();
int z = this.location.getBlockZ(); 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 // center
Block current = this.warzone.getWorld().getBlockAt(x, y - 1, z); BlockState current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
current.setType(main); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(mainData); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.update(true);
// inner ring // inner ring
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1).getState();
current.setType(light); current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
current.setData(lightData); current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z); current.update(true);
current.setType(main); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z).getState();
current.setData(mainData); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.setType(main); current.update(true);
current.setData(mainData); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1).getState();
current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1); current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1).getState();
current.setType(main); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(mainData); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current = this.warzone.getWorld().getBlockAt(x, y - 1, z); current.update(true);
current.setType(light); current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
current.setData(lightData); current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1); current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
current.setType(main); current.update(true);
current.setData(mainData); current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1).getState();
current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1); current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1).getState();
current.setType(main); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(mainData); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z); current.update(true);
current.setType(main); current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z).getState();
current.setData(mainData); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.setType(light); current.update(true);
current.setData(lightData); current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).getState();
current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
current.update(true);
// block holder // block holder
current = this.warzone.getWorld().getBlockAt(x, y, z); current = this.warzone.getWorld().getBlockAt(x, y, z).getState();
current.setType(stand); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current.setData(standData); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
Block tntBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z); current.update(true);
tntBlock.setType(Material.TNT); this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(Material.TNT);
} }
public boolean isBombBlock(Location otherLocation) { public boolean isBombBlock(Location otherLocation) {

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.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
@ -53,56 +54,58 @@ public class Cake {
int y = this.location.getBlockY(); int y = this.location.getBlockY();
int z = this.location.getBlockZ(); 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 // center
Block current = this.warzone.getWorld().getBlockAt(x, y - 1, z); BlockState current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
current.setType(main); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(mainData); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.update(true);
// inner ring // inner ring
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1).getState();
current.setType(main); current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
current.setData(mainData); current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z); current.update(true);
current.setType(main); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z).getState();
current.setData(mainData); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.setType(light); current.update(true);
current.setData(lightData); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1).getState();
current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1); current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1).getState();
current.setType(main); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(mainData); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current = this.warzone.getWorld().getBlockAt(x, y - 1, z); current.update(true);
current.setType(light); current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
current.setData(lightData); current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1); current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
current.setType(main); current.update(true);
current.setData(mainData); current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1).getState();
current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1); current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1).getState();
current.setType(light); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current.setData(lightData); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z); current.update(true);
current.setType(main); current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z).getState();
current.setData(mainData); current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1); current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
current.setType(main); current.update(true);
current.setData(mainData); current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).getState();
current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
current.update(true);
// block holder // block holder
current = this.warzone.getWorld().getBlockAt(x, y, z); current = this.warzone.getWorld().getBlockAt(x, y, z).getState();
current.setType(stand); current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
current.setData(standData); current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
current.update(true);
Block cakeBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z); this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(Material.CAKE_BLOCK);
cakeBlock.setType(Material.CAKE_BLOCK);
} }
public boolean isCakeBlock(Location otherLocation) { public boolean isCakeBlock(Location otherLocation) {

View File

@ -1,131 +1,70 @@
package com.tommytony.war.structure; package com.tommytony.war.structure;
import java.util.logging.Level; import org.apache.commons.lang.Validate;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import com.tommytony.war.War; public class HubLobbyMaterials implements Cloneable {
public class HubLobbyMaterials { private ItemStack floorBlock;
private int floorId; private ItemStack outlineBlock;
private byte floorData; private ItemStack gateBlock;
private ItemStack lightBlock;
private int outlineId;
private byte outlineData; public HubLobbyMaterials(ItemStack floorBlock, ItemStack outlineBlock,
ItemStack gateBlock, ItemStack lightBlock) {
private int gateId; Validate.isTrue(floorBlock.getType().isBlock()
private byte gateData; || floorBlock.getType() == Material.AIR);
Validate.isTrue(outlineBlock.getType().isBlock()
private int lightId; || outlineBlock.getType() == Material.AIR);
private byte lightData; Validate.isTrue(gateBlock.getType().isBlock()
|| gateBlock.getType() == Material.AIR);
public HubLobbyMaterials(int floorId, byte floorData, int outlineId, byte outlineData, int gateId, byte gateData, int lightId, byte lightData) { Validate.isTrue(lightBlock.getType().isBlock()
// Make sure we are using legal blocks or AIR as material || lightBlock.getType() == Material.AIR);
if (isBlockOrAir(floorId)) { this.floorBlock = floorBlock;
this.setFloorId(floorId); this.outlineBlock = outlineBlock;
this.setFloorData(floorData); this.gateBlock = gateBlock;
} else { this.lightBlock = lightBlock;
this.setFloorId(20); // default glass }
this.setFloorData((byte)0);
} public ItemStack getFloorBlock() {
return floorBlock;
if (isBlockOrAir(outlineId)) { }
this.setOutlineId(outlineId);
this.setOutlineData(outlineData); public void setFloorBlock(ItemStack floorBlock) {
} else { this.floorBlock = floorBlock;
this.setOutlineId(5); // default planks }
this.setOutlineData((byte)0);
} public ItemStack getOutlineBlock() {
return outlineBlock;
if (isBlockOrAir(gateId)) { }
this.setGateId(gateId);
this.setGateData(gateData); public void setOutlineBlock(ItemStack outlineBlock) {
} else { this.outlineBlock = outlineBlock;
this.setGateId(49); // default obsidian }
this.setGateData((byte)0);
} public ItemStack getGateBlock() {
return gateBlock;
if (isBlockOrAir(lightId)) { }
this.setLightId(lightId);
this.setLightData(lightData); public void setGateBlock(ItemStack gateBlock) {
} else { this.gateBlock = gateBlock;
this.setLightId(89); // default glowstone }
this.setLightData((byte)0);
public ItemStack getLightBlock() {
return lightBlock;
}
public void setLightBlock(ItemStack lightBlock) {
this.lightBlock = lightBlock;
}
@Override
public HubLobbyMaterials clone() {
try {
return (HubLobbyMaterials) super.clone();
} catch (CloneNotSupportedException e) {
throw new Error(e);
} }
} }
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 lobby or warhub material.", Level.WARNING);
return false;
}
}
public int getFloorId() {
return floorId;
}
public byte getFloorData() {
return floorData;
}
public int getGateId() {
return gateId;
}
public byte getGateData() {
return gateData;
}
public int getLightId() {
return lightId;
}
public byte getLightData() {
return lightData;
}
public int getOutlineId() {
return outlineId;
}
public byte getOutlineData() {
return outlineData;
}
public void setFloorId(int floorId) {
this.floorId = floorId;
}
public void setFloorData(byte floorData) {
this.floorData = floorData;
}
public void setOutlineId(int outlineId) {
this.outlineId = outlineId;
}
public void setOutlineData(byte outlineData) {
this.outlineData = outlineData;
}
public void setGateId(int gateId) {
this.gateId = gateId;
}
public void setGateData(byte gateData) {
this.gateData = gateData;
}
public void setLightId(int lightId) {
this.lightId = lightId;
}
public void setLightData(byte lightData) {
this.lightData = lightData;
}
} }

View File

@ -4,6 +4,8 @@ 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.block.BlockState;
import org.bukkit.material.MaterialData;
import com.tommytony.war.Team; import com.tommytony.war.Team;
import com.tommytony.war.Warzone; import com.tommytony.war.Warzone;
@ -53,127 +55,158 @@ public class Monument {
int x = this.location.getBlockX(); int x = this.location.getBlockX();
int y = this.location.getBlockY(); int y = this.location.getBlockY();
int z = this.location.getBlockZ(); int z = this.location.getBlockZ();
final Material main = this.warzone.getWarzoneMaterials().getMainBlock().getType();
Material main = Material.getMaterial(this.warzone.getWarzoneMaterials().getMainId()); final MaterialData mainData = this.warzone.getWarzoneMaterials().getMainBlock().getData();
byte mainData = this.warzone.getWarzoneMaterials().getMainData(); final Material light = this.warzone.getWarzoneMaterials().getLightBlock().getType();
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId()); final MaterialData lightData = this.warzone.getWarzoneMaterials().getLightBlock().getData();
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
// center // center
Block current = this.warzone.getWorld().getBlockAt(x, y - 1, z); BlockState current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
// inner ring // inner ring
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z); current.update(true);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1); current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1); current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z); current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
// outer ring // outer ring
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 2); current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 2).getState();
current.setType(light); current.setType(light);
current.setData(lightData); current.setData(lightData);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z); current.update(true);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z - 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z - 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z - 2); current.update(true);
current = this.warzone.getWorld().getBlockAt(x + 2, y - 1, z - 2).getState();
current.setType(light); current.setType(light);
current.setData(lightData); current.setData(lightData);
current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 2); current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 2).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 2); current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 2).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 2); current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 2).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 2); current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 2).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 2); current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 2).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 2); current.update(true);
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 2).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z + 2); current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z + 2).getState();
current.setType(light); current.setType(light);
current.setData(lightData); current.setData(lightData);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z + 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z + 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z); current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z - 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z - 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z - 2); current.update(true);
current = this.warzone.getWorld().getBlockAt(x - 2, y - 1, z - 2).getState();
current.setType(light); current.setType(light);
current.setData(lightData); current.setData(lightData);
current.update(true);
// block holder // block holder
current = this.warzone.getWorld().getBlockAt(x, y, z); current = this.warzone.getWorld().getBlockAt(x, y, z).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y, z - 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y, z - 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y, z + 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y, z + 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y + 1, z - 1); current = this.warzone.getWorld().getBlockAt(x, y + 1, z - 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y + 1, z + 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y + 1, z + 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y + 2, z); current = this.warzone.getWorld().getBlockAt(x, y + 2, z).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y + 2, z - 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y + 2, z - 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current = this.warzone.getWorld().getBlockAt(x, y + 2, z + 1); current.update(true);
current = this.warzone.getWorld().getBlockAt(x, y + 2, z + 1).getState();
current.setType(main); current.setType(main);
current.setData(mainData); current.setData(mainData);
current.update(true);
} }
public boolean isNear(Location playerLocation) { public boolean isNear(Location playerLocation) {

View File

@ -1,5 +1,6 @@
package com.tommytony.war.structure; package com.tommytony.war.structure;
import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
@ -8,7 +9,8 @@ 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.block.BlockState;
import org.bukkit.material.Sign;
import com.tommytony.war.Team; import com.tommytony.war.Team;
import com.tommytony.war.War; import com.tommytony.war.War;
@ -16,7 +18,6 @@ import com.tommytony.war.Warzone;
import com.tommytony.war.config.TeamConfig; import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarzoneConfig; import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.utility.Direction; import com.tommytony.war.utility.Direction;
import com.tommytony.war.utility.SignHelper;
import com.tommytony.war.volume.BlockInfo; import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume; import com.tommytony.war.volume.Volume;
@ -98,7 +99,9 @@ public class WarHub {
Warzone zone = null; Warzone zone = null;
for (String zoneName : this.zoneGateBlocks.keySet()) { for (String zoneName : this.zoneGateBlocks.keySet()) {
Block gate = this.zoneGateBlocks.get(zoneName); Block gate = this.zoneGateBlocks.get(zoneName);
if (gate.getX() == playerLocation.getBlockX() && gate.getY() == playerLocation.getBlockY() && gate.getZ() == playerLocation.getBlockZ()) { if (gate.getX() == playerLocation.getBlockX()
&& gate.getY() == playerLocation.getBlockY()
&& gate.getZ() == playerLocation.getBlockZ()) {
zone = War.war.findWarzone(zoneName); zone = War.war.findWarzone(zoneName);
} }
} }
@ -125,24 +128,19 @@ public class WarHub {
BlockFace right; BlockFace right;
BlockFace front = this.getOrientation(); BlockFace front = this.getOrientation();
BlockFace back; BlockFace back;
byte data;
if (this.getOrientation() == Direction.SOUTH()) { if (this.getOrientation() == Direction.SOUTH()) {
data = (byte) 4;
left = Direction.EAST(); left = Direction.EAST();
right = Direction.WEST(); right = Direction.WEST();
back = Direction.NORTH(); back = Direction.NORTH();
} else if (this.getOrientation() == Direction.NORTH()) { } else if (this.getOrientation() == Direction.NORTH()) {
data = (byte) 12;
left = Direction.WEST(); left = Direction.WEST();
right = Direction.EAST(); right = Direction.EAST();
back = Direction.SOUTH(); back = Direction.SOUTH();
} else if (this.getOrientation() == Direction.EAST()) { } else if (this.getOrientation() == Direction.EAST()) {
data = (byte) 0;
left = Direction.NORTH(); left = Direction.NORTH();
right = Direction.SOUTH(); right = Direction.SOUTH();
back = Direction.WEST(); back = Direction.WEST();
} else { } else {
data = (byte) 8;
left = Direction.SOUTH(); left = Direction.SOUTH();
right = Direction.NORTH(); right = Direction.NORTH();
back = Direction.EAST(); back = Direction.EAST();
@ -154,26 +152,16 @@ public class WarHub {
this.volume.setCornerOne(locationBlock.getRelative(back).getRelative(left, halfHubWidth).getRelative(BlockFace.DOWN)); this.volume.setCornerOne(locationBlock.getRelative(back).getRelative(left, halfHubWidth).getRelative(BlockFace.DOWN));
this.volume.setCornerTwo(locationBlock.getRelative(right, halfHubWidth).getRelative(front, hubDepth).getRelative(BlockFace.UP, hubHeigth)); this.volume.setCornerTwo(locationBlock.getRelative(right, halfHubWidth).getRelative(front, hubDepth).getRelative(BlockFace.UP, hubHeigth));
this.volume.saveBlocks(); this.volume.saveBlocks();
// materials
Material floor = Material.getMaterial(War.war.getWarhubMaterials().getFloorId());
byte floorData = War.war.getWarhubMaterials().getFloorData();
Material outline = Material.getMaterial(War.war.getWarhubMaterials().getOutlineId());
byte outlineData = War.war.getWarhubMaterials().getOutlineData();
Material gate = Material.getMaterial(War.war.getWarhubMaterials().getGateId());
byte gateData = War.war.getWarhubMaterials().getGateData();
Material light = Material.getMaterial(War.war.getWarhubMaterials().getLightId());
byte lightData = War.war.getWarhubMaterials().getLightData();
// glass floor // glass floor
if (!floor.equals(Material.AIR)) { if (!War.war.getWarhubMaterials().getFloorBlock().getType().equals(Material.AIR)) {
// If air, don't set floor to air, just leave original ground. Otherwise apply material. // If air, don't set floor to air, just leave original ground. Otherwise apply material.
this.volume.setFaceMaterial(BlockFace.DOWN, floor, floorData); this.volume.setFaceMaterial(BlockFace.DOWN, War.war.getWarhubMaterials().getFloorBlock());
} }
if (!outline.equals(Material.AIR)) { if (!War.war.getWarhubMaterials().getOutlineBlock().getType().equals(Material.AIR)) {
// If air, leave original blocks. // If air, leave original blocks.
this.volume.setFloorOutlineMaterial(outline, outlineData); this.volume.setFloorOutline(War.war.getWarhubMaterials().getOutlineBlock());
} }
// clear minimal path around warhub tp // clear minimal path around warhub tp
@ -202,46 +190,41 @@ public class WarHub {
currentGateBlock.getRelative(back, 2).getRelative(left, 2).getRelative(BlockFace.UP).setType(Material.AIR); currentGateBlock.getRelative(back, 2).getRelative(left, 2).getRelative(BlockFace.UP).setType(Material.AIR);
currentGateBlock.getRelative(back, 2).getRelative(left, 2).getRelative(BlockFace.UP, 2).setType(Material.AIR); currentGateBlock.getRelative(back, 2).getRelative(left, 2).getRelative(BlockFace.UP, 2).setType(Material.AIR);
BlockState cgbdl = currentGateBlock.getRelative(BlockFace.DOWN).getState();
cgbdl.setType(War.war.getWarhubMaterials().getLightBlock().getType());
cgbdl.setData(War.war.getWarhubMaterials().getLightBlock().getData());
cgbdl.update(true);
// gate blocks // gate blocks
currentGateBlock.getRelative(BlockFace.DOWN).setType(light); Block[] gateBlocks = {
currentGateBlock.getRelative(BlockFace.DOWN).setData(lightData); currentGateBlock.getRelative(left),
currentGateBlock.getRelative(right).getRelative(BlockFace.UP),
currentGateBlock.getRelative(left).setType(gate); currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP),
currentGateBlock.getRelative(left).setData(gateData); currentGateBlock.getRelative(right),
currentGateBlock.getRelative(left).getRelative(BlockFace.UP),
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).setType(gate); currentGateBlock.getRelative(right).getRelative(BlockFace.UP).getRelative(BlockFace.UP),
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).setData(gateData); currentGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP)
};
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(gate); for (Block gateBlock : gateBlocks) {
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setData(gateData); BlockState gb = gateBlock.getState();
gb.setType(War.war.getWarhubMaterials().getGateBlock().getType());
currentGateBlock.getRelative(right).setType(gate); gb.setData(War.war.getWarhubMaterials().getGateBlock().getData());
currentGateBlock.getRelative(right).setData(gateData); gb.update(true);
}
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).setType(gate);
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).setData(gateData);
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(gate);
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setData(gateData);
currentGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(gate);
currentGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP).setData(gateData);
currentGateBlock = currentGateBlock.getRelative(right, 4); currentGateBlock = currentGateBlock.getRelative(right, 4);
} }
} }
// War hub sign // War hub sign
Block signBlock = locationBlock.getRelative(front, 2); locationBlock.getRelative(front, 2).setType(Material.SIGN_POST);
String[] lines = "War hub\n(/warhub)\nPick your\nbattle!".split("\n");
String[] lines = new String[4]; org.bukkit.block.Sign locationBlockFront = (org.bukkit.block.Sign) locationBlock.getRelative(front, 2).getState();
lines[0] = "War hub"; for (int i = 0; i < 4; i++) {
lines[1] = "(/warhub)"; locationBlockFront.setLine(i, lines[i]);
lines[2] = "Pick your"; }
lines[3] = "battle!"; org.bukkit.material.Sign sign = (Sign) locationBlockFront.getData();
SignHelper.setToSign(War.war, signBlock, data, lines); sign.setFacingDirection(orientation.getOppositeFace());
locationBlockFront.setData(sign);
locationBlockFront.update(true);
// Warzone signs // Warzone signs
for (Warzone zone : War.war.getWarzones()) { for (Warzone zone : War.war.getWarzones()) {
if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED) && zone.ready()) { if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED) && zone.ready()) {
@ -260,45 +243,41 @@ public class WarHub {
public void resetZoneSign(Warzone zone) { public void resetZoneSign(Warzone zone) {
BlockFace left; BlockFace left;
BlockFace back; BlockFace back;
byte data;
if (this.getOrientation() == Direction.SOUTH()) { if (this.getOrientation() == Direction.SOUTH()) {
data = (byte) 4;
left = Direction.EAST(); left = Direction.EAST();
back = Direction.NORTH(); back = Direction.NORTH();
} else if (this.getOrientation() == Direction.NORTH()) { } else if (this.getOrientation() == Direction.NORTH()) {
data = (byte) 12;
left = Direction.WEST(); left = Direction.WEST();
back = Direction.SOUTH(); back = Direction.SOUTH();
} else if (this.getOrientation() == Direction.EAST()) { } else if (this.getOrientation() == Direction.EAST()) {
data = (byte) 0;
left = Direction.NORTH(); left = Direction.NORTH();
back = Direction.WEST(); back = Direction.WEST();
} else { } else {
data = (byte) 8;
left = Direction.SOUTH(); left = Direction.SOUTH();
back = Direction.EAST(); back = Direction.EAST();
} }
Block zoneGate = this.zoneGateBlocks.get(zone.getName()); Block zoneGate = this.zoneGateBlocks.get(zone.getName());
if (zoneGate != null) { if (zoneGate != null) {
Block block = zoneGate.getRelative(left).getRelative(back, 1); zoneGate.getRelative(left).getRelative(back, 1).setType(Material.SIGN_POST);
if (block.getType() != Material.SIGN_POST) { org.bukkit.block.Sign block = (org.bukkit.block.Sign) zoneGate.getRelative(left).getRelative(back, 1).getState();
block.setType(Material.SIGN_POST); org.bukkit.material.Sign data = (Sign) block.getData();
} data.setFacingDirection(this.getOrientation().getOppositeFace());
block.setData(data); block.setData(data);
int zoneCap = 0; int zoneCap = 0;
int zonePlayers = 0; int zonePlayers = 0;
for (Team t : zone.getTeams()) { for (Team t : zone.getTeams()) {
zonePlayers += t.getPlayers().size(); zonePlayers += t.getPlayers().size();
zoneCap += t.getTeamConfig().resolveInt(TeamConfig.TEAMSIZE); zoneCap += t.getTeamConfig().resolveInt(TeamConfig.TEAMSIZE);
} }
String[] lines = new String[4]; String[] lines = MessageFormat.format(
lines[0] = "Warzone"; "Warzone\n{0}\n{1}/{2} players\n{3} teams",
lines[1] = zone.getName(); zone.getName(), zonePlayers, zoneCap,
lines[2] = zonePlayers + "/" + zoneCap + " players"; zone.getTeams().size()).split("\n");
lines[3] = zone.getTeams().size() + " teams"; for (int i = 0; i < 4; i++) {
SignHelper.setToSign(War.war, block, data, lines); block.setLine(i, lines[i]);
}
block.update(true);
} else { } else {
War.war.log("Failed to find warhub gate for " + zone.getName() + " warzone.", Level.WARNING); War.war.log("Failed to find warhub gate for " + zone.getName() + " warzone.", Level.WARNING);
} }

View File

@ -1,104 +1,53 @@
package com.tommytony.war.structure; package com.tommytony.war.structure;
import java.util.logging.Level; import org.apache.commons.lang.Validate;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import com.tommytony.war.War; public class WarzoneMaterials implements Cloneable {
private ItemStack mainBlock;
private ItemStack standBlock;
private ItemStack lightBlock;
public class WarzoneMaterials { public WarzoneMaterials(ItemStack mainBlock, ItemStack standBlock, ItemStack lightBlock) {
private int mainId; Validate.isTrue(mainBlock.getType().isBlock() || mainBlock.getType() == Material.AIR);
private byte mainData; Validate.isTrue(standBlock.getType().isBlock() || standBlock.getType() == Material.AIR);
Validate.isTrue(lightBlock.getType().isBlock() || lightBlock.getType() == Material.AIR);
private int standId; this.mainBlock = mainBlock;
private byte standData; this.standBlock = standBlock;
this.lightBlock = lightBlock;
}
private int lightId; public ItemStack getMainBlock() {
private byte lightData; return mainBlock;
}
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 public void setMainBlock(ItemStack mainBlock) {
if (isBlockOrAir(mainId)) { this.mainBlock = mainBlock;
this.setMainId(mainId); }
this.setMainData(mainData);
} else { public ItemStack getStandBlock() {
this.setMainId(49); // default obsidian return standBlock;
this.setMainData((byte)0); }
}
public void setStandBlock(ItemStack standBlock) {
if (isBlockOrAir(standId)) { this.standBlock = standBlock;
this.setStandId(standId); }
this.setStandData(standData);
} else { public ItemStack getLightBlock() {
this.setStandId(85); // default ladder return lightBlock;
this.setStandData((byte)0); }
}
public void setLightBlock(ItemStack lightBlock) {
if (isBlockOrAir(lightId)) { this.lightBlock = lightBlock;
this.setLightId(lightId); }
this.setLightData(lightData);
} else { @Override
this.setLightId(89); // default glowstone public WarzoneMaterials clone() {
this.setLightData((byte)0); try {
return (WarzoneMaterials) super.clone();
} catch (CloneNotSupportedException e) {
throw new Error(e);
} }
} }
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

@ -1,5 +1,6 @@
package com.tommytony.war.structure; package com.tommytony.war.structure;
import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -9,8 +10,10 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Sign;
import com.tommytony.war.Team; import com.tommytony.war.Team;
import com.tommytony.war.War; import com.tommytony.war.War;
@ -19,7 +22,6 @@ import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.TeamKind; import com.tommytony.war.config.TeamKind;
import com.tommytony.war.config.WarzoneConfig; import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.utility.Direction; import com.tommytony.war.utility.Direction;
import com.tommytony.war.utility.SignHelper;
import com.tommytony.war.volume.BlockInfo; import com.tommytony.war.volume.BlockInfo;
import com.tommytony.war.volume.Volume; import com.tommytony.war.volume.Volume;
import com.tommytony.war.volume.ZoneVolume; import com.tommytony.war.volume.ZoneVolume;
@ -275,35 +277,22 @@ public class ZoneLobby {
// maybe the number of teams change, now reset the gate positions // maybe the number of teams change, now reset the gate positions
if (this.lobbyMiddleWallBlock != null && this.volume != null) { if (this.lobbyMiddleWallBlock != null && this.volume != null) {
this.setGatePositions(BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock)); this.setGatePositions(BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock));
if (!warzone.getLobbyMaterials().getFloorBlock().getType().equals(Material.AIR)) {
// Add the floor and outline
Material floor = Material.getMaterial(warzone.getLobbyMaterials().getFloorId());
byte floorData = warzone.getLobbyMaterials().getFloorData();
Material outline = Material.getMaterial(warzone.getLobbyMaterials().getOutlineId());
byte outlineData = warzone.getLobbyMaterials().getOutlineData();
Material gate = Material.getMaterial(warzone.getLobbyMaterials().getGateId());
byte gateData = warzone.getLobbyMaterials().getGateData();
if (!floor.equals(Material.AIR)) {
// If air, leave original blocks. // If air, leave original blocks.
this.volume.setFaceMaterial(BlockFace.DOWN, floor, floorData); this.volume.setFaceMaterial(BlockFace.DOWN, warzone.getLobbyMaterials().getFloorBlock());
} }
if (!outline.equals(Material.AIR)) { if (!warzone.getLobbyMaterials().getOutlineBlock().getType().equals(Material.AIR)) {
// If air, leave original blocks. // If air, leave original blocks.
this.volume.setFloorOutlineMaterial(outline, outlineData); this.volume.setFloorOutline(warzone.getLobbyMaterials().getOutlineBlock());
} }
// add war hub link gate // add war hub link gate
if (War.war.getWarHub() != null) { if (War.war.getWarHub() != null) {
Block linkGateBlock = BlockInfo.getBlock(this.volume.getWorld(), this.warHubLinkGate); Block linkGateBlock = BlockInfo.getBlock(this.volume.getWorld(), this.warHubLinkGate);
this.placeWarhubLinkGate(linkGateBlock, gate, gateData); this.placeWarhubLinkGate(linkGateBlock, warzone.getLobbyMaterials().getGateBlock());
// add warhub sign // add warhub sign
String[] lines = new String[4]; String[] lines = "\nTo War hub\n\n ".split("\n");
lines[0] = "";
lines[1] = "To War hub";
lines[2] = "";
lines[3] = "";
this.resetGateSign(linkGateBlock, lines, false); this.resetGateSign(linkGateBlock, lines, false);
} }
@ -371,45 +360,40 @@ public class ZoneLobby {
// set zone sign // set zone sign
Block zoneSignBlock = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(this.wall, 4); Block zoneSignBlock = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(this.wall, 4);
byte data = 0; zoneSignBlock.setType(Material.SIGN_POST);
if (this.wall == Direction.NORTH()) { org.bukkit.block.Sign block = (org.bukkit.block.Sign) zoneSignBlock.getState();
data = (byte) 4; org.bukkit.material.Sign data = (Sign) block.getData();
} else if (this.wall == Direction.EAST()) { data.setFacingDirection(this.wall);
data = (byte) 8; block.setData(data);
} else if (this.wall == Direction.SOUTH()) {
data = (byte) 12;
} else if (this.wall == Direction.WEST()) {
data = (byte) 0;
}
String[] lines = new String[4]; String[] lines = new String[4];
lines[0] = "Warzone";
lines[1] = this.warzone.getName();
if (this.autoAssignGate != null) { if (this.autoAssignGate != null) {
lines[2] = "Enter the auto-"; lines = MessageFormat.format("Warzone\n{0}\nEnter the auto-\nassign gate.", warzone.getName()).split("\n");
lines[3] = "assign gate.";
} else { } else {
lines[2] = ""; lines = MessageFormat.format("Warzone\n{0}\n\nPick your team.", warzone.getName()).split("\n");
lines[3] = "Pick your team.";
} }
SignHelper.setToSign(War.war, zoneSignBlock, data, lines); for (int i = 0; i < 4; i++) {
block.setLine(i, lines[i]);
}
block.update(true);
// lets get some light in here // lets get some light in here
Material light = Material.getMaterial(this.warzone.getLobbyMaterials().getLightId());
byte lightData = this.warzone.getLobbyMaterials().getLightData();
if (this.wall == Direction.NORTH() || this.wall == Direction.SOUTH()) { if (this.wall == Direction.NORTH() || this.wall == Direction.SOUTH()) {
Block one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.WEST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9); BlockState one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.WEST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
one.setType(light); one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
one.setData(lightData); one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
Block two = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9); one.update(true);
two.setType(light); one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
two.setData(lightData); one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
one.update(true);
} else { } else {
Block one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.NORTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9); BlockState one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.NORTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
one.setType(light); one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
one.setData(lightData); one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
Block two = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.SOUTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9); one.update(true);
two.setType(light); one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.SOUTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
two.setData(lightData); one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
one.update(true);
} }
} else { } else {
War.war.log("Failed to initalize zone lobby for zone " + this.warzone.getName(), java.util.logging.Level.WARNING); War.war.log("Failed to initalize zone lobby for zone " + this.warzone.getName(), java.util.logging.Level.WARNING);
@ -486,8 +470,10 @@ public class ZoneLobby {
this.clearGatePath(block, front, leftSide, rightSide, true); this.clearGatePath(block, front, leftSide, rightSide, true);
// gate blocks // gate blocks
block.getRelative(BlockFace.DOWN).setType(Material.getMaterial(this.warzone.getLobbyMaterials().getLightId())); BlockState lightBlock = block.getRelative(BlockFace.DOWN).getState();
block.getRelative(BlockFace.DOWN).setData(this.warzone.getLobbyMaterials().getLightData()); lightBlock.setType(warzone.getLobbyMaterials().getLightBlock().getType());
lightBlock.setData(warzone.getLobbyMaterials().getLightBlock().getData());
lightBlock.update(true);
this.setBlock(block.getRelative(leftSide), teamKind); this.setBlock(block.getRelative(leftSide), teamKind);
this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP), teamKind); this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP), teamKind);
this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), teamKind); this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), teamKind);
@ -498,7 +484,7 @@ public class ZoneLobby {
} }
} }
private void placeWarhubLinkGate(Block block, Material material, byte data) { private void placeWarhubLinkGate(Block block, ItemStack frame) {
if (block != null) { if (block != null) {
BlockFace front = null; BlockFace front = null;
BlockFace leftSide = null; // looking at the zone BlockFace leftSide = null; // looking at the zone
@ -534,26 +520,34 @@ public class ZoneLobby {
this.clearGatePath(block, front, leftSide, rightSide, false); this.clearGatePath(block, front, leftSide, rightSide, false);
// gate blocks // gate blocks
block.getRelative(BlockFace.DOWN).setType(Material.getMaterial(this.warzone.getLobbyMaterials().getLightId())); BlockState lightBlock = block.getRelative(BlockFace.DOWN).getState();
block.getRelative(BlockFace.DOWN).setData(this.warzone.getLobbyMaterials().getLightData()); lightBlock.setType(warzone.getLobbyMaterials().getLightBlock().getType());
this.setBlock(block.getRelative(leftSide), material, data); lightBlock.setData(warzone.getLobbyMaterials().getLightBlock().getData());
this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP), material, data); lightBlock.update(true);
this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), material, data); Block[] updateBlocks = {
this.setBlock(block.getRelative(rightSide), material, data); block.getRelative(leftSide),
this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP), material, data); block.getRelative(rightSide).getRelative(BlockFace.UP),
this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), material, data); block.getRelative(leftSide).getRelative(BlockFace.UP)
this.setBlock(block.getRelative(BlockFace.UP).getRelative(BlockFace.UP), material, data); .getRelative(BlockFace.UP),
block.getRelative(rightSide),
block.getRelative(leftSide).getRelative(BlockFace.UP),
block.getRelative(rightSide).getRelative(BlockFace.UP)
.getRelative(BlockFace.UP),
block.getRelative(BlockFace.UP).getRelative(BlockFace.UP) };
for (Block update : updateBlocks) {
BlockState state = update.getState();
state.setType(frame.getType());
state.setData(frame.getData());
state.update(true);
}
} }
} }
private void setBlock(Block block, TeamKind kind) { private void setBlock(Block block, TeamKind kind) {
block.setType(kind.getMaterial()); BlockState blockState = block.getState();
block.setData(kind.getData()); blockState.setType(kind.getBlockHead().getType());
} blockState.setData(kind.getBlockHead().getData());
blockState.update(true);
private void setBlock(Block block, Material material, byte data) {
block.setType(material);
block.setData(data);
} }
private void placeAutoAssignGate() { private void placeAutoAssignGate() {
@ -585,9 +579,10 @@ public class ZoneLobby {
this.clearGatePath(autoAssignGateBlock, front, leftSide, rightSide, false); this.clearGatePath(autoAssignGateBlock, front, leftSide, rightSide, false);
// gate blocks // gate blocks
this.setBlock(autoAssignGateBlock.getRelative(BlockFace.DOWN), BlockState lightBlock = autoAssignGateBlock.getRelative(BlockFace.DOWN).getState();
Material.getMaterial(this.warzone.getLobbyMaterials().getLightId()), lightBlock.setType(warzone.getLobbyMaterials().getLightBlock().getType());
this.warzone.getLobbyMaterials().getLightData()); lightBlock.setData(warzone.getLobbyMaterials().getLightBlock().getData());
lightBlock.update(true);
int size = teams.size(); int size = teams.size();
if (size > 0) { if (size > 0) {
TeamKind[] doorBlockKinds = new TeamKind[7]; TeamKind[] doorBlockKinds = new TeamKind[7];
@ -702,14 +697,30 @@ public class ZoneLobby {
private void resetTeamGateSign(Team team, Block gate) { private void resetTeamGateSign(Team team, Block gate) {
if (gate != null) { if (gate != null) {
String[] lines = new String[4]; String[] lines;
lines[0] = "Team " + team.getName();
lines[1] = team.getPlayers().size() + "/" + team.getTeamConfig().resolveInt(TeamConfig.TEAMSIZE) + " players";
lines[2] = team.getPoints() + "/" + team.getTeamConfig().resolveInt(TeamConfig.MAXSCORE) + " pts";
if (team.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL) == -1) { if (team.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL) == -1) {
lines[3] = "unlimited lives"; lines = MessageFormat
.format("Team {0}\n{1}/{2} players\n{3}/{4} pts\nunlimited lives",
team.getName(),
team.getPlayers().size(),
team.getTeamConfig().resolveInt(
TeamConfig.TEAMSIZE),
team.getPoints(),
team.getTeamConfig().resolveInt(
TeamConfig.MAXSCORE)).split("\n");
} else { } else {
lines[3] = team.getRemainingLifes() + "/" + team.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL) + " lives left"; lines = MessageFormat
.format("Team {0}\n{1}/{2} players\n{3}/{4} pts\n{5} lives left",
team.getName(),
team.getPlayers().size(),
team.getTeamConfig().resolveInt(
TeamConfig.TEAMSIZE),
team.getPoints(),
team.getTeamConfig().resolveInt(
TeamConfig.MAXSCORE),
team.getRemainingLifes(),
team.getTeamConfig().resolveInt(
TeamConfig.LIFEPOOL)).split("\n");
} }
this.resetGateSign(gate, lines, true); this.resetGateSign(gate, lines, true);
} }
@ -729,38 +740,25 @@ public class ZoneLobby {
} else if (this.wall == Direction.WEST()) { } else if (this.wall == Direction.WEST()) {
direction = Direction.EAST(); direction = Direction.EAST();
} }
byte data = 0;
if (this.wall == Direction.NORTH()) { if (this.wall == Direction.NORTH()) {
block = gate.getRelative(direction).getRelative(Direction.EAST()); block = gate.getRelative(direction).getRelative(Direction.EAST());
if (awayFromWall) {
data = (byte) 4;
} else {
data = (byte) 12;
}
} else if (this.wall == Direction.EAST()) { } else if (this.wall == Direction.EAST()) {
block = gate.getRelative(direction).getRelative(Direction.SOUTH()); block = gate.getRelative(direction).getRelative(Direction.SOUTH());
if (awayFromWall) {
data = (byte) 8;
} else {
data = (byte) 0;
}
} else if (this.wall == Direction.SOUTH()) { } else if (this.wall == Direction.SOUTH()) {
block = gate.getRelative(direction).getRelative(Direction.WEST()); block = gate.getRelative(direction).getRelative(Direction.WEST());
if (awayFromWall) {
data = (byte) 12;
} else {
data = (byte) 4;
}
} else if (this.wall == Direction.WEST()) { } else if (this.wall == Direction.WEST()) {
block = gate.getRelative(direction).getRelative(Direction.NORTH()); block = gate.getRelative(direction).getRelative(Direction.NORTH());
if (awayFromWall) {
data = (byte) 0;
} else {
data = (byte) 8;
}
} }
SignHelper.setToSign(War.war, block, data, lines); block.setType(Material.SIGN_POST);
org.bukkit.block.Sign state = (org.bukkit.block.Sign) block.getState();
org.bukkit.material.Sign data = (Sign) state.getData();
data.setFacingDirection(direction);
state.setData(data);
for (int i = 0; i < 4; i++) {
state.setLine(i, lines[i]);
}
state.update(true);
} }
public boolean isLeavingZone(Location location) { public boolean isLeavingZone(Location location) {

View File

@ -1,36 +0,0 @@
package com.tommytony.war.utility;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import com.tommytony.war.War;
public class SignHelper {
public static void setToSign(War war, Block block, byte data, String[] lines) {
if (block.getType() != Material.SIGN_POST) {
block.setType(Material.SIGN_POST);
}
try {
BlockState state = block.getState();
state.setData(new org.bukkit.material.Sign(Material.SIGN_POST, data));
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);
}
}
} catch (Exception e) {
// just can't stand this anymore
}
}
}

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.apache.commons.lang.Validate;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
@ -41,6 +42,17 @@ public class Volume {
this.name = name; this.name = name;
this.world = world; this.world = world;
} }
public Volume(World world) {
this(null, world);
}
public Volume(Location corner1, Location corner2) {
this(corner1.getWorld());
Validate.isTrue(corner1.getWorld() == corner2.getWorld(), "Cross-world volume");
this.cornerOne = new BlockInfo(corner1.getBlock());
this.cornerTwo = new BlockInfo(corner2.getBlock());
}
public void setName(String newName) { public void setName(String newName) {
this.name = newName; this.name = newName;
@ -294,7 +306,6 @@ public class Volume {
} }
public byte[][][] getBlockDatas() { public byte[][][] getBlockDatas() {
// TODO Auto-generated method stub
return this.blockDatas; return this.blockDatas;
} }
@ -427,136 +438,98 @@ public class Volume {
} }
public void setToMaterial(Material material) { public void setToMaterial(Material material) {
try { Validate.notNull(material);
if (this.hasTwoCorners()) { Validate.isTrue(this.hasTwoCorners(), "Incomplete volume");
int x = this.getMinX(); for (int x = this.getMinX(); x <= this.getMaxX(); x++) {
for (int i = 0; i < this.getSizeX(); i++) { for (int y = this.getMinY(); y <= this.getMaxY(); y++) {
int y = this.getMaxY(); for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
for (int j = this.getSizeY(); j > 0; j--) { this.getWorld().getBlockAt(x, y, z).setType(material);
int z = this.getMinZ();
for (int k = 0; k < this.getSizeZ(); k++) {
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
currentBlock.setType(material);
z++;
}
y--;
}
x++;
} }
} }
} catch (Exception e) {
War.war.log("Failed to set block to " + material + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
} }
} }
public void setFaceMaterial(BlockFace face, Material material, byte data) { public void setFaceMaterial(BlockFace face, ItemStack faceBlock) {
try { Validate.isTrue(this.hasTwoCorners(), "Incomplete volume");
if (this.hasTwoCorners() && this.isSaved()) { for (int x = this.getMinX(); x <= this.getMaxX(); x++) {
int x = this.getMinX(); for (int y = this.getMinY(); y <= this.getMaxY(); y++) {
for (int i = 0; i < this.getSizeX(); i++) { for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
int y = this.getMinY(); if ((face == BlockFace.DOWN && y == this.getMinY())
for (int j = 0; j < this.getSizeY(); j++) { || (face == BlockFace.UP && y == this.getMaxY())
int z = this.getMinZ(); || (face == Direction.NORTH() && x == this.getMinX())
for (int k = 0; k < this.getSizeZ(); k++) { || (face == Direction.EAST() && z == this.getMinZ())
if ((face == BlockFace.DOWN && y == this.getMinY()) || (face == BlockFace.UP && y == this.getMaxY()) || (face == Direction.NORTH() && x == this.getMinX()) || (face == Direction.EAST() && z == this.getMinZ()) || (face == Direction.SOUTH() && x == this.getMaxX()) || (face == Direction.WEST() && z == this.getMaxZ())) { || (face == Direction.SOUTH() && x == this.getMaxX())
Block currentBlock = this.getWorld().getBlockAt(x, y, z); || (face == Direction.WEST() && z == this.getMaxZ())) {
currentBlock.setType(material); BlockState currentBlock = this.getWorld().getBlockAt(x, y, z).getState();
currentBlock.setData(data); currentBlock.setType(faceBlock.getType());
} currentBlock.setData(faceBlock.getData());
z++; currentBlock.update(true);
}
y++;
} }
x++;
} }
} }
} catch (Exception e) {
War.war.log("Failed to set block to " + material + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
} }
} }
public void setFloorOutlineMaterial(Material outline, byte outlineData) { public void setFloorOutline(ItemStack outlineBlock) {
try { Validate.isTrue(this.hasTwoCorners(), "Incomplete volume");
if (this.hasTwoCorners() && this.isSaved()) { for (int x = this.getMinX(); x <= this.getMaxX(); x++) {
int x = this.getMinX(); for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
for (int i = 0; i < this.getSizeX(); i++) { if (x == this.getMinX() || x == this.getMaxX() || z == this.getMinZ() || z == this.getMaxZ()) {
int z = this.getMinZ(); BlockState currentBlock = this.getWorld().getBlockAt(x, this.getMinY(), z).getState();
for (int k = 0; k < this.getSizeZ(); k++) { currentBlock.setType(outlineBlock.getType());
if (x == this.getMinX() || x == this.getMaxX() || z == this.getMinZ() || z == this.getMaxZ()) { currentBlock.setData(outlineBlock.getData());
Block currentBlock = this.getWorld().getBlockAt(x, this.getMinY(), z); currentBlock.update(true);
currentBlock.setType(outline);
currentBlock.setData(outlineData);
}
z++;
}
x++;
} }
} }
} catch (Exception e) {
War.war.log("Failed to set floor ouline block to " + outline + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
} }
} }
private void switchMaterials(Material[] oldTypes, Material newType) { public void replaceMaterial(Material original, Material replacement) {
try { Validate.isTrue(this.hasTwoCorners(), "Incomplete volume");
int i = 0, j = 0, k = 0; for (int x = this.getMinX(); x <= this.getMaxX(); x++) {
int x, y, z; for (int y = this.getMinY(); y <= this.getMaxY(); y++) {
Block currentBlock = null; for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
if (this.hasTwoCorners() && this.isSaved()) { if (this.getWorld().getBlockAt(x, y, z).getType() == original) {
x = this.getMinX(); this.getWorld().getBlockAt(x, y, z).setType(replacement);
for (i = 0; i < this.getSizeX(); i++) {
y = this.getMaxY();
for (j = this.getSizeY(); j > 0; j--) {
z = this.getMinZ();
for (k = 0; k < this.getSizeZ(); k++) {
currentBlock = this.getWorld().getBlockAt(x, y, z);
for (Material oldType : oldTypes) {
if (currentBlock.getType().getId() == oldType.getId()) {
currentBlock.setType(newType);
// BlockState state = currentBlock.getState();
// if (state != null) {
// state.setType(newType);
// state.update(true);
// }
}
}
z++;
}
y--;
} }
x++;
} }
} }
} catch (Exception e) {
War.war.log("Failed to switch block to " + newType + "in volume " + this.name + "." + e.getClass().toString() + " " + e.getMessage(), Level.WARNING);
} }
} }
public void replaceMaterials(Material[] materials, Material replacement) {
for (Material mat: materials) {
this.replaceMaterial(mat, replacement);
}
}
private static final Material[] nonFloatingBlocks = {
Material.SIGN_POST,
Material.WALL_SIGN,
Material.IRON_DOOR,
Material.WOOD_DOOR,
Material.LADDER,
Material.YELLOW_FLOWER,
Material.RED_ROSE,
Material.RED_MUSHROOM,
Material.BROWN_MUSHROOM,
Material.SAPLING,
Material.TORCH,
Material.RAILS,
Material.STONE_BUTTON,
Material.STONE_PLATE,
Material.WOOD_PLATE,
Material.LEVER,
Material.REDSTONE,
Material.REDSTONE_TORCH_ON,
Material.REDSTONE_TORCH_OFF,
Material.CACTUS,
Material.SNOW,
Material.ICE
};
public void clearBlocksThatDontFloat() { public void clearBlocksThatDontFloat() {
Material[] toAirMaterials = new Material[22]; this.replaceMaterials(nonFloatingBlocks, Material.AIR);
toAirMaterials[0] = Material.SIGN_POST;
toAirMaterials[1] = Material.WALL_SIGN;
toAirMaterials[2] = Material.IRON_DOOR;
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;
this.switchMaterials(toAirMaterials, Material.AIR);
} }
public void setSignLines(HashMap<String, String[]> signLines) { public void setSignLines(HashMap<String, String[]> signLines) {