mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-22 09:08:03 +01:00
WIP - using blockdata - doesn't work completely yet.
This commit is contained in:
parent
acbcd27142
commit
ae3a341b89
@ -259,22 +259,27 @@ public class Clipboard {
|
|||||||
int x = location.getBlockX() + Integer.valueOf(pos[0]);
|
int x = location.getBlockX() + Integer.valueOf(pos[0]);
|
||||||
int y = location.getBlockY() + Integer.valueOf(pos[1]);
|
int y = location.getBlockY() + Integer.valueOf(pos[1]);
|
||||||
int z = location.getBlockZ() + Integer.valueOf(pos[2]);
|
int z = location.getBlockZ() + Integer.valueOf(pos[2]);
|
||||||
|
|
||||||
// Default type is air
|
// Default type is air
|
||||||
Material mat = Material.getMaterial(config.getString("type", "AIR"));
|
Material mat = Material.getMaterial(config.getString("type", "AIR"));
|
||||||
Material material = mat != null ? mat : Material.getMaterial(config.getString("type", "AIR"), true);
|
Material material = mat != null ? mat : Material.getMaterial(config.getString("type", "AIR"), true);
|
||||||
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
Block block = world.getBlockAt(x, y, z);
|
||||||
|
String blockData = config.getString("bd");
|
||||||
|
if (blockData != null) {
|
||||||
if (config.getBoolean(ATTACHED)) {
|
if (config.getBoolean(ATTACHED)) {
|
||||||
plugin.getServer().getScheduler().runTask(plugin, () -> setBlock(island, block, config, material));
|
plugin.getServer().getScheduler().runTask(plugin, () -> setBlock(island, block, config, blockData));
|
||||||
} else {
|
} else {
|
||||||
setBlock(island, block, config, material);
|
|
||||||
|
setBlock(island, block, config, blockData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
private void setBlock(Island island, Block block, ConfigurationSection config, String blockData) {
|
||||||
private void setBlock(Island island, Block block, ConfigurationSection config, Material material) {
|
block.setBlockData(Bukkit.createBlockData(blockData));
|
||||||
// Block state
|
// Block state
|
||||||
|
/*
|
||||||
if (config.getBoolean(ATTACHED) && material.toString().contains("TORCH")) {
|
if (config.getBoolean(ATTACHED) && material.toString().contains("TORCH")) {
|
||||||
TorchDir d = TorchDir.valueOf(config.getString(FACING));
|
TorchDir d = TorchDir.valueOf(config.getString(FACING));
|
||||||
// The block below has to be set to something solid for this to work
|
// The block below has to be set to something solid for this to work
|
||||||
@ -299,9 +304,15 @@ public class Clipboard {
|
|||||||
// Set the block data
|
// Set the block data
|
||||||
byte data = (byte)config.getInt("data");
|
byte data = (byte)config.getInt("data");
|
||||||
// FIXME block.setBlockData(data);
|
// FIXME block.setBlockData(data);
|
||||||
|
*/
|
||||||
// Get the block state
|
// Get the block state
|
||||||
BlockState bs = block.getState();
|
BlockState bs = block.getState();
|
||||||
|
// Signs
|
||||||
|
if (bs instanceof Sign) {
|
||||||
|
List<String> lines = config.getStringList("lines");
|
||||||
|
writeSign(island, block, lines);
|
||||||
|
}
|
||||||
|
/*
|
||||||
// Material Data
|
// Material Data
|
||||||
MaterialData md = bs.getData();
|
MaterialData md = bs.getData();
|
||||||
if (md instanceof Openable) {
|
if (md instanceof Openable) {
|
||||||
@ -363,7 +374,7 @@ public class Clipboard {
|
|||||||
spawner.setRequiredPlayerRange(config.getInt("requiredPlayerRange", 16));
|
spawner.setRequiredPlayerRange(config.getInt("requiredPlayerRange", 16));
|
||||||
spawner.setSpawnRange(config.getInt("spawnRange", 4));
|
spawner.setSpawnRange(config.getInt("spawnRange", 4));
|
||||||
bs.update(true, false);
|
bs.update(true, false);
|
||||||
}
|
}*/
|
||||||
// Chests, in general
|
// Chests, in general
|
||||||
if (bs instanceof InventoryHolder) {
|
if (bs instanceof InventoryHolder) {
|
||||||
bs.update(true, false);
|
bs.update(true, false);
|
||||||
@ -416,7 +427,6 @@ public class Clipboard {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private boolean copyBlock(Block block, Location copyOrigin, boolean copyAir, Collection<LivingEntity> entities) {
|
private boolean copyBlock(Block block, Location copyOrigin, boolean copyAir, Collection<LivingEntity> entities) {
|
||||||
if (!copyAir && block.getType().equals(Material.AIR) && entities.isEmpty()) {
|
if (!copyAir && block.getType().equals(Material.AIR) && entities.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
@ -470,11 +480,14 @@ public class Clipboard {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.set("bd", block.getBlockData().getAsString());
|
||||||
|
|
||||||
// Set the block type
|
// Set the block type
|
||||||
|
/*
|
||||||
s.set("type", block.getType().toString());
|
s.set("type", block.getType().toString());
|
||||||
if (block.getData() != 0) {
|
if (block.getData() != 0) {
|
||||||
s.set("data", block.getData());
|
s.set("data", block.getData());
|
||||||
}
|
}*/
|
||||||
if (block.getType().equals(Material.BEDROCK)) {
|
if (block.getType().equals(Material.BEDROCK)) {
|
||||||
blockConfig.set(BEDROCK, x + "," + y + "," + z);
|
blockConfig.set(BEDROCK, x + "," + y + "," + z);
|
||||||
}
|
}
|
||||||
@ -482,6 +495,22 @@ public class Clipboard {
|
|||||||
// Block state
|
// Block state
|
||||||
BlockState bs = block.getState();
|
BlockState bs = block.getState();
|
||||||
|
|
||||||
|
if (bs instanceof InventoryHolder) {
|
||||||
|
InventoryHolder ih = (InventoryHolder)bs;
|
||||||
|
for (int index = 0; index < ih.getInventory().getSize(); index++) {
|
||||||
|
ItemStack i = ih.getInventory().getItem(index);
|
||||||
|
if (i != null) {
|
||||||
|
s.set("inventory." + index, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bs instanceof Sign) {
|
||||||
|
Sign sign = (Sign)bs;
|
||||||
|
s.set("lines", Arrays.asList(sign.getLines()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// Material Data
|
// Material Data
|
||||||
MaterialData md = bs.getData();
|
MaterialData md = bs.getData();
|
||||||
if (md instanceof Openable) {
|
if (md instanceof Openable) {
|
||||||
@ -542,7 +571,7 @@ public class Clipboard {
|
|||||||
s.set("requiredPlayerRange", spawner.getRequiredPlayerRange());
|
s.set("requiredPlayerRange", spawner.getRequiredPlayerRange());
|
||||||
s.set("spawnRange", spawner.getSpawnRange());
|
s.set("spawnRange", spawner.getSpawnRange());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user