Search in sources :

Example 6 with ItemActionInfo

use of com.gamingmesh.jobs.actions.ItemActionInfo in project Jobs by GamingMesh.

the class JobsPaymentListener method onPlayerFish.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
    // make sure plugin is enabled
    if (!plugin.isEnabled())
        return;
    Player player = event.getPlayer();
    // check if in creative
    if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
        return;
    if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
        return;
    // restricted area multiplier
    double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
    if (event.getState().equals(PlayerFishEvent.State.CAUGHT_FISH) && event.getCaught() instanceof Item) {
        JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
        ItemStack items = ((Item) event.getCaught()).getItemStack();
        Jobs.action(jPlayer, new ItemActionInfo(items, ActionType.FISH), multiplier);
    }
}
Also used : Item(org.bukkit.entity.Item) 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) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ItemActionInfo (com.gamingmesh.jobs.actions.ItemActionInfo)6 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)6 Player (org.bukkit.entity.Player)6 EventHandler (org.bukkit.event.EventHandler)6 ItemStack (org.bukkit.inventory.ItemStack)4 CraftingInventory (org.bukkit.inventory.CraftingInventory)3 Block (org.bukkit.block.Block)2 AnvilInventory (org.bukkit.inventory.AnvilInventory)2 EnchantingInventory (org.bukkit.inventory.EnchantingInventory)2 Inventory (org.bukkit.inventory.Inventory)2 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)2 MetadataValue (org.bukkit.metadata.MetadataValue)2 Item (org.bukkit.entity.Item)1 CraftItemEvent (org.bukkit.event.inventory.CraftItemEvent)1 Recipe (org.bukkit.inventory.Recipe)1