use of com.gamingmesh.jobs.actions.ItemActionInfo in project Jobs by GamingMesh.
the class JobsPaymentListener method onBrewEvent.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBrewEvent(BrewEvent event) {
if (!plugin.isEnabled())
return;
Block block = event.getBlock();
if (block == null)
return;
if (!block.hasMetadata(brewingOwnerMetadata))
return;
List<MetadataValue> data = block.getMetadata(brewingOwnerMetadata);
if (data.isEmpty())
return;
// only care about first
MetadataValue value = data.get(0);
String playerName = value.asString();
Player player = Bukkit.getServer().getPlayerExact(playerName);
if (player == null || !player.isOnline())
return;
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
return;
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
Jobs.action(jPlayer, new ItemActionInfo(event.getContents().getIngredient(), ActionType.BREW), multiplier);
}
use of com.gamingmesh.jobs.actions.ItemActionInfo 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);
}
use of com.gamingmesh.jobs.actions.ItemActionInfo in project Jobs by GamingMesh.
the class JobsPaymentListener method onEnchantItem.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEnchantItem(EnchantItemEvent event) {
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
Inventory inv = event.getInventory();
if (!(inv instanceof EnchantingInventory))
return;
Player player = event.getEnchanter();
ItemStack resultStack = ((EnchantingInventory) inv).getItem();
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.ENCHANT), multiplier);
}
use of com.gamingmesh.jobs.actions.ItemActionInfo in project Jobs by GamingMesh.
the class JobsPaymentListener method onFurnaceSmelt.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
if (!plugin.isEnabled())
return;
Block block = event.getBlock();
if (block == null)
return;
if (!block.hasMetadata(furnaceOwnerMetadata))
return;
List<MetadataValue> data = block.getMetadata(furnaceOwnerMetadata);
if (data.isEmpty())
return;
// only care about first
MetadataValue value = data.get(0);
String playerName = value.asString();
Player player = Bukkit.getServer().getPlayerExact(playerName);
if (player == null || !player.isOnline())
return;
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
return;
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
Jobs.action(jPlayer, new ItemActionInfo(event.getResult(), ActionType.SMELT), multiplier);
}
use of com.gamingmesh.jobs.actions.ItemActionInfo in project Jobs by GamingMesh.
the class JobsPaymentListener method onInventoryCraft.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryCraft(InventoryClickEvent e) {
if (!(e instanceof CraftItemEvent))
return;
CraftItemEvent event = (CraftItemEvent) e;
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
// 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;
}
if (event.getAction() == InventoryAction.NOTHING)
return;
CraftingInventory inv = event.getInventory();
if (!(inv instanceof CraftingInventory) || !event.getSlotType().equals(SlotType.RESULT))
return;
Recipe recipe = event.getRecipe();
if (recipe == null)
return;
if (!(event.getWhoClicked() instanceof Player))
return;
Player player = (Player) event.getWhoClicked();
ItemStack resultStack = recipe.getResult();
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.CRAFT), multiplier);
}
Aggregations