From adbe09ad82df08a4f8a739411ae4b61048091dbb Mon Sep 17 00:00:00 2001 From: isokissa3 Date: Sun, 9 Dec 2018 00:08:38 +0200 Subject: [PATCH] Also added potion effect types javadoc link --- .../flags/helpers/PotionEffectFlag.java | 16 +++++++++++++--- .../flags/helpers/PotionEffectTypeFlag.java | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectFlag.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectFlag.java index e3cfce0..5b2d09d 100644 --- a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectFlag.java +++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectFlag.java @@ -9,6 +9,12 @@ import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; public class PotionEffectFlag extends Flag { + //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 } 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: "); + throw new InvalidFlagFormat("Please use the following format: "); } } @@ -46,6 +52,10 @@ public class PotionEffectFlag extends Flag 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); } } diff --git a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectTypeFlag.java b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectTypeFlag.java index c687735..7f0ad0f 100644 --- a/WG/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectTypeFlag.java +++ b/WG/src/main/java/net/goldtreeservers/worldguardextraflags/flags/helpers/PotionEffectTypeFlag.java @@ -29,7 +29,7 @@ public class PotionEffectTypeFlag extends Flag } 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"); } }