Search in sources :

Example 1 with PostLootGenerateEvent

use of dev.rosewood.roseloot.event.PostLootGenerateEvent in project RoseLoot by Rosewood-Development.

the class LootTableManager method callEvent.

/**
 * Calls the PostLootGenerateEvent for the given LootResult.
 * May modify the given LootResult or return a new one entirely.
 *
 * @param lootResult The LootResult to call the event with
 * @return The LootResult after the event has been called
 */
private LootResult callEvent(LootResult lootResult) {
    PostLootGenerateEvent event = new PostLootGenerateEvent(lootResult);
    Bukkit.getPluginManager().callEvent(event);
    if (event.isCancelled())
        return new LootResult(lootResult.getLootContext(), new LootContents(lootResult.getLootContext()), OverwriteExisting.NONE);
    if (!event.shouldDropItems())
        lootResult.getLootContents().removeItems();
    if (!event.shouldDropExperience())
        lootResult.getLootContents().removeExperience();
    if (!event.shouldTriggerExtras())
        lootResult.getLootContents().removeExtraTriggers();
    lootResult.setOverwriteExisting(event.getOverwriteExisting());
    return lootResult;
}
Also used : LootResult(dev.rosewood.roseloot.loot.LootResult) LootContents(dev.rosewood.roseloot.loot.LootContents) PostLootGenerateEvent(dev.rosewood.roseloot.event.PostLootGenerateEvent)

Aggregations

PostLootGenerateEvent (dev.rosewood.roseloot.event.PostLootGenerateEvent)1 LootContents (dev.rosewood.roseloot.loot.LootContents)1 LootResult (dev.rosewood.roseloot.loot.LootResult)1