Made config allow material names
This commit is contained in:
1
Metropolis/.gitignore
vendored
1
Metropolis/.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
/Plugin.jardesc
|
/Plugin.jardesc
|
||||||
/Plugin-Release.jardesc
|
/Plugin-Release.jardesc
|
||||||
/lib
|
/lib
|
||||||
|
/target
|
||||||
|
|||||||
@@ -21,19 +21,20 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
|
||||||
<id>sk89q-mvn2</id>
|
|
||||||
<url>http://mvn2.sk89q.com/repo</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>bukkit-repo</id>
|
<id>bukkit-repo</id>
|
||||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- Bukkit -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<version>1.2.3-R0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- WorldEdit -->
|
<!-- WorldEdit -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
@@ -41,13 +42,6 @@
|
|||||||
<version>5.3-SNAPSHOT</version>
|
<version>5.3-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Bukkit -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>bukkit</artifactId>
|
|
||||||
<version>1.1-R4-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- WorldGuard -->
|
<!-- WorldGuard -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
|
|||||||
@@ -60,21 +60,21 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
private int roadWidth = 4;
|
private int roadWidth = 4;
|
||||||
private int roadLevel = 62;
|
private int roadLevel = 62;
|
||||||
private int spaceAboveRoad = 2;
|
private int spaceAboveRoad = 2;
|
||||||
private int roadMaterial = 4;
|
private Material roadMaterial = Material.COBBLESTONE;
|
||||||
private boolean generateRoadSupports = true;
|
private boolean generateRoadSupports = true;
|
||||||
private int roadSupportMaterial = 2;
|
private Material roadSupportMaterial = Material.STONE;
|
||||||
private String worldName = "world";
|
private String worldName = "world";
|
||||||
private boolean generateFloor = false;
|
private boolean generateFloor = false;
|
||||||
private int floorMaterial = 2;
|
private Material floorMaterial = Material.GRASS;
|
||||||
private int spaceAboveFloor = 2;
|
private int spaceAboveFloor = 2;
|
||||||
private boolean generateSign = false;
|
private boolean generateSign = false;
|
||||||
private boolean generateSpawn = true;
|
private boolean generateSpawn = true;
|
||||||
private boolean setWorldSpawn = true;
|
private boolean setWorldSpawn = true;
|
||||||
private int spawnFloorMaterial = 4;
|
private Material spawnFloorMaterial = Material.COBBLESTONE;
|
||||||
private boolean generateFloorSupports = false;
|
private boolean generateFloorSupports = false;
|
||||||
private int floorSupportMaterial = 1;
|
private Material floorSupportMaterial = Material.STONE;
|
||||||
private boolean generateWall = false;
|
private boolean generateWall = false;
|
||||||
private int wallMaterial = 20;
|
private Material wallMaterial = Material.GLASS;
|
||||||
private int wallHeight = 128;
|
private int wallHeight = 128;
|
||||||
|
|
||||||
private Cuboid _spawnCuboid = null;
|
private Cuboid _spawnCuboid = null;
|
||||||
@@ -121,22 +121,22 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
plotSizeX = safeGetIntFromConfig(config, "plot.sizeX");
|
plotSizeX = safeGetIntFromConfig(config, "plot.sizeX");
|
||||||
plotSizeZ = safeGetIntFromConfig(config, "plot.sizeZ");
|
plotSizeZ = safeGetIntFromConfig(config, "plot.sizeZ");
|
||||||
generateFloor = safeGetBooleanFromConfig(config, "plot.floor.generate");
|
generateFloor = safeGetBooleanFromConfig(config, "plot.floor.generate");
|
||||||
floorMaterial = safeGetIntFromConfig(config, "plot.floor.material");
|
floorMaterial = safeGetMaterialFromConfig(config, "plot.floor.material");
|
||||||
spaceAboveFloor = safeGetIntFromConfig(config, "plot.floor.clearSpaceAbove");
|
spaceAboveFloor = safeGetIntFromConfig(config, "plot.floor.clearSpaceAbove");
|
||||||
generateFloorSupports = safeGetBooleanFromConfig(config, "plot.floor.supports.generate");
|
generateFloorSupports = safeGetBooleanFromConfig(config, "plot.floor.supports.generate");
|
||||||
floorSupportMaterial = safeGetIntFromConfig(config, "plot.floor.supports.material");
|
floorSupportMaterial = safeGetMaterialFromConfig(config, "plot.floor.supports.material");
|
||||||
generateSign = safeGetBooleanFromConfig(config, "plot.sign.generate");
|
generateSign = safeGetBooleanFromConfig(config, "plot.sign.generate");
|
||||||
roadWidth = safeGetIntFromConfig(config, "road.width");
|
roadWidth = safeGetIntFromConfig(config, "road.width");
|
||||||
spaceAboveRoad = safeGetIntFromConfig(config, "road.clearSpaceAbove");
|
spaceAboveRoad = safeGetIntFromConfig(config, "road.clearSpaceAbove");
|
||||||
roadLevel = safeGetIntFromConfig(config, "road.level");
|
roadLevel = safeGetIntFromConfig(config, "road.level");
|
||||||
roadMaterial = safeGetIntFromConfig(config, "road.material");
|
roadMaterial = safeGetMaterialFromConfig(config, "road.material");
|
||||||
generateRoadSupports = safeGetBooleanFromConfig(config, "road.supports.generate");
|
generateRoadSupports = safeGetBooleanFromConfig(config, "road.supports.generate");
|
||||||
roadSupportMaterial = safeGetIntFromConfig(config, "road.supports.material");
|
roadSupportMaterial = safeGetMaterialFromConfig(config, "road.supports.material");
|
||||||
generateSpawn = safeGetBooleanFromConfig(config, "spawn.generate");
|
generateSpawn = safeGetBooleanFromConfig(config, "spawn.generate");
|
||||||
setWorldSpawn = safeGetBooleanFromConfig(config, "spawn.setAsWorldSpawn");
|
setWorldSpawn = safeGetBooleanFromConfig(config, "spawn.setAsWorldSpawn");
|
||||||
spawnFloorMaterial = safeGetIntFromConfig(config, "spawn.material");
|
spawnFloorMaterial = safeGetMaterialFromConfig(config, "spawn.material");
|
||||||
generateWall = safeGetBooleanFromConfig(config, "wall.generate");
|
generateWall = safeGetBooleanFromConfig(config, "wall.generate");
|
||||||
wallMaterial = safeGetIntFromConfig(config, "wall.material");
|
wallMaterial = safeGetMaterialFromConfig(config, "wall.material");
|
||||||
wallHeight = safeGetIntFromConfig(config, "wall.material");
|
wallHeight = safeGetIntFromConfig(config, "wall.material");
|
||||||
worldName = safeGetStringFromConfig(config, "worldname");
|
worldName = safeGetStringFromConfig(config, "worldname");
|
||||||
saveConfig();
|
saveConfig();
|
||||||
@@ -250,6 +250,20 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Material safeGetMaterialFromConfig(Configuration config, String name){
|
||||||
|
Material material = null;
|
||||||
|
if(config.isInt(name)){
|
||||||
|
material = Material.getMaterial(config.getInt(name));
|
||||||
|
}else if(config.isString(name)){
|
||||||
|
material = Material.getMaterial(config.getString(name));
|
||||||
|
if(material== null){
|
||||||
|
material = Material.matchMaterial(config.getString(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
private void throwInvalidConfigException() {
|
private void throwInvalidConfigException() {
|
||||||
log.info("Metropolis: ERROR config file is invalid. Please correct Metropolis/config.yml and restart the server.");
|
log.info("Metropolis: ERROR config file is invalid. Please correct Metropolis/config.yml and restart the server.");
|
||||||
@@ -269,12 +283,12 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
for(z=min.getBlockZ(); z<= max.getBlockZ(); z++){
|
for(z=min.getBlockZ(); z<= max.getBlockZ(); z++){
|
||||||
for(y=roadLevel+1; y<world.getMaxHeight(); y++){
|
for(y=roadLevel+1; y<world.getMaxHeight(); y++){
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
block.setTypeId(0);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
y=roadLevel;
|
y=roadLevel;
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
block.setTypeId(spawnFloorMaterial);
|
block.setType(spawnFloorMaterial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,19 +349,19 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
for(z=plotCuboid.minZ + roadWidth/2; z<=plotCuboid.maxZ - roadWidth/2; z++){
|
for(z=plotCuboid.minZ + roadWidth/2; z<=plotCuboid.maxZ - roadWidth/2; z++){
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
//Set the floor block
|
//Set the floor block
|
||||||
block.setTypeId(floorMaterial);
|
block.setType(floorMaterial);
|
||||||
|
|
||||||
//Set the support
|
//Set the support
|
||||||
if(generateFloorSupports && isPhysicsMaterial(block.getType())){
|
if(generateFloorSupports && isPhysicsMaterial(block.getType())){
|
||||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
Block blockUnder = world.getBlockAt(x, y-1, z);
|
||||||
if(!isSolidMaterial(blockUnder.getType())){
|
if(!isSolidMaterial(blockUnder.getType())){
|
||||||
blockUnder.setTypeId(floorSupportMaterial);
|
blockUnder.setType(floorSupportMaterial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i<spaceAboveFloor; i++){
|
for(int i=0; i<spaceAboveFloor; i++){
|
||||||
block = world.getBlockAt(x, y+1+i, z);
|
block = world.getBlockAt(x, y+1+i, z);
|
||||||
block.setTypeId(0);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,19 +384,19 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
for(z=plotCuboid.minZ; z<=plotCuboid.maxZ; z++){
|
for(z=plotCuboid.minZ; z<=plotCuboid.maxZ; z++){
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
//Set the road block
|
//Set the road block
|
||||||
block.setTypeId(roadMaterial);
|
block.setType(roadMaterial);
|
||||||
//Set the support
|
//Set the support
|
||||||
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
||||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
Block blockUnder = world.getBlockAt(x, y-1, z);
|
||||||
if(!isSolidMaterial(blockUnder.getType())){
|
if(!isSolidMaterial(blockUnder.getType())){
|
||||||
blockUnder.setTypeId(roadSupportMaterial);
|
blockUnder.setType(roadSupportMaterial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clear the space above
|
//Clear the space above
|
||||||
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
||||||
block = world.getBlockAt(x, y+y1+1, z);
|
block = world.getBlockAt(x, y+y1+1, z);
|
||||||
block.setTypeId(0);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -391,19 +405,19 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
for(z=plotCuboid.minZ; z<=plotCuboid.maxZ; z++){
|
for(z=plotCuboid.minZ; z<=plotCuboid.maxZ; z++){
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
//Set the road block
|
//Set the road block
|
||||||
block.setTypeId(roadMaterial);
|
block.setType(roadMaterial);
|
||||||
//Set the support
|
//Set the support
|
||||||
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
||||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
Block blockUnder = world.getBlockAt(x, y-1, z);
|
||||||
if(!isSolidMaterial(blockUnder.getType())){
|
if(!isSolidMaterial(blockUnder.getType())){
|
||||||
blockUnder.setTypeId(roadSupportMaterial);
|
blockUnder.setType(roadSupportMaterial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clear the space above
|
//Clear the space above
|
||||||
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
||||||
block = world.getBlockAt(x, y+y1+1, z);
|
block = world.getBlockAt(x, y+y1+1, z);
|
||||||
block.setTypeId(0);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,19 +426,19 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
for(x=plotCuboid.minX; x<=plotCuboid.maxX; x++){
|
for(x=plotCuboid.minX; x<=plotCuboid.maxX; x++){
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
//Set the road block
|
//Set the road block
|
||||||
block.setTypeId(roadMaterial);
|
block.setType(roadMaterial);
|
||||||
//Set the support
|
//Set the support
|
||||||
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
||||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
Block blockUnder = world.getBlockAt(x, y-1, z);
|
||||||
if(!isSolidMaterial(blockUnder.getType())){
|
if(!isSolidMaterial(blockUnder.getType())){
|
||||||
blockUnder.setTypeId(roadSupportMaterial);
|
blockUnder.setType(roadSupportMaterial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clear the space above
|
//Clear the space above
|
||||||
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
||||||
block = world.getBlockAt(x, y+y1+1, z);
|
block = world.getBlockAt(x, y+y1+1, z);
|
||||||
block.setTypeId(0);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,19 +447,19 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
for(x=plotCuboid.minX; x<=plotCuboid.maxX; x++){
|
for(x=plotCuboid.minX; x<=plotCuboid.maxX; x++){
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
//Set the road block
|
//Set the road block
|
||||||
block.setTypeId(roadMaterial);
|
block.setType(roadMaterial);
|
||||||
//Set the support
|
//Set the support
|
||||||
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
if(generateRoadSupports && isPhysicsMaterial(block.getType())){
|
||||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
Block blockUnder = world.getBlockAt(x, y-1, z);
|
||||||
if(!isSolidMaterial(blockUnder.getType())){
|
if(!isSolidMaterial(blockUnder.getType())){
|
||||||
blockUnder.setTypeId(roadSupportMaterial);
|
blockUnder.setType(roadSupportMaterial);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clear the space above
|
//Clear the space above
|
||||||
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
for(int y1 = 0; y1 < spaceAboveRoad; y1++){
|
||||||
block = world.getBlockAt(x, y+y1+1, z);
|
block = world.getBlockAt(x, y+y1+1, z);
|
||||||
block.setTypeId(0);
|
block.setType(Material.AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -453,7 +467,8 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSolidMaterial(Material material) {
|
private boolean isSolidMaterial(Material material) {
|
||||||
return material != Material.AIR &&
|
return material.isBlock() &&
|
||||||
|
material != Material.AIR &&
|
||||||
material != Material.WATER &&
|
material != Material.WATER &&
|
||||||
material != Material.LAVA &&
|
material != Material.LAVA &&
|
||||||
material != Material.TORCH &&
|
material != Material.TORCH &&
|
||||||
@@ -462,7 +477,8 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPhysicsMaterial(Material material) {
|
private boolean isPhysicsMaterial(Material material) {
|
||||||
return material == Material.GRAVEL || material == Material.SAND;
|
return material == Material.GRAVEL ||
|
||||||
|
material == Material.SAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlockOccupied(int row, int col){
|
public boolean isBlockOccupied(int row, int col){
|
||||||
@@ -471,8 +487,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
if(plot.getCuboid().intersects(cuboid)){
|
if(plot.getCuboid().intersects(cuboid)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(cuboid.intersects(_spawnCuboid)){
|
if(cuboid.intersects(_spawnCuboid)){
|
||||||
return true;
|
return true;
|
||||||
@@ -686,4 +701,19 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
_occupiedPlots.add(Plot.get(reservedRegion));
|
_occupiedPlots.add(Plot.get(reservedRegion));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cuboid getCityCuboid(){
|
||||||
|
return _cityCuboid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getGenerateWall(){
|
||||||
|
return generateWall;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getWallMaterial(){
|
||||||
|
return wallMaterial;
|
||||||
|
}
|
||||||
|
public int getWallheight(){
|
||||||
|
return wallHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package com.majinnaibu.bukkitplugins.metropolis;
|
|||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
|
|
||||||
import com.avaje.ebean.validation.NotNull;
|
import com.avaje.ebean.validation.NotNull;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
|
|||||||
Reference in New Issue
Block a user