SPIGOT-1638 / SPIGOT-1673: Rework Potions API

This commit is contained in:
t00thpick1
2016-03-02 20:43:58 -05:00
committed by md_5
parent 75286088fe
commit 4a8818c5fd
20 changed files with 622 additions and 121 deletions

View File

@@ -30,6 +30,8 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.MapMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import org.bukkit.support.AbstractTestingBase;
import org.junit.Test;
@@ -177,6 +179,7 @@ public class ItemMetaTest extends AbstractTestingBase {
new StackProvider(Material.POTION) {
@Override ItemStack operate(final ItemStack cleanStack) {
final PotionMeta meta = (PotionMeta) cleanStack.getItemMeta();
meta.setBasePotionData(new PotionData(PotionType.UNCRAFTABLE, false, false));
meta.addCustomEffect(PotionEffectType.CONFUSION.createEffect(1, 1), false);
cleanStack.setItemMeta(meta);
return cleanStack;

View File

@@ -14,19 +14,6 @@ import org.bukkit.support.AbstractTestingBase;
import org.junit.Test;
public class PotionTest extends AbstractTestingBase {
@Test
public void getEffects() {
for (PotionType type : PotionType.values()) {
for (PotionEffect effect : new Potion(type).getEffects()) {
PotionEffectType potionType = effect.getType();
assertThat(effect.getType(), is(sameInstance(PotionEffectType.getById(potionType.getId()))));
assertNotNull(potionType.getName(), PotionType.getByEffect(potionType));
}
}
}
@Test
public void testEffectCompleteness() throws Throwable {
Map<PotionType, String> effects = new EnumMap(PotionType.class);
@@ -43,6 +30,6 @@ public class PotionTest extends AbstractTestingBase {
effects.put(enumType, enumType.name());
}
assertEquals(effects.entrySet().size(), PotionType.values().length - /* WATER */ 1);
assertEquals(effects.entrySet().size(), PotionType.values().length - /* PotionTypes with no Effects */ 5);
}
}

View File

@@ -77,7 +77,6 @@ public abstract class AbstractTestingBase {
public static void setup() {
DispenserRegistry.c();
DummyServer.setup();
DummyPotions.setup();
DummyEnchantments.setup();
}
}

View File

@@ -1,17 +0,0 @@
package org.bukkit.support;
import net.minecraft.server.MobEffects;
import org.bukkit.craftbukkit.potion.CraftPotionBrewer;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffectType;
public class DummyPotions {
static {
Potion.setPotionBrewer(new CraftPotionBrewer());
MobEffects.BLINDNESS.getClass();
PotionEffectType.stopAcceptingRegistrations();
}
public static void setup() {}
}