Search in sources :

Example 1 with RosePlugin

use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.

the class PersistentDataUtils method getTotalSpawnCount.

public static long getTotalSpawnCount(StackedSpawnerTile spawner) {
    RosePlugin rosePlugin = RoseStacker.getInstance();
    PersistentDataContainer persistentDataContainer = spawner.getPersistentDataContainer();
    if (persistentDataContainer == null)
        return 0;
    NamespacedKey key = new NamespacedKey(rosePlugin, TOTAL_SPAWNS_METADATA_NAME);
    Long amount = persistentDataContainer.get(key, PersistentDataType.LONG);
    return amount != null ? amount : 0;
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) RosePlugin(dev.rosewood.rosegarden.RosePlugin) PersistentDataContainer(org.bukkit.persistence.PersistentDataContainer)

Example 2 with RosePlugin

use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.

the class PersistentDataUtils method increaseSpawnCount.

public static void increaseSpawnCount(StackedSpawnerTile spawner, long amount) {
    RosePlugin rosePlugin = RoseStacker.getInstance();
    PersistentDataContainer dataContainer = spawner.getPersistentDataContainer();
    if (dataContainer != null) {
        NamespacedKey key = new NamespacedKey(rosePlugin, TOTAL_SPAWNS_METADATA_NAME);
        if (!dataContainer.has(key, PersistentDataType.LONG)) {
            dataContainer.set(key, PersistentDataType.LONG, amount);
        } else {
            dataContainer.set(key, PersistentDataType.LONG, getTotalSpawnCount(spawner) + amount);
        }
    }
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) RosePlugin(dev.rosewood.rosegarden.RosePlugin) PersistentDataContainer(org.bukkit.persistence.PersistentDataContainer)

Example 3 with RosePlugin

use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.

the class PersistentDataUtils method tagSpawnedFromSpawner.

public static void tagSpawnedFromSpawner(LivingEntity entity) {
    RosePlugin rosePlugin = RoseStacker.getInstance();
    entity.getPersistentDataContainer().set(new NamespacedKey(rosePlugin, SPAWNED_FROM_SPAWNER_METADATA_NAME), PersistentDataType.INTEGER, 1);
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) RosePlugin(dev.rosewood.rosegarden.RosePlugin)

Example 4 with RosePlugin

use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.

the class PersistentDataUtils method setEntitySpawnReason.

/**
 * Sets the spawn reason for the given LivingEntity.
 * Does not overwrite an existing spawn reason.
 *
 * @param entity The entity to set the spawn reason of
 * @param spawnReason The spawn reason to set
 */
public static void setEntitySpawnReason(LivingEntity entity, SpawnReason spawnReason) {
    RosePlugin rosePlugin = RoseStacker.getInstance();
    PersistentDataContainer dataContainer = entity.getPersistentDataContainer();
    NamespacedKey key = new NamespacedKey(rosePlugin, SPAWN_REASON_METADATA_NAME);
    if (!dataContainer.has(key, PersistentDataType.STRING))
        dataContainer.set(key, PersistentDataType.STRING, spawnReason.name());
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) RosePlugin(dev.rosewood.rosegarden.RosePlugin) PersistentDataContainer(org.bukkit.persistence.PersistentDataContainer)

Example 5 with RosePlugin

use of dev.rosewood.rosegarden.RosePlugin in project RoseStacker by Rosewood-Development.

the class PersistentDataUtils method removeEntityAi.

public static void removeEntityAi(LivingEntity entity) {
    RosePlugin rosePlugin = RoseStacker.getInstance();
    PersistentDataContainer dataContainer = entity.getPersistentDataContainer();
    NamespacedKey key = new NamespacedKey(rosePlugin, NO_AI_METADATA_NAME);
    if (!dataContainer.has(key, PersistentDataType.INTEGER))
        dataContainer.set(key, PersistentDataType.INTEGER, 1);
    applyDisabledAi(entity);
}
Also used : NamespacedKey(org.bukkit.NamespacedKey) RosePlugin(dev.rosewood.rosegarden.RosePlugin) PersistentDataContainer(org.bukkit.persistence.PersistentDataContainer)

Aggregations

RosePlugin (dev.rosewood.rosegarden.RosePlugin)7 NamespacedKey (org.bukkit.NamespacedKey)6 PersistentDataContainer (org.bukkit.persistence.PersistentDataContainer)4 GuiUtil (dev.rosewood.guiframework.framework.util.GuiUtil)1 RoseStacker (dev.rosewood.rosestacker.RoseStacker)1 AsyncEntityDeathEvent (dev.rosewood.rosestacker.event.AsyncEntityDeathEvent)1 Setting (dev.rosewood.rosestacker.manager.ConfigurationManager.Setting)1 EntityCacheManager (dev.rosewood.rosestacker.manager.EntityCacheManager)1 StackManager (dev.rosewood.rosestacker.manager.StackManager)1 StackSettingManager (dev.rosewood.rosestacker.manager.StackSettingManager)1 NMSAdapter (dev.rosewood.rosestacker.nms.NMSAdapter)1 NMSHandler (dev.rosewood.rosestacker.nms.NMSHandler)1 StackedEntityDataEntry (dev.rosewood.rosestacker.nms.storage.StackedEntityDataEntry)1 StackedEntity (dev.rosewood.rosestacker.stack.StackedEntity)1 StackedItem (dev.rosewood.rosestacker.stack.StackedItem)1 StackedSpawner (dev.rosewood.rosestacker.stack.StackedSpawner)1 ItemStackSettings (dev.rosewood.rosestacker.stack.settings.ItemStackSettings)1 SpawnerStackSettings (dev.rosewood.rosestacker.stack.settings.SpawnerStackSettings)1 ChickenStackSettings (dev.rosewood.rosestacker.stack.settings.entity.ChickenStackSettings)1 MushroomCowStackSettings (dev.rosewood.rosestacker.stack.settings.entity.MushroomCowStackSettings)1