Also added potion effect types javadoc link

This commit is contained in:
isokissa3 2018-12-09 00:08:38 +02:00
parent 5c69855195
commit adbe09ad82
2 changed files with 14 additions and 4 deletions

View file

@ -9,6 +9,12 @@ import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
public class PotionEffectFlag extends Flag<PotionEffect>
{
//This is in ticks
//So 20 * 15 gives us 15s of the potion effect
//This avoid the effect running out indication
//Also we add extra 19 ticks (almost a second) to avoid the timer constantly going from 15s to 14s and back (Its annoying)
private static final int POTION_EFFECT_DURATION = 20 * 15 + 19;
public PotionEffectFlag(String name)
{
super(name);
@ -33,12 +39,12 @@ public class PotionEffectFlag extends Flag<PotionEffect>
}
else
{
throw new InvalidFlagFormat("Unable to find the potion effect!");
throw new InvalidFlagFormat("Unable to find the potion effect type! Please refer to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html");
}
}
else
{
throw new InvalidFlagFormat("Please use format: <effect name> <effect amplifier>");
throw new InvalidFlagFormat("Please use the following format: <effect name> <effect amplifier>");
}
}
@ -46,6 +52,10 @@ public class PotionEffectFlag extends Flag<PotionEffect>
public PotionEffect unmarshal(Object o)
{
String[] splitd = o.toString().split(" ");
return new PotionEffect(PotionEffectType.getByName(splitd[0]), 319, new Integer(splitd[1]));
PotionEffectType type = PotionEffectType.getByName(splitd[0]);
int amplifier = Integer.parseInt(splitd[1]);
return new PotionEffect(type, PotionEffectFlag.POTION_EFFECT_DURATION, amplifier);
}
}

View file

@ -29,7 +29,7 @@ public class PotionEffectTypeFlag extends Flag<PotionEffectType>
}
else
{
throw new InvalidFlagFormat("Unable to find the potion effect!");
throw new InvalidFlagFormat("Unable to find the potion effect type! Please refer to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html");
}
}