mirror of
https://github.com/taoneill/war.git
synced 2024-12-03 15:43:27 +01:00
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:
parent
e38b2aa62b
commit
39b0ead3bd
@ -81,7 +81,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.2-R0.1</version>
|
||||
<version>1.6.2-R1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kitteh</groupId>
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.tommytony.war;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -16,7 +17,10 @@ import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Sign;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
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.Cake;
|
||||
import com.tommytony.war.utility.Direction;
|
||||
import com.tommytony.war.utility.SignHelper;
|
||||
import com.tommytony.war.volume.BlockInfo;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
|
||||
@ -118,8 +121,7 @@ public class Team {
|
||||
int y = teamSpawn.getBlockY();
|
||||
int z = teamSpawn.getBlockZ();
|
||||
|
||||
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
|
||||
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
|
||||
ItemStack light = this.warzone.getWarzoneMaterials().getLightBlock();
|
||||
|
||||
TeamSpawnStyle style = this.getTeamConfig().resolveSpawnStyle();
|
||||
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 - 1, this.kind);
|
||||
this.setBlock(x, y - 1, z + 1, this.kind);
|
||||
Block lightBlock = this.warzone.getWorld().getBlockAt(x, y - 1, z);
|
||||
lightBlock.setType(light);
|
||||
lightBlock.setData(lightData);
|
||||
BlockState lightBlock = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
|
||||
lightBlock.setType(light.getType());
|
||||
lightBlock.setData(light.getData());
|
||||
lightBlock.update(true);
|
||||
this.setBlock(x, y - 1, z - 1, this.kind);
|
||||
this.setBlock(x - 1, y - 1, z + 1, this.kind);
|
||||
this.setBlock(x - 1, y - 1, z, this.kind);
|
||||
@ -145,21 +148,21 @@ public class Team {
|
||||
yaw = (int) (360 + (teamSpawn.getYaw() % 360));
|
||||
}
|
||||
Block signBlock = null;
|
||||
int signData = 0;
|
||||
BlockFace signDirection = null;
|
||||
|
||||
if (style.equals(TeamSpawnStyle.SMALL)) {
|
||||
// SMALL style
|
||||
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());
|
||||
} 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());
|
||||
} 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());
|
||||
} 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());
|
||||
}
|
||||
} else if (!style.equals(TeamSpawnStyle.INVISIBLE)) {
|
||||
@ -186,7 +189,7 @@ public class Team {
|
||||
this.setBlock(x - 2, y - 1, z - 2, this.kind);
|
||||
|
||||
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);
|
||||
|
||||
if (style.equals(TeamSpawnStyle.BIG)) {
|
||||
@ -217,7 +220,7 @@ public class Team {
|
||||
this.setBlock(x + 2, y + 3, z - 2, this.kind);
|
||||
}
|
||||
} 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);
|
||||
if (style.equals(TeamSpawnStyle.BIG)) {
|
||||
// rim
|
||||
@ -247,7 +250,7 @@ public class Team {
|
||||
this.setBlock(x + 2, y + 3, z + 2, this.kind);
|
||||
}
|
||||
} 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);
|
||||
if (style.equals(TeamSpawnStyle.BIG)) {
|
||||
// rim
|
||||
@ -277,7 +280,7 @@ public class Team {
|
||||
this.setBlock(x - 2, y + 3, z + 2, this.kind);
|
||||
}
|
||||
} 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);
|
||||
if (style.equals(TeamSpawnStyle.BIG)) {
|
||||
// rim
|
||||
@ -310,17 +313,41 @@ public class Team {
|
||||
}
|
||||
|
||||
if (signBlock != null) {
|
||||
String[] lines = new String[4];
|
||||
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";
|
||||
String[] lines;
|
||||
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 {
|
||||
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");
|
||||
}
|
||||
|
||||
SignHelper.setToSign(War.war, signBlock, (byte) signData, lines);
|
||||
signBlock.setType(Material.SIGN_POST);
|
||||
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()) {
|
||||
@ -329,9 +356,10 @@ public class Team {
|
||||
}
|
||||
|
||||
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.setData(kind.getData());
|
||||
block.setData(kind.getBlockData());
|
||||
block.update(true);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void initializeTeamFlag() {
|
||||
// make air (old two-high above floor)
|
||||
Volume airGap = new Volume("airgap", this.warzone.getWorld());
|
||||
@ -557,46 +584,50 @@ public class Team {
|
||||
int x = this.teamFlag.getBlockX();
|
||||
int y = this.teamFlag.getBlockY();
|
||||
int z = this.teamFlag.getBlockZ();
|
||||
|
||||
Material main = Material.getMaterial(this.warzone.getWarzoneMaterials().getMainId());
|
||||
byte mainData = this.warzone.getWarzoneMaterials().getMainData();
|
||||
Material stand = Material.getMaterial(this.warzone.getWarzoneMaterials().getStandId());
|
||||
byte standData = this.warzone.getWarzoneMaterials().getStandData();
|
||||
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
|
||||
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
|
||||
|
||||
// first ring
|
||||
Block current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
|
||||
current.setType(light);
|
||||
current.setData(lightData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
BlockState 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 + 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);
|
||||
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, y - 1, z).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
|
||||
current.update(true);
|
||||
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).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).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
|
||||
this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(this.kind.getMaterial());
|
||||
this.warzone.getWorld().getBlockAt(x, y + 1, z).setData(this.kind.getData());
|
||||
BlockState flagBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z).getState();
|
||||
flagBlock.setType(this.kind.getMaterial());
|
||||
flagBlock.setData(this.kind.getBlockData());
|
||||
flagBlock.update(true);
|
||||
|
||||
// Flag post using Orientation
|
||||
int yaw = 0;
|
||||
@ -605,44 +636,42 @@ public class Team {
|
||||
} else {
|
||||
yaw = (int) (360 + (this.teamFlag.getYaw() % 360));
|
||||
}
|
||||
BlockFace facing = null;
|
||||
BlockFace opposite = null;
|
||||
if ((yaw >= 0 && yaw < 45) || (yaw >= 315 && yaw <= 360)) {
|
||||
facing = Direction.WEST();
|
||||
opposite = Direction.EAST();
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z - 1);
|
||||
current.setType(stand);
|
||||
current.setData(standData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y + 1, z - 1);
|
||||
current.setType(stand);
|
||||
current.setData(standData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z - 1).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y + 1, z - 1).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
} else if (yaw >= 45 && yaw < 135) {
|
||||
facing = Direction.NORTH();
|
||||
opposite = Direction.SOUTH();
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y, z);
|
||||
current.setType(stand);
|
||||
current.setData(standData);
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y + 1, z);
|
||||
current.setType(stand);
|
||||
current.setData(standData);
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y, z).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y + 1, z).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
} else if (yaw >= 135 && yaw < 225) {
|
||||
facing = Direction.EAST();
|
||||
opposite = Direction.WEST();
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z + 1);
|
||||
current.setType(stand);
|
||||
current.setData(standData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y + 1, z + 1);
|
||||
current.setType(stand);
|
||||
current.setData(standData);;
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z + 1).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y + 1, z + 1).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
} else if (yaw >= 225 && yaw < 315) {
|
||||
facing = Direction.SOUTH();
|
||||
opposite = Direction.NORTH();
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y, z);
|
||||
current.setType(stand);
|
||||
current.setData(standData);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y + 1, z);
|
||||
current.setType(stand);
|
||||
current.setData(standData);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y, z).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y + 1, z).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,9 @@ public class War extends JavaPlugin {
|
||||
|
||||
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() {
|
||||
super();
|
||||
@ -355,22 +357,21 @@ public class War extends JavaPlugin {
|
||||
int i = 0;
|
||||
for (ItemStack stack : inv.getContents()) {
|
||||
if (stack != null && stack.getType() != Material.AIR) {
|
||||
loadout.put(i, this.copyStack(stack));
|
||||
loadout.put(i, stack.clone());
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
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) {
|
||||
loadout.put(101, this.copyStack(inv.getLeggings()));
|
||||
loadout.put(101, inv.getLeggings().clone());
|
||||
}
|
||||
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) {
|
||||
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();
|
||||
}
|
||||
|
||||
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) {
|
||||
try {
|
||||
if (level > enchantment.getMaxLevel()) {
|
||||
target.addUnsafeEnchantment(Enchantment.getById(enchantment.getId()), level);
|
||||
} else {
|
||||
target.addEnchantment(Enchantment.getById(enchantment.getId()), level);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
War.war.log("Failed to apply enchantment id:" + enchantment.getId() + " level:" + level, Level.WARNING);
|
||||
if (level > enchantment.getMaxLevel()) {
|
||||
target.addUnsafeEnchantment(enchantment, level);
|
||||
} else {
|
||||
target.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
|
||||
@ -577,34 +567,24 @@ public class War extends JavaPlugin {
|
||||
ItemStack blockInHand = player.getItemInHand();
|
||||
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)) {
|
||||
this.badMsg(player, "Can only use blocks or air as lobby material.");
|
||||
} else {
|
||||
if (whichBlocks.equals("floor")) {
|
||||
warzone.getLobbyMaterials().setFloorId(id);
|
||||
warzone.getLobbyMaterials().setFloorData(data);
|
||||
returnMessage.append(" lobby floor material set to id:" + id + " data:" + data + ".");
|
||||
warzone.getLobbyMaterials().setFloorBlock(blockInHand);
|
||||
returnMessage.append(" lobby floor material set to " + blockInHand.getType());
|
||||
updatedLobbyMaterials = true;
|
||||
} else if (whichBlocks.equals("outline")) {
|
||||
warzone.getLobbyMaterials().setOutlineId(id);
|
||||
warzone.getLobbyMaterials().setOutlineData(data);
|
||||
returnMessage.append(" lobby outline material set to id:" + id + " data:" + data + ".");
|
||||
warzone.getLobbyMaterials().setOutlineBlock(blockInHand);
|
||||
returnMessage.append(" lobby outline material set to " + blockInHand.getType());
|
||||
updatedLobbyMaterials = true;
|
||||
} else if (whichBlocks.equals("gate")) {
|
||||
warzone.getLobbyMaterials().setGateId(id);
|
||||
warzone.getLobbyMaterials().setGateData(data);
|
||||
returnMessage.append(" lobby gate material set to id:" + id + " data:" + data + ".");
|
||||
warzone.getLobbyMaterials().setGateBlock(blockInHand);
|
||||
returnMessage.append(" lobby gate material set to " + blockInHand.getType());
|
||||
updatedLobbyMaterials = true;
|
||||
} else if (whichBlocks.equals("light")) {
|
||||
warzone.getLobbyMaterials().setLightId(id);
|
||||
warzone.getLobbyMaterials().setLightData(data);
|
||||
returnMessage.append(" lobby light material set to id:" + id + " data:" + data + ".");
|
||||
warzone.getLobbyMaterials().setLightBlock(blockInHand);
|
||||
returnMessage.append(" lobby light material set to " + blockInHand.getType());
|
||||
updatedLobbyMaterials = true;
|
||||
}
|
||||
|
||||
@ -619,29 +599,20 @@ public class War extends JavaPlugin {
|
||||
ItemStack blockInHand = player.getItemInHand();
|
||||
boolean updatedMaterials = false;
|
||||
|
||||
int id = blockInHand.getTypeId();
|
||||
byte data = (byte)0;
|
||||
if (blockInHand.getData() != null) {
|
||||
data = blockInHand.getData().getData();
|
||||
}
|
||||
|
||||
if (!blockInHand.getType().isBlock()) {
|
||||
this.badMsg(player, "Can only use blocks as material.");
|
||||
} else {
|
||||
if (whichBlocks.equals("main")) {
|
||||
warzone.getWarzoneMaterials().setMainId(id);
|
||||
warzone.getWarzoneMaterials().setMainData(data);
|
||||
returnMessage.append(" main material set to id:" + id + " data:" + data + ".");
|
||||
warzone.getWarzoneMaterials().setMainBlock(blockInHand);
|
||||
returnMessage.append(" main material set to " + blockInHand.getType());
|
||||
updatedMaterials = true;
|
||||
} else if (whichBlocks.equals("stand")) {
|
||||
warzone.getWarzoneMaterials().setStandId(id);
|
||||
warzone.getWarzoneMaterials().setStandData(data);
|
||||
returnMessage.append(" stand material set to id:" + id + " data:" + data + ".");
|
||||
warzone.getWarzoneMaterials().setStandBlock(blockInHand);
|
||||
returnMessage.append(" stand material set to " + blockInHand.getType());
|
||||
updatedMaterials = true;
|
||||
} else if (whichBlocks.equals("light")) {
|
||||
warzone.getWarzoneMaterials().setLightId(id);
|
||||
warzone.getWarzoneMaterials().setLightData(data);
|
||||
returnMessage.append(" light material set to id:" + id + " data:" + data + ".");
|
||||
warzone.getWarzoneMaterials().setLightBlock(blockInHand);
|
||||
returnMessage.append(" light material set to " + blockInHand.getType());
|
||||
updatedMaterials = true;
|
||||
}
|
||||
|
||||
@ -752,34 +723,24 @@ public class War extends JavaPlugin {
|
||||
ItemStack blockInHand = player.getItemInHand();
|
||||
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)) {
|
||||
this.badMsg(player, "Can only use blocks or air as warhub material.");
|
||||
} else {
|
||||
if (whichBlocks.equals("floor")) {
|
||||
War.war.getWarhubMaterials().setFloorId(id);
|
||||
War.war.getWarhubMaterials().setFloorData(data);
|
||||
returnMessage.append(" warhub floor material set to id:" + id + " data:" + data + ".");
|
||||
this.warhubMaterials.setFloorBlock(blockInHand);
|
||||
returnMessage.append(" warhub floor material set to " + blockInHand.getType());
|
||||
updatedWarhubMaterials = true;
|
||||
} else if (whichBlocks.equals("outline")) {
|
||||
War.war.getWarhubMaterials().setOutlineId(id);
|
||||
War.war.getWarhubMaterials().setOutlineData(data);
|
||||
returnMessage.append(" warhub outline material set to id:" + id + " data:" + data + ".");
|
||||
this.warhubMaterials.setOutlineBlock(blockInHand);
|
||||
returnMessage.append(" warhub outline material set to " + blockInHand.getType());
|
||||
updatedWarhubMaterials = true;
|
||||
} else if (whichBlocks.equals("gate")) {
|
||||
War.war.getWarhubMaterials().setGateId(id);
|
||||
War.war.getWarhubMaterials().setGateData(data);
|
||||
returnMessage.append(" warhub gate material set to id:" + id + " data:" + data + ".");
|
||||
this.warhubMaterials.setGateBlock(blockInHand);
|
||||
returnMessage.append(" warhub gate material set to " + blockInHand.getType());
|
||||
updatedWarhubMaterials = true;
|
||||
} else if (whichBlocks.equals("light")) {
|
||||
War.war.getWarhubMaterials().setLightId(id);
|
||||
War.war.getWarhubMaterials().setLightData(data);
|
||||
returnMessage.append(" warhub light material set to id:" + id + " data:" + data + ".");
|
||||
this.warhubMaterials.setLightBlock(blockInHand);
|
||||
returnMessage.append(" warhub light material set to " + blockInHand.getType());
|
||||
updatedWarhubMaterials = true;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,6 @@ import com.tommytony.war.config.TeamKind;
|
||||
import com.tommytony.war.config.WarzoneConfig;
|
||||
import com.tommytony.war.config.WarzoneConfigBag;
|
||||
import com.tommytony.war.event.WarBattleWinEvent;
|
||||
import com.tommytony.war.event.WarPlayerDeathEvent;
|
||||
import com.tommytony.war.event.WarPlayerLeaveEvent;
|
||||
import com.tommytony.war.event.WarPlayerThiefEvent;
|
||||
import com.tommytony.war.event.WarScoreCapEvent;
|
||||
@ -95,7 +94,7 @@ public class Warzone {
|
||||
private final List<Player> respawn = new ArrayList<Player>();
|
||||
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 TeamConfigBag teamDefaultConfig;
|
||||
@ -104,7 +103,9 @@ public class Warzone {
|
||||
private Scoreboard scoreboard;
|
||||
|
||||
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 isReinitializing = false;
|
||||
@ -116,16 +117,7 @@ public class Warzone {
|
||||
this.warzoneConfig = new WarzoneConfigBag(this);
|
||||
this.teamDefaultConfig = new TeamConfigBag(); // don't use ctor with Warzone, as this changes config resolution
|
||||
this.volume = new ZoneVolume(name, this.getWorld(), this);
|
||||
this.lobbyMaterials = new HubLobbyMaterials(
|
||||
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()
|
||||
);
|
||||
this.lobbyMaterials = War.war.getWarhubMaterials().clone();
|
||||
}
|
||||
|
||||
public static Warzone getZoneByName(String name) {
|
||||
@ -617,7 +609,7 @@ public class Warzone {
|
||||
|
||||
int invIndex = 0;
|
||||
for (ItemStack item : originalContents.getContents()) {
|
||||
if (item != null && item.getTypeId() != 0) {
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
playerInv.setItem(invIndex, item);
|
||||
}
|
||||
invIndex++;
|
||||
@ -963,8 +955,7 @@ public class Warzone {
|
||||
sp.sendNotification(
|
||||
SpoutDisplayer.cleanForNotification("Round over! " + playerTeam.getKind().getColor() + playerTeam.getName()),
|
||||
SpoutDisplayer.cleanForNotification("ran out of lives."),
|
||||
playerTeam.getKind().getMaterial(),
|
||||
playerTeam.getKind().getDyeColor().getWoolData(),
|
||||
playerTeam.getKind().getBlockHead(),
|
||||
10000);
|
||||
}
|
||||
}
|
||||
@ -1041,8 +1032,7 @@ public class Warzone {
|
||||
sp.sendNotification(
|
||||
SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
|
||||
SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "your flag."),
|
||||
playerTeam.getKind().getMaterial(),
|
||||
playerTeam.getKind().getDyeColor().getWoolData(),
|
||||
playerTeam.getKind().getBlockHead(),
|
||||
5000);
|
||||
}
|
||||
}
|
||||
@ -1484,7 +1474,7 @@ public class Warzone {
|
||||
int invIndex = 0;
|
||||
playerItems = new HashMap<Integer, ItemStack>();
|
||||
for (ItemStack item : originalState.getContents()) {
|
||||
if (item != null && item.getTypeId() != 0) {
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
playerItems.put(invIndex, item);
|
||||
}
|
||||
invIndex++;
|
||||
|
@ -1,15 +1,11 @@
|
||||
package com.tommytony.war.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.config.TeamConfig;
|
||||
import com.tommytony.war.config.TeamKind;
|
||||
import com.tommytony.war.config.WarzoneConfig;
|
||||
import com.tommytony.war.structure.ZoneLobby;
|
||||
|
@ -60,7 +60,7 @@ public class KillstreakReward {
|
||||
*/
|
||||
public KillstreakReward(ConfigurationSection section) {
|
||||
this.section = section;
|
||||
this.airstrikePlayers = new HashSet();
|
||||
this.airstrikePlayers = new HashSet<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,6 +53,7 @@ public enum TeamKind {
|
||||
*
|
||||
* @return wool color data value
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public byte getData() {
|
||||
return this.dyeColor.getWoolData();
|
||||
}
|
||||
|
@ -55,7 +55,10 @@ public class WarBlockListener implements Listener {
|
||||
Team team = Team.getTeamByPlayerName(player.getName());
|
||||
Warzone zone = Warzone.getZoneByLocation(player);
|
||||
// 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);
|
||||
if (monument != null && !monument.hasOwner()) {
|
||||
monument.capture(team);
|
||||
@ -122,7 +125,7 @@ public class WarBlockListener implements Listener {
|
||||
}
|
||||
|
||||
// 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.");
|
||||
cancelAndKeepItem(event);
|
||||
return;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.tommytony.war.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@ -9,8 +8,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.NoteBlock;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
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.ExplosionPrimeEvent;
|
||||
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.player.SpoutPlayer;
|
||||
|
||||
@ -43,7 +39,6 @@ import com.tommytony.war.config.WarzoneConfig;
|
||||
import com.tommytony.war.job.DeferredBlockResetsJob;
|
||||
import com.tommytony.war.spout.SpoutDisplayer;
|
||||
import com.tommytony.war.structure.Bomb;
|
||||
import com.tommytony.war.utility.DeferredBlockReset;
|
||||
import com.tommytony.war.utility.LoadoutSelection;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -339,8 +334,10 @@ public class WarEntityListener implements Listener {
|
||||
if (zone.isBombBlock(block)) {
|
||||
// tnt doesn't get reset like normal blocks, gotta schedule a later reset just for the Bomb
|
||||
// structure's tnt block
|
||||
DeferredBlockResetsJob job = new DeferredBlockResetsJob(block.getWorld());
|
||||
job.add(new DeferredBlockReset(block.getX(), block.getY(), block.getZ(), Material.TNT.getId(), (byte)0));
|
||||
DeferredBlockResetsJob job = new DeferredBlockResetsJob();
|
||||
BlockState tnt = block.getState();
|
||||
tnt.setType(Material.TNT);
|
||||
job.add(tnt);
|
||||
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job, 10);
|
||||
}
|
||||
inOneZone = true;
|
||||
@ -364,37 +361,9 @@ public class WarEntityListener implements Listener {
|
||||
int dontExplodeSize = dontExplode.size();
|
||||
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
|
||||
DeferredBlockResetsJob job = new DeferredBlockResetsJob(dontExplode.get(0).getWorld());
|
||||
List<Block> doors = new ArrayList<Block>();
|
||||
DeferredBlockResetsJob job = new DeferredBlockResetsJob();
|
||||
for (Block dont : dontExplode) {
|
||||
DeferredBlockReset deferred = null;
|
||||
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);
|
||||
}
|
||||
job.add(dont.getState());
|
||||
}
|
||||
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
|
||||
*
|
||||
|
@ -104,7 +104,7 @@ public class WarPlayerListener implements Listener {
|
||||
Item item = event.getItemDrop();
|
||||
if (item != null) {
|
||||
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
|
||||
War.war.badMsg(player, "Can't drop " + team.getName() + " blocks.");
|
||||
event.setCancelled(true);
|
||||
|
@ -3,167 +3,45 @@ package com.tommytony.war.job;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.NoteBlock;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Entity;
|
||||
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.Direction;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
|
||||
public class DeferredBlockResetsJob implements Runnable {
|
||||
|
||||
List<DeferredBlockReset> deferred = new ArrayList<DeferredBlockReset>();
|
||||
private final World world;
|
||||
|
||||
public DeferredBlockResetsJob(World world) {
|
||||
this.world = world;
|
||||
List<BlockState> deferred = new ArrayList<BlockState>();
|
||||
|
||||
public DeferredBlockResetsJob() {
|
||||
}
|
||||
|
||||
public void add(DeferredBlockReset pleaseResetLater) {
|
||||
@Deprecated
|
||||
public DeferredBlockResetsJob(World humor) {
|
||||
}
|
||||
|
||||
public void add(BlockState pleaseResetLater) {
|
||||
this.deferred.add(pleaseResetLater);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void add(DeferredBlockReset humor) {
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.deferred.isEmpty();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
ArrayList<DeferredBlockReset> doors = new ArrayList<DeferredBlockReset>();
|
||||
|
||||
for (DeferredBlockReset reset : this.deferred) {
|
||||
if (this.world != null && reset != null) {
|
||||
Block worldBlock = this.world.getBlockAt(reset.getX(), reset.getY(), reset.getZ());
|
||||
worldBlock.setType(Material.getMaterial(reset.getBlockType()));
|
||||
|
||||
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;
|
||||
}
|
||||
for (BlockState reset : this.deferred) {
|
||||
reset.update(true, false);
|
||||
for (Entity ent : reset.getWorld().getEntities()) {
|
||||
if (ent instanceof Item
|
||||
&& ent.getLocation().distance(reset.getLocation()) < 2) {
|
||||
ent.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class HelmetProtectionTask implements Runnable {
|
||||
int removed = 0;
|
||||
for (ItemStack item : playerInv.getContents()) {
|
||||
// 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);
|
||||
removed++;
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -5,12 +5,12 @@ import java.util.logging.Level;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.mapper.VolumeMapper;
|
||||
import com.tommytony.war.structure.WarHub;
|
||||
import com.tommytony.war.structure.HubLobbyMaterials;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
|
||||
public class RestoreYmlWarhubJob implements Runnable {
|
||||
@ -21,6 +21,7 @@ public class RestoreYmlWarhubJob implements Runnable {
|
||||
this.warhubConfig = warhubConfig;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void run() {
|
||||
int hubX = warhubConfig.getInt("x");
|
||||
int hubY = warhubConfig.getInt("y");
|
||||
@ -30,40 +31,54 @@ public class RestoreYmlWarhubJob implements Runnable {
|
||||
String hubOrientation = warhubConfig.getString("orientation");
|
||||
|
||||
// materials
|
||||
int floorId = 20; // default glass
|
||||
int floorData = 0;
|
||||
ConfigurationSection floorMaterialSection = warhubConfig.getConfigurationSection("materials.floor");
|
||||
if (floorMaterialSection != null) {
|
||||
floorId = floorMaterialSection.getInt("id");
|
||||
floorData = floorMaterialSection.getInt("data");
|
||||
if (warhubConfig.isItemStack("materials.floor")) {
|
||||
War.war.getWarhubMaterials().setFloorBlock(
|
||||
warhubConfig.getItemStack("materials.floor"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warhubConfig
|
||||
.getConfigurationSection("materials.floor");
|
||||
if (floorMaterialSection != null) {
|
||||
War.war.getWarhubMaterials().setFloorBlock(
|
||||
new ItemStack(floorMaterialSection.getInt("id"), 1,
|
||||
(short) floorMaterialSection.getInt("data")));
|
||||
}
|
||||
}
|
||||
|
||||
int outlineId = 5; // default planks
|
||||
int outlineData = 0;
|
||||
ConfigurationSection outlineMaterialSection = warhubConfig.getConfigurationSection("materials.outline");
|
||||
if (outlineMaterialSection != null) {
|
||||
outlineId = outlineMaterialSection.getInt("id");
|
||||
outlineData = outlineMaterialSection.getInt("data");
|
||||
if (warhubConfig.isItemStack("materials.outline")) {
|
||||
War.war.getWarhubMaterials().setOutlineBlock(
|
||||
warhubConfig.getItemStack("materials.outline"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warhubConfig
|
||||
.getConfigurationSection("materials.outline");
|
||||
if (floorMaterialSection != null) {
|
||||
War.war.getWarhubMaterials().setOutlineBlock(
|
||||
new ItemStack(floorMaterialSection.getInt("id"), 1,
|
||||
(short) floorMaterialSection.getInt("data")));
|
||||
}
|
||||
}
|
||||
|
||||
int gateId = 49; // default obsidian
|
||||
int gateData = 0;
|
||||
ConfigurationSection gateMaterialSection = warhubConfig.getConfigurationSection("materials.gate");
|
||||
if (gateMaterialSection != null) {
|
||||
gateId = gateMaterialSection.getInt("id");
|
||||
gateData = gateMaterialSection.getInt("data");
|
||||
if (warhubConfig.isItemStack("materials.gate")) {
|
||||
War.war.getWarhubMaterials().setGateBlock(
|
||||
warhubConfig.getItemStack("materials.gate"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warhubConfig
|
||||
.getConfigurationSection("materials.gate");
|
||||
if (floorMaterialSection != null) {
|
||||
War.war.getWarhubMaterials().setGateBlock(
|
||||
new ItemStack(floorMaterialSection.getInt("id"), 1,
|
||||
(short) floorMaterialSection.getInt("data")));
|
||||
}
|
||||
}
|
||||
|
||||
int lightId = 89; // default glowstone
|
||||
int lightData = 0;
|
||||
ConfigurationSection lightMaterialSection = warhubConfig.getConfigurationSection("materials.light");
|
||||
if (lightMaterialSection != null) {
|
||||
lightId = lightMaterialSection.getInt("id");
|
||||
lightData = lightMaterialSection.getInt("data");
|
||||
if (warhubConfig.isItemStack("materials.light")) {
|
||||
War.war.getWarhubMaterials().setLightBlock(
|
||||
warhubConfig.getItemStack("materials.light"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warhubConfig
|
||||
.getConfigurationSection("materials.light");
|
||||
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);
|
||||
if (world != null) {
|
||||
Location hubLocation = new Location(world, hubX, hubY, hubZ);
|
||||
|
@ -50,6 +50,7 @@ public class LoadoutYmlMapper {
|
||||
* @param loadoutName The name of the loadout
|
||||
* @return new style loadout
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Loadout fromConfigToLoadout(ConfigurationSection config, HashMap<Integer, ItemStack> loadout, String loadoutName) {
|
||||
List<Integer> slots = config.getIntegerList(loadoutName + ".slots");
|
||||
for (Integer slot : slots) {
|
||||
|
@ -184,18 +184,10 @@ public class WarYmlMapper {
|
||||
hubConfigSection.set("world", hub.getLocation().getWorld().getName());
|
||||
hubConfigSection.set("orientation", orientationStr);
|
||||
|
||||
ConfigurationSection floorSection = hubConfigSection.createSection("materials.floor");
|
||||
floorSection.set("id", War.war.getWarhubMaterials().getFloorId());
|
||||
floorSection.set("data", War.war.getWarhubMaterials().getFloorData());
|
||||
ConfigurationSection outlineSection = hubConfigSection.createSection("materials.outline");
|
||||
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());
|
||||
hubConfigSection.set("materials.floor", War.war.getWarhubMaterials().getFloorBlock());
|
||||
hubConfigSection.set("materials.outline", War.war.getWarhubMaterials().getOutlineBlock());
|
||||
hubConfigSection.set("materials.gate", War.war.getWarhubMaterials().getGateBlock());
|
||||
hubConfigSection.set("materials.light", War.war.getWarhubMaterials().getLightBlock());
|
||||
|
||||
VolumeMapper.save(hub.getVolume(), "");
|
||||
}
|
||||
|
@ -22,9 +22,7 @@ import com.tommytony.war.config.TeamConfig;
|
||||
import com.tommytony.war.config.TeamKind;
|
||||
import com.tommytony.war.structure.Bomb;
|
||||
import com.tommytony.war.structure.Cake;
|
||||
import com.tommytony.war.structure.HubLobbyMaterials;
|
||||
import com.tommytony.war.structure.Monument;
|
||||
import com.tommytony.war.structure.WarzoneMaterials;
|
||||
import com.tommytony.war.structure.ZoneLobby;
|
||||
import com.tommytony.war.utility.Direction;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
@ -32,6 +30,7 @@ import com.tommytony.war.volume.ZoneVolume;
|
||||
|
||||
public class WarzoneYmlMapper {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Warzone load(String name, boolean createNewVolume) {
|
||||
File warzoneTxtFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".txt");
|
||||
File warzoneYmlFile = new File(War.war.getDataFolder().getPath() + "/warzone-" + name + ".yml");
|
||||
@ -323,40 +322,55 @@ public class WarzoneYmlMapper {
|
||||
}
|
||||
|
||||
// lobby materials
|
||||
int floorId = War.war.getWarhubMaterials().getFloorId(); // default warhub
|
||||
int floorData = War.war.getWarhubMaterials().getFloorData();
|
||||
ConfigurationSection floorMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.floor");
|
||||
if (floorMaterialSection != null) {
|
||||
floorId = floorMaterialSection.getInt("id");
|
||||
floorData = floorMaterialSection.getInt("data");
|
||||
if (warzoneRootSection.isItemStack(lobbyPrefix + "materials.floor")) {
|
||||
warzone.getLobbyMaterials().setFloorBlock(
|
||||
warzoneRootSection.getItemStack(lobbyPrefix + "materials.floor"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warzoneRootSection
|
||||
.getConfigurationSection(lobbyPrefix + "materials.floor");
|
||||
if (floorMaterialSection != null) {
|
||||
warzone.getLobbyMaterials().setFloorBlock(
|
||||
new ItemStack(floorMaterialSection.getInt("id"), 1,
|
||||
(short) floorMaterialSection.getInt("data")));
|
||||
}
|
||||
}
|
||||
|
||||
int outlineId = War.war.getWarhubMaterials().getOutlineId();
|
||||
int outlineData = War.war.getWarhubMaterials().getOutlineData();
|
||||
ConfigurationSection outlineMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.outline");
|
||||
if (outlineMaterialSection != null) {
|
||||
outlineId = outlineMaterialSection.getInt("id");
|
||||
outlineData = outlineMaterialSection.getInt("data");
|
||||
if (warzoneRootSection.isItemStack(lobbyPrefix + "materials.outline")) {
|
||||
warzone.getLobbyMaterials().setOutlineBlock(
|
||||
warzoneRootSection.getItemStack(lobbyPrefix + "materials.outline"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warzoneRootSection
|
||||
.getConfigurationSection(lobbyPrefix + "materials.outline");
|
||||
if (floorMaterialSection != null) {
|
||||
warzone.getLobbyMaterials().setOutlineBlock(
|
||||
new ItemStack(floorMaterialSection.getInt("id"), 1,
|
||||
(short) floorMaterialSection.getInt("data")));
|
||||
}
|
||||
}
|
||||
|
||||
int gateId = War.war.getWarhubMaterials().getGateId();
|
||||
int gateData = War.war.getWarhubMaterials().getGateData();;
|
||||
ConfigurationSection gateMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.gate");
|
||||
if (gateMaterialSection != null) {
|
||||
gateId = gateMaterialSection.getInt("id");
|
||||
gateData = gateMaterialSection.getInt("data");
|
||||
if (warzoneRootSection.isItemStack(lobbyPrefix + "materials.gate")) {
|
||||
warzone.getLobbyMaterials().setGateBlock(
|
||||
warzoneRootSection.getItemStack(lobbyPrefix + "materials.gate"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warzoneRootSection
|
||||
.getConfigurationSection(lobbyPrefix + "materials.gate");
|
||||
if (floorMaterialSection != null) {
|
||||
warzone.getLobbyMaterials().setGateBlock(
|
||||
new ItemStack(floorMaterialSection.getInt("id"), 1,
|
||||
(short) floorMaterialSection.getInt("data")));
|
||||
}
|
||||
}
|
||||
|
||||
int lobbyLightId = War.war.getWarhubMaterials().getLightId();
|
||||
int lobbyLightData = War.war.getWarhubMaterials().getLightData();
|
||||
ConfigurationSection lobbyLightMaterialSection = warzoneRootSection.getConfigurationSection(lobbyPrefix + "materials.light");
|
||||
if (lobbyLightMaterialSection != null) {
|
||||
lobbyLightId = lobbyLightMaterialSection.getInt("id");
|
||||
lobbyLightData = lobbyLightMaterialSection.getInt("data");
|
||||
if (warzoneRootSection.isItemStack(lobbyPrefix + "materials.light")) {
|
||||
warzone.getLobbyMaterials().setLightBlock(
|
||||
warzoneRootSection.getItemStack(lobbyPrefix + "materials.light"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warzoneRootSection
|
||||
.getConfigurationSection(lobbyPrefix + "materials.light");
|
||||
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
|
||||
String lobbyWorldName = warzoneRootSection.getString(lobbyPrefix + "world");
|
||||
World lobbyWorld = War.war.getServer().getWorld(lobbyWorldName);
|
||||
@ -367,32 +381,43 @@ public class WarzoneYmlMapper {
|
||||
warzone.setLobby(lobby);
|
||||
|
||||
// warzone materials
|
||||
int mainId = warzone.getWarzoneMaterials().getMainId();
|
||||
int mainData = warzone.getWarzoneMaterials().getMainData();
|
||||
ConfigurationSection mainMaterialSection = warzoneRootSection.getConfigurationSection(zoneInfoPrefix + "materials.main");
|
||||
if (mainMaterialSection != null) {
|
||||
mainId = mainMaterialSection.getInt("id");
|
||||
mainData = mainMaterialSection.getInt("data");
|
||||
if (warzoneRootSection.isItemStack(zoneInfoPrefix + "materials.main")) {
|
||||
warzone.getWarzoneMaterials().setMainBlock(
|
||||
warzoneRootSection.getItemStack(zoneInfoPrefix + "materials.main"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warzoneRootSection
|
||||
.getConfigurationSection(zoneInfoPrefix + "materials.main");
|
||||
if (floorMaterialSection != null) {
|
||||
warzone.getWarzoneMaterials().setMainBlock(
|
||||
new ItemStack(floorMaterialSection.getInt("id"), 1,
|
||||
(short) floorMaterialSection.getInt("data")));
|
||||
}
|
||||
}
|
||||
|
||||
int standId = warzone.getWarzoneMaterials().getStandId();
|
||||
int standData = warzone.getWarzoneMaterials().getStandData();
|
||||
ConfigurationSection standMaterialSection = warzoneRootSection.getConfigurationSection(zoneInfoPrefix + "materials.stand");
|
||||
if (standMaterialSection != null) {
|
||||
standId = standMaterialSection.getInt("id");
|
||||
standData = standMaterialSection.getInt("data");
|
||||
if (warzoneRootSection.isItemStack(zoneInfoPrefix + "materials.stand")) {
|
||||
warzone.getWarzoneMaterials().setStandBlock(
|
||||
warzoneRootSection.getItemStack(zoneInfoPrefix + "materials.stand"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warzoneRootSection
|
||||
.getConfigurationSection(zoneInfoPrefix + "materials.stand");
|
||||
if (floorMaterialSection != null) {
|
||||
warzone.getWarzoneMaterials().setStandBlock(
|
||||
new ItemStack(floorMaterialSection.getInt("id"), 1,
|
||||
(short) floorMaterialSection.getInt("data")));
|
||||
}
|
||||
}
|
||||
|
||||
int lightId = warzone.getWarzoneMaterials().getLightId();
|
||||
int lightData = warzone.getWarzoneMaterials().getLightData();
|
||||
ConfigurationSection lightMaterialSection = warzoneRootSection.getConfigurationSection(zoneInfoPrefix + "materials.light");
|
||||
if (lightMaterialSection != null) {
|
||||
lightId = lightMaterialSection.getInt("id");
|
||||
lightData = lightMaterialSection.getInt("data");
|
||||
if (warzoneRootSection.isItemStack(zoneInfoPrefix + "materials.light")) {
|
||||
warzone.getWarzoneMaterials().setLightBlock(
|
||||
warzoneRootSection.getItemStack(zoneInfoPrefix + "materials.light"));
|
||||
} else {
|
||||
ConfigurationSection floorMaterialSection = warzoneRootSection
|
||||
.getConfigurationSection(zoneInfoPrefix + "materials.light");
|
||||
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;
|
||||
}
|
||||
|
||||
@ -444,31 +469,17 @@ public class WarzoneYmlMapper {
|
||||
lobbySection.set("orientation", lobbyOrientation);
|
||||
lobbySection.set("world", warzone.getLobby().getVolume().getWorld().getName());
|
||||
|
||||
ConfigurationSection floorSection = lobbySection.createSection("materials.floor");
|
||||
floorSection.set("id", warzone.getLobbyMaterials().getFloorId());
|
||||
floorSection.set("data", warzone.getLobbyMaterials().getFloorData());
|
||||
ConfigurationSection outlineSection = lobbySection.createSection("materials.outline");
|
||||
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());
|
||||
lobbySection.set("materials.floor", warzone.getLobbyMaterials().getFloorBlock());
|
||||
lobbySection.set("materials.outline", warzone.getLobbyMaterials().getOutlineBlock());
|
||||
lobbySection.set("materials.gate", warzone.getLobbyMaterials().getGateBlock());
|
||||
lobbySection.set("materials.light", warzone.getLobbyMaterials().getLightBlock());
|
||||
}
|
||||
|
||||
// materials
|
||||
if (warzone.getLobby() != null) {
|
||||
ConfigurationSection mainSection = warzoneInfoSection.createSection("materials.main");
|
||||
mainSection.set("id", warzone.getWarzoneMaterials().getMainId());
|
||||
mainSection.set("data", warzone.getWarzoneMaterials().getMainData());
|
||||
ConfigurationSection standSection = warzoneInfoSection.createSection("materials.stand");
|
||||
standSection.set("id", warzone.getWarzoneMaterials().getStandId());
|
||||
standSection.set("data", warzone.getWarzoneMaterials().getStandData());
|
||||
ConfigurationSection lightSection = warzoneInfoSection.createSection("materials.light");
|
||||
lightSection.set("id", warzone.getWarzoneMaterials().getLightId());
|
||||
lightSection.set("data", warzone.getWarzoneMaterials().getLightData());
|
||||
warzoneInfoSection.set("materials.main", warzone.getWarzoneMaterials().getMainBlock());
|
||||
warzoneInfoSection.set("materials.stand", warzone.getWarzoneMaterials().getStandBlock());
|
||||
warzoneInfoSection.set("materials.light", warzone.getWarzoneMaterials().getLightBlock());
|
||||
}
|
||||
|
||||
// rallyPoint
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.tommytony.war.Warzone;
|
||||
@ -53,55 +54,58 @@ public class Bomb {
|
||||
int y = this.location.getBlockY();
|
||||
int z = this.location.getBlockZ();
|
||||
|
||||
Material main = Material.getMaterial(this.warzone.getWarzoneMaterials().getMainId());
|
||||
byte mainData = this.warzone.getWarzoneMaterials().getMainData();
|
||||
Material stand = Material.getMaterial(this.warzone.getWarzoneMaterials().getStandId());
|
||||
byte standData = this.warzone.getWarzoneMaterials().getStandData();
|
||||
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
|
||||
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
|
||||
|
||||
// center
|
||||
Block current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
BlockState current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
|
||||
current.update(true);
|
||||
|
||||
// inner ring
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1);
|
||||
current.setType(light);
|
||||
current.setData(lightData);
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
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);
|
||||
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);
|
||||
|
||||
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
|
||||
current.setType(light);
|
||||
current.setData(lightData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, 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).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
|
||||
current.update(true);
|
||||
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.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1);
|
||||
current.setType(light);
|
||||
current.setData(lightData);
|
||||
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 - 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().getLightBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
|
||||
current.update(true);
|
||||
|
||||
// block holder
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z);
|
||||
current.setType(stand);
|
||||
current.setData(standData);
|
||||
Block tntBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z);
|
||||
tntBlock.setType(Material.TNT);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(Material.TNT);
|
||||
}
|
||||
|
||||
public boolean isBombBlock(Location otherLocation) {
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.tommytony.war.Warzone;
|
||||
@ -53,56 +54,58 @@ public class Cake {
|
||||
int y = this.location.getBlockY();
|
||||
int z = this.location.getBlockZ();
|
||||
|
||||
Material main = Material.getMaterial(this.warzone.getWarzoneMaterials().getMainId());
|
||||
byte mainData = this.warzone.getWarzoneMaterials().getMainData();
|
||||
Material stand = Material.getMaterial(this.warzone.getWarzoneMaterials().getStandId());
|
||||
byte standData = this.warzone.getWarzoneMaterials().getStandData();
|
||||
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
|
||||
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
|
||||
|
||||
// center
|
||||
Block current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
BlockState current = this.warzone.getWorld().getBlockAt(x, y - 1, z).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getMainBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getMainBlock().getData());
|
||||
current.update(true);
|
||||
|
||||
// inner ring
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1);
|
||||
current.setType(light);
|
||||
current.setData(lightData);
|
||||
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);
|
||||
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);
|
||||
|
||||
current = this.warzone.getWorld().getBlockAt(x, y - 1, z + 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y - 1, z);
|
||||
current.setType(light);
|
||||
current.setData(lightData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y - 1, z - 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x, 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).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getLightBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
|
||||
current.update(true);
|
||||
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.setType(light);
|
||||
current.setData(lightData);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
current = this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1);
|
||||
current.setType(main);
|
||||
current.setData(mainData);
|
||||
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 - 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().getLightBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getLightBlock().getData());
|
||||
current.update(true);
|
||||
|
||||
// block holder
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z);
|
||||
current.setType(stand);
|
||||
current.setData(standData);
|
||||
|
||||
Block cakeBlock = this.warzone.getWorld().getBlockAt(x, y + 1, z);
|
||||
cakeBlock.setType(Material.CAKE_BLOCK);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z).getState();
|
||||
current.setType(this.warzone.getWarzoneMaterials().getStandBlock().getType());
|
||||
current.setData(this.warzone.getWarzoneMaterials().getStandBlock().getData());
|
||||
current.update(true);
|
||||
this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(Material.CAKE_BLOCK);
|
||||
}
|
||||
|
||||
public boolean isCakeBlock(Location otherLocation) {
|
||||
|
@ -1,131 +1,70 @@
|
||||
package com.tommytony.war.structure;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.tommytony.war.War;
|
||||
public class HubLobbyMaterials implements Cloneable {
|
||||
|
||||
public class HubLobbyMaterials {
|
||||
private int floorId;
|
||||
private byte floorData;
|
||||
|
||||
private int outlineId;
|
||||
private byte outlineData;
|
||||
|
||||
private int gateId;
|
||||
private byte gateData;
|
||||
|
||||
private int lightId;
|
||||
private byte lightData;
|
||||
|
||||
public HubLobbyMaterials(int floorId, byte floorData, int outlineId, byte outlineData, int gateId, byte gateData, int lightId, byte lightData) {
|
||||
// Make sure we are using legal blocks or AIR as material
|
||||
if (isBlockOrAir(floorId)) {
|
||||
this.setFloorId(floorId);
|
||||
this.setFloorData(floorData);
|
||||
} else {
|
||||
this.setFloorId(20); // default glass
|
||||
this.setFloorData((byte)0);
|
||||
}
|
||||
|
||||
if (isBlockOrAir(outlineId)) {
|
||||
this.setOutlineId(outlineId);
|
||||
this.setOutlineData(outlineData);
|
||||
} else {
|
||||
this.setOutlineId(5); // default planks
|
||||
this.setOutlineData((byte)0);
|
||||
}
|
||||
|
||||
if (isBlockOrAir(gateId)) {
|
||||
this.setGateId(gateId);
|
||||
this.setGateData(gateData);
|
||||
} else {
|
||||
this.setGateId(49); // default obsidian
|
||||
this.setGateData((byte)0);
|
||||
}
|
||||
|
||||
if (isBlockOrAir(lightId)) {
|
||||
this.setLightId(lightId);
|
||||
this.setLightData(lightData);
|
||||
} else {
|
||||
this.setLightId(89); // default glowstone
|
||||
this.setLightData((byte)0);
|
||||
private ItemStack floorBlock;
|
||||
private ItemStack outlineBlock;
|
||||
private ItemStack gateBlock;
|
||||
private ItemStack lightBlock;
|
||||
|
||||
public HubLobbyMaterials(ItemStack floorBlock, ItemStack outlineBlock,
|
||||
ItemStack gateBlock, ItemStack lightBlock) {
|
||||
Validate.isTrue(floorBlock.getType().isBlock()
|
||||
|| floorBlock.getType() == Material.AIR);
|
||||
Validate.isTrue(outlineBlock.getType().isBlock()
|
||||
|| outlineBlock.getType() == Material.AIR);
|
||||
Validate.isTrue(gateBlock.getType().isBlock()
|
||||
|| gateBlock.getType() == Material.AIR);
|
||||
Validate.isTrue(lightBlock.getType().isBlock()
|
||||
|| lightBlock.getType() == Material.AIR);
|
||||
this.floorBlock = floorBlock;
|
||||
this.outlineBlock = outlineBlock;
|
||||
this.gateBlock = gateBlock;
|
||||
this.lightBlock = lightBlock;
|
||||
}
|
||||
|
||||
public ItemStack getFloorBlock() {
|
||||
return floorBlock;
|
||||
}
|
||||
|
||||
public void setFloorBlock(ItemStack floorBlock) {
|
||||
this.floorBlock = floorBlock;
|
||||
}
|
||||
|
||||
public ItemStack getOutlineBlock() {
|
||||
return outlineBlock;
|
||||
}
|
||||
|
||||
public void setOutlineBlock(ItemStack outlineBlock) {
|
||||
this.outlineBlock = outlineBlock;
|
||||
}
|
||||
|
||||
public ItemStack getGateBlock() {
|
||||
return gateBlock;
|
||||
}
|
||||
|
||||
public void setGateBlock(ItemStack gateBlock) {
|
||||
this.gateBlock = gateBlock;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.Warzone;
|
||||
@ -53,127 +55,158 @@ public class Monument {
|
||||
int x = this.location.getBlockX();
|
||||
int y = this.location.getBlockY();
|
||||
int z = this.location.getBlockZ();
|
||||
|
||||
Material main = Material.getMaterial(this.warzone.getWarzoneMaterials().getMainId());
|
||||
byte mainData = this.warzone.getWarzoneMaterials().getMainData();
|
||||
Material light = Material.getMaterial(this.warzone.getWarzoneMaterials().getLightId());
|
||||
byte lightData = this.warzone.getWarzoneMaterials().getLightData();
|
||||
final Material main = this.warzone.getWarzoneMaterials().getMainBlock().getType();
|
||||
final MaterialData mainData = this.warzone.getWarzoneMaterials().getMainBlock().getData();
|
||||
final Material light = this.warzone.getWarzoneMaterials().getLightBlock().getType();
|
||||
final MaterialData lightData = this.warzone.getWarzoneMaterials().getLightBlock().getData();
|
||||
|
||||
// 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.setData(mainData);
|
||||
current.update(true);
|
||||
|
||||
// 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.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.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.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.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.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.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.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.setData(mainData);
|
||||
current.update(true);
|
||||
|
||||
// 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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.setData(lightData);
|
||||
current.update(true);
|
||||
|
||||
// block holder
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z);
|
||||
current = this.warzone.getWorld().getBlockAt(x, y, z).getState();
|
||||
current.setType(main);
|
||||
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.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.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.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.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.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.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.setData(mainData);
|
||||
|
||||
current.update(true);
|
||||
}
|
||||
|
||||
public boolean isNear(Location playerLocation) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.tommytony.war.structure;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
@ -8,7 +9,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.material.Sign;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
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.WarzoneConfig;
|
||||
import com.tommytony.war.utility.Direction;
|
||||
import com.tommytony.war.utility.SignHelper;
|
||||
import com.tommytony.war.volume.BlockInfo;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
|
||||
@ -98,7 +99,9 @@ public class WarHub {
|
||||
Warzone zone = null;
|
||||
for (String zoneName : this.zoneGateBlocks.keySet()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -125,24 +128,19 @@ public class WarHub {
|
||||
BlockFace right;
|
||||
BlockFace front = this.getOrientation();
|
||||
BlockFace back;
|
||||
byte data;
|
||||
if (this.getOrientation() == Direction.SOUTH()) {
|
||||
data = (byte) 4;
|
||||
left = Direction.EAST();
|
||||
right = Direction.WEST();
|
||||
back = Direction.NORTH();
|
||||
} else if (this.getOrientation() == Direction.NORTH()) {
|
||||
data = (byte) 12;
|
||||
left = Direction.WEST();
|
||||
right = Direction.EAST();
|
||||
back = Direction.SOUTH();
|
||||
} else if (this.getOrientation() == Direction.EAST()) {
|
||||
data = (byte) 0;
|
||||
left = Direction.NORTH();
|
||||
right = Direction.SOUTH();
|
||||
back = Direction.WEST();
|
||||
} else {
|
||||
data = (byte) 8;
|
||||
left = Direction.SOUTH();
|
||||
right = Direction.NORTH();
|
||||
back = Direction.EAST();
|
||||
@ -154,26 +152,16 @@ public class WarHub {
|
||||
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.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
|
||||
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.
|
||||
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.
|
||||
this.volume.setFloorOutlineMaterial(outline, outlineData);
|
||||
this.volume.setFloorOutline(War.war.getWarhubMaterials().getOutlineBlock());
|
||||
}
|
||||
|
||||
// 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, 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
|
||||
currentGateBlock.getRelative(BlockFace.DOWN).setType(light);
|
||||
currentGateBlock.getRelative(BlockFace.DOWN).setData(lightData);
|
||||
|
||||
currentGateBlock.getRelative(left).setType(gate);
|
||||
currentGateBlock.getRelative(left).setData(gateData);
|
||||
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).setType(gate);
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).setData(gateData);
|
||||
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(gate);
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setData(gateData);
|
||||
|
||||
currentGateBlock.getRelative(right).setType(gate);
|
||||
currentGateBlock.getRelative(right).setData(gateData);
|
||||
|
||||
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);
|
||||
|
||||
Block[] gateBlocks = {
|
||||
currentGateBlock.getRelative(left),
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP),
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP),
|
||||
currentGateBlock.getRelative(right),
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP),
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).getRelative(BlockFace.UP),
|
||||
currentGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP)
|
||||
};
|
||||
for (Block gateBlock : gateBlocks) {
|
||||
BlockState gb = gateBlock.getState();
|
||||
gb.setType(War.war.getWarhubMaterials().getGateBlock().getType());
|
||||
gb.setData(War.war.getWarhubMaterials().getGateBlock().getData());
|
||||
gb.update(true);
|
||||
}
|
||||
currentGateBlock = currentGateBlock.getRelative(right, 4);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// War hub sign
|
||||
Block signBlock = locationBlock.getRelative(front, 2);
|
||||
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "War hub";
|
||||
lines[1] = "(/warhub)";
|
||||
lines[2] = "Pick your";
|
||||
lines[3] = "battle!";
|
||||
SignHelper.setToSign(War.war, signBlock, data, lines);
|
||||
|
||||
locationBlock.getRelative(front, 2).setType(Material.SIGN_POST);
|
||||
String[] lines = "War hub\n(/warhub)\nPick your\nbattle!".split("\n");
|
||||
org.bukkit.block.Sign locationBlockFront = (org.bukkit.block.Sign) locationBlock.getRelative(front, 2).getState();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
locationBlockFront.setLine(i, lines[i]);
|
||||
}
|
||||
org.bukkit.material.Sign sign = (Sign) locationBlockFront.getData();
|
||||
sign.setFacingDirection(orientation.getOppositeFace());
|
||||
locationBlockFront.setData(sign);
|
||||
locationBlockFront.update(true);
|
||||
// Warzone signs
|
||||
for (Warzone zone : War.war.getWarzones()) {
|
||||
if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED) && zone.ready()) {
|
||||
@ -260,45 +243,41 @@ public class WarHub {
|
||||
public void resetZoneSign(Warzone zone) {
|
||||
BlockFace left;
|
||||
BlockFace back;
|
||||
byte data;
|
||||
if (this.getOrientation() == Direction.SOUTH()) {
|
||||
data = (byte) 4;
|
||||
left = Direction.EAST();
|
||||
back = Direction.NORTH();
|
||||
} else if (this.getOrientation() == Direction.NORTH()) {
|
||||
data = (byte) 12;
|
||||
left = Direction.WEST();
|
||||
back = Direction.SOUTH();
|
||||
} else if (this.getOrientation() == Direction.EAST()) {
|
||||
data = (byte) 0;
|
||||
left = Direction.NORTH();
|
||||
back = Direction.WEST();
|
||||
} else {
|
||||
data = (byte) 8;
|
||||
left = Direction.SOUTH();
|
||||
back = Direction.EAST();
|
||||
}
|
||||
|
||||
Block zoneGate = this.zoneGateBlocks.get(zone.getName());
|
||||
if (zoneGate != null) {
|
||||
Block block = zoneGate.getRelative(left).getRelative(back, 1);
|
||||
if (block.getType() != Material.SIGN_POST) {
|
||||
block.setType(Material.SIGN_POST);
|
||||
}
|
||||
zoneGate.getRelative(left).getRelative(back, 1).setType(Material.SIGN_POST);
|
||||
org.bukkit.block.Sign block = (org.bukkit.block.Sign) zoneGate.getRelative(left).getRelative(back, 1).getState();
|
||||
org.bukkit.material.Sign data = (Sign) block.getData();
|
||||
data.setFacingDirection(this.getOrientation().getOppositeFace());
|
||||
block.setData(data);
|
||||
|
||||
int zoneCap = 0;
|
||||
int zonePlayers = 0;
|
||||
for (Team t : zone.getTeams()) {
|
||||
zonePlayers += t.getPlayers().size();
|
||||
zoneCap += t.getTeamConfig().resolveInt(TeamConfig.TEAMSIZE);
|
||||
}
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "Warzone";
|
||||
lines[1] = zone.getName();
|
||||
lines[2] = zonePlayers + "/" + zoneCap + " players";
|
||||
lines[3] = zone.getTeams().size() + " teams";
|
||||
SignHelper.setToSign(War.war, block, data, lines);
|
||||
String[] lines = MessageFormat.format(
|
||||
"Warzone\n{0}\n{1}/{2} players\n{3} teams",
|
||||
zone.getName(), zonePlayers, zoneCap,
|
||||
zone.getTeams().size()).split("\n");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
block.setLine(i, lines[i]);
|
||||
}
|
||||
block.update(true);
|
||||
} else {
|
||||
War.war.log("Failed to find warhub gate for " + zone.getName() + " warzone.", Level.WARNING);
|
||||
}
|
||||
|
@ -1,104 +1,53 @@
|
||||
package com.tommytony.war.structure;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
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 {
|
||||
private int mainId;
|
||||
private byte mainData;
|
||||
|
||||
private int standId;
|
||||
private byte standData;
|
||||
public WarzoneMaterials(ItemStack mainBlock, ItemStack standBlock, ItemStack lightBlock) {
|
||||
Validate.isTrue(mainBlock.getType().isBlock() || mainBlock.getType() == Material.AIR);
|
||||
Validate.isTrue(standBlock.getType().isBlock() || standBlock.getType() == Material.AIR);
|
||||
Validate.isTrue(lightBlock.getType().isBlock() || lightBlock.getType() == Material.AIR);
|
||||
this.mainBlock = mainBlock;
|
||||
this.standBlock = standBlock;
|
||||
this.lightBlock = lightBlock;
|
||||
}
|
||||
|
||||
private int lightId;
|
||||
private byte lightData;
|
||||
|
||||
public WarzoneMaterials(int mainId, byte mainData, int standId, byte standData, int lightId, byte lightData) {
|
||||
// Make sure we are using legal blocks or AIR as material
|
||||
if (isBlockOrAir(mainId)) {
|
||||
this.setMainId(mainId);
|
||||
this.setMainData(mainData);
|
||||
} else {
|
||||
this.setMainId(49); // default obsidian
|
||||
this.setMainData((byte)0);
|
||||
}
|
||||
|
||||
if (isBlockOrAir(standId)) {
|
||||
this.setStandId(standId);
|
||||
this.setStandData(standData);
|
||||
} else {
|
||||
this.setStandId(85); // default ladder
|
||||
this.setStandData((byte)0);
|
||||
}
|
||||
|
||||
if (isBlockOrAir(lightId)) {
|
||||
this.setLightId(lightId);
|
||||
this.setLightData(lightData);
|
||||
} else {
|
||||
this.setLightId(89); // default glowstone
|
||||
this.setLightData((byte)0);
|
||||
public ItemStack getMainBlock() {
|
||||
return mainBlock;
|
||||
}
|
||||
|
||||
public void setMainBlock(ItemStack mainBlock) {
|
||||
this.mainBlock = mainBlock;
|
||||
}
|
||||
|
||||
public ItemStack getStandBlock() {
|
||||
return standBlock;
|
||||
}
|
||||
|
||||
public void setStandBlock(ItemStack standBlock) {
|
||||
this.standBlock = standBlock;
|
||||
}
|
||||
|
||||
public ItemStack getLightBlock() {
|
||||
return lightBlock;
|
||||
}
|
||||
|
||||
public void setLightBlock(ItemStack lightBlock) {
|
||||
this.lightBlock = lightBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WarzoneMaterials clone() {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.tommytony.war.structure;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -9,8 +10,10 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Sign;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
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.WarzoneConfig;
|
||||
import com.tommytony.war.utility.Direction;
|
||||
import com.tommytony.war.utility.SignHelper;
|
||||
import com.tommytony.war.volume.BlockInfo;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
import com.tommytony.war.volume.ZoneVolume;
|
||||
@ -275,35 +277,22 @@ public class ZoneLobby {
|
||||
// maybe the number of teams change, now reset the gate positions
|
||||
if (this.lobbyMiddleWallBlock != null && this.volume != null) {
|
||||
this.setGatePositions(BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock));
|
||||
|
||||
// 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 (!warzone.getLobbyMaterials().getFloorBlock().getType().equals(Material.AIR)) {
|
||||
// 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.
|
||||
this.volume.setFloorOutlineMaterial(outline, outlineData);
|
||||
this.volume.setFloorOutline(warzone.getLobbyMaterials().getOutlineBlock());
|
||||
}
|
||||
|
||||
// add war hub link gate
|
||||
if (War.war.getWarHub() != null) {
|
||||
Block linkGateBlock = BlockInfo.getBlock(this.volume.getWorld(), this.warHubLinkGate);
|
||||
this.placeWarhubLinkGate(linkGateBlock, gate, gateData);
|
||||
this.placeWarhubLinkGate(linkGateBlock, warzone.getLobbyMaterials().getGateBlock());
|
||||
// add warhub sign
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "";
|
||||
lines[1] = "To War hub";
|
||||
lines[2] = "";
|
||||
lines[3] = "";
|
||||
String[] lines = "\nTo War hub\n\n ".split("\n");
|
||||
this.resetGateSign(linkGateBlock, lines, false);
|
||||
}
|
||||
|
||||
@ -371,45 +360,40 @@ public class ZoneLobby {
|
||||
|
||||
// set zone sign
|
||||
Block zoneSignBlock = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(this.wall, 4);
|
||||
byte data = 0;
|
||||
if (this.wall == Direction.NORTH()) {
|
||||
data = (byte) 4;
|
||||
} else if (this.wall == Direction.EAST()) {
|
||||
data = (byte) 8;
|
||||
} else if (this.wall == Direction.SOUTH()) {
|
||||
data = (byte) 12;
|
||||
} else if (this.wall == Direction.WEST()) {
|
||||
data = (byte) 0;
|
||||
}
|
||||
zoneSignBlock.setType(Material.SIGN_POST);
|
||||
org.bukkit.block.Sign block = (org.bukkit.block.Sign) zoneSignBlock.getState();
|
||||
org.bukkit.material.Sign data = (Sign) block.getData();
|
||||
data.setFacingDirection(this.wall);
|
||||
block.setData(data);
|
||||
String[] lines = new String[4];
|
||||
lines[0] = "Warzone";
|
||||
lines[1] = this.warzone.getName();
|
||||
if (this.autoAssignGate != null) {
|
||||
lines[2] = "Enter the auto-";
|
||||
lines[3] = "assign gate.";
|
||||
lines = MessageFormat.format("Warzone\n{0}\nEnter the auto-\nassign gate.", warzone.getName()).split("\n");
|
||||
} else {
|
||||
lines[2] = "";
|
||||
lines[3] = "Pick your team.";
|
||||
lines = MessageFormat.format("Warzone\n{0}\n\nPick your team.", warzone.getName()).split("\n");
|
||||
}
|
||||
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
|
||||
Material light = Material.getMaterial(this.warzone.getLobbyMaterials().getLightId());
|
||||
byte lightData = this.warzone.getLobbyMaterials().getLightData();
|
||||
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);
|
||||
one.setType(light);
|
||||
one.setData(lightData);
|
||||
Block two = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9);
|
||||
two.setType(light);
|
||||
two.setData(lightData);
|
||||
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(warzone.getLobbyMaterials().getLightBlock().getType());
|
||||
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
|
||||
one.update(true);
|
||||
one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
|
||||
one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
|
||||
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
|
||||
one.update(true);
|
||||
} else {
|
||||
Block one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.NORTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9);
|
||||
one.setType(light);
|
||||
one.setData(lightData);
|
||||
Block two = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.SOUTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9);
|
||||
two.setType(light);
|
||||
two.setData(lightData);
|
||||
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(warzone.getLobbyMaterials().getLightBlock().getType());
|
||||
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
|
||||
one.update(true);
|
||||
one = BlockInfo.getBlock(this.volume.getWorld(), this.lobbyMiddleWallBlock).getRelative(BlockFace.DOWN).getRelative(Direction.SOUTH(), this.lobbyHalfSide - 1).getRelative(this.wall, 9).getState();
|
||||
one.setType(warzone.getLobbyMaterials().getLightBlock().getType());
|
||||
one.setData(warzone.getLobbyMaterials().getLightBlock().getData());
|
||||
one.update(true);
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
|
||||
// gate blocks
|
||||
block.getRelative(BlockFace.DOWN).setType(Material.getMaterial(this.warzone.getLobbyMaterials().getLightId()));
|
||||
block.getRelative(BlockFace.DOWN).setData(this.warzone.getLobbyMaterials().getLightData());
|
||||
BlockState lightBlock = block.getRelative(BlockFace.DOWN).getState();
|
||||
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(rightSide).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) {
|
||||
BlockFace front = null;
|
||||
BlockFace leftSide = null; // looking at the zone
|
||||
@ -534,26 +520,34 @@ public class ZoneLobby {
|
||||
this.clearGatePath(block, front, leftSide, rightSide, false);
|
||||
|
||||
// gate blocks
|
||||
block.getRelative(BlockFace.DOWN).setType(Material.getMaterial(this.warzone.getLobbyMaterials().getLightId()));
|
||||
block.getRelative(BlockFace.DOWN).setData(this.warzone.getLobbyMaterials().getLightData());
|
||||
this.setBlock(block.getRelative(leftSide), material, data);
|
||||
this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP), material, data);
|
||||
this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), material, data);
|
||||
this.setBlock(block.getRelative(rightSide), material, data);
|
||||
this.setBlock(block.getRelative(leftSide).getRelative(BlockFace.UP), material, data);
|
||||
this.setBlock(block.getRelative(rightSide).getRelative(BlockFace.UP).getRelative(BlockFace.UP), material, data);
|
||||
this.setBlock(block.getRelative(BlockFace.UP).getRelative(BlockFace.UP), material, data);
|
||||
BlockState lightBlock = block.getRelative(BlockFace.DOWN).getState();
|
||||
lightBlock.setType(warzone.getLobbyMaterials().getLightBlock().getType());
|
||||
lightBlock.setData(warzone.getLobbyMaterials().getLightBlock().getData());
|
||||
lightBlock.update(true);
|
||||
Block[] updateBlocks = {
|
||||
block.getRelative(leftSide),
|
||||
block.getRelative(rightSide).getRelative(BlockFace.UP),
|
||||
block.getRelative(leftSide).getRelative(BlockFace.UP)
|
||||
.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) {
|
||||
block.setType(kind.getMaterial());
|
||||
block.setData(kind.getData());
|
||||
}
|
||||
|
||||
private void setBlock(Block block, Material material, byte data) {
|
||||
block.setType(material);
|
||||
block.setData(data);
|
||||
BlockState blockState = block.getState();
|
||||
blockState.setType(kind.getBlockHead().getType());
|
||||
blockState.setData(kind.getBlockHead().getData());
|
||||
blockState.update(true);
|
||||
}
|
||||
|
||||
private void placeAutoAssignGate() {
|
||||
@ -585,9 +579,10 @@ public class ZoneLobby {
|
||||
this.clearGatePath(autoAssignGateBlock, front, leftSide, rightSide, false);
|
||||
|
||||
// gate blocks
|
||||
this.setBlock(autoAssignGateBlock.getRelative(BlockFace.DOWN),
|
||||
Material.getMaterial(this.warzone.getLobbyMaterials().getLightId()),
|
||||
this.warzone.getLobbyMaterials().getLightData());
|
||||
BlockState lightBlock = autoAssignGateBlock.getRelative(BlockFace.DOWN).getState();
|
||||
lightBlock.setType(warzone.getLobbyMaterials().getLightBlock().getType());
|
||||
lightBlock.setData(warzone.getLobbyMaterials().getLightBlock().getData());
|
||||
lightBlock.update(true);
|
||||
int size = teams.size();
|
||||
if (size > 0) {
|
||||
TeamKind[] doorBlockKinds = new TeamKind[7];
|
||||
@ -702,14 +697,30 @@ public class ZoneLobby {
|
||||
|
||||
private void resetTeamGateSign(Team team, Block gate) {
|
||||
if (gate != null) {
|
||||
String[] lines = new String[4];
|
||||
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";
|
||||
String[] lines;
|
||||
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 {
|
||||
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);
|
||||
}
|
||||
@ -729,38 +740,25 @@ public class ZoneLobby {
|
||||
} else if (this.wall == Direction.WEST()) {
|
||||
direction = Direction.EAST();
|
||||
}
|
||||
byte data = 0;
|
||||
if (this.wall == Direction.NORTH()) {
|
||||
block = gate.getRelative(direction).getRelative(Direction.EAST());
|
||||
if (awayFromWall) {
|
||||
data = (byte) 4;
|
||||
} else {
|
||||
data = (byte) 12;
|
||||
}
|
||||
} else if (this.wall == Direction.EAST()) {
|
||||
block = gate.getRelative(direction).getRelative(Direction.SOUTH());
|
||||
if (awayFromWall) {
|
||||
data = (byte) 8;
|
||||
} else {
|
||||
data = (byte) 0;
|
||||
}
|
||||
} else if (this.wall == Direction.SOUTH()) {
|
||||
block = gate.getRelative(direction).getRelative(Direction.WEST());
|
||||
if (awayFromWall) {
|
||||
data = (byte) 12;
|
||||
} else {
|
||||
data = (byte) 4;
|
||||
}
|
||||
} else if (this.wall == Direction.WEST()) {
|
||||
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) {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -41,6 +42,17 @@ public class Volume {
|
||||
this.name = name;
|
||||
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) {
|
||||
this.name = newName;
|
||||
@ -294,7 +306,6 @@ public class Volume {
|
||||
}
|
||||
|
||||
public byte[][][] getBlockDatas() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.blockDatas;
|
||||
}
|
||||
|
||||
@ -427,136 +438,98 @@ public class Volume {
|
||||
}
|
||||
|
||||
public void setToMaterial(Material material) {
|
||||
try {
|
||||
if (this.hasTwoCorners()) {
|
||||
int x = this.getMinX();
|
||||
for (int i = 0; i < this.getSizeX(); i++) {
|
||||
int y = this.getMaxY();
|
||||
for (int j = this.getSizeY(); j > 0; j--) {
|
||||
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++;
|
||||
Validate.notNull(material);
|
||||
Validate.isTrue(this.hasTwoCorners(), "Incomplete volume");
|
||||
for (int x = this.getMinX(); x <= this.getMaxX(); x++) {
|
||||
for (int y = this.getMinY(); y <= this.getMaxY(); y++) {
|
||||
for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
|
||||
this.getWorld().getBlockAt(x, y, z).setType(material);
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
try {
|
||||
if (this.hasTwoCorners() && this.isSaved()) {
|
||||
int x = this.getMinX();
|
||||
for (int i = 0; i < this.getSizeX(); i++) {
|
||||
int y = this.getMinY();
|
||||
for (int j = 0; j < this.getSizeY(); j++) {
|
||||
int z = this.getMinZ();
|
||||
for (int k = 0; k < this.getSizeZ(); k++) {
|
||||
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())) {
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
currentBlock.setType(material);
|
||||
currentBlock.setData(data);
|
||||
}
|
||||
z++;
|
||||
}
|
||||
y++;
|
||||
public void setFaceMaterial(BlockFace face, ItemStack faceBlock) {
|
||||
Validate.isTrue(this.hasTwoCorners(), "Incomplete volume");
|
||||
for (int x = this.getMinX(); x <= this.getMaxX(); x++) {
|
||||
for (int y = this.getMinY(); y <= this.getMaxY(); y++) {
|
||||
for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
|
||||
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())) {
|
||||
BlockState currentBlock = this.getWorld().getBlockAt(x, y, z).getState();
|
||||
currentBlock.setType(faceBlock.getType());
|
||||
currentBlock.setData(faceBlock.getData());
|
||||
currentBlock.update(true);
|
||||
}
|
||||
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) {
|
||||
try {
|
||||
if (this.hasTwoCorners() && this.isSaved()) {
|
||||
int x = this.getMinX();
|
||||
for (int i = 0; i < this.getSizeX(); i++) {
|
||||
int z = this.getMinZ();
|
||||
for (int k = 0; k < this.getSizeZ(); k++) {
|
||||
if (x == this.getMinX() || x == this.getMaxX() || z == this.getMinZ() || z == this.getMaxZ()) {
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, this.getMinY(), z);
|
||||
currentBlock.setType(outline);
|
||||
currentBlock.setData(outlineData);
|
||||
}
|
||||
z++;
|
||||
}
|
||||
x++;
|
||||
public void setFloorOutline(ItemStack outlineBlock) {
|
||||
Validate.isTrue(this.hasTwoCorners(), "Incomplete volume");
|
||||
for (int x = this.getMinX(); x <= this.getMaxX(); x++) {
|
||||
for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
|
||||
if (x == this.getMinX() || x == this.getMaxX() || z == this.getMinZ() || z == this.getMaxZ()) {
|
||||
BlockState currentBlock = this.getWorld().getBlockAt(x, this.getMinY(), z).getState();
|
||||
currentBlock.setType(outlineBlock.getType());
|
||||
currentBlock.setData(outlineBlock.getData());
|
||||
currentBlock.update(true);
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
try {
|
||||
int i = 0, j = 0, k = 0;
|
||||
int x, y, z;
|
||||
Block currentBlock = null;
|
||||
if (this.hasTwoCorners() && this.isSaved()) {
|
||||
x = this.getMinX();
|
||||
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--;
|
||||
public void replaceMaterial(Material original, Material replacement) {
|
||||
Validate.isTrue(this.hasTwoCorners(), "Incomplete volume");
|
||||
for (int x = this.getMinX(); x <= this.getMaxX(); x++) {
|
||||
for (int y = this.getMinY(); y <= this.getMaxY(); y++) {
|
||||
for (int z = this.getMinZ(); z <= this.getMaxZ(); z++) {
|
||||
if (this.getWorld().getBlockAt(x, y, z).getType() == original) {
|
||||
this.getWorld().getBlockAt(x, y, z).setType(replacement);
|
||||
}
|
||||
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() {
|
||||
Material[] toAirMaterials = new Material[22];
|
||||
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);
|
||||
this.replaceMaterials(nonFloatingBlocks, Material.AIR);
|
||||
}
|
||||
|
||||
public void setSignLines(HashMap<String, String[]> signLines) {
|
||||
|
Loading…
Reference in New Issue
Block a user