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; return true;
} }
blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[1]), (byte) 0) }; 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) { } catch (final Exception e2) {
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK);
return false; return false;

View File

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

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"); 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()) { if (!file.exists()) {
PlotSquared.log(file.toString() + " doesn't exist"); PlotSquared.log(file.toString() + " doesn't exist");
return null; return null;

View File

@ -293,4 +293,15 @@ public class BukkitUtil extends BlockManager {
return false; 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;
}
}
} }