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