diff --git a/NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/compat/bukkit/BukkitAttributeAccess.java b/NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/compat/bukkit/BukkitAttributeAccess.java index 4aea09fb..4a17596e 100644 --- a/NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/compat/bukkit/BukkitAttributeAccess.java +++ b/NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/compat/bukkit/BukkitAttributeAccess.java @@ -10,9 +10,16 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; public class BukkitAttributeAccess implements IAttributeAccess { + public BukkitAttributeAccess() { + if (ReflectionUtil.getClass("org.bukkit.attribute.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + private int operationToInt(final Operation operation) { switch (operation) { case ADD_NUMBER: diff --git a/NCPCompatCB2794/src/main/java/fr/neatmonster/nocheatplus/compat/cb2794/AttributeAccess.java b/NCPCompatCB2794/src/main/java/fr/neatmonster/nocheatplus/compat/cb2794/AttributeAccess.java index e596149f..cb69d00f 100644 --- a/NCPCompatCB2794/src/main/java/fr/neatmonster/nocheatplus/compat/cb2794/AttributeAccess.java +++ b/NCPCompatCB2794/src/main/java/fr/neatmonster/nocheatplus/compat/cb2794/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_6_R1.AttributeInstance; import net.minecraft.server.v1_6_R1.AttributeModifier; import net.minecraft.server.v1_6_R1.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_6_R1.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().a(GenericAttributes.d); diff --git a/NCPCompatCB2808/src/main/java/fr/neatmonster/nocheatplus/compat/cb2808/AttributeAccess.java b/NCPCompatCB2808/src/main/java/fr/neatmonster/nocheatplus/compat/cb2808/AttributeAccess.java index 8fe18b26..3ff96635 100644 --- a/NCPCompatCB2808/src/main/java/fr/neatmonster/nocheatplus/compat/cb2808/AttributeAccess.java +++ b/NCPCompatCB2808/src/main/java/fr/neatmonster/nocheatplus/compat/cb2808/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_6_R2.AttributeInstance; import net.minecraft.server.v1_6_R2.AttributeModifier; import net.minecraft.server.v1_6_R2.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_6_R2.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d); diff --git a/NCPCompatCB2882/src/main/java/fr/neatmonster/nocheatplus/compat/cb2882/AttributeAccess.java b/NCPCompatCB2882/src/main/java/fr/neatmonster/nocheatplus/compat/cb2882/AttributeAccess.java index ab83fdfb..dababf26 100644 --- a/NCPCompatCB2882/src/main/java/fr/neatmonster/nocheatplus/compat/cb2882/AttributeAccess.java +++ b/NCPCompatCB2882/src/main/java/fr/neatmonster/nocheatplus/compat/cb2882/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_6_R3.AttributeInstance; import net.minecraft.server.v1_6_R3.AttributeModifier; import net.minecraft.server.v1_6_R3.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_6_R3.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d); diff --git a/NCPCompatCB2922/src/main/java/fr/neatmonster/nocheatplus/compat/cb2922/AttributeAccess.java b/NCPCompatCB2922/src/main/java/fr/neatmonster/nocheatplus/compat/cb2922/AttributeAccess.java index c33ad971..73538fea 100644 --- a/NCPCompatCB2922/src/main/java/fr/neatmonster/nocheatplus/compat/cb2922/AttributeAccess.java +++ b/NCPCompatCB2922/src/main/java/fr/neatmonster/nocheatplus/compat/cb2922/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_7_R1.AttributeInstance; import net.minecraft.server.v1_7_R1.AttributeModifier; import net.minecraft.server.v1_7_R1.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_7_R1.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d); diff --git a/NCPCompatCB3026/src/main/java/fr/neatmonster/nocheatplus/compat/cb3026/AttributeAccess.java b/NCPCompatCB3026/src/main/java/fr/neatmonster/nocheatplus/compat/cb3026/AttributeAccess.java index 47e2b49b..d36daf2e 100644 --- a/NCPCompatCB3026/src/main/java/fr/neatmonster/nocheatplus/compat/cb3026/AttributeAccess.java +++ b/NCPCompatCB3026/src/main/java/fr/neatmonster/nocheatplus/compat/cb3026/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_7_R2.AttributeInstance; import net.minecraft.server.v1_7_R2.AttributeModifier; import net.minecraft.server.v1_7_R2.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_7_R2.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d); diff --git a/NCPCompatCB3043/src/main/java/fr/neatmonster/nocheatplus/compat/cb3043/AttributeAccess.java b/NCPCompatCB3043/src/main/java/fr/neatmonster/nocheatplus/compat/cb3043/AttributeAccess.java index 3e1b7393..7bff4a43 100644 --- a/NCPCompatCB3043/src/main/java/fr/neatmonster/nocheatplus/compat/cb3043/AttributeAccess.java +++ b/NCPCompatCB3043/src/main/java/fr/neatmonster/nocheatplus/compat/cb3043/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_7_R3.AttributeInstance; import net.minecraft.server.v1_7_R3.AttributeModifier; import net.minecraft.server.v1_7_R3.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_7_R3.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d); diff --git a/NCPCompatCB3100/src/main/java/fr/neatmonster/nocheatplus/compat/cb3100/AttributeAccess.java b/NCPCompatCB3100/src/main/java/fr/neatmonster/nocheatplus/compat/cb3100/AttributeAccess.java index ba668516..c5e42584 100644 --- a/NCPCompatCB3100/src/main/java/fr/neatmonster/nocheatplus/compat/cb3100/AttributeAccess.java +++ b/NCPCompatCB3100/src/main/java/fr/neatmonster/nocheatplus/compat/cb3100/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_7_R4.AttributeInstance; import net.minecraft.server.v1_7_R4.AttributeModifier; import net.minecraft.server.v1_7_R4.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_7_R4.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(final Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d); diff --git a/NCPCompatCBDev/src/main/java/fr/neatmonster/nocheatplus/compat/cbdev/AttributeAccess.java b/NCPCompatCBDev/src/main/java/fr/neatmonster/nocheatplus/compat/cbdev/AttributeAccess.java index 1f54f470..8a577e06 100644 --- a/NCPCompatCBDev/src/main/java/fr/neatmonster/nocheatplus/compat/cbdev/AttributeAccess.java +++ b/NCPCompatCBDev/src/main/java/fr/neatmonster/nocheatplus/compat/cbdev/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_10_R1.AttributeInstance; import net.minecraft.server.v1_10_R1.AttributeModifier; import net.minecraft.server.v1_10_R1.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_10_R1.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); diff --git a/NCPCompatSpigotCB1_8_R1/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R1/AttributeAccess.java b/NCPCompatSpigotCB1_8_R1/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R1/AttributeAccess.java index dbaa9de0..aa17dbf0 100644 --- a/NCPCompatSpigotCB1_8_R1/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R1/AttributeAccess.java +++ b/NCPCompatSpigotCB1_8_R1/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R1/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_8_R1.AttributeInstance; import net.minecraft.server.v1_8_R1.AttributeModifier; import net.minecraft.server.v1_8_R1.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_8_R1.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d); diff --git a/NCPCompatSpigotCB1_8_R2/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R2/AttributeAccess.java b/NCPCompatSpigotCB1_8_R2/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R2/AttributeAccess.java index 541e99ef..d1b66d30 100644 --- a/NCPCompatSpigotCB1_8_R2/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R2/AttributeAccess.java +++ b/NCPCompatSpigotCB1_8_R2/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R2/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_8_R2.AttributeInstance; import net.minecraft.server.v1_8_R2.AttributeModifier; import net.minecraft.server.v1_8_R2.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_8_R2.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d); diff --git a/NCPCompatSpigotCB1_8_R3/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R3/AttributeAccess.java b/NCPCompatSpigotCB1_8_R3/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R3/AttributeAccess.java index ae9db58f..325b3fca 100644 --- a/NCPCompatSpigotCB1_8_R3/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R3/AttributeAccess.java +++ b/NCPCompatSpigotCB1_8_R3/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_8_R3/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_8_R3.AttributeInstance; import net.minecraft.server.v1_8_R3.AttributeModifier; import net.minecraft.server.v1_8_R3.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_8_R3.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); diff --git a/NCPCompatSpigotCB1_9_R1/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_9_R1/AttributeAccess.java b/NCPCompatSpigotCB1_9_R1/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_9_R1/AttributeAccess.java index 1ba3e173..e3856834 100644 --- a/NCPCompatSpigotCB1_9_R1/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_9_R1/AttributeAccess.java +++ b/NCPCompatSpigotCB1_9_R1/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_9_R1/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_9_R1.AttributeInstance; import net.minecraft.server.v1_9_R1.AttributeModifier; import net.minecraft.server.v1_9_R1.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_9_R1.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); diff --git a/NCPCompatSpigotCB1_9_R2/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_9_R2/AttributeAccess.java b/NCPCompatSpigotCB1_9_R2/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_9_R2/AttributeAccess.java index 7f0679f7..7468ffef 100644 --- a/NCPCompatSpigotCB1_9_R2/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_9_R2/AttributeAccess.java +++ b/NCPCompatSpigotCB1_9_R2/src/main/java/fr/neatmonster/nocheatplus/compat/spigotcb1_9_R2/AttributeAccess.java @@ -5,12 +5,19 @@ import org.bukkit.entity.Player; import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess; import fr.neatmonster.nocheatplus.utilities.AttribUtil; +import fr.neatmonster.nocheatplus.utilities.ReflectionUtil; import net.minecraft.server.v1_9_R2.AttributeInstance; import net.minecraft.server.v1_9_R2.AttributeModifier; import net.minecraft.server.v1_9_R2.GenericAttributes; public class AttributeAccess implements IAttributeAccess { + public AttributeAccess() { + if (ReflectionUtil.getClass("net.minecraft.server.v1_9_R2.AttributeInstance") == null) { + throw new RuntimeException("Service not available."); + } + } + @Override public double getSpeedAttributeMultiplier(Player player) { final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/AttributeAccessFactory.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/AttributeAccessFactory.java index 6d317dcc..438fafcf 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/AttributeAccessFactory.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/compat/AttributeAccessFactory.java @@ -22,7 +22,7 @@ public class AttributeAccessFactory { } catch (Throwable t) {} RegistryHelper.setupGenericInstance(new String[] { - "fr.neatmonster.nocheatplus.compat.cbdev", + "fr.neatmonster.nocheatplus.compat.cbdev.AttributeAccess", "fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2.AttributeAccess", "fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1.AttributeAccess", "fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3.AttributeAccess",