mirror of
https://github.com/TotalFreedomMC/TF-WorldGuardExtraFlagsPlugin.git
synced 2024-06-01 01:11:19 +00:00
42 lines
949 B
Java
42 lines
949 B
Java
package net.goldtreeservers.worldguardextraflags.flags.helpers;
|
|
|
|
import org.bukkit.potion.PotionEffectType;
|
|
|
|
import com.sk89q.worldguard.protection.flags.Flag;
|
|
import com.sk89q.worldguard.protection.flags.FlagContext;
|
|
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
|
|
|
public class PotionEffectTypeFlag extends Flag<PotionEffectType>
|
|
{
|
|
public PotionEffectTypeFlag(String name)
|
|
{
|
|
super(name);
|
|
}
|
|
|
|
@Override
|
|
public Object marshal(PotionEffectType o)
|
|
{
|
|
return o.getName();
|
|
}
|
|
|
|
@Override
|
|
public PotionEffectType parseInput(FlagContext context) throws InvalidFlagFormat
|
|
{
|
|
PotionEffectType potionEffect = PotionEffectType.getByName(context.getUserInput().trim());
|
|
if (potionEffect != null)
|
|
{
|
|
return potionEffect;
|
|
}
|
|
else
|
|
{
|
|
throw new InvalidFlagFormat("Unable to find the potion effect!");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public PotionEffectType unmarshal(Object o)
|
|
{
|
|
return PotionEffectType.getByName(o.toString());
|
|
}
|
|
}
|