SmeltingManager.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package com.gmail.nossr50.skills.smelting;
  2. import org.bukkit.entity.Player;
  3. import org.bukkit.event.block.BlockBreakEvent;
  4. import org.bukkit.event.inventory.FurnaceBurnEvent;
  5. import org.bukkit.event.inventory.FurnaceExtractEvent;
  6. import org.bukkit.event.inventory.FurnaceSmeltEvent;
  7. import com.gmail.nossr50.skills.SkillManager;
  8. import com.gmail.nossr50.skills.utilities.SkillType;
  9. import com.gmail.nossr50.util.Misc;
  10. import com.gmail.nossr50.util.Permissions;
  11. public class SmeltingManager extends SkillManager {
  12. public SmeltingManager(Player player) {
  13. super(player, SkillType.SMELTING);
  14. }
  15. /**
  16. * Increases burn time for furnace fuel.
  17. *
  18. * @param event The {@link FurnaceBurnEvent} to modify.
  19. */
  20. public void fuelEfficiency(FurnaceBurnEvent event) {
  21. if (Misc.isNPCPlayer(player) || !Permissions.fuelEfficiency(player)) {
  22. return;
  23. }
  24. FuelEfficiencyEventHandler eventHandler = new FuelEfficiencyEventHandler(this, event);
  25. eventHandler.calculateBurnModifier();
  26. eventHandler.modifyBurnTime();
  27. }
  28. public void smeltProcessing(FurnaceSmeltEvent event) {
  29. if (Misc.isNPCPlayer(player)) {
  30. return;
  31. }
  32. SmeltResourceEventHandler eventHandler = new SmeltResourceEventHandler(this, event);
  33. if (Permissions.smelting(player)) {
  34. eventHandler.handleXPGain();
  35. }
  36. if (!Permissions.secondSmelt(player)) {
  37. return;
  38. }
  39. eventHandler.calculateSkillModifier();
  40. double chance = (Smelting.secondSmeltMaxChance / Smelting.secondSmeltMaxLevel) * eventHandler.skillModifier;
  41. if (chance > Misc.getRandom().nextInt(activationChance)) {
  42. eventHandler.handleBonusSmelts();
  43. }
  44. }
  45. public void fluxMining(BlockBreakEvent event) {
  46. if (skillLevel < Smelting.fluxMiningUnlockLevel) {
  47. return;
  48. }
  49. if (Smelting.fluxMiningChance > Misc.getRandom().nextInt(activationChance)) {
  50. FluxMiningEventHandler eventHandler = new FluxMiningEventHandler(this, event);
  51. eventHandler.processDrops();
  52. eventHandler.eventCancellationAndProcessing();
  53. eventHandler.sendAbilityMessage();
  54. }
  55. }
  56. public void vanillaXPBoost(FurnaceExtractEvent event) {
  57. if (skillLevel < Smelting.vanillaXPBoostRank1Level || !Permissions.smeltingVanillaXPBoost(player)) {
  58. return;
  59. }
  60. SmeltingVanillaXPEventHandler eventHandler = new SmeltingVanillaXPEventHandler(this, event);
  61. eventHandler.calculateModifier();
  62. eventHandler.modifyVanillaXP();
  63. }
  64. }