Search in sources :

Example 1 with MetadataValue

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);
}
Also used : FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) MetadataValue(org.bukkit.metadata.MetadataValue) Player(org.bukkit.entity.Player) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) ItemActionInfo(com.gamingmesh.jobs.actions.ItemActionInfo) Block(org.bukkit.block.Block) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 2 with MetadataValue

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);
}
Also used : FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) MetadataValue(org.bukkit.metadata.MetadataValue) Player(org.bukkit.entity.Player) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) ItemActionInfo(com.gamingmesh.jobs.actions.ItemActionInfo) Block(org.bukkit.block.Block) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ItemActionInfo (com.gamingmesh.jobs.actions.ItemActionInfo)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 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)2 MetadataValue (org.bukkit.metadata.MetadataValue)2