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;
}
Aggregations