Fix potions. Fixes #2813, #2814

This commit is contained in:
t00thpick1
2016-03-16 00:39:23 -05:00
parent 1488946fc5
commit ec774b590b
7 changed files with 103 additions and 27 deletions

View File

@ -236,7 +236,7 @@ public class PotionConfig extends ConfigLoader {
}
public boolean isValidPotion(ItemStack item) {
return potionMap.containsKey(item.getDurability());
return getPotion(item) != null;
}
public AlchemyPotion getPotion(String name) {

View File

@ -139,15 +139,15 @@ public class AlchemyPotion {
return false;
}
}
if (!meta.hasLore()) {
if (!meta.hasLore() && !lore.isEmpty()) {
return false;
}
if (!meta.getLore().equals(lore)) {
if (!(lore.isEmpty() && !meta.hasLore()) && !meta.getLore().equals(lore)) {
return false;
}
if (!meta.hasDisplayName()) {
if (!meta.hasDisplayName() && name != null) {
return false;
}
return meta.getDisplayName().equals(name);
return (name == null && !meta.hasDisplayName()) || meta.getDisplayName().equals(name);
}
}

View File

@ -54,8 +54,8 @@ public enum PotionStage {
int stage = 1;
// Check if potion has base effect
if (data.getType().getEffectType() != null) {
// Check if potion has an effect of any sort
if (data.getType().getEffectType() != null || !effects.isEmpty()) {
stage++;
}
@ -63,8 +63,7 @@ public enum PotionStage {
// Else check if the potion has a custom effect with an amplifier added by mcMMO
if (data.isUpgraded()) {
stage++;
}
if(!effects.isEmpty()){
} else if(!effects.isEmpty()) {
for (PotionEffect effect : effects){
if(effect.getAmplifier() > 0){
stage++;

View File

@ -165,7 +165,7 @@ public class InventoryListener implements Listener {
ItemStack clicked = event.getCurrentItem();
ItemStack cursor = event.getCursor();
if ((clicked != null && clicked.getType() == Material.POTION) || (cursor != null && cursor.getType() == Material.POTION)) {
if ((clicked != null && (clicked.getType() == Material.POTION || clicked.getType() == Material.SPLASH_POTION || clicked.getType() == Material.LINGERING_POTION)) || (cursor != null && (cursor.getType() == Material.POTION || cursor.getType() == Material.SPLASH_POTION || cursor.getType() == Material.LINGERING_POTION))) {
AlchemyPotionBrewer.scheduleCheck(player, stand);
return;
}
@ -296,12 +296,12 @@ public class InventoryListener implements Listener {
ItemStack item = event.getItem();
if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) {
event.setCancelled(true);
return;
}
if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
if (Config.getInstance().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) {
event.setCancelled(true);
return;
}

View File

@ -32,7 +32,7 @@ public final class AlchemyPotionBrewer {
}
for (int i = 0; i < 3; i++) {
if (contents[i] == null || contents[i].getType() != Material.POTION) {
if (contents[i] == null || contents[i].getType() != Material.POTION && contents[i].getType() != Material.SPLASH_POTION && contents[i].getType() != Material.LINGERING_POTION) {
continue;
}