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