Zone lobby well under way. Updated to new bukkit with capitalized materials. Craftbukkit is still broken so all of this is untested.

This commit is contained in:
taoneill 2011-01-13 22:50:29 -05:00
parent e5497786f3
commit 6c39559c04
12 changed files with 414 additions and 90 deletions

View File

@ -43,8 +43,8 @@ public class War extends JavaPlugin {
private final HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
private int defaultLifepool = 7;
private boolean defaultFriendlyFire = false;
private boolean defaultDrawZoneOutline = true;
private boolean defaultDrawZoneOutline = true;
private boolean defaultAutoAssignOnly = false;
public void onDisable() {
Logger.getLogger("Minecraft").info(name + " " + version + " disabled.");
@ -71,15 +71,16 @@ public class War extends JavaPlugin {
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this); // BROKEN
// Load files from disk or create them (using these defaults)
this.defaultLoadout.put(0, new ItemStack(Material.StoneSword));
this.defaultLoadout.put(1, new ItemStack(Material.Bow));
this.defaultLoadout.put(2, new ItemStack(Material.Arrow, 7));
this.defaultLoadout.put(3, new ItemStack(Material.StonePickaxe));
this.defaultLoadout.put(4, new ItemStack(Material.StoneSpade));
this.defaultLoadout.put(5, new ItemStack(Material.StoneAxe));
this.defaultLoadout.put(6, new ItemStack(Material.Bread, 2));
this.defaultLoadout.put(0, new ItemStack(Material.STONE_SWORD));
this.defaultLoadout.put(1, new ItemStack(Material.BOW));
this.defaultLoadout.put(2, new ItemStack(Material.ARROW, 7));
this.defaultLoadout.put(3, new ItemStack(Material.STONE_PICKAXE));
this.defaultLoadout.put(4, new ItemStack(Material.STONE_SPADE));
this.defaultLoadout.put(5, new ItemStack(Material.STONE_AXE));
this.defaultLoadout.put(6, new ItemStack(Material.BREAD, 2));
this.defaultLifepool = 7;
this.defaultFriendlyFire = false;
this.defaultAutoAssignOnly = false;
WarMapper.load(this);
getLogger().info(name + " " + version + " enabled.");
@ -138,7 +139,7 @@ public class War extends JavaPlugin {
}
public String str(String str) {
String out = Color.GRAY + "[war] " + Color.WHITE + str;
String out = ChatColor.GRAY + "[war] " + ChatColor.WHITE + str;
return out;
}
@ -197,5 +198,14 @@ public class War extends JavaPlugin {
return defaultDrawZoneOutline ;
}
public boolean getDefaultAutoAssignOnly() {
return defaultAutoAssignOnly;
}
public void setDefaultAutoAssignOnly(boolean autoAssign) {
this.defaultAutoAssignOnly = autoAssign;
}
}

View File

@ -41,54 +41,54 @@ public class Monument {
int z = location.getBlockZ();
// center
warzone.getWorld().getBlockAt(x, y-1, z).getState().setType(Material.Air);
warzone.getWorld().getBlockAt(x, y-2, z).setType(Material.LightStone);
warzone.getWorld().getBlockAt(x, y-1, z).getState().setType(Material.AIR);
warzone.getWorld().getBlockAt(x, y-2, z).setType(Material.GLOWSTONE);
// inner ring
warzone.getWorld().getBlockAt(x+1, y-1, z+1).setType(Material.LightStone);
warzone.getWorld().getBlockAt(x+1, y-1, z).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.LightStone);
warzone.getWorld().getBlockAt(x+1, y-1, z+1).setType(Material.GLOWSTONE);
warzone.getWorld().getBlockAt(x+1, y-1, z).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.GLOWSTONE);
warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x, y-1, z-1).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x, y-1, z-1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.LightStone);
warzone.getWorld().getBlockAt(x-1, y-1, z).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.LightStone);
warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.GLOWSTONE);
warzone.getWorld().getBlockAt(x-1, y-1, z).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.GLOWSTONE);
// outer ring
warzone.getWorld().getBlockAt(x+2, y-1, z+2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+2, y-1, z+1).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+2, y-1, z).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+2, y-1, z-1).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+2, y-1, z-2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+2, y-1, z+2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+2, y-1, z+1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+2, y-1, z).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+2, y-1, z-1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+2, y-1, z-2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-1, y-1, z+2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-1, y-1, z-2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-1, y-1, z+2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-1, y-1, z-2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x, y-1, z+2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x, y-1, z-2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x, y-1, z+2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x, y-1, z-2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+1, y-1, z+2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+1, y-1, z-2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+1, y-1, z+2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+1, y-1, z-2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-2, y-1, z+2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-2, y-1, z+1).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-2, y-1, z).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-2, y-1, z-1).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-2, y-1, z-2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-2, y-1, z+2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-2, y-1, z+1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-2, y-1, z).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-2, y-1, z-1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-2, y-1, z-2).setType(Material.OBSIDIAN);
// towers
warzone.getWorld().getBlockAt(x-2, y, z-1).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-2, y, z-2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-1, y, z-2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-2, y+1, z-2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x-2, y, z-1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-2, y, z-2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-1, y, z-2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x-2, y+1, z-2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+2, y, z+1).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+2, y, z+2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+1, y, z+2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+2, y+1, z+2).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(x+2, y, z+1).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+2, y, z+2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+1, y, z+2).setType(Material.OBSIDIAN);
warzone.getWorld().getBlockAt(x+2, y+1, z+2).setType(Material.OBSIDIAN);
}
public boolean isNear(Location playerLocation) {
@ -125,7 +125,7 @@ public class Monument {
public void uncapture() {
ownerTeam = null;
warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(Material.Obsidian);
warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).setType(Material.OBSIDIAN);
}

View File

@ -62,7 +62,7 @@ public class Team {
warzone.getWorld().getBlockAt(x+1, y-1, z).setType(material);
warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(material);
warzone.getWorld().getBlockAt(x, y-1, z+1).setType(material);
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.LightStone);
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
warzone.getWorld().getBlockAt(x, y-1, z-1).setType(material);
warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(material);
warzone.getWorld().getBlockAt(x-1, y-1, z).setType(material);
@ -203,7 +203,7 @@ public class Team {
int z = teamSpawn.getBlockZ();
Block block = warzone.getWorld().getBlockAt(x, y, z);
block.setType(Material.SignPost);
block.setType(Material.SIGN_POST);
BlockState state = block.getState();
Sign sign = (Sign) state;

View File

@ -8,9 +8,9 @@ import org.bukkit.Material;
*
*/
public class TeamMaterials {
public static final Material TEAMDIAMOND = Material.DiamondBlock;
public static final Material TEAMIRON = Material.IronBlock;
public static final Material TEAMGOLD = Material.GoldBlock;
public static final Material TEAMDIAMOND = Material.DIAMOND_BLOCK;
public static final Material TEAMIRON = Material.IRON_BLOCK;
public static final Material TEAMGOLD = Material.GOLD_BLOCK;
public static Material teamMaterialFromString(String str) {
String lowered = str.toLowerCase();

View File

@ -42,6 +42,7 @@ public class Warzone {
private final int minSafeDistanceFromWall = 5;
private List<ZoneWallGuard> zoneWallGuards = new ArrayList<ZoneWallGuard>();
private War war;
private boolean autoAssignOnly;
public Warzone(War war, World world, String name) {
@ -52,6 +53,7 @@ public class Warzone {
this.setLifePool(war.getDefaultLifepool());
this.setLoadout(war.getDefaultLoadout());
this.drawZoneOutline = war.getDefaultDrawZoneOutline();
this.autoAssignOnly = war.getDefaultAutoAssignOnly();
this.volume = new VerticalVolume(name, war, this.getWorld());
}
@ -103,7 +105,7 @@ public class Warzone {
int newHighest = this.world.getHighestBlockYAt(this.northwest.getBlockX(), this.northwest.getBlockZ()) - 1;
Block topNWBlock = this.world.getBlockAt(this.northwest.getBlockX(), newHighest, this.northwest.getBlockZ());
originalNorthWestBlock = topNWBlock.getType(); // save block for reset
topNWBlock.setType(Material.Glass);
topNWBlock.setType(Material.GLASS);
this.volume.setCornerOne(world.getBlockAt(northwest.getBlockX(), northwest.getBlockY(), northwest.getBlockZ()));
}
@ -124,7 +126,7 @@ public class Warzone {
int newHighest = this.world.getHighestBlockYAt(this.southeast.getBlockX(), this.southeast.getBlockZ()) - 1;
Block topSEBlock = this.world.getBlockAt(this.southeast.getBlockX(), newHighest, this.southeast.getBlockZ());
originalSouthEastBlock = topSEBlock.getType(); // save block for reset
topSEBlock.setType(Material.Glass);
topSEBlock.setType(Material.GLASS);
this.volume.setCornerTwo(world.getBlockAt(southeast.getBlockX(), southeast.getBlockY(), southeast.getBlockZ()));
}
@ -229,12 +231,12 @@ public class Warzone {
int highest = world.getHighestBlockYAt(x, z);
Block block = world.getBlockAt(x, highest -1 , z);
if(block.getType() == Material.Leaves) { // top of tree, lets find some dirt
if(block.getType() == Material.LEAVES) { // top of tree, lets find some dirt
Block over = block.getFace(BlockFace.Down);
Block under = over.getFace(BlockFace.Down);
int treeHeight = 0;
while(!((over.getType() == Material.Air || over.getType() == Material.Leaves || over.getType() == Material.Wood)
&& (under.getType() != Material.Air || under.getType() == Material.Leaves || under.getType() == Material.Leaves))
while(!((over.getType() == Material.AIR || over.getType() == Material.LEAVES || over.getType() == Material.WOOD)
&& (under.getType() != Material.AIR || under.getType() == Material.LEAVES || under.getType() == Material.LEAVES))
&& treeHeight < 40) {
over = under;
under = over.getFace(BlockFace.Down);
@ -243,20 +245,20 @@ public class Warzone {
block = under; // found the ground
}
block.setType(Material.Glass);
block.setType(Material.GLASS);
if(lastBlock != null) {
// link the new block and the old vertically if there's a big drop or rise
if(block.getY() - lastBlock.getY() > 1) { // new block too high
Block under = block.getFace(BlockFace.Down);
while(under.getY() != lastBlock.getY() - 1) {
under.setType(Material.Glass);
under.setType(Material.GLASS);
under = under.getFace(BlockFace.Down);
}
} else if (lastBlock.getY() - block.getY() > 1) { // new block too low
Block over = block.getFace(BlockFace.Up);
while(over.getY() != lastBlock.getY() + 1) {
over.setType(Material.Glass);
over.setType(Material.GLASS);
over = over.getFace(BlockFace.Up);
}
}
@ -291,12 +293,12 @@ public class Warzone {
//}
}
if(team.getMaterial() == Material.GoldBlock) {
playerInv.setHelmet(new ItemStack(Material.GoldBoots));
} else if (team.getMaterial() == Material.DiamondBlock) {
playerInv.setHelmet(new ItemStack(Material.DiamondBoots));
} else if (team.getMaterial() == Material.IronBlock) {
playerInv.setHelmet(new ItemStack(Material.IronBoots));
if(team.getMaterial() == Material.GOLD_BLOCK) {
playerInv.setHelmet(new ItemStack(Material.GOLD_BOOTS));
} else if (team.getMaterial() == Material.DIAMOND_BLOCK) {
playerInv.setHelmet(new ItemStack(Material.DIAMOND_BOOTS));
} else if (team.getMaterial() == Material.IRON_BLOCK) {
playerInv.setHelmet(new ItemStack(Material.IRON_BOOTS));
}
player.setHealth(20);
@ -381,7 +383,7 @@ public class Warzone {
List<ItemStack> originalContents = inventories.remove(player.getName());
PlayerInventory playerInv = player.getInventory();
for(int i = 0; i < playerInv.getSize(); i++) {
playerInv.setItem(i, new ItemStack(Material.Air));
playerInv.setItem(i, new ItemStack(Material.AIR));
}
for(int i = 0; i < playerInv.getSize(); i++) {
playerInv.setItem(i, originalContents.get(i));
@ -610,6 +612,11 @@ public class Warzone {
playerGuards.clear();
}
public boolean getAutoAssignOnly() {
return autoAssignOnly;
}
}

View File

@ -1,5 +1,240 @@
package com.tommytony.war;
import org.bukkit.Block;
import org.bukkit.BlockFace;
import org.bukkit.Location;
import org.bukkit.Material;
import com.tommytony.war.mappers.VolumeMapper;
import com.tommytony.war.volumes.VerticalVolume;
import com.tommytony.war.volumes.Volume;
import bukkit.tommytony.war.War;
public class ZoneLobby {
private final War war;
private final Warzone warzone;
private BlockFace wall;
private Volume volume;
Block warHubLinkGate = null;
Block diamondGate = null;
Block ironGate = null;
Block goldGate = null;
Block autoAssignGate = null;
public ZoneLobby(War war, Warzone warzone, BlockFace wall) {
this.war = war;
this.warzone = warzone;
this.setWall(wall);
this.volume = new Volume("lobby", war, warzone.getWorld());
}
public void initialize() {
// first, find center of the wall and position of all elements
VerticalVolume zoneVolume = warzone.getVolume();
Location nw = warzone.getNorthwest();
Block nwBlock = warzone.getWorld().getBlockAt(nw.getBlockX(), nw.getBlockY(), nw.getBlockZ());
Location se = warzone.getSoutheast();
Block seBlock = warzone.getWorld().getBlockAt(se.getBlockX(), se.getBlockY(), se.getBlockZ());
Block lobbyMiddleWallBlock = null;
Block corner1 = null;
Block corner2 = null;
int lobbyHeight = 3;
int lobbyHalfSide = 7;
int lobbyDepth = 10;
if(wall == BlockFace.North) {
int wallStart = zoneVolume.getMinZ();
int wallEnd = zoneVolume.getMaxZ();
int x = zoneVolume.getMinX();
int wallLength = wallEnd - wallStart + 1;
int wallCenterPos = wallLength / 2;
int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos);
lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter+1, wallCenterPos);
corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter+1, wallCenterPos + lobbyHalfSide);
corner2 = warzone.getWorld().getBlockAt(x - lobbyDepth, highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos - lobbyHalfSide);
setGatePositions(lobbyMiddleWallBlock);
} else if (wall == BlockFace.East){
int wallStart = zoneVolume.getMinX();
int wallEnd = zoneVolume.getMaxX();
int z = zoneVolume.getMinZ();
int wallLength = wallEnd - wallStart + 1;
int wallCenterPos = wallLength / 2;
int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z);
lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z);
corner1 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter+1, z);
corner2 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z - lobbyDepth);
setGatePositions(lobbyMiddleWallBlock);
} else if (wall == BlockFace.South){
int wallStart = zoneVolume.getMinZ();
int wallEnd = zoneVolume.getMaxZ();
int x = zoneVolume.getMaxX();
int wallLength = wallEnd - wallStart + 1;
int wallCenterPos = wallLength / 2;
int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(x, wallCenterPos);
lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter + 1, wallCenterPos);
corner1 = warzone.getWorld().getBlockAt(x, highestNonAirBlockAtCenter+1, wallCenterPos - lobbyHalfSide);
corner2 = warzone.getWorld().getBlockAt(x + lobbyDepth, highestNonAirBlockAtCenter + 1 + lobbyHeight, wallCenterPos + lobbyHalfSide);
setGatePositions(lobbyMiddleWallBlock);
} else if (wall == BlockFace.West){
int wallStart = zoneVolume.getMinX();
int wallEnd = zoneVolume.getMaxX();
int z = zoneVolume.getMaxZ();
int wallLength = wallEnd - wallStart + 1;
int wallCenterPos = wallLength / 2;
int highestNonAirBlockAtCenter = warzone.getWorld().getHighestBlockYAt(wallCenterPos, z);
lobbyMiddleWallBlock = warzone.getWorld().getBlockAt(wallCenterPos, highestNonAirBlockAtCenter + 1, z);
corner1 = warzone.getWorld().getBlockAt(wallCenterPos + lobbyHalfSide, highestNonAirBlockAtCenter+1, z);
corner2 = warzone.getWorld().getBlockAt(wallCenterPos - lobbyHalfSide, highestNonAirBlockAtCenter + 1 + lobbyHeight, z + lobbyDepth);
setGatePositions(lobbyMiddleWallBlock);
}
if(lobbyMiddleWallBlock != null && corner1 != null && corner2 != null) {
// save the blocks, wide enough for three team gates, 3 high and 10 deep, extruding out from the zone wall.
this.volume.setCornerOne(corner1);
this.volume.setCornerTwo(corner2);
this.volume.saveBlocks();
VolumeMapper.save(volume, "lobby", war);
// flatten the area (set all but floor to air, then replace any floor air blocks with glass)
this.volume.setToMaterial(Material.AIR);
this.volume.setFaceMaterial(BlockFace.Down, Material.AIR);
// add war hub link gate
// add team gates or single auto assign gate
placeGateOnNorthOrSouthWall(lobbyMiddleWallBlock, TeamMaterials.TEAMDIAMOND);
// set zone tp
}
}
private void setGatePositions(Block lobbyMiddleWallBlock) {
BlockFace leftSide = null; // look at the zone
BlockFace rightSide = null;
if(wall == BlockFace.North) {
leftSide = BlockFace.East;
rightSide = BlockFace.West;
} else if(wall == BlockFace.East) {
leftSide = BlockFace.South;
rightSide = BlockFace.North;
} else if(wall == BlockFace.South) {
leftSide = BlockFace.West;
rightSide = BlockFace.East;
} else if(wall == BlockFace.West) {
leftSide = BlockFace.North;
rightSide = BlockFace.South;
}
if(warzone.getAutoAssignOnly()){
autoAssignGate = lobbyMiddleWallBlock;
} else if(warzone.getTeams().size() == 1) {
if(warzone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND) != null) {
diamondGate = lobbyMiddleWallBlock;
} else if (warzone.getTeamByMaterial(TeamMaterials.TEAMIRON) != null) {
ironGate = lobbyMiddleWallBlock;
} else if (warzone.getTeamByMaterial(TeamMaterials.TEAMGOLD) != null) {
goldGate = lobbyMiddleWallBlock;
}
} else if(warzone.getTeams().size() == 2) {
if(warzone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND) != null
&& warzone.getTeamByMaterial(TeamMaterials.TEAMIRON) != null) {
diamondGate = lobbyMiddleWallBlock.getFace(leftSide, 2);
ironGate = lobbyMiddleWallBlock.getFace(BlockFace.West, 2);
} else if (warzone.getTeamByMaterial(TeamMaterials.TEAMIRON) != null
&& warzone.getTeamByMaterial(TeamMaterials.TEAMGOLD) != null) {
ironGate = lobbyMiddleWallBlock.getFace(leftSide, 2);
goldGate = lobbyMiddleWallBlock.getFace(rightSide, 2);
}
if (warzone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND) != null
&& warzone.getTeamByMaterial(TeamMaterials.TEAMGOLD) != null) {
diamondGate = lobbyMiddleWallBlock.getFace(leftSide, 2);
goldGate = lobbyMiddleWallBlock.getFace(rightSide, 2);
}
} else if(warzone.getTeams().size() == 3) {
diamondGate = lobbyMiddleWallBlock.getFace(leftSide, 4);
ironGate = lobbyMiddleWallBlock;
goldGate = lobbyMiddleWallBlock.getFace(rightSide, 4);
}
warHubLinkGate = lobbyMiddleWallBlock.getFace(wall, 8);
}
private void placeGateOnNorthOrSouthWall(Block block,
Material teamMaterial) {
block.setType(Material.PORTAL);
block.getFace(BlockFace.Up).setType(Material.PORTAL);
block.getFace(BlockFace.East).setType(teamMaterial);
block.getFace(BlockFace.East).getFace(BlockFace.Up).setType(teamMaterial);
block.getFace(BlockFace.East).getFace(BlockFace.Up).getFace(BlockFace.Up).setType(teamMaterial);
block.getFace(BlockFace.West).setType(teamMaterial);
block.getFace(BlockFace.West).getFace(BlockFace.Up).setType(teamMaterial);
block.getFace(BlockFace.West).getFace(BlockFace.Up).getFace(BlockFace.Up).setType(teamMaterial);
block.getFace(BlockFace.Up).getFace(BlockFace.Up).setType(teamMaterial);
}
private void placeGateOnEastOrWestWall(Block block,
Material teamMaterial) {
block.setType(Material.PORTAL);
block.getFace(BlockFace.Up).setType(Material.PORTAL);
block.getFace(BlockFace.North).setType(teamMaterial);
block.getFace(BlockFace.North).getFace(BlockFace.Up).setType(teamMaterial);
block.getFace(BlockFace.North).getFace(BlockFace.Up).getFace(BlockFace.Up).setType(teamMaterial);
block.getFace(BlockFace.South).setType(teamMaterial);
block.getFace(BlockFace.South).getFace(BlockFace.Up).setType(teamMaterial);
block.getFace(BlockFace.South).getFace(BlockFace.Up).getFace(BlockFace.Up).setType(teamMaterial);
block.getFace(BlockFace.Up).getFace(BlockFace.Up).setType(teamMaterial);
}
public boolean isInTeamGate(Material team, Location location) {
if(team == TeamMaterials.TEAMDIAMOND && diamondGate != null
&& location.getBlockX() == diamondGate.getX()
&& location.getBlockY() == diamondGate.getY()
&& location.getBlockZ() == diamondGate.getZ()) {
return true;
} else if(team == TeamMaterials.TEAMIRON && ironGate != null
&& location.getBlockX() == ironGate.getX()
&& location.getBlockY() == ironGate.getY()
&& location.getBlockZ() == ironGate.getZ()) {
return true;
} else if(team == TeamMaterials.TEAMGOLD && goldGate != null
&& location.getBlockX() == goldGate.getX()
&& location.getBlockY() == goldGate.getY()
&& location.getBlockZ() == goldGate.getZ()) {
return true;
}
return false;
}
public boolean isAutoAssignGate(Location location) {
if(autoAssignGate != null
&& location.getBlockX() == autoAssignGate.getX()
&& location.getBlockY() == autoAssignGate.getY()
&& location.getBlockZ() == autoAssignGate.getZ()) {
return true;
}
return false;
}
public void resetSigns() {
// TODO later
}
public Volume getVolume() {
return this.volume;
}
public void setVolume(Volume volume) {
this.volume = volume;
}
public BlockFace getWall() {
return wall;
}
public void setWall(BlockFace wall) {
this.wall = wall;
}
}

View File

@ -49,9 +49,9 @@ public class ZoneWallGuard {
// add wall guard blocks
for(Block block : nearestWallBlocks) {
block.setType(Material.Glass);
block.getFace(BlockFace.Up).setType(Material.Glass);
block.getFace(BlockFace.Down).setType(Material.Glass);
block.setType(Material.GLASS);
block.getFace(BlockFace.Up).setType(Material.GLASS);
block.getFace(BlockFace.Down).setType(Material.GLASS);
if(this.wall == BlockFace.North && warzone.getVolume().isNorthWallBlock(block)) {
toGlass(block.getFace(BlockFace.East), BlockFace.North);
toGlass(block.getFace(BlockFace.East).getFace(BlockFace.Up), BlockFace.North);
@ -133,19 +133,19 @@ public class ZoneWallGuard {
// face here means which wall we are working on
if(wall == BlockFace.North) {
if(warzone.getVolume().isNorthWallBlock(block)) {
block.setType(Material.Glass);
block.setType(Material.GLASS);
}
} else if (wall == BlockFace.South) {
if(warzone.getVolume().isSouthWallBlock(block)) {
block.setType(Material.Glass);
block.setType(Material.GLASS);
}
} else if (wall == BlockFace.East) {
if(warzone.getVolume().isEastWallBlock(block)) {
block.setType(Material.Glass);
block.setType(Material.GLASS);
}
} else if (wall == BlockFace.West) {
if(warzone.getVolume().isWestWallBlock(block)) {
block.setType(Material.Glass);
block.setType(Material.GLASS);
}
}
}

View File

@ -49,6 +49,7 @@ public class VolumeMapper {
int x1 = Integer.parseInt(in.readLine());
int y1 = Integer.parseInt(in.readLine());
int z1 = Integer.parseInt(in.readLine());
in.readLine();
int x2 = Integer.parseInt(in.readLine());
int y2 = Integer.parseInt(in.readLine());
int z2 = Integer.parseInt(in.readLine());
@ -71,7 +72,7 @@ public class VolumeMapper {
int typeID = Integer.parseInt(blockSplit[0]);
byte data = Byte.parseByte(blockSplit[1]);
String[] lines = null;
if(typeID == Material.Sign.getID() || typeID == Material.SignPost.getID()) {
if(typeID == Material.SIGN.getID() || typeID == Material.SIGN_POST.getID()) {
String signLines = blockSplit[2];
if(blockSplit.length > 3) {
// sign includes commas
@ -112,14 +113,25 @@ public class VolumeMapper {
BufferedWriter out = null;
try {
out = new BufferedWriter(new FileWriter(new File("War/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
out.write("corner1"); out.newLine();
out.write(volume.getCornerOne().getX()); out.newLine();
out.write(volume.getCornerOne().getY()); out.newLine();
out.write(volume.getCornerOne().getZ()); out.newLine();
out.write("corner2"); out.newLine();
out.write(volume.getCornerTwo().getX()); out.newLine();
out.write(volume.getCornerTwo().getY()); out.newLine();
out.write(volume.getCornerTwo().getZ()); out.newLine();
if(volume instanceof CenteredVolume) {
out.write("center"); out.newLine();
out.write(volume.getCornerOne().getX()); out.newLine();
out.write(volume.getCornerOne().getY()); out.newLine();
out.write(volume.getCornerOne().getZ()); out.newLine();
out.write("nothing"); out.newLine();
out.write(0); out.newLine();
out.write(0); out.newLine();
out.write(0); out.newLine();
} else {
out.write("corner1"); out.newLine();
out.write(volume.getCornerOne().getX()); out.newLine();
out.write(volume.getCornerOne().getY()); out.newLine();
out.write(volume.getCornerOne().getZ()); out.newLine();
out.write("corner2"); out.newLine();
out.write(volume.getCornerTwo().getX()); out.newLine();
out.write(volume.getCornerTwo().getY()); out.newLine();
out.write(volume.getCornerTwo().getZ()); out.newLine();
}
for(int i = 0; i < volume.getSizeX(); i++){
for(int j = 0; j < volume.getSizeY(); j++) {
@ -128,7 +140,7 @@ public class VolumeMapper {
if(info == null) {
out.write("0,0,"); out.newLine();
} else {
if(info.getType() == Material.Sign || info.getType() == Material.SignPost) {
if(info.getType() == Material.SIGN || info.getType() == Material.SIGN_POST) {
String[] lines = info.getSignLines();
out.write(info.getTypeID() + "," + info.getData() + "," + lines[0] + "[line]" + lines[1]
+ "[line]" + lines[2] + "[line]"+ lines[3]);

View File

@ -86,6 +86,9 @@ public class WarMapper {
// defaultDrawZoneOutline
war.setDefaultFriendlyFire(warConfig.getBoolean("defaultDrawZoneOutline"));
// defaultAutoAssignOnly
war.setDefaultAutoAssignOnly(warConfig.getBoolean("defaultAutoAssignOnly"));
warConfig.close();
war.getLogger().info("Loaded war config.");
}
@ -126,6 +129,9 @@ public class WarMapper {
// defaultFriendlyFire
warConfig.setBoolean("defaultDrawZoneOutline", war.getDefaultDrawZoneOutline());
// defaultAutoAssignOnly
warConfig.setBoolean("defaultAutoAssignOnly", war.getDefaultAutoAssignOnly());
warConfig.save();
warConfig.close();
//war.getLogger().info("Saved war config.");

View File

@ -27,7 +27,7 @@ public class BlockInfo {
this.z = blockState.getX();
this.type = blockState.getTypeID();
this.data = blockState.getData();
if(is(Material.Sign) || is(Material.SignPost)) {
if(is(Material.SIGN) || is(Material.SIGN_POST)) {
Sign sign = (Sign)blockState;
this.signLines = sign.getLines();
}
@ -68,7 +68,7 @@ public class BlockInfo {
}
public String[] getSignLines() {
if(is(Material.Sign) || is(Material.SignPost)){
if(is(Material.SIGN) || is(Material.SIGN_POST)){
return signLines;
}
return null;

View File

@ -158,12 +158,12 @@ public class VerticalVolume extends Volume{
if(currentBlock.getTypeID() != oldBlockInfo.getTypeID() ||
(currentBlock.getTypeID() == oldBlockInfo.getTypeID() && currentBlock.getData() != oldBlockInfo.getData()) ||
(currentBlock.getTypeID() == oldBlockInfo.getTypeID() && currentBlock.getData() == oldBlockInfo.getData() &&
(oldBlockInfo.is(Material.Sign) || oldBlockInfo.is(Material.SignPost))
(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST))
)
) {
currentBlock.setType(oldBlockInfo.getType());
currentBlock.setData(oldBlockInfo.getData());
if(oldBlockInfo.is(Material.Sign) || oldBlockInfo.is(Material.SignPost)) {
if(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST)) {
BlockState state = currentBlock.getState();
Sign currentSign = (Sign) state;
currentSign.setLine(0, oldBlockInfo.getSignLines()[0]);

View File

@ -14,6 +14,7 @@ import java.util.Scanner;
import javax.naming.BinaryRefAddr;
import org.bukkit.Block;
import org.bukkit.BlockFace;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@ -77,7 +78,7 @@ public class Volume {
}
}
} catch (Exception e) {
this.getWar().getLogger().warning(getWar().str("Failed to save volume " + getName() + " blocks. " + e.getMessage()));
this.getWar().getLogger().warning("Failed to save volume " + getName() + " blocks. " + e.getMessage());
}
return noOfSavedBlocks;
}
@ -97,12 +98,12 @@ public class Volume {
if(currentBlock.getTypeID() != oldBlockInfo.getTypeID() ||
(currentBlock.getTypeID() == oldBlockInfo.getTypeID() && currentBlock.getData() != oldBlockInfo.getData()) ||
(currentBlock.getTypeID() == oldBlockInfo.getTypeID() && currentBlock.getData() == oldBlockInfo.getData() &&
(oldBlockInfo.is(Material.Sign) || oldBlockInfo.is(Material.SignPost))
(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST))
)
) {
currentBlock.setType(oldBlockInfo.getType());
currentBlock.setData(oldBlockInfo.getData());
if(oldBlockInfo.is(Material.Sign) || oldBlockInfo.is(Material.SignPost)) {
if(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST)) {
BlockState state = currentBlock.getState();
Sign currentSign = (Sign) state;
currentSign.setLine(0, oldBlockInfo.getSignLines()[0]);
@ -121,7 +122,7 @@ public class Volume {
}
}
} catch (Exception e) {
this.getWar().getLogger().warning(getWar().str("Failed to reset volume " + getName() + " blocks. " + e.getClass().toString() + " " + e.getMessage()));
this.getWar().getLogger().warning("Failed to reset volume " + getName() + " blocks. " + e.getClass().toString() + " " + e.getMessage());
}
return noOfResetBlocks;
}
@ -318,4 +319,57 @@ public class Volume {
return name;
}
public void setToMaterial(Material material) {
try {
if(hasTwoCorners() && getBlockInfos() != null) {
int x = getMinX();
for(int i = 0; i < getSizeX(); i++){
int y = getMinY();
for(int j = 0; j < getSizeY(); j++){
int z = getMinZ();
for(int k = 0;k < getSizeZ(); k++) {
Block currentBlock = getWorld().getBlockAt(x, y, z);
currentBlock.setType(material);
z++;
}
y++;
}
x++;
}
}
} catch (Exception e) {
this.getWar().getLogger().warning("Failed to set block to " + material + "in volume " + name + "." + e.getClass().toString() + " " + e.getMessage());
}
}
public void setFaceMaterial(BlockFace face, Material material) {
try {
if(hasTwoCorners() && getBlockInfos() != null) {
int x = getMinX();
for(int i = 0; i < getSizeX(); i++){
int y = getMinY();
for(int j = 0; j < getSizeY(); j++){
int z = getMinZ();
for(int k = 0;k < getSizeZ(); k++) {
if((face == BlockFace.Down && y == getMinY())
|| (face == BlockFace.Up && y == getMaxY())
|| (face == BlockFace.North && x == getMinX())
|| (face == BlockFace.East && z == getMinZ())
|| (face == BlockFace.South && x == getMaxX())
|| (face == BlockFace.West && z == getMaxZ())) {
Block currentBlock = getWorld().getBlockAt(x, y, z);
currentBlock.setType(material);
}
z++;
}
y++;
}
x++;
}
}
} catch (Exception e) {
this.getWar().getLogger().warning("Failed to set block to " + material + "in volume " + name + "." + e.getClass().toString() + " " + e.getMessage());
}
}
}