Fix for custom potions being missed in potion stage calculation. #2386

This commit is contained in:
Stephen Jenkins 2015-07-10 18:04:53 -04:00
parent 93ad040936
commit d3d7c254f4

View File

@ -1,6 +1,9 @@
package com.gmail.nossr50.datatypes.skills.alchemy; package com.gmail.nossr50.datatypes.skills.alchemy;
import java.util.List;
import org.bukkit.potion.Potion; import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
public enum PotionStage { public enum PotionStage {
FIVE(5), FIVE(5),
@ -44,17 +47,27 @@ public enum PotionStage {
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) { public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
Potion potion = alchemyPotion.toPotion(1); Potion potion = alchemyPotion.toPotion(1);
List<PotionEffect> effects = alchemyPotion.getEffects();
int stage = 1; int stage = 1;
// Check if potion isn't awkward or mundane // Check if potion isn't awkward or mundane
if (potion.getType() != null) { // Check for custom effects added by mcMMO
if (potion.getType() != null || !effects.isEmpty()) {
stage++; stage++;
} }
// Check if potion has a glowstone dust amplifier // Check if potion has a glowstone dust amplifier
// Else check if the potion has a custom effect with an amplifier added by mcMMO
if (potion.getLevel() > 1) { if (potion.getLevel() > 1) {
stage++; stage++;
}else if(!effects.isEmpty()){
for (PotionEffect effect : effects){
if(effect.getAmplifier() > 0){
stage++;
break;
}
}
} }
// Check if potion has a redstone dust amplifier // Check if potion has a redstone dust amplifier