mcMMO/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java

72 lines
2.3 KiB
Java
Raw Normal View History

2013-01-23 22:34:01 +01:00
package com.gmail.nossr50.skills.smelting;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.event.inventory.FurnaceExtractEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent;
import com.gmail.nossr50.datatypes.McMMOPlayer;
2013-01-23 22:34:01 +01:00
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillType;
2013-01-23 22:34:01 +01:00
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class SmeltingManager extends SkillManager {
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.SMELTING);
2013-01-23 22:34:01 +01:00
}
/**
* Increases burn time for furnace fuel.
*
* @param event The {@link FurnaceBurnEvent} to modify.
*/
public void fuelEfficiency(FurnaceBurnEvent event) {
Player player = mcMMOPlayer.getPlayer();
if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) {
2013-01-23 22:34:01 +01:00
return;
}
FuelEfficiencyEventHandler eventHandler = new FuelEfficiencyEventHandler(this, event);
eventHandler.calculateBurnModifier();
eventHandler.modifyBurnTime();
}
public void smeltProcessing(FurnaceSmeltEvent event) {
Player player = mcMMOPlayer.getPlayer();
if (Misc.isNPCEntity(player)) {
2013-01-23 22:34:01 +01:00
return;
}
SmeltResourceEventHandler eventHandler = new SmeltResourceEventHandler(this, event);
if (Permissions.skillEnabled(player, skill)) {
2013-01-23 22:34:01 +01:00
eventHandler.handleXPGain();
}
if (!Permissions.doubleDrops(player, skill)) {
2013-01-23 22:34:01 +01:00
return;
}
eventHandler.calculateSkillModifier();
double chance = (Smelting.secondSmeltMaxChance / Smelting.secondSmeltMaxLevel) * eventHandler.skillModifier;
if (chance > Misc.getRandom().nextInt(activationChance)) {
eventHandler.handleBonusSmelts();
}
}
public void vanillaXPBoost(FurnaceExtractEvent event) {
if (skillLevel < Smelting.vanillaXPBoostRank1Level || !Permissions.vanillaXpBoost(mcMMOPlayer.getPlayer(), skill)) {
2013-01-23 22:34:01 +01:00
return;
}
SmeltingVanillaXPEventHandler eventHandler = new SmeltingVanillaXPEventHandler(this, event);
eventHandler.calculateModifier();
eventHandler.modifyVanillaXP();
}
}