mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-12-25 18:27:36 +01:00
Remove Forge support as it was used only in 1.7
This commit is contained in:
parent
4214b251cf
commit
6d095f8165
@ -20,8 +20,6 @@ import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
|||||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_10_R1.Entity;
|
import net.minecraft.server.v1_10_R1.Entity;
|
||||||
import net.minecraft.server.v1_10_R1.EntityTypes;
|
import net.minecraft.server.v1_10_R1.EntityTypes;
|
||||||
import net.minecraft.server.v1_10_R1.MathHelper;
|
import net.minecraft.server.v1_10_R1.MathHelper;
|
||||||
@ -42,16 +40,10 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||||
public void registerCustomEntity(Class entityClass, String name, int id) throws Exception {
|
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
throw new UnsupportedOperationException("Forge based servers are not supported");
|
|
||||||
} else {
|
|
||||||
// Normal entity registration.
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
|
@ -20,8 +20,6 @@ import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
|||||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_11_R1.Entity;
|
import net.minecraft.server.v1_11_R1.Entity;
|
||||||
import net.minecraft.server.v1_11_R1.EntityTypes;
|
import net.minecraft.server.v1_11_R1.EntityTypes;
|
||||||
import net.minecraft.server.v1_11_R1.MathHelper;
|
import net.minecraft.server.v1_11_R1.MathHelper;
|
||||||
@ -44,9 +42,6 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
throw new UnsupportedOperationException("Forge based servers are not supported");
|
|
||||||
} else {
|
|
||||||
// Use reflection to get the RegistryID of entities.
|
// Use reflection to get the RegistryID of entities.
|
||||||
RegistryID<Class<? extends Entity>> registryID = (RegistryID<Class<? extends Entity>>) ReflectionUtils.getPrivateField(RegistryMaterials.class, EntityTypes.b, "a");
|
RegistryID<Class<? extends Entity>> registryID = (RegistryID<Class<? extends Entity>>) ReflectionUtils.getPrivateField(RegistryMaterials.class, EntityTypes.b, "a");
|
||||||
Object[] idToClassMap = (Object[]) ReflectionUtils.getPrivateField(RegistryID.class, registryID, "d");
|
Object[] idToClassMap = (Object[]) ReflectionUtils.getPrivateField(RegistryID.class, registryID, "d");
|
||||||
@ -60,7 +55,6 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
// Restore the ID -> entity class mapping.
|
// Restore the ID -> entity class mapping.
|
||||||
idToClassMap[id] = oldValue;
|
idToClassMap[id] = oldValue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
|
@ -20,8 +20,6 @@ import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
|||||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_12_R1.Entity;
|
import net.minecraft.server.v1_12_R1.Entity;
|
||||||
import net.minecraft.server.v1_12_R1.EntityTypes;
|
import net.minecraft.server.v1_12_R1.EntityTypes;
|
||||||
import net.minecraft.server.v1_12_R1.MathHelper;
|
import net.minecraft.server.v1_12_R1.MathHelper;
|
||||||
@ -44,9 +42,6 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
throw new UnsupportedOperationException("Forge based servers are not supported");
|
|
||||||
} else {
|
|
||||||
// Use reflection to get the RegistryID of entities.
|
// Use reflection to get the RegistryID of entities.
|
||||||
RegistryID<Class<? extends Entity>> registryID = (RegistryID<Class<? extends Entity>>) ReflectionUtils.getPrivateField(RegistryMaterials.class, EntityTypes.b, "a");
|
RegistryID<Class<? extends Entity>> registryID = (RegistryID<Class<? extends Entity>>) ReflectionUtils.getPrivateField(RegistryMaterials.class, EntityTypes.b, "a");
|
||||||
Object[] idToClassMap = (Object[]) ReflectionUtils.getPrivateField(RegistryID.class, registryID, "d");
|
Object[] idToClassMap = (Object[]) ReflectionUtils.getPrivateField(RegistryID.class, registryID, "d");
|
||||||
@ -60,7 +55,6 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
// Restore the ID -> entity class mapping.
|
// Restore the ID -> entity class mapping.
|
||||||
idToClassMap[id] = oldValue;
|
idToClassMap[id] = oldValue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
|
@ -21,8 +21,6 @@ import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
|||||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_13_R1.Entity;
|
import net.minecraft.server.v1_13_R1.Entity;
|
||||||
import net.minecraft.server.v1_13_R1.EntityTypes;
|
import net.minecraft.server.v1_13_R1.EntityTypes;
|
||||||
import net.minecraft.server.v1_13_R1.MathHelper;
|
import net.minecraft.server.v1_13_R1.MathHelper;
|
||||||
@ -45,9 +43,6 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
public void registerCustomEntity(Class<? extends Entity> entityClass, int id) throws Exception {
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
throw new UnsupportedOperationException("Forge based servers are not supported");
|
|
||||||
} else {
|
|
||||||
// Use reflection to get the RegistryID of entities.
|
// Use reflection to get the RegistryID of entities.
|
||||||
RegistryID<EntityTypes<?>> registryID = (RegistryID<EntityTypes<?>>) ReflectionUtils.getPrivateField(RegistryMaterials.class, EntityTypes.REGISTRY, "a");
|
RegistryID<EntityTypes<?>> registryID = (RegistryID<EntityTypes<?>>) ReflectionUtils.getPrivateField(RegistryMaterials.class, EntityTypes.REGISTRY, "a");
|
||||||
Object[] idToClassMap = (Object[]) ReflectionUtils.getPrivateField(RegistryID.class, registryID, "d");
|
Object[] idToClassMap = (Object[]) ReflectionUtils.getPrivateField(RegistryID.class, registryID, "d");
|
||||||
@ -68,7 +63,6 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
// Restore the ID -> EntityTypes mapping.
|
// Restore the ID -> EntityTypes mapping.
|
||||||
idToClassMap[id] = oldValue;
|
idToClassMap[id] = oldValue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
|
@ -20,8 +20,6 @@ import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
|||||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R1.Entity;
|
import net.minecraft.server.v1_8_R1.Entity;
|
||||||
import net.minecraft.server.v1_8_R1.EntityTypes;
|
import net.minecraft.server.v1_8_R1.EntityTypes;
|
||||||
import net.minecraft.server.v1_8_R1.MathHelper;
|
import net.minecraft.server.v1_8_R1.MathHelper;
|
||||||
@ -38,25 +36,14 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
||||||
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
||||||
|
|
||||||
if (!VersionUtils.isForgeServer()) {
|
|
||||||
validateEntityMethod = World.class.getDeclaredMethod("a", Entity.class);
|
validateEntityMethod = World.class.getDeclaredMethod("a", Entity.class);
|
||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||||
public void registerCustomEntity(Class entityClass, String name, int id) throws Exception {
|
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
// Forge entity registration.
|
|
||||||
Class<?> entityTypesClass = Class.forName("net.minecraft.server.v1_8_R1.EntityTypes");
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(entityTypesClass, "field_75626_c", entityClass, name);
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(entityTypesClass, "field_75624_e", entityClass, Integer.valueOf(id));
|
|
||||||
} else {
|
|
||||||
// Normal entity registration.
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
|
@ -20,8 +20,6 @@ import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
|||||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R2.Entity;
|
import net.minecraft.server.v1_8_R2.Entity;
|
||||||
import net.minecraft.server.v1_8_R2.EntityTypes;
|
import net.minecraft.server.v1_8_R2.EntityTypes;
|
||||||
import net.minecraft.server.v1_8_R2.MathHelper;
|
import net.minecraft.server.v1_8_R2.MathHelper;
|
||||||
@ -38,25 +36,14 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
||||||
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
||||||
|
|
||||||
if (!VersionUtils.isForgeServer()) {
|
|
||||||
validateEntityMethod = World.class.getDeclaredMethod("a", Entity.class);
|
validateEntityMethod = World.class.getDeclaredMethod("a", Entity.class);
|
||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||||
public void registerCustomEntity(Class entityClass, String name, int id) throws Exception {
|
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
// Forge entity registration.
|
|
||||||
Class<?> entityTypesClass = Class.forName("net.minecraft.server.v1_8_R2.EntityTypes");
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(entityTypesClass, "field_75626_c", entityClass, name);
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(entityTypesClass, "field_75624_e", entityClass, Integer.valueOf(id));
|
|
||||||
} else {
|
|
||||||
// Normal entity registration.
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
|
@ -20,8 +20,6 @@ import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
|||||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R3.Entity;
|
import net.minecraft.server.v1_8_R3.Entity;
|
||||||
import net.minecraft.server.v1_8_R3.EntityTypes;
|
import net.minecraft.server.v1_8_R3.EntityTypes;
|
||||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||||
@ -38,25 +36,14 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
registerCustomEntity(EntityNMSItem.class, "Item", 1);
|
||||||
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
registerCustomEntity(EntityNMSSlime.class, "Slime", 55);
|
||||||
|
|
||||||
if (!VersionUtils.isForgeServer()) {
|
|
||||||
validateEntityMethod = World.class.getDeclaredMethod("a", Entity.class);
|
validateEntityMethod = World.class.getDeclaredMethod("a", Entity.class);
|
||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||||
public void registerCustomEntity(Class entityClass, String name, int id) throws Exception {
|
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
// Forge entity registration.
|
|
||||||
Class<?> entityTypesClass = Class.forName("net.minecraft.server.v1_8_R3.EntityTypes");
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(entityTypesClass, "field_75626_c", entityClass, name);
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(entityTypesClass, "field_75624_e", entityClass, Integer.valueOf(id));
|
|
||||||
} else {
|
|
||||||
// Normal entity registration.
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
|
@ -19,7 +19,6 @@ import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
|||||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_9_R1.Entity;
|
import net.minecraft.server.v1_9_R1.Entity;
|
||||||
import net.minecraft.server.v1_9_R1.EntityTypes;
|
import net.minecraft.server.v1_9_R1.EntityTypes;
|
||||||
@ -41,16 +40,10 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||||
public void registerCustomEntity(Class entityClass, String name, int id) throws Exception {
|
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
throw new UnsupportedOperationException("Forge based servers are not supported");
|
|
||||||
} else {
|
|
||||||
// Normal entity registration.
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
|
@ -20,8 +20,6 @@ import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
|
|||||||
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
import com.gmail.filoghost.holographicdisplays.util.Validator;
|
||||||
import com.gmail.filoghost.holographicdisplays.util.VersionUtils;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_9_R2.Entity;
|
import net.minecraft.server.v1_9_R2.Entity;
|
||||||
import net.minecraft.server.v1_9_R2.EntityTypes;
|
import net.minecraft.server.v1_9_R2.EntityTypes;
|
||||||
import net.minecraft.server.v1_9_R2.MathHelper;
|
import net.minecraft.server.v1_9_R2.MathHelper;
|
||||||
@ -42,16 +40,10 @@ public class NmsManagerImpl implements NMSManager {
|
|||||||
validateEntityMethod.setAccessible(true);
|
validateEntityMethod.setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
public void registerCustomEntity(Class<?> entityClass, String name, int id) throws Exception {
|
||||||
public void registerCustomEntity(Class entityClass, String name, int id) throws Exception {
|
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
throw new UnsupportedOperationException("Forge based servers are not supported");
|
|
||||||
} else {
|
|
||||||
// Normal entity registration.
|
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "d", entityClass, name);
|
||||||
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
ReflectionUtils.putInPrivateStaticMap(EntityTypes.class, "f", entityClass, Integer.valueOf(id));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
public NMSItem spawnNMSItem(org.bukkit.World bukkitWorld, double x, double y, double z, ItemLine parentPiece, ItemStack stack, ItemPickupManager itemPickupManager) {
|
||||||
|
@ -111,16 +111,7 @@ public class HolographicDisplays extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
getLogger().info("Trying to enable Forge support...");
|
|
||||||
}
|
|
||||||
|
|
||||||
nmsManager.setup();
|
nmsManager.setup();
|
||||||
|
|
||||||
if (VersionUtils.isForgeServer()) {
|
|
||||||
getLogger().info("Successfully added Forge support!");
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
printWarnAndDisable(
|
printWarnAndDisable(
|
||||||
|
@ -21,31 +21,6 @@ public class VersionUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method uses a regex to get the version of this Minecraft release.
|
|
||||||
* Example: 1.8.1
|
|
||||||
* @return the version of this release or null if not found.
|
|
||||||
*/
|
|
||||||
public static String extractMinecraftVersion() {
|
|
||||||
Matcher matcher = Pattern.compile("(\\(MC: )([\\d\\.]+)(\\))").matcher(Bukkit.getVersion());
|
|
||||||
if (matcher.find()) {
|
|
||||||
return matcher.group(2);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return if the server is based on Forge.
|
|
||||||
*/
|
|
||||||
public static boolean isForgeServer() {
|
|
||||||
try {
|
|
||||||
Class.forName("net.minecraftforge.common.MinecraftForge");
|
|
||||||
return true;
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 1 if reference > comparison, 0 if reference == comparison, -1 if reference < comparison
|
* @return 1 if reference > comparison, 0 if reference == comparison, -1 if reference < comparison
|
||||||
|
Loading…
Reference in New Issue
Block a user