Fix Particle Effects in Minecraft 1.10

This commit is contained in:
Olof Larsson 2016-06-13 09:37:48 +02:00
parent 6da65053ae
commit 1439eef15d
No known key found for this signature in database
GPG Key ID: BBEF14F97DA52474
2 changed files with 31 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import org.bukkit.util.Vector;
import com.massivecraft.massivecore.particleeffect.ReflectionUtils.PackageType; import com.massivecraft.massivecore.particleeffect.ReflectionUtils.PackageType;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.ReflectionUtil;
/** /**
* <b>ParticleEffect Library</b> * <b>ParticleEffect Library</b>
@ -1388,7 +1389,7 @@ public enum ParticleEffect {
return; return;
} }
try { try {
version = Integer.parseInt(Character.toString(PackageType.getServerVersion().charAt(3))); version = ReflectionUtil.getVersionMinor();
if (version > 7) { if (version > 7) {
enumParticle = PackageType.MINECRAFT_SERVER.getClass("EnumParticle"); enumParticle = PackageType.MINECRAFT_SERVER.getClass("EnumParticle");
} }

View File

@ -9,6 +9,8 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import com.massivecraft.massivecore.predicate.Predicate; import com.massivecraft.massivecore.predicate.Predicate;
public class ReflectionUtil public class ReflectionUtil
@ -436,4 +438,31 @@ public class ReflectionUtil
return new IllegalStateException(t.getClass().getSimpleName() + ": " + t.getMessage()); 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; }
} }