2013-01-23 22:34:01 +01:00
|
|
|
package com.gmail.nossr50.skills.smelting;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.block.BlockBreakEvent;
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (Permissions.smelting(player)) {
|
|
|
|
eventHandler.handleXPGain();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Permissions.secondSmelt(player)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
eventHandler.calculateSkillModifier();
|
|
|
|
|
|
|
|
double chance = (Smelting.secondSmeltMaxChance / Smelting.secondSmeltMaxLevel) * eventHandler.skillModifier;
|
|
|
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
|
|
|
eventHandler.handleBonusSmelts();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void fluxMining(BlockBreakEvent event) {
|
2013-01-25 18:33:48 +01:00
|
|
|
if (skillLevel < Smelting.fluxMiningUnlockLevel) {
|
2013-01-23 22:34:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Smelting.fluxMiningChance > Misc.getRandom().nextInt(activationChance)) {
|
|
|
|
FluxMiningEventHandler eventHandler = new FluxMiningEventHandler(this, event);
|
|
|
|
eventHandler.processDrops();
|
|
|
|
eventHandler.eventCancellationAndProcessing();
|
|
|
|
eventHandler.sendAbilityMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void vanillaXPBoost(FurnaceExtractEvent event) {
|
2013-02-01 06:38:25 +01:00
|
|
|
if (skillLevel < Smelting.vanillaXPBoostRank1Level || !Permissions.smeltingVanillaXPBoost(mcMMOPlayer.getPlayer())) {
|
2013-01-23 22:34:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SmeltingVanillaXPEventHandler eventHandler = new SmeltingVanillaXPEventHandler(this, event);
|
|
|
|
eventHandler.calculateModifier();
|
|
|
|
eventHandler.modifyVanillaXP();
|
|
|
|
}
|
|
|
|
}
|