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;
|
|
|
|
|
2013-02-01 06:38:25 +01:00
|
|
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
2013-01-23 22:34:01 +01:00
|
|
|
import com.gmail.nossr50.skills.SkillManager;
|
2013-01-30 17:53:51 +01:00
|
|
|
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 {
|
|
|
|
|
2013-02-01 06:38:25 +01:00
|
|
|
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) {
|
2013-02-01 06:38:25 +01:00
|
|
|
Player player = mcMMOPlayer.getPlayer();
|
|
|
|
|
2013-02-19 01:46:50 +01:00
|
|
|
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) {
|
2013-02-01 06:38:25 +01:00
|
|
|
Player player = mcMMOPlayer.getPlayer();
|
|
|
|
|
2013-02-19 01:46:50 +01:00
|
|
|
if (Misc.isNPCEntity(player)) {
|
2013-01-23 22:34:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SmeltResourceEventHandler eventHandler = new SmeltResourceEventHandler(this, event);
|
|
|
|
|
2013-02-19 06:56:25 +01:00
|
|
|
if (Permissions.skillEnabled(player, skill)) {
|
2013-01-23 22:34:01 +01:00
|
|
|
eventHandler.handleXPGain();
|
|
|
|
}
|
|
|
|
|
2013-02-19 06:56:25 +01:00
|
|
|
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) {
|
2013-02-19 06:56:25 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|