use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemSpawnerMaxNearbyEntities method getObjectAttribute.
@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
// -->
if (attribute.startsWith("spawner_max_nearby_entities")) {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
return new ElementTag(state.getMaxNearbyEntities()).getObjectAttribute(attribute.fulfill(1));
}
return null;
}
use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemBaseColor method setBaseColor.
private void setBaseColor(DyeColor color, TagContext context) {
if (color == null && item.getBukkitMaterial() == Material.SHIELD) {
ItemRawNBT property = ItemRawNBT.getFrom(item);
MapTag nbt = property.getFullNBTMap();
nbt.putObject("BlockEntityTag", null);
property.setFullNBT(item, nbt, context, false);
return;
}
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta instanceof BlockStateMeta) {
Banner banner = (Banner) ((BlockStateMeta) itemMeta).getBlockState();
banner.setBaseColor(color);
banner.update();
((BlockStateMeta) itemMeta).setBlockState(banner);
} else {
((BannerMeta) itemMeta).setBaseColor(color);
}
item.setItemMeta(itemMeta);
}
use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemPatterns method setPatterns.
private void setPatterns(List<Pattern> patterns) {
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta instanceof BannerMeta) {
((BannerMeta) itemMeta).setPatterns(patterns);
} else if (itemMeta instanceof BlockStateMeta) {
try {
Banner banner = (Banner) ((BlockStateMeta) itemMeta).getBlockState();
banner.setPatterns(patterns);
banner.update();
((BlockStateMeta) itemMeta).setBlockState(banner);
} catch (Exception ex) {
Debug.echoError("Banner setPatterns failed!");
Debug.echoError(ex);
}
} else {
// ...???
}
item.setItemMeta(itemMeta);
}
use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemSpawnerRange method getObjectAttribute.
@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
// -->
if (attribute.startsWith("spawner_range")) {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
return new ElementTag(state.getSpawnRange()).getObjectAttribute(attribute.fulfill(1));
}
return null;
}
use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemSpawnerDelay method getObjectAttribute.
@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
// -->
if (attribute.startsWith("spawner_spawn_delay")) {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
return new ElementTag(state.getDelay()).getObjectAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("spawner_minimum_spawn_delay")) {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
return new ElementTag(state.getMinSpawnDelay()).getObjectAttribute(attribute.fulfill(1));
}
// -->
if (attribute.startsWith("spawner_maximum_spawn_delay")) {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
return new ElementTag(state.getMaxSpawnDelay()).getObjectAttribute(attribute.fulfill(1));
}
return null;
}
Aggregations