Search in sources :

Example 1 with CrateSpawnItemEvent

use of gg.projecteden.nexus.features.crates.models.events.CrateSpawnItemEvent in project Nexus by ProjectEdenGG.

the class Crate method spawnItem.

public Item spawnItem(Location location, ItemStack itemStack) {
    try {
        Item item = location.getWorld().dropItem(location, itemStack);
        item.setVelocity(new Vector(0, 0, 0));
        item.setCanPlayerPickup(false);
        item.setCustomNameVisible(true);
        item.setCustomName(StringUtils.colorize(loot.getTitle()));
        spawnedItem = item;
        new CrateSpawnItemEvent(player, loot, getCrateType()).callEvent();
        return item;
    } catch (Exception ex) {
        player.getInventory().addItem(getCrateType().getKey());
        throw new CrateOpeningException("There was an error while trying to play the crate animation");
    }
}
Also used : Item(org.bukkit.entity.Item) MuteMenuItem(gg.projecteden.nexus.features.commands.MuteMenuCommand.MuteMenuProvider.MuteMenuItem) Vector(org.bukkit.util.Vector) CrateSpawnItemEvent(gg.projecteden.nexus.features.crates.models.events.CrateSpawnItemEvent) CrateOpeningException(gg.projecteden.nexus.framework.exceptions.postconfigured.CrateOpeningException) CrateOpeningException(gg.projecteden.nexus.framework.exceptions.postconfigured.CrateOpeningException)

Example 2 with CrateSpawnItemEvent

use of gg.projecteden.nexus.features.crates.models.events.CrateSpawnItemEvent in project Nexus by ProjectEdenGG.

the class FebVoteRewardCrate method spawnItem.

@Override
public Item spawnItem(Location location, ItemStack itemStack) {
    try {
        Item item = location.getWorld().spawn(location, Item.class);
        item.setVelocity(new Vector(0, 0, 0));
        item.setItemStack(itemStack);
        item.setCanPlayerPickup(false);
        item.setCustomName(itemStack.getItemMeta().getDisplayName());
        item.setCustomNameVisible(true);
        spawnedItem = item;
        new CrateSpawnItemEvent(player, loot, getCrateType()).callEvent();
        return item;
    } catch (Exception ex) {
        player.getInventory().addItem(getCrateType().getKey());
        throw new CrateOpeningException("There was an error while trying to play the crate animation");
    }
}
Also used : Item(org.bukkit.entity.Item) Vector(org.bukkit.util.Vector) CrateSpawnItemEvent(gg.projecteden.nexus.features.crates.models.events.CrateSpawnItemEvent) CrateOpeningException(gg.projecteden.nexus.framework.exceptions.postconfigured.CrateOpeningException) CrateOpeningException(gg.projecteden.nexus.framework.exceptions.postconfigured.CrateOpeningException)

Aggregations

CrateSpawnItemEvent (gg.projecteden.nexus.features.crates.models.events.CrateSpawnItemEvent)2 CrateOpeningException (gg.projecteden.nexus.framework.exceptions.postconfigured.CrateOpeningException)2 Item (org.bukkit.entity.Item)2 Vector (org.bukkit.util.Vector)2 MuteMenuItem (gg.projecteden.nexus.features.commands.MuteMenuCommand.MuteMenuProvider.MuteMenuItem)1