int lz1 = z1;
int lz2 = z1 + 6;
// Save the precious patch
HashMap<EntityPosition,Integer> preciousPatch = new HashMap<EntityPosition,Integer>();
Location lo;
int id;
for (int i = x1; i <= x2; i++)
{
for (int j = ly1; j <= y2; j++)
{
for (int k = z1; k <= z2; k++)
{
lo = world.getBlockAt(i,j,k).getLocation();
id = world.getBlockAt(i,j,k).getTypeId();
preciousPatch.put(new EntityPosition(lo),id);
}
}
}
try
{
new File("plugins" + sep + "MobArena" + sep + "agbackup").mkdir();
FileOutputStream fos = new FileOutputStream("plugins" + sep + "MobArena" + sep + "agbackup" + sep + name + ".tmp");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(preciousPatch);
oos.close();
}
catch (Exception e)
{
e.printStackTrace();
Messenger.warning("Couldn't create backup file. Aborting auto-generate...");
return false;
}
// Build some monster walls.
for (int i = x1; i <= x2; i++)
{
for (int j = y1; j <= y2; j++)
{
world.getBlockAt(i,j,z1).setTypeId(24);
world.getBlockAt(i,j,z2).setTypeId(24);
}
}
for (int k = z1; k <= z2; k++)
{
for (int j = y1; j <= y2; j++)
{
world.getBlockAt(x1,j,k).setTypeId(24);
world.getBlockAt(x2,j,k).setTypeId(24);
}
}
// Add some hippie light.
for (int i = x1; i <= x2; i++)
{
world.getBlockAt(i,y1+2,z1).setTypeId(89);
world.getBlockAt(i,y1+2,z2).setTypeId(89);
}
for (int k = z1; k <= z2; k++)
{
world.getBlockAt(x1,y1+2,k).setTypeId(89);
world.getBlockAt(x2,y1+2,k).setTypeId(89);
}
// Build a monster floor, and some Obsidian foundation.
for (int i = x1; i <= x2; i++)
{
for (int k = z1; k <= z2; k++)
{
world.getBlockAt(i,y1,k).setTypeId(24);
world.getBlockAt(i,y1-1,k).setTypeId(49);
}
}
// Make a hippie roof.
for (int i = x1; i <= x2; i++)
{
for (int k = z1; k <= z2; k++)
world.getBlockAt(i,y2,k).setTypeId(20);
}
// Monster bulldoze
for (int i = x1+1; i < x2; i++)
for (int j = y1+1; j < y2; j++)
for (int k = z1+1; k < z2; k++)
world.getBlockAt(i,j,k).setTypeId(0);
// Build a hippie lobby
for (int i = lx1; i <= lx2; i++) // Walls
{
for (int j = ly1; j <= ly2; j++)
{
world.getBlockAt(i,j,lz1).setTypeId(24);
world.getBlockAt(i,j,lz2).setTypeId(24);
}
}
for (int k = lz1; k <= lz2; k++) // Walls
{
for (int j = ly1; j <= ly2; j++)
{
world.getBlockAt(lx1,j,k).setTypeId(24);
world.getBlockAt(lx2,j,k).setTypeId(24);
}
}
for (int k = lz1; k <= lz2; k++) // Lights
{
world.getBlockAt(lx1,ly1+2,k).setTypeId(89);
world.getBlockAt(lx2,ly1+2,k).setTypeId(89);
world.getBlockAt(lx1,ly1+3,k).setTypeId(89);
world.getBlockAt(lx2,ly1+3,k).setTypeId(89);
}
for (int i = lx1; i <= lx2; i++) // Floor
{
for (int k = lz1; k <= lz2; k++)
world.getBlockAt(i,ly1,k).setTypeId(24);
}
for (int i = x1+1; i < lx2; i++) // Bulldoze
for (int j = ly1+1; j <= ly2; j++)
for (int k = lz1+1; k < lz2; k++)
world.getBlockAt(i,j,k).setTypeId(0);
// Place the hippie signs
//Iterator<String> iterator = am.getClasses().iterator();
Iterator<String> iterator = am.getClasses().keySet().iterator();
for (int i = lx1+2; i <= lx2-2; i++) // Signs
{
world.getBlockAt(i,ly1+1,lz2-1).setTypeIdAndData(63, (byte)0x8, false);
Sign sign = (Sign) world.getBlockAt(i,ly1+1,lz2-1).getState();
sign.setLine(0, TextUtils.camelCase((String)iterator.next()));
sign.update();
}
world.getBlockAt(lx2-2,ly1+1,lz1+2).setType(Material.IRON_BLOCK);
// Set up the monster points.
ArenaRegion region = arena.getRegion();
region.set("p1", new Location(world, x1, ly1, z1));
region.set("p2", new Location(world, x2, y2+1, z2));
region.set("arena", new Location(world, loc.getX(), y1+1, loc.getZ()));
region.set("lobby", new Location(world, x1+2, ly1+1, z1+2));
region.set("spectator", new Location(world, loc.getX(), y2+1, loc.getZ()));
region.addSpawn("s1", new Location(world, x1+3, y1+2, z1+3));
region.addSpawn("s2", new Location(world, x1+3, y1+2, z2-3));
region.addSpawn("s3", new Location(world, x2-3, y1+2, z1+3));
region.addSpawn("s4", new Location(world, x2-3, y1+2, z2-3));
region.save();
am.reloadConfig();
return true;
}