use of org.bukkit.event.inventory.CraftItemEvent in project Jobs by GamingMesh.
the class JobsPaymentListener method onInventoryCraft.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryCraft(InventoryClickEvent e) {
if (!(e instanceof CraftItemEvent))
return;
CraftItemEvent event = (CraftItemEvent) e;
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
// If event is nothing or place, do nothing
switch(event.getAction()) {
case NOTHING:
case PLACE_ONE:
case PLACE_ALL:
case PLACE_SOME:
return;
default:
break;
}
if (event.getAction() == InventoryAction.NOTHING)
return;
CraftingInventory inv = event.getInventory();
if (!(inv instanceof CraftingInventory) || !event.getSlotType().equals(SlotType.RESULT))
return;
Recipe recipe = event.getRecipe();
if (recipe == null)
return;
if (!(event.getWhoClicked() instanceof Player))
return;
Player player = (Player) event.getWhoClicked();
ItemStack resultStack = recipe.getResult();
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.CRAFT), multiplier);
}
Aggregations