#962: Make PotionEffectType implement Keyed
This commit is contained in:
parent
806bb02c17
commit
af8a8b708c
@ -8,7 +8,7 @@ public class CraftPotionEffectType extends PotionEffectType {
|
|||||||
private final MobEffectList handle;
|
private final MobEffectList handle;
|
||||||
|
|
||||||
public CraftPotionEffectType(MobEffectList handle) {
|
public CraftPotionEffectType(MobEffectList handle) {
|
||||||
super(MobEffectList.getId(handle));
|
super(MobEffectList.getId(handle), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(net.minecraft.core.IRegistry.MOB_EFFECT.getKey(handle)));
|
||||||
this.handle = handle;
|
this.handle = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
src/test/java/org/bukkit/PotionEffectTypeTest.java
Normal file
33
src/test/java/org/bukkit/PotionEffectTypeTest.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package org.bukkit;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.core.IRegistry;
|
||||||
|
import net.minecraft.resources.MinecraftKey;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.support.AbstractTestingBase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class PotionEffectTypeTest extends AbstractTestingBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyMapping() {
|
||||||
|
List<PotionEffectType> effects = Lists.newArrayList(PotionEffectType.values());
|
||||||
|
|
||||||
|
for (MinecraftKey key : IRegistry.MOB_EFFECT.keySet()) {
|
||||||
|
String name = key.getPath();
|
||||||
|
PotionEffectType effect = PotionEffectType.getByKey(CraftNamespacedKey.fromMinecraft(key));
|
||||||
|
|
||||||
|
String message = String.format("org.bukkit.PotionEffectType is missing '%s'", name);
|
||||||
|
assertNotNull(message, effect);
|
||||||
|
|
||||||
|
effects.remove(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThat("org.bukkit.PotionEffectType has too many effects", effects, is(Collections.EMPTY_LIST));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user