diff --git a/src/com/massivecraft/massivecore/particleeffect/ParticleEffect.java b/src/com/massivecraft/massivecore/particleeffect/ParticleEffect.java index 8f49199e..d6edd887 100644 --- a/src/com/massivecraft/massivecore/particleeffect/ParticleEffect.java +++ b/src/com/massivecraft/massivecore/particleeffect/ParticleEffect.java @@ -16,6 +16,7 @@ import org.bukkit.util.Vector; import com.massivecraft.massivecore.particleeffect.ReflectionUtils.PackageType; import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.ReflectionUtil; /** * ParticleEffect Library @@ -1388,7 +1389,7 @@ public enum ParticleEffect { return; } try { - version = Integer.parseInt(Character.toString(PackageType.getServerVersion().charAt(3))); + version = ReflectionUtil.getVersionMinor(); if (version > 7) { enumParticle = PackageType.MINECRAFT_SERVER.getClass("EnumParticle"); } diff --git a/src/com/massivecraft/massivecore/util/ReflectionUtil.java b/src/com/massivecraft/massivecore/util/ReflectionUtil.java index cfc5df8f..c962ba70 100644 --- a/src/com/massivecraft/massivecore/util/ReflectionUtil.java +++ b/src/com/massivecraft/massivecore/util/ReflectionUtil.java @@ -9,6 +9,8 @@ import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; +import org.bukkit.Bukkit; + import com.massivecraft.massivecore.predicate.Predicate; public class ReflectionUtil @@ -436,4 +438,31 @@ public class ReflectionUtil return new IllegalStateException(t.getClass().getSimpleName() + ": " + t.getMessage()); } + // -------------------------------------------- // + // BUKKIT VERSION + // -------------------------------------------- // + + // Example: "v1_9_R4" + private static String versionRaw = Bukkit.getServer().getClass().getPackage().getName().substring(23); + public static String getVersionRaw() { return versionRaw; } + + public static String getVersionRawPart(int index) + { + String versionRaw = getVersionRaw(); + String[] parts = versionRaw.split("_"); + return parts[index]; + } + + // Example: 1 + private static int versionMajor = Integer.valueOf(getVersionRawPart(0).substring(1)); + public static int getVersionMajor() { return versionMajor; } + + // Example: 9 + private static int versionMinor = Integer.valueOf(getVersionRawPart(1)); + public static int getVersionMinor() { return versionMinor; } + + // Example: 4 + private static int versionRelease = Integer.valueOf(getVersionRawPart(2).substring(1)); + public static int getVersionRelease() { return versionRelease; } + }