Search in sources :

Example 1 with EnchantingInventory

use of org.bukkit.inventory.EnchantingInventory in project Jobs by GamingMesh.

the class JobsPaymentListener method onEnchantItem.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEnchantItem(EnchantItemEvent event) {
    // make sure plugin is enabled
    if (!plugin.isEnabled())
        return;
    Inventory inv = event.getInventory();
    if (!(inv instanceof EnchantingInventory))
        return;
    Player player = event.getEnchanter();
    ItemStack resultStack = ((EnchantingInventory) inv).getItem();
    if (resultStack == null)
        return;
    if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
        return;
    // check if in creative
    if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
        return;
    double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
    JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
    Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT), multiplier);
}
Also used : Player(org.bukkit.entity.Player) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) ItemActionInfo(com.gamingmesh.jobs.actions.ItemActionInfo) ItemStack(org.bukkit.inventory.ItemStack) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) CraftingInventory(org.bukkit.inventory.CraftingInventory) Inventory(org.bukkit.inventory.Inventory) EnchantingInventory(org.bukkit.inventory.EnchantingInventory) AnvilInventory(org.bukkit.inventory.AnvilInventory) EnchantingInventory(org.bukkit.inventory.EnchantingInventory) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ItemActionInfo (com.gamingmesh.jobs.actions.ItemActionInfo)1 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1 AnvilInventory (org.bukkit.inventory.AnvilInventory)1 CraftingInventory (org.bukkit.inventory.CraftingInventory)1 EnchantingInventory (org.bukkit.inventory.EnchantingInventory)1 Inventory (org.bukkit.inventory.Inventory)1 ItemStack (org.bukkit.inventory.ItemStack)1