Forge Support 🎉

This commit is contained in:
Mark Hughes 2016-08-18 16:42:24 +10:00 committed by Olof Larsson
parent 76e7702d2f
commit 30a4c20822
No known key found for this signature in database
GPG Key ID: BBEF14F97DA52474
3 changed files with 44 additions and 1 deletions

View File

@ -56,6 +56,11 @@ public class NmsItemStackCreate17R4P extends NmsItemStackCreate
public static Class<?> getClassCraftItemStack() throws ClassNotFoundException
{
if (ServerType.get() == ServerType.FORGE)
{
return PackageType.MINECRAFT_ITEM.getClass("ItemStack");
}
return PackageType.MINECRAFT_SERVER.getClass("ItemStack");
}

View File

@ -0,0 +1,36 @@
package com.massivecraft.massivecore.nms;
public enum ServerType
{
// -------------------------------------------- //
// ENUM
// -------------------------------------------- //
BUKKIT,
FORGE,
;
// -------------------------------------------- //
// STATIC
// -------------------------------------------- //
private static final ServerType type = determineType();
public static ServerType get() { return type; }
private static ServerType determineType()
{
try
{
// this is a class used by ALL forge based servers
Class.forName("cpw.mods.fml.common.FMLCommonHandler");
return FORGE;
}
catch (Exception e)
{
return BUKKIT;
}
}
}

View File

@ -352,7 +352,9 @@ public final class ReflectionUtils {
* @since 1.0
*/
public enum PackageType {
MINECRAFT_SERVER("net.minecraft.server." + getServerVersion()),
MINECRAFT("net.minecraft"),
MINECRAFT_ITEM(MINECRAFT, "item"),
MINECRAFT_SERVER(MINECRAFT, "server." + getServerVersion()),
CRAFTBUKKIT("org.bukkit.craftbukkit." + getServerVersion()),
CRAFTBUKKIT_BLOCK(CRAFTBUKKIT, "block"),
CRAFTBUKKIT_CHUNKIO(CRAFTBUKKIT, "chunkio"),