mirror of
https://github.com/TotalFreedomMC/TF-WorldGuardExtraFlagsPlugin.git
synced 2024-06-28 14:10:36 +00:00
Also added potion effect types javadoc link
This commit is contained in:
parent
5c69855195
commit
adbe09ad82
|
@ -9,6 +9,12 @@ import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||||
|
|
||||||
public class PotionEffectFlag extends Flag<PotionEffect>
|
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)
|
public PotionEffectFlag(String name)
|
||||||
{
|
{
|
||||||
super(name);
|
super(name);
|
||||||
|
@ -33,12 +39,12 @@ public class PotionEffectFlag extends Flag<PotionEffect>
|
||||||
}
|
}
|
||||||
else
|
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
|
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)
|
public PotionEffect unmarshal(Object o)
|
||||||
{
|
{
|
||||||
String[] splitd = o.toString().split(" ");
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class PotionEffectTypeFlag extends Flag<PotionEffectType>
|
||||||
}
|
}
|
||||||
else
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue