mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 20:52:12 -07:00
SPIGOT-1638 / SPIGOT-1673: Rework Potions API
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -77,7 +77,6 @@ public abstract class AbstractTestingBase {
|
||||
public static void setup() {
|
||||
DispenserRegistry.c();
|
||||
DummyServer.setup();
|
||||
DummyPotions.setup();
|
||||
DummyEnchantments.setup();
|
||||
}
|
||||
}
|
@@ -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() {}
|
||||
}
|
Reference in New Issue
Block a user