use of org.bukkit.metadata.MetadataValue 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 org.bukkit.metadata.MetadataValue 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);
}
Aggregations