use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsListener method onPlayerWorldChange.
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
if (!plugin.isEnabled())
return;
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(event.getPlayer());
Jobs.getPermissionHandler().recalculatePermissions(jPlayer);
}
use of com.gamingmesh.jobs.container.JobsPlayer in project Jobs by GamingMesh.
the class JobsPaymentListener method onEntityDeath.
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
// Entity that died must be living
if (!(event.getEntity() instanceof LivingEntity))
return;
LivingEntity lVictim = (LivingEntity) event.getEntity();
// mob spawner, no payment or experience
if (lVictim.hasMetadata(mobSpawnerMetadata)) {
lVictim.removeMetadata(mobSpawnerMetadata, plugin);
return;
}
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event.getEntity().getLastDamageCause();
org.bukkit.entity.Player pDamager = null;
if (e.getDamager() instanceof org.bukkit.entity.Player) {
pDamager = (org.bukkit.entity.Player) e.getDamager();
} else if (e.getDamager() instanceof Projectile && ((Projectile) e.getDamager()).getShooter() instanceof org.bukkit.entity.Player) {
pDamager = (org.bukkit.entity.Player) ((Projectile) e.getDamager()).getShooter();
} else if (e.getDamager() instanceof Tameable) {
Tameable t = (Tameable) e.getDamager();
if (t.isTamed() && t.getOwner() instanceof org.bukkit.entity.Player) {
pDamager = (org.bukkit.entity.Player) t.getOwner();
}
}
if (pDamager != null) {
// check if in creative
if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
return;
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
return;
// restricted area multiplier
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(pDamager);
// pay
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
Jobs.action(jDamager, new EntityActionInfo(lVictim.getType(), ActionType.KILL), multiplier);
}
}
}
use of com.gamingmesh.jobs.container.JobsPlayer 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.container.JobsPlayer 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);
}
use of com.gamingmesh.jobs.container.JobsPlayer 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);
}
}
Aggregations