This commit is contained in:
boy0001 2015-04-14 23:55:00 +10:00
parent ba64bf37de
commit 8f09a19a06
4 changed files with 30 additions and 0 deletions

View File

@ -240,6 +240,12 @@ public class Set extends SubCommand {
return true;
}
blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[1]), (byte) 0) };
for (PlotBlock block : blocks) {
if (!BlockManager.manager.isBlockSolid(block)) {
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK);
return false;
}
}
} catch (final Exception e2) {
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK);
return false;

View File

@ -6,6 +6,8 @@ import com.intellectualcrafters.plot.object.schematic.PlotItem;
public abstract class BlockManager {
public static BlockManager manager;
public abstract boolean isBlockSolid(PlotBlock block);
public abstract String[] getBiomeList();

View File

@ -183,6 +183,17 @@ public abstract class SchematicHandler {
}
}
final File file = new File(PlotSquared.IMP.getDirectory() + File.separator + "schematics" + File.separator + name + ".schematic");
return getSchematic(file);
}
/**
* Get a schematic
*
* @param name to check
*
* @return schematic if found, else null
*/
public Schematic getSchematic(File file) {
if (!file.exists()) {
PlotSquared.log(file.toString() + " doesn't exist");
return null;

View File

@ -293,4 +293,15 @@ public class BukkitUtil extends BlockManager {
return false;
}
@Override
public boolean isBlockSolid(PlotBlock block) {
try {
Material material = Material.getMaterial(block.id);
return material.isBlock() && material.isSolid() && material.isOccluding() && !material.hasGravity();
}
catch (Exception e) {
return false;
}
}
}