use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemSpawnerDelay method getPropertyString.
@Override
public String getPropertyString() {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
return state.getDelay() + "," + state.getMinSpawnDelay() + "," + state.getMaxSpawnDelay();
}
use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemSpawnerDelay method adjust.
@Override
public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("spawner_delay_data")) {
ListTag list = mechanism.valueAsType(ListTag.class);
if (list.size() < 3) {
return;
}
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
state.setDelay(Integer.parseInt(list.get(0)));
int minDelay = Integer.parseInt(list.get(1));
int maxDelay = Integer.parseInt(list.get(2));
// or new min would be higher than the current max
if (minDelay > state.getMaxSpawnDelay()) {
state.setMaxSpawnDelay(maxDelay);
state.setMinSpawnDelay(minDelay);
} else {
state.setMinSpawnDelay(minDelay);
state.setMaxSpawnDelay(maxDelay);
}
meta.setBlockState(state);
item.setItemMeta(meta);
}
}
use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemSpawnerPlayerRange method getObjectAttribute.
@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
// -->
if (attribute.startsWith("spawner_player_range")) {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
return new ElementTag(state.getRequiredPlayerRange()).getObjectAttribute(attribute.fulfill(1));
}
return null;
}
use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemSpawnerType method getObjectAttribute.
@Override
public ObjectTag getObjectAttribute(Attribute attribute) {
if (attribute == null) {
return null;
}
// -->
if (attribute.startsWith("spawner_type")) {
BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
CreatureSpawner state = (CreatureSpawner) meta.getBlockState();
return new EntityTag(state.getSpawnedType()).getObjectAttribute(attribute.fulfill(1));
}
return null;
}
use of org.bukkit.inventory.meta.BlockStateMeta in project Denizen-For-Bukkit by DenizenScript.
the class ItemInventory method getItemInventory.
private InventoryTag getItemInventory() {
InventoryHolder holder = ((InventoryHolder) ((BlockStateMeta) item.getItemMeta()).getBlockState());
Inventory inv = getInventoryFor(holder);
return InventoryTag.mirrorBukkitInventory(inv);
}
Aggregations