mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
Quit passing this event around.
This commit is contained in:
parent
e46ed07b94
commit
0201ed332f
@ -388,23 +388,23 @@ public class EntityListener implements Listener {
|
||||
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, event);
|
||||
break;
|
||||
event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel1, newFoodLevel));
|
||||
return;
|
||||
|
||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, event);
|
||||
break;
|
||||
event.setFoodLevel(Herbalism.farmersDiet(player, Herbalism.farmersDietRankLevel2, newFoodLevel));
|
||||
return;
|
||||
|
||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, event);
|
||||
break;
|
||||
event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel1, newFoodLevel));
|
||||
return;
|
||||
|
||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, event);
|
||||
break;
|
||||
event.setFoodLevel(Fishing.beginFishermansDiet(player, Fishing.fishermansDietRankLevel2, newFoodLevel));
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -26,30 +25,28 @@ import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public final class Fishing {
|
||||
static final AdvancedConfig ADVANCED_CONFIG = AdvancedConfig.getInstance();
|
||||
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
protected enum Tier {
|
||||
FIVE(5) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier5();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank5();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank5();}},
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier5();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank5();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5();}},
|
||||
FOUR(4) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier4();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank4();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank4();}},
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier4();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank4();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4();}},
|
||||
THREE(3) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier3();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank3();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank3();}},
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier3();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank3();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3();}},
|
||||
TWO(2) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier2();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank2();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank2();}},
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier2();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank2();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2();}},
|
||||
ONE(1) {
|
||||
@Override public int getLevel() {return ADVANCED_CONFIG.getFishingTierLevelsTier1();}
|
||||
@Override public int getShakeChance() {return ADVANCED_CONFIG.getShakeChanceRank1();}
|
||||
@Override public int getVanillaXPBoostModifier() {return ADVANCED_CONFIG.getFishingVanillaXPModifierRank1();}};
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier1();}
|
||||
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank1();}
|
||||
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1();}};
|
||||
|
||||
int numerical;
|
||||
|
||||
@ -67,7 +64,7 @@ public final class Fishing {
|
||||
}
|
||||
|
||||
// TODO: Get rid of that
|
||||
public static int fishermansDietRankLevel1 = ADVANCED_CONFIG.getFishermanDietRankChange();
|
||||
public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
|
||||
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
||||
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
||||
|
||||
@ -80,14 +77,13 @@ public final class Fishing {
|
||||
* @param rankChange ???
|
||||
* @param event Event to process
|
||||
*/
|
||||
public static void beginFishermansDiet(Player player, int rankChange, FoodLevelChangeEvent event) {
|
||||
public static int beginFishermansDiet(Player player, int rankChange, int eventFoodLevel) {
|
||||
// TODO: The permission should probably not be checked here
|
||||
// TODO: Also I don't like the idea of moving event around
|
||||
if (!Permissions.fishermansDiet(player)) {
|
||||
return;
|
||||
return eventFoodLevel;
|
||||
}
|
||||
|
||||
SkillTools.handleFoodSkills(player, SkillType.FISHING, event, fishermansDietRankLevel1, fishermansDietMaxLevel, rankChange);
|
||||
return SkillTools.handleFoodSkills(player, SkillType.FISHING, eventFoodLevel, fishermansDietRankLevel1, fishermansDietMaxLevel, rankChange);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,7 +194,7 @@ public final class Fishing {
|
||||
activationChance = (int) (activationChance * 0.909);
|
||||
}
|
||||
|
||||
if (Misc.getRandom().nextInt(activationChance) > getLootTier(skillLevel) * ADVANCED_CONFIG.getFishingMagicMultiplier()) {
|
||||
if (Misc.getRandom().nextInt(activationChance) > getLootTier(skillLevel) * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
@ -57,12 +56,12 @@ public class Herbalism {
|
||||
* @param rankChange The # of levels to change rank for the food
|
||||
* @param event The actual FoodLevelChange event
|
||||
*/
|
||||
public static void farmersDiet(Player player, int rankChange, FoodLevelChangeEvent event) {
|
||||
public static int farmersDiet(Player player, int rankChange, int eventFoodLevel) {
|
||||
if (!Permissions.farmersDiet(player)) {
|
||||
return;
|
||||
return eventFoodLevel;
|
||||
}
|
||||
|
||||
SkillTools.handleFoodSkills(player, SkillType.HERBALISM, event, farmersDietRankLevel1, farmersDietMaxLevel, rankChange);
|
||||
return SkillTools.handleFoodSkills(player, SkillType.HERBALISM, eventFoodLevel, farmersDietRankLevel1, farmersDietMaxLevel, rankChange);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -38,12 +37,11 @@ import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillTools {
|
||||
public static void handleFoodSkills(Player player, SkillType skill, FoodLevelChangeEvent event, int baseLevel, int maxLevel, int rankChange) {
|
||||
public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) {
|
||||
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
int foodChange = eventFoodLevel - currentFoodLevel;
|
||||
|
||||
for (int i = baseLevel; i <= maxLevel; i+= rankChange) {
|
||||
if (skillLevel >= i) {
|
||||
@ -51,7 +49,7 @@ public class SkillTools {
|
||||
}
|
||||
}
|
||||
|
||||
event.setFoodLevel(currentFoodLevel + foodChange);
|
||||
return currentFoodLevel + foodChange;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user