Search in sources :

Example 1 with BlockActionInfo

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

the class JobsPaymentListener method onBlockPlace.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlock();
    if (block == null)
        return;
    // make sure plugin is enabled
    if (!plugin.isEnabled())
        return;
    // check to make sure you can build
    if (!event.canBuild())
        return;
    Player player = event.getPlayer();
    if (!player.isOnline())
        return;
    // 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);
    JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
    Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.PLACE), multiplier);
}
Also used : Player(org.bukkit.entity.Player) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) Block(org.bukkit.block.Block) BlockActionInfo(com.gamingmesh.jobs.actions.BlockActionInfo) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 2 with BlockActionInfo

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

the class JobsPaymentListener method onBlockBreak.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
    // remove furnace metadata for broken block
    Block block = event.getBlock();
    if (block == null)
        return;
    if (block.getType().equals(Material.FURNACE) && block.hasMetadata(furnaceOwnerMetadata))
        block.removeMetadata(furnaceOwnerMetadata, plugin);
    // make sure plugin is enabled
    if (!plugin.isEnabled())
        return;
    Player player = event.getPlayer();
    if (!player.isOnline())
        return;
    // 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);
    JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
    Jobs.action(jPlayer, new BlockActionInfo(block, ActionType.BREAK), multiplier);
}
Also used : Player(org.bukkit.entity.Player) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) Block(org.bukkit.block.Block) BlockActionInfo(com.gamingmesh.jobs.actions.BlockActionInfo) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) EventHandler(org.bukkit.event.EventHandler)

Aggregations

BlockActionInfo (com.gamingmesh.jobs.actions.BlockActionInfo)2 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)2 Block (org.bukkit.block.Block)2 Player (org.bukkit.entity.Player)2 EventHandler (org.bukkit.event.EventHandler)2