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;
}

View File

@ -405,6 +405,16 @@ Potions:
SULPHUR: SPLASH_POTION_OF_HASTE
REDSTONE: POTION_OF_HASTE_EXTENDED
GLOWSTONE_DUST: POTION_OF_HASTE_II
POTION_OF_HEALTH_BOOST:
Name: Potion Of Health Boost
Material: POTION
PotionData:
PotionType: UNCRAFTABLE
Effects: ["HEALTH_BOOST 0 1800"]
Children:
GLOWSTONE_DUST: POTION_OF_HEALTH_BOOST_II
SULPHUR: SPLASH_POTION_OF_HEALTH_BOOST
REDSTONE: POTION_OF_HEALTH_BOOST_EXTENDED
POTION_OF_HUNGER:
Name: Potion Of Hunger
Material: POTION
@ -475,6 +485,12 @@ Potions:
PotionData:
PotionType: UNCRAFTABLE
Effects: ["FAST_DIGGING 0 7200"]
POTION_OF_HEALTH_BOOST_EXTENDED:
Name: Potion Of Health Boost Extended
Material: POTION
PotionData:
PotionType: UNCRAFTABLE
Effects: ["HEALTH_BOOST 0 3600"]
POTION_OF_HUNGER_EXTENDED:
Name: Potion Of Hunger Extended
Material: POTION
@ -529,6 +545,12 @@ Potions:
PotionData:
PotionType: UNCRAFTABLE
Effects: ["FAST_DIGGING 1 1800"]
POTION_OF_HEALTH_BOOST_II:
Name: Potion Of Health Boost II
Material: POTION
PotionData:
PotionType: UNCRAFTABLE
Effects: ["HEALTH_BOOST 1 900"]
POTION_OF_HUNGER_II:
Name: Potion Of Hunger II
Material: POTION
@ -862,9 +884,9 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["ABSORPTION 0 1350"]
Children:
REDSTONE: SPLASH_POTION_OF_ABSORPTION_EXTENDED
GLOWSTONE_DUST: SPLASH_POTION_OF_ABSORPTION_II
DRAGONS_BREATH: LINGERING_POTION_OF_ABSORPTION
GLOWSTONE_DUST: SPLASH_POTION_OF_ABSORPTION_II
REDSTONE: SPLASH_POTION_OF_ABSORPTION_EXTENDED
SPLASH_POTION_OF_BLINDNESS:
Name: Splash Potion Of Blindness
Material: SPLASH_POTION
@ -872,9 +894,9 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["BLINDNESS 0 168"]
Children:
DRAGONS_BREATH: LINGERING_POTION_OF_BLINDNESS
REDSTONE: SPLASH_POTION_OF_BLINDNESS_EXTENDED
GLOWSTONE_DUST: SPLASH_POTION_OF_BLINDNESS_II
REDSTONE: SPLASH_POTION_OF_BLINDNESS_EXTENDED
DRAGONS_BREATH: LINGERING_POTION_OF_BLINDNESS
SPLASH_POTION_OF_DECAY:
Name: Splash Potion Of Decay
Material: SPLASH_POTION
@ -902,9 +924,19 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["FAST_DIGGING 0 2700"]
Children:
GLOWSTONE_DUST: SPLASH_POTION_OF_HASTE_II
DRAGONS_BREATH: LINGERING_POTION_OF_HASTE
REDSTONE: SPLASH_POTION_OF_HASTE_EXTENDED
GLOWSTONE_DUST: SPLASH_POTION_OF_HASTE_II
SPLASH_POTION_OF_HEALTH_BOOST:
Name: Splash Potion Of Health Boost
Material: SPLASH_POTION
PotionData:
PotionType: UNCRAFTABLE
Effects: ["HEALTH_BOOST 0 1350"]
Children:
GLOWSTONE_DUST: SPLASH_POTION_OF_HEALTH_BOOST_II
REDSTONE: SPLASH_POTION_OF_HEALTH_BOOST_EXTENDED
DRAGONS_BREATH: LINGERING_POTION_OF_HEALTH_BOOST
SPLASH_POTION_OF_HUNGER:
Name: Splash Potion Of Hunger
Material: SPLASH_POTION
@ -912,8 +944,8 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["HUNGER 0 675"]
Children:
GLOWSTONE_DUST: SPLASH_POTION_OF_HUNGER_II
REDSTONE: SPLASH_POTION_OF_HUNGER_EXTENDED
GLOWSTONE_DUST: SPLASH_POTION_OF_HUNGER_II
DRAGONS_BREATH: LINGERING_POTION_OF_HUNGER
SPLASH_POTION_OF_NAUSEA:
Name: Splash Potion Of Nausea
@ -922,9 +954,9 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["CONFUSION 0 337"]
Children:
GLOWSTONE_DUST: SPLASH_POTION_OF_NAUSEA_II
DRAGONS_BREATH: LINGERING_POTION_OF_NAUSEA
REDSTONE: SPLASH_POTION_OF_NAUSEA_EXTENDED
GLOWSTONE_DUST: SPLASH_POTION_OF_NAUSEA_II
SPLASH_POTION_OF_RESISTANCE:
Name: Splash Potion Of Resistance
Material: SPLASH_POTION
@ -932,9 +964,9 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["DAMAGE_RESISTANCE 0 337"]
Children:
GLOWSTONE_DUST: SPLASH_POTION_OF_RESISTANCE_II
DRAGONS_BREATH: LINGERING_POTION_OF_RESISTANCE
REDSTONE: SPLASH_POTION_OF_RESISTANCE_EXTENDED
GLOWSTONE_DUST: SPLASH_POTION_OF_RESISTANCE_II
SPLASH_POTION_OF_SATURATION:
Name: Splash Potion Of Saturation
Material: SPLASH_POTION
@ -975,6 +1007,12 @@ Potions:
PotionData:
PotionType: UNCRAFTABLE
Effects: ["FAST_DIGGING 0 5400"]
SPLASH_POTION_OF_HEALTH_BOOST_EXTENDED:
Name: Splash Potion Of Health Boost Extended
Material: SPLASH_POTION
PotionData:
PotionType: UNCRAFTABLE
Effects: ["HEALTH_BOOST 0 2700"]
SPLASH_POTION_OF_HUNGER_EXTENDED:
Name: Splash Potion Of Hunger Extended
Material: SPLASH_POTION
@ -1029,6 +1067,12 @@ Potions:
PotionData:
PotionType: UNCRAFTABLE
Effects: ["FAST_DIGGING 1 1350"]
SPLASH_POTION_OF_HEALTH_BOOST_II:
Name: Splash Potion Of Health Boost II
Material: SPLASH_POTION
PotionData:
PotionType: UNCRAFTABLE
Effects: ["HEALTH_BOOST 1 675"]
SPLASH_POTION_OF_HUNGER_II:
Name: Splash Potion Of Hunger II
Material: SPLASH_POTION
@ -1310,8 +1354,8 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["ABSORPTION 0 450"]
Children:
REDSTONE: LINGERING_POTION_OF_ABSORPTION_EXTENDED
GLOWSTONE_DUST: LINGERING_POTION_OF_ABSORPTION_II
REDSTONE: LINGERING_POTION_OF_ABSORPTION_EXTENDED
LINGERING_POTION_OF_BLINDNESS:
Name: Lingering Potion Of Blindness
Material: LINGERING_POTION
@ -1319,8 +1363,8 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["BLINDNESS 0 56"]
Children:
GLOWSTONE_DUST: LINGERING_POTION_OF_BLINDNESS_II
REDSTONE: LINGERING_POTION_OF_BLINDNESS_EXTENDED
GLOWSTONE_DUST: LINGERING_POTION_OF_BLINDNESS_II
LINGERING_POTION_OF_DECAY:
Name: Lingering Potion Of Decay
Material: LINGERING_POTION
@ -1328,8 +1372,8 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["WITHER 0 112"]
Children:
REDSTONE: LINGERING_POTION_OF_DECAY_EXTENDED
GLOWSTONE_DUST: LINGERING_POTION_OF_DECAY_II
REDSTONE: LINGERING_POTION_OF_DECAY_EXTENDED
LINGERING_POTION_OF_DULLNESS:
Name: Lingering Potion Of Dullness
Material: LINGERING_POTION
@ -1337,8 +1381,8 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["SLOW_DIGGING 0 900"]
Children:
GLOWSTONE_DUST: LINGERING_POTION_OF_DULLNESS_II
REDSTONE: LINGERING_POTION_OF_DULLNESS_EXTENDED
GLOWSTONE_DUST: LINGERING_POTION_OF_DULLNESS_II
LINGERING_POTION_OF_HASTE:
Name: Lingering Potion Of Haste
Material: LINGERING_POTION
@ -1348,6 +1392,15 @@ Potions:
Children:
GLOWSTONE_DUST: LINGERING_POTION_OF_HASTE_II
REDSTONE: LINGERING_POTION_OF_HASTE_EXTENDED
LINGERING_POTION_OF_HEALTH_BOOST:
Name: Lingering Potion Of Health Boost
Material: LINGERING_POTION
PotionData:
PotionType: UNCRAFTABLE
Effects: ["HEALTH_BOOST 0 450"]
Children:
GLOWSTONE_DUST: LINGERING_POTION_OF_HEALTH_BOOST_II
REDSTONE: LINGERING_POTION_OF_HEALTH_BOOST_EXTENDED
LINGERING_POTION_OF_HUNGER:
Name: Lingering Potion Of Hunger
Material: LINGERING_POTION
@ -1355,8 +1408,8 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["HUNGER 0 225"]
Children:
REDSTONE: LINGERING_POTION_OF_HUNGER_EXTENDED
GLOWSTONE_DUST: LINGERING_POTION_OF_HUNGER_II
REDSTONE: LINGERING_POTION_OF_HUNGER_EXTENDED
LINGERING_POTION_OF_NAUSEA:
Name: Lingering Potion Of Nausea
Material: LINGERING_POTION
@ -1373,8 +1426,8 @@ Potions:
PotionType: UNCRAFTABLE
Effects: ["DAMAGE_RESISTANCE 0 112"]
Children:
GLOWSTONE_DUST: LINGERING_POTION_OF_RESISTANCE_II
REDSTONE: LINGERING_POTION_OF_RESISTANCE_EXTENDED
GLOWSTONE_DUST: LINGERING_POTION_OF_RESISTANCE_II
LINGERING_POTION_OF_SATURATION:
Name: Lingering Potion Of Saturation
Material: LINGERING_POTION
@ -1414,6 +1467,12 @@ Potions:
PotionData:
PotionType: UNCRAFTABLE
Effects: ["FAST_DIGGING 0 1800"]
LINGERING_POTION_OF_HEALTH_BOOST_EXTENDED:
Name: Lingering Potion Of Health Boost Extended
Material: LINGERING_POTION
PotionData:
PotionType: UNCRAFTABLE
Effects: ["HEALTH_BOOST 0 900"]
LINGERING_POTION_OF_HUNGER_EXTENDED:
Name: Lingering Potion Of Hunger Extended
Material: LINGERING_POTION
@ -1468,6 +1527,12 @@ Potions:
PotionData:
PotionType: UNCRAFTABLE
Effects: ["FAST_DIGGING 1 450"]
LINGERING_POTION_OF_HEALTH_BOOST_II:
Name: Lingering Potion Of Health Boost II
Material: LINGERING_POTION
PotionData:
PotionType: UNCRAFTABLE
Effects: ["HEALTH_BOOST 1 225"]
LINGERING_POTION_OF_HUNGER_II:
Name: Lingering Potion Of Hunger II
Material: LINGERING_POTION
@ -1492,3 +1557,4 @@ Potions:
PotionData:
PotionType: UNCRAFTABLE
Effects: ["SATURATION 1 1"]

View File

@ -638,6 +638,17 @@ public class PotionConfigGenerator {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HEALTH_BOOST, (int) (1800 * mod), 0), "HEALTH_BOOST");
children = new HashMap<Ingredient, WriteablePotion>();
if (material == Material.POTION) {
PotionEffect effect = new PotionEffect(data.effect.getType(), (int) (data.effect.getDuration() * 0.75), data.effect.getAmplifier());
children.put(new Ingredient(Material.SULPHUR), new WriteablePotion(Material.SPLASH_POTION, data.data, effect, data.baseName));
} else if (material == Material.SPLASH_POTION) {
PotionEffect effect = new PotionEffect(data.effect.getType(), (int) (data.effect.getDuration() * 0.33), data.effect.getAmplifier());
children.put(new Ingredient(Material.DRAGONS_BREATH), new WriteablePotion(Material.LINGERING_POTION, data.data, effect, data.baseName));
}
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
mcMMOPotions.put(data, children);
}
}
}