use of org.bukkit.inventory.AnvilInventory in project Jobs by GamingMesh.
the class JobsPaymentListener method onInventoryRepair.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryRepair(InventoryClickEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Inventory inv = event.getInventory();
// 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;
}
// must be anvil inventory
if (!(inv instanceof AnvilInventory))
return;
// Must be "container" slot 9
if (!event.getSlotType().equals(SlotType.CONTAINER) || event.getSlot() != 2)
return;
if (!(event.getWhoClicked() instanceof Player))
return;
Player player = (Player) event.getWhoClicked();
ItemStack resultStack = event.getCurrentItem();
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.REPAIR), multiplier);
}
Aggregations