#1404: Add PotionEffectTypeCategory to distinguish between beneficial and harmful effects
By: 2008Choco <hawkeboyz2@hotmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import org.bukkit.craftbukkit.CraftRegistry;
|
||||
import org.bukkit.craftbukkit.util.Handleable;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionEffectTypeCategory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CraftPotionEffectType extends PotionEffectType implements Handleable<MobEffectList> {
|
||||
@@ -112,6 +113,11 @@ public class CraftPotionEffectType extends PotionEffectType implements Handleabl
|
||||
return handle.isInstantenous();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PotionEffectTypeCategory getCategory() {
|
||||
return CraftPotionEffectTypeCategory.minecraftToBukkit(handle.getCategory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor() {
|
||||
return Color.fromRGB(handle.getColor());
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.bukkit.craftbukkit.potion;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.effect.MobEffectInfo;
|
||||
import org.bukkit.potion.PotionEffectTypeCategory;
|
||||
|
||||
public final class CraftPotionEffectTypeCategory {
|
||||
|
||||
public static PotionEffectTypeCategory minecraftToBukkit(MobEffectInfo minecraft) {
|
||||
Preconditions.checkArgument(minecraft != null);
|
||||
return PotionEffectTypeCategory.valueOf(minecraft.name());
|
||||
}
|
||||
|
||||
public static MobEffectInfo bukkitToMinecraft(PotionEffectTypeCategory bukkit) {
|
||||
Preconditions.checkArgument(bukkit != null);
|
||||
return MobEffectInfo.valueOf(bukkit.name());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user