[BREAKING] Generic instance based attribute access.

MCAccess will be split into smaller providers with time, so do expect
more breaking changes of this type. If this is an issue, please contact
us, so we can see how to smoothen things. E.g. we could still make
MCAccess an aggregate, that just delegates to the more fine grained
providers, or we could provide other 
(default) aggregates.

This also adds a Bukkit-based provider for future updates.
This commit is contained in:
asofold 2016-06-09 18:57:20 +02:00
parent 8ba1f2cf74
commit 765383834b
49 changed files with 789 additions and 789 deletions

View File

@ -17,7 +17,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<version>1.9.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -0,0 +1,65 @@
package fr.neatmonster.nocheatplus.compat.bukkit;
import java.util.UUID;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.attribute.AttributeModifier.Operation;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
public class BukkitAttributeAccess implements IAttributeAccess {
private int operationToInt(final Operation operation) {
switch (operation) {
case ADD_NUMBER:
return 0;
case ADD_SCALAR:
return 1;
case MULTIPLY_SCALAR_1:
return 2;
default:
throw new RuntimeException("Unknown operation: " + operation);
}
}
/**
* The first modifier with the given id that can be found, or null if none
* is found.
*
* @param attrInst
* @param id
* @return
*/
private AttributeModifier getModifier(final AttributeInstance attrInst, final UUID id) {
for (final AttributeModifier mod : attrInst.getModifiers()) {
if (id.equals(mod.getUniqueId())) {
return mod;
}
}
return null;
}
private double getMultiplier(final AttributeModifier mod) {
return AttribUtil.getMultiplier(operationToInt(mod.getOperation()), mod.getAmount());
}
@Override
public double getSpeedAttributeMultiplier(final Player player) {
final AttributeInstance attrInst = player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED);
final double val = attrInst.getValue() / attrInst.getBaseValue();
final AttributeModifier mod = getModifier(attrInst, AttribUtil.ID_SPRINT_BOOST);
return mod == null ? val : (val / getMultiplier(mod));
}
@Override
public double getSprintAttributeMultiplier(final Player player) {
final AttributeInstance attrInst = player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED);
final AttributeModifier mod = getModifier(attrInst, AttribUtil.ID_SPRINT_BOOST);
return mod == null ? 1.0 : getMultiplier(mod);
}
}

View File

@ -243,16 +243,6 @@ public class MCAccessBukkitBase implements MCAccess {
return PotionUtil.getPotionEffectAmplifier(player, PotionEffectType.SPEED);
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public double getSprintAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public int getInvulnerableTicks(final Player player) {
return Integer.MAX_VALUE; // NOT SUPPORTED.

View File

@ -31,7 +31,7 @@ import fr.neatmonster.nocheatplus.utilities.BlockCache;
public class MCAccessCBReflect extends MCAccessBukkitBase {
protected final ReflectHelper helper;
/** Generally supported Minecraft version (know for sure). */
protected final boolean knownSupportedVersion;
/** We know for sure that dealFallDamage will fire a damage event. */
@ -149,26 +149,6 @@ public class MCAccessCBReflect extends MCAccessBukkitBase {
}
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
try {
return helper.getSpeedAttributeMultiplier(player, true);
}
catch (ReflectFailureException ex) {
return super.getSpeedAttributeMultiplier(player);
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
try {
return helper.getSprintAttributeMultiplier(player);
}
catch (ReflectFailureException ex) {
return super.getSprintAttributeMultiplier(player);
}
}
@Override
public AlmostBoolean isBlockSolid(final int id) {
try {

View File

@ -1,62 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbreflect.reflect;
import java.lang.reflect.Method;
import java.util.UUID;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
public class ReflectAttributeInstance {
/** (Custom naming.) */
public final Method nmsGetBaseValue;
public final Method nmsGetValue;
/** (Custom naming.) */
public final Method nmsGetAttributeModifier;
public ReflectAttributeInstance(ReflectBase base) throws ClassNotFoundException {
Class<?> clazz = Class.forName(base.nmsPackageName + ".AttributeInstance");
// Base value.
Method method = ReflectionUtil.getMethodNoArgs(clazz, "b", double.class);
if (method == null) {
// TODO: Consider to search (as long as only two exist).
method = ReflectionUtil.getMethodNoArgs(clazz, "getBaseValue", double.class);
if (method == null) {
method = ReflectionUtil.getMethodNoArgs(clazz, "getBase", double.class);
}
}
nmsGetBaseValue = method;
// Value (final value).
method = ReflectionUtil.getMethodNoArgs(clazz, "getValue", double.class);
if (method == null) {
// TODO: Consider to search (as long as only two exist).
method = ReflectionUtil.getMethodNoArgs(clazz, "e", double.class); // 1.6.1
}
nmsGetValue = method;
// Get AttributeModifier.
// TODO: If name changes: scan.
method = ReflectionUtil.getMethod(clazz, "a", UUID.class);
if (method == null) {
method = ReflectionUtil.getMethod(clazz, "getAttributeModifier", UUID.class);
if (method == null) {
method = ReflectionUtil.getMethod(clazz, "getModifier", UUID.class);
}
}
nmsGetAttributeModifier = method;
}
}

View File

@ -1,35 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbreflect.reflect;
import java.lang.reflect.Method;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
public class ReflectAttributeModifier {
/** (Custom naming.) */
public Method nmsGetOperation;
/** (Custom naming.) */
public Method nmsGetValue;
public ReflectAttributeModifier(ReflectBase base) throws ClassNotFoundException {
Class<?> clazz = Class.forName(base.nmsPackageName + ".AttributeModifier");
// TODO: Scan in a more future proof way.
nmsGetOperation = ReflectionUtil.getMethodNoArgs(clazz, "c", int.class);
nmsGetValue = ReflectionUtil.getMethodNoArgs(clazz, "d", double.class);
}
}

View File

@ -1,36 +0,0 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.neatmonster.nocheatplus.compat.cbreflect.reflect;
import java.lang.reflect.Field;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
public class ReflectGenericAttributes {
public final Object nmsMOVEMENT_SPEED;
public ReflectGenericAttributes(ReflectBase base) throws ClassNotFoundException {
Class<?> clazz = Class.forName(base.nmsPackageName + ".GenericAttributes");
Field field = ReflectionUtil.getField(clazz, "MOVEMENT_SPEED", null);
if (field != null) {
nmsMOVEMENT_SPEED = ReflectionUtil.get(field, clazz, null);
}
else {
nmsMOVEMENT_SPEED = null;
}
}
}

View File

@ -26,7 +26,6 @@ import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.logging.Streams;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
@ -71,11 +70,6 @@ public class ReflectHelper {
protected final ReflectEntityDamage reflectEntity;
protected final ReflectPlayer reflectPlayer;
protected final ReflectGenericAttributes reflectGenericAttributes;
protected final ReflectAttributeInstance reflectAttributeInstance;
protected final ReflectAttributeModifier reflectAttributeModifier;
protected final boolean hasAttributes;
public ReflectHelper() throws ReflectFailureException {
// TODO: Allow some to not work?
try {
@ -93,21 +87,6 @@ public class ReflectHelper {
this.reflectDamageSource = new ReflectDamageSource(this.reflectBase);
this.reflectEntity = new ReflectEntityDamage(this.reflectBase, this.reflectDamageSource);
this.reflectPlayer = new ReflectPlayer(this.reflectBase, this.reflectDamageSource);
ReflectGenericAttributes reflectGenericAttributes = null;
ReflectAttributeInstance reflectAttributeInstance = null;
ReflectAttributeModifier reflectAttributeModifier = null;
boolean hasAttributes = false;
try {
reflectGenericAttributes = new ReflectGenericAttributes(this.reflectBase);
reflectAttributeInstance = new ReflectAttributeInstance(this.reflectBase);
reflectAttributeModifier = new ReflectAttributeModifier(this.reflectBase);
hasAttributes = true; // TODO: null checks (...).
}
catch (ClassNotFoundException ex) {}
this.reflectGenericAttributes = reflectGenericAttributes;
this.reflectAttributeInstance = reflectAttributeInstance;
this.reflectAttributeModifier = reflectAttributeModifier;
this.hasAttributes = hasAttributes;
}
catch (ClassNotFoundException ex) {
throw new ReflectFailureException(ex);
@ -240,69 +219,6 @@ public class ReflectHelper {
}
}
/**
* Get the speed attribute (MOVEMENT_SPEED) for a player.
* @param handle EntityPlayer
* @return AttributeInstance
*/
public Object getMovementSpeedAttributeInstance(Player player) {
if (!hasAttributes || this.reflectPlayer.nmsGetAttributeInstance == null || this.reflectGenericAttributes.nmsMOVEMENT_SPEED == null) {
fail();
}
return ReflectionUtil.invokeMethod(this.reflectPlayer.nmsGetAttributeInstance, getHandle(player), this.reflectGenericAttributes.nmsMOVEMENT_SPEED);
}
/**
*
* @param player
* @param removeSprint If to calculate away the sprint boost modifier.
* @return
*/
public double getSpeedAttributeMultiplier(Player player, boolean removeSprint) {
if (!hasAttributes || this.reflectAttributeInstance.nmsGetValue == null ||
this.reflectAttributeInstance.nmsGetBaseValue == null) {
fail();
}
Object attributeInstance = getMovementSpeedAttributeInstance(player);
double val = ((Double) ReflectionUtil.invokeMethodNoArgs(this.reflectAttributeInstance.nmsGetValue, attributeInstance)).doubleValue() / ((Double) ReflectionUtil.invokeMethodNoArgs(this.reflectAttributeInstance.nmsGetBaseValue, attributeInstance)).doubleValue();
if (!removeSprint) {
return val;
}
else {
return val / nmsAttributeInstance_getAttributeModifierMultiplier(attributeInstance);
}
}
public double getSprintAttributeMultiplier(Player player) {
if (!hasAttributes || this.reflectAttributeModifier.nmsGetOperation == null || this.reflectAttributeModifier.nmsGetValue == null) {
fail();
}
Object attributeInstance = getMovementSpeedAttributeInstance(player);
if (attributeInstance == null) {
fail();
}
return nmsAttributeInstance_getAttributeModifierMultiplier(attributeInstance);
}
/**
* (Not an existing method.)
* @param attributeInstance
*/
public double nmsAttributeInstance_getAttributeModifierMultiplier(Object attributeInstance) {
if (this.reflectAttributeInstance.nmsGetAttributeModifier == null) {
fail();
}
// TODO: Need to fall back in case of errors.
Object mod = ReflectionUtil.invokeMethod(this.reflectAttributeInstance.nmsGetAttributeModifier, attributeInstance, AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
}
else {
return AttribUtil.getMultiplier((Integer) ReflectionUtil.invokeMethodNoArgs(this.reflectAttributeModifier.nmsGetOperation, mod), (Double) ReflectionUtil.invokeMethodNoArgs(this.reflectAttributeModifier.nmsGetValue, mod));
}
}
public Object getHandle(World world) {
if (this.reflectWorld.obcGetHandle == null) {
fail();

View File

@ -126,16 +126,6 @@ public class MCAccessCB2512 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public double getSprintAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -126,16 +126,6 @@ public class MCAccessCB2545 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public double getSprintAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -127,16 +127,6 @@ public class MCAccessCB2602 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public double getSprintAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -128,16 +128,6 @@ public class MCAccessCB2645 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public double getSprintAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -130,16 +130,6 @@ public class MCAccessCB2691 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public double getSprintAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -128,16 +128,6 @@ public class MCAccessCB2763 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public double getSprintAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.cb2794;
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().a(GenericAttributes.d);
double val = attr.e() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().a(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,16 +14,6 @@
*/
package fr.neatmonster.nocheatplus.compat.cb2794;
import net.minecraft.server.v1_6_R1.AxisAlignedBB;
import net.minecraft.server.v1_6_R1.Block;
import net.minecraft.server.v1_6_R1.DamageSource;
import net.minecraft.server.v1_6_R1.EntityComplexPart;
import net.minecraft.server.v1_6_R1.EntityPlayer;
import net.minecraft.server.v1_6_R1.MobEffectList;
import net.minecraft.server.v1_6_R1.AttributeInstance;
import net.minecraft.server.v1_6_R1.AttributeModifier;
import net.minecraft.server.v1_6_R1.GenericAttributes;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
@ -31,16 +21,20 @@ import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_6_R1.CraftServer;
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_6_R1.entity.CraftLivingEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_6_R1.AxisAlignedBB;
import net.minecraft.server.v1_6_R1.Block;
import net.minecraft.server.v1_6_R1.DamageSource;
import net.minecraft.server.v1_6_R1.EntityComplexPart;
import net.minecraft.server.v1_6_R1.EntityPlayer;
import net.minecraft.server.v1_6_R1.MobEffectList;
public class MCAccessCB2794 implements MCAccess{
@ -133,28 +127,6 @@ public class MCAccessCB2794 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().a(GenericAttributes.d);
double val = attr.e() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().a(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.cb2808;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,16 +14,6 @@
*/
package fr.neatmonster.nocheatplus.compat.cb2808;
import net.minecraft.server.v1_6_R2.AxisAlignedBB;
import net.minecraft.server.v1_6_R2.Block;
import net.minecraft.server.v1_6_R2.DamageSource;
import net.minecraft.server.v1_6_R2.EntityComplexPart;
import net.minecraft.server.v1_6_R2.EntityPlayer;
import net.minecraft.server.v1_6_R2.MobEffectList;
import net.minecraft.server.v1_6_R2.AttributeInstance;
import net.minecraft.server.v1_6_R2.AttributeModifier;
import net.minecraft.server.v1_6_R2.GenericAttributes;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
@ -31,16 +21,20 @@ import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_6_R2.CraftServer;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftLivingEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_6_R2.AxisAlignedBB;
import net.minecraft.server.v1_6_R2.Block;
import net.minecraft.server.v1_6_R2.DamageSource;
import net.minecraft.server.v1_6_R2.EntityComplexPart;
import net.minecraft.server.v1_6_R2.EntityPlayer;
import net.minecraft.server.v1_6_R2.MobEffectList;
public class MCAccessCB2808 implements MCAccess{
@ -134,28 +128,6 @@ public class MCAccessCB2808 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.cb2882;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,16 +14,6 @@
*/
package fr.neatmonster.nocheatplus.compat.cb2882;
import net.minecraft.server.v1_6_R3.AxisAlignedBB;
import net.minecraft.server.v1_6_R3.Block;
import net.minecraft.server.v1_6_R3.DamageSource;
import net.minecraft.server.v1_6_R3.EntityComplexPart;
import net.minecraft.server.v1_6_R3.EntityPlayer;
import net.minecraft.server.v1_6_R3.MobEffectList;
import net.minecraft.server.v1_6_R3.AttributeInstance;
import net.minecraft.server.v1_6_R3.AttributeModifier;
import net.minecraft.server.v1_6_R3.GenericAttributes;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
@ -31,16 +21,20 @@ import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_6_R3.CraftServer;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_6_R3.AxisAlignedBB;
import net.minecraft.server.v1_6_R3.Block;
import net.minecraft.server.v1_6_R3.DamageSource;
import net.minecraft.server.v1_6_R3.EntityComplexPart;
import net.minecraft.server.v1_6_R3.EntityPlayer;
import net.minecraft.server.v1_6_R3.MobEffectList;
public class MCAccessCB2882 implements MCAccess{
@ -135,28 +129,6 @@ public class MCAccessCB2882 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.cb2922;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,16 +14,6 @@
*/
package fr.neatmonster.nocheatplus.compat.cb2922;
import net.minecraft.server.v1_7_R1.AxisAlignedBB;
import net.minecraft.server.v1_7_R1.Block;
import net.minecraft.server.v1_7_R1.DamageSource;
import net.minecraft.server.v1_7_R1.EntityComplexPart;
import net.minecraft.server.v1_7_R1.EntityPlayer;
import net.minecraft.server.v1_7_R1.MobEffectList;
import net.minecraft.server.v1_7_R1.AttributeInstance;
import net.minecraft.server.v1_7_R1.AttributeModifier;
import net.minecraft.server.v1_7_R1.GenericAttributes;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
@ -31,16 +21,20 @@ import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_7_R1.CraftServer;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftLivingEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_7_R1.AxisAlignedBB;
import net.minecraft.server.v1_7_R1.Block;
import net.minecraft.server.v1_7_R1.DamageSource;
import net.minecraft.server.v1_7_R1.EntityComplexPart;
import net.minecraft.server.v1_7_R1.EntityPlayer;
import net.minecraft.server.v1_7_R1.MobEffectList;
public class MCAccessCB2922 implements MCAccess{
@ -135,28 +129,6 @@ public class MCAccessCB2922 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.cb3026;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,23 +14,12 @@
*/
package fr.neatmonster.nocheatplus.compat.cb3026;
import net.minecraft.server.v1_7_R2.AttributeInstance;
import net.minecraft.server.v1_7_R2.AttributeModifier;
import net.minecraft.server.v1_7_R2.AxisAlignedBB;
import net.minecraft.server.v1_7_R2.Block;
import net.minecraft.server.v1_7_R2.DamageSource;
import net.minecraft.server.v1_7_R2.EntityComplexPart;
import net.minecraft.server.v1_7_R2.EntityPlayer;
import net.minecraft.server.v1_7_R2.GenericAttributes;
import net.minecraft.server.v1_7_R2.MobEffectList;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_7_R2.CraftServer;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -38,9 +27,14 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_7_R2.AxisAlignedBB;
import net.minecraft.server.v1_7_R2.Block;
import net.minecraft.server.v1_7_R2.DamageSource;
import net.minecraft.server.v1_7_R2.EntityComplexPart;
import net.minecraft.server.v1_7_R2.EntityPlayer;
import net.minecraft.server.v1_7_R2.MobEffectList;
public class MCAccessCB3026 implements MCAccess{
@ -135,28 +129,6 @@ public class MCAccessCB3026 implements MCAccess{
else return Double.NEGATIVE_INFINITY;
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.cb3043;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,23 +14,12 @@
*/
package fr.neatmonster.nocheatplus.compat.cb3043;
import net.minecraft.server.v1_7_R3.AttributeInstance;
import net.minecraft.server.v1_7_R3.AttributeModifier;
import net.minecraft.server.v1_7_R3.AxisAlignedBB;
import net.minecraft.server.v1_7_R3.Block;
import net.minecraft.server.v1_7_R3.DamageSource;
import net.minecraft.server.v1_7_R3.EntityComplexPart;
import net.minecraft.server.v1_7_R3.EntityPlayer;
import net.minecraft.server.v1_7_R3.GenericAttributes;
import net.minecraft.server.v1_7_R3.MobEffectList;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_7_R3.CraftServer;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -38,9 +27,14 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_7_R3.AxisAlignedBB;
import net.minecraft.server.v1_7_R3.Block;
import net.minecraft.server.v1_7_R3.DamageSource;
import net.minecraft.server.v1_7_R3.EntityComplexPart;
import net.minecraft.server.v1_7_R3.EntityPlayer;
import net.minecraft.server.v1_7_R3.MobEffectList;
public class MCAccessCB3043 implements MCAccess{
@ -154,28 +148,6 @@ public class MCAccessCB3043 implements MCAccess{
}
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.cb3100;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(final Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,23 +14,12 @@
*/
package fr.neatmonster.nocheatplus.compat.cb3100;
import net.minecraft.server.v1_7_R4.AttributeInstance;
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
import net.minecraft.server.v1_7_R4.Block;
import net.minecraft.server.v1_7_R4.DamageSource;
import net.minecraft.server.v1_7_R4.EntityComplexPart;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.GenericAttributes;
import net.minecraft.server.v1_7_R4.MobEffectList;
import net.minecraft.server.v1_7_R4.AttributeModifier;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -38,9 +27,14 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
import net.minecraft.server.v1_7_R4.Block;
import net.minecraft.server.v1_7_R4.DamageSource;
import net.minecraft.server.v1_7_R4.EntityComplexPart;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.MobEffectList;
public class MCAccessCB3100 implements MCAccess{
@ -156,28 +150,6 @@ public class MCAccessCB3100 implements MCAccess{
}
}
@Override
public double getSpeedAttributeMultiplier(final Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.cbdev;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,26 +14,12 @@
*/
package fr.neatmonster.nocheatplus.compat.cbdev;
import net.minecraft.server.v1_10_R1.AttributeInstance;
import net.minecraft.server.v1_10_R1.AttributeModifier;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Block;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.DamageSource;
import net.minecraft.server.v1_10_R1.EntityComplexPart;
import net.minecraft.server.v1_10_R1.EntityPlayer;
import net.minecraft.server.v1_10_R1.GenericAttributes;
import net.minecraft.server.v1_10_R1.IBlockAccess;
import net.minecraft.server.v1_10_R1.IBlockData;
import net.minecraft.server.v1_10_R1.MobEffectList;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -41,9 +27,17 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Block;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.DamageSource;
import net.minecraft.server.v1_10_R1.EntityComplexPart;
import net.minecraft.server.v1_10_R1.EntityPlayer;
import net.minecraft.server.v1_10_R1.IBlockAccess;
import net.minecraft.server.v1_10_R1.IBlockData;
import net.minecraft.server.v1_10_R1.MobEffectList;
public class MCAccessCBDev implements MCAccess {
@ -213,28 +207,6 @@ public class MCAccessCBDev implements MCAccess {
}
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R1;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,23 +14,12 @@
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R1;
import net.minecraft.server.v1_8_R1.AttributeInstance;
import net.minecraft.server.v1_8_R1.AxisAlignedBB;
import net.minecraft.server.v1_8_R1.Block;
import net.minecraft.server.v1_8_R1.DamageSource;
import net.minecraft.server.v1_8_R1.EntityComplexPart;
import net.minecraft.server.v1_8_R1.EntityPlayer;
import net.minecraft.server.v1_8_R1.GenericAttributes;
import net.minecraft.server.v1_8_R1.MobEffectList;
import net.minecraft.server.v1_8_R1.AttributeModifier;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_8_R1.CraftServer;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -38,9 +27,14 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_8_R1.AxisAlignedBB;
import net.minecraft.server.v1_8_R1.Block;
import net.minecraft.server.v1_8_R1.DamageSource;
import net.minecraft.server.v1_8_R1.EntityComplexPart;
import net.minecraft.server.v1_8_R1.EntityPlayer;
import net.minecraft.server.v1_8_R1.MobEffectList;
public class MCAccessSpigotCB1_8_R1 implements MCAccess{
@ -157,28 +151,6 @@ public class MCAccessSpigotCB1_8_R1 implements MCAccess{
}
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R2;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,23 +14,12 @@
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R2;
import net.minecraft.server.v1_8_R2.AttributeInstance;
import net.minecraft.server.v1_8_R2.AttributeModifier;
import net.minecraft.server.v1_8_R2.AxisAlignedBB;
import net.minecraft.server.v1_8_R2.Block;
import net.minecraft.server.v1_8_R2.DamageSource;
import net.minecraft.server.v1_8_R2.EntityComplexPart;
import net.minecraft.server.v1_8_R2.EntityPlayer;
import net.minecraft.server.v1_8_R2.GenericAttributes;
import net.minecraft.server.v1_8_R2.MobEffectList;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_8_R2.CraftServer;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -38,9 +27,14 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_8_R2.AxisAlignedBB;
import net.minecraft.server.v1_8_R2.Block;
import net.minecraft.server.v1_8_R2.DamageSource;
import net.minecraft.server.v1_8_R2.EntityComplexPart;
import net.minecraft.server.v1_8_R2.EntityPlayer;
import net.minecraft.server.v1_8_R2.MobEffectList;
public class MCAccessSpigotCB1_8_R2 implements MCAccess{
@ -157,28 +151,6 @@ public class MCAccessSpigotCB1_8_R2 implements MCAccess{
}
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,23 +14,12 @@
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3;
import net.minecraft.server.v1_8_R3.AttributeInstance;
import net.minecraft.server.v1_8_R3.AttributeModifier;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityComplexPart;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.GenericAttributes;
import net.minecraft.server.v1_8_R3.MobEffectList;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -38,9 +27,14 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.DamageSource;
import net.minecraft.server.v1_8_R3.EntityComplexPart;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.MobEffectList;
public class MCAccessSpigotCB1_8_R3 implements MCAccess{
@ -177,28 +171,6 @@ public class MCAccessSpigotCB1_8_R3 implements MCAccess{
}
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,26 +14,12 @@
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1;
import net.minecraft.server.v1_9_R1.AttributeInstance;
import net.minecraft.server.v1_9_R1.AttributeModifier;
import net.minecraft.server.v1_9_R1.AxisAlignedBB;
import net.minecraft.server.v1_9_R1.Block;
import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.DamageSource;
import net.minecraft.server.v1_9_R1.EntityComplexPart;
import net.minecraft.server.v1_9_R1.EntityPlayer;
import net.minecraft.server.v1_9_R1.GenericAttributes;
import net.minecraft.server.v1_9_R1.IBlockAccess;
import net.minecraft.server.v1_9_R1.IBlockData;
import net.minecraft.server.v1_9_R1.MobEffectList;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_9_R1.CraftServer;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -41,9 +27,17 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_9_R1.AxisAlignedBB;
import net.minecraft.server.v1_9_R1.Block;
import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.DamageSource;
import net.minecraft.server.v1_9_R1.EntityComplexPart;
import net.minecraft.server.v1_9_R1.EntityPlayer;
import net.minecraft.server.v1_9_R1.IBlockAccess;
import net.minecraft.server.v1_9_R1.IBlockData;
import net.minecraft.server.v1_9_R1.MobEffectList;
public class MCAccessSpigotCB1_9_R1 implements MCAccess {
@ -211,28 +205,6 @@ public class MCAccessSpigotCB1_9_R1 implements MCAccess {
}
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -0,0 +1,36 @@
package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
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 {
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
}

View File

@ -14,26 +14,12 @@
*/
package fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2;
import net.minecraft.server.v1_9_R2.AttributeInstance;
import net.minecraft.server.v1_9_R2.AttributeModifier;
import net.minecraft.server.v1_9_R2.AxisAlignedBB;
import net.minecraft.server.v1_9_R2.Block;
import net.minecraft.server.v1_9_R2.BlockPosition;
import net.minecraft.server.v1_9_R2.DamageSource;
import net.minecraft.server.v1_9_R2.EntityComplexPart;
import net.minecraft.server.v1_9_R2.EntityPlayer;
import net.minecraft.server.v1_9_R2.GenericAttributes;
import net.minecraft.server.v1_9_R2.IBlockAccess;
import net.minecraft.server.v1_9_R2.IBlockData;
import net.minecraft.server.v1_9_R2.MobEffectList;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandMap;
import org.bukkit.craftbukkit.v1_9_R2.CraftServer;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -41,9 +27,17 @@ import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.AttribUtil;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
import net.minecraft.server.v1_9_R2.AxisAlignedBB;
import net.minecraft.server.v1_9_R2.Block;
import net.minecraft.server.v1_9_R2.BlockPosition;
import net.minecraft.server.v1_9_R2.DamageSource;
import net.minecraft.server.v1_9_R2.EntityComplexPart;
import net.minecraft.server.v1_9_R2.EntityPlayer;
import net.minecraft.server.v1_9_R2.IBlockAccess;
import net.minecraft.server.v1_9_R2.IBlockData;
import net.minecraft.server.v1_9_R2.MobEffectList;
public class MCAccessSpigotCB1_9_R2 implements MCAccess {
@ -213,28 +207,6 @@ public class MCAccessSpigotCB1_9_R2 implements MCAccess {
}
}
@Override
public double getSpeedAttributeMultiplier(Player player) {
final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
final double val = attr.getValue() / attr.b();
final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return val;
} else {
return val / AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public double getSprintAttributeMultiplier(Player player) {
final AttributeModifier mod = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).a(AttribUtil.ID_SPRINT_BOOST);
if (mod == null) {
return 1.0;
} else {
return AttribUtil.getMultiplier(mod.c(), mod.d());
}
}
@Override
public int getInvulnerableTicks(final Player player) {
return ((CraftPlayer) player).getHandle().invulnerableTicks;

View File

@ -89,6 +89,7 @@ import fr.neatmonster.nocheatplus.components.INotifyReload;
import fr.neatmonster.nocheatplus.components.IRemoveData;
import fr.neatmonster.nocheatplus.components.JoinLeaveListener;
import fr.neatmonster.nocheatplus.components.TickListener;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.config.ConfPaths;
import fr.neatmonster.nocheatplus.config.ConfigManager;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
@ -154,6 +155,8 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
/** Auxiliary functionality. */
private final AuxMoving aux = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(AuxMoving.class);
private IAttributeAccess attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IAttributeAccess.class);
/** Statistics / debugging counters. */
private final Counters counters = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(Counters.class);
private final int idMoveHandled = counters.registerKey("event.player.move.handled");
@ -533,7 +536,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Hard to confine assumesprint further (some logics change with hdist or sprinting).
if (player.getFoodLevel() > 5 || player.isFlying()) {
data.timeSprinting = time;
data.multSprinting = mcAccess.getSprintAttributeMultiplier(player);
data.multSprinting = attributeAccess.getSprintAttributeMultiplier(player);
if (data.multSprinting == Double.MAX_VALUE) {
data.multSprinting = 1.30000002;
}
@ -2013,4 +2016,10 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
}
}
@Override
public void setMCAccess(MCAccess mcAccess) {
super.setMCAccess(mcAccess);
attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IAttributeAccess.class);
}
}

View File

@ -42,9 +42,11 @@ import fr.neatmonster.nocheatplus.checks.moving.util.AuxMoving;
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
import fr.neatmonster.nocheatplus.compat.BridgeEnchant;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker;
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker.BlockChangeEntry;
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker.Direction;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
import fr.neatmonster.nocheatplus.logging.Streams;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
@ -89,6 +91,9 @@ public class SurvivalFly extends Check {
private final AuxMoving aux = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(AuxMoving.class);
private IAttributeAccess attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IAttributeAccess.class);
/**
* Instantiates a new survival fly check.
*/
@ -739,7 +744,7 @@ public class SurvivalFly extends Check {
hAllowedDistance *= data.multSprinting;
}
// Note: Attributes count in slowness potions, thus leaving out isn't possible.
final double attrMod = mcAccess.getSpeedAttributeMultiplier(player);
final double attrMod = attributeAccess.getSpeedAttributeMultiplier(player);
if (attrMod == Double.MAX_VALUE) {
// TODO: Slowness potion.
// Count in speed potions.
@ -1929,4 +1934,10 @@ public class SurvivalFly extends Check {
debug(player, "SurvivalFly Post violation handling tag update:\n" + StringUtil.join(tags, "+"));
}
@Override
public void setMCAccess(MCAccess mcAccess) {
super.setMCAccess(mcAccess);
attributeAccess = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstance(IAttributeAccess.class);
}
}

View File

@ -111,25 +111,6 @@ public interface MCAccess {
*/
public double getFasterMovementAmplifier(Player player);
/**
* Generic speed modifier as a multiplier.
*
* @param player
* @return A multiplier for the allowed speed, excluding the sprint boost
* modifier (!). If not possible to determine, it should
* Double.MAX_VALUE.
*/
public double getSpeedAttributeMultiplier(Player player);
/**
* Sprint boost modifier as a multiplier.
*
* @param player
* @return The sprint boost modifier as a multiplier. If not possible to
* determine, it should be Double.MAX_VALUE.
*/
public double getSprintAttributeMultiplier(Player player);
/**
*
* @param player
@ -137,8 +118,19 @@ public interface MCAccess {
*/
public int getInvulnerableTicks(Player player);
/**
*
* @param player
* @param ticks
*/
public void setInvulnerableTicks(Player player, int ticks);
/**
* Deal damage with DamageCause.FALL as cause.
*
* @param player
* @param damage
*/
public void dealFallDamage(Player player, double damage);
/**

View File

@ -0,0 +1,23 @@
package fr.neatmonster.nocheatplus.components.modifiers;
import org.bukkit.entity.Player;
/**
* Default implementation for access not being available.
*
* @author asofold
*
*/
public class DummyAttributeAccess implements IAttributeAccess {
@Override
public double getSpeedAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
@Override
public double getSprintAttributeMultiplier(Player player) {
return Double.MAX_VALUE;
}
}

View File

@ -0,0 +1,34 @@
package fr.neatmonster.nocheatplus.components.modifiers;
import org.bukkit.entity.Player;
/**
* Encapsulate attribute access. Note that some of the methods may exclude
* specific modifiers, or otherwise perform calculations, e.g. in order to
* return a multiplier to be applied to typical walking speed.
*
* @author asofold
*
*/
public interface IAttributeAccess {
/**
* Generic speed modifier as a multiplier.
*
* @param player
* @return A multiplier for the allowed speed, excluding the sprint boost
* modifier (!). If not possible to determine, it should
* Double.MAX_VALUE.
*/
public double getSpeedAttributeMultiplier(Player player);
/**
* Sprint boost modifier as a multiplier.
*
* @param player
* @return The sprint boost modifier as a multiplier. If not possible to
* determine, it should be Double.MAX_VALUE.
*/
public double getSprintAttributeMultiplier(Player player);
}

View File

@ -66,6 +66,7 @@ import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
import fr.neatmonster.nocheatplus.clients.ModUtil;
import fr.neatmonster.nocheatplus.command.NoCheatPlusCommand;
import fr.neatmonster.nocheatplus.command.admin.VersionCommand;
import fr.neatmonster.nocheatplus.compat.AttributeAccessFactory;
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
import fr.neatmonster.nocheatplus.compat.DefaultComponentFactory;
import fr.neatmonster.nocheatplus.compat.EntityAccessFactory;
@ -1179,8 +1180,10 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
// TODO: Might fire a NCPSetMCAccessFromFactoryEvent (include getting and setting)!
final MCAccessConfig mcaC = new MCAccessConfig(config);
final MCAccess mcAccess = new MCAccessFactory().getMCAccess(mcaC);
new EntityAccessFactory().setupEntityAccess(mcAccess, mcaC); // TODO: Registry listeners/events are missing.
// TODO: Consider registry events for generic instances too.
new AttributeAccessFactory().setupAttributeAccess(mcAccess, mcaC);
new EntityAccessFactory().setupEntityAccess(mcAccess, mcaC);
setMCAccess(mcAccess);
return mcAccess;
}

View File

@ -0,0 +1,41 @@
package fr.neatmonster.nocheatplus.compat;
import fr.neatmonster.nocheatplus.compat.bukkit.BukkitAttributeAccess;
import fr.neatmonster.nocheatplus.components.modifiers.DummyAttributeAccess;
import fr.neatmonster.nocheatplus.components.modifiers.IAttributeAccess;
public class AttributeAccessFactory {
/**
* Set up alongside with MCAccess. The MCAccess instance is passed here,
* before it has been set internally and before it has been advertised to
* MCAccessHolder instances, so the latter can get other specific access
* providers during handling setMCAccess.
*
* @param mcAccess
* @param config
*/
public void setupAttributeAccess(final MCAccess mcAccess, final MCAccessConfig config) {
IAttributeAccess fallBack = new DummyAttributeAccess();
try {
fallBack = new BukkitAttributeAccess();
}
catch (Throwable t) {}
RegistryHelper.setupGenericInstance(new String[] {
"fr.neatmonster.nocheatplus.compat.cbdev",
"fr.neatmonster.nocheatplus.compat.spigotcb1_9_R2.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.spigotcb1_9_R1.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.spigotcb1_8_R3.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.spigotcb1_8_R2.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.spigotcb1_8_R1.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.cb3100.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.cb3043.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.cb3026.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.cb2922.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.cb2882.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.cb2808.AttributeAccess",
"fr.neatmonster.nocheatplus.compat.cb2794.AttributeAccess"
}, null, IAttributeAccess.class, config, fallBack);
}
}

View File

@ -29,8 +29,10 @@ import fr.neatmonster.nocheatplus.components.location.IEntityAccessLastPositionA
public class EntityAccessFactory {
/**
* Set up alongside with MCAccess. This is called before setMCAccess is used
* internally, so the MCAccess instance is passed here.
* Set up alongside with MCAccess. The MCAccess instance is passed here,
* before it has been set internally and before it has been advertised to
* MCAccessHolder instances, so the latter can get other specific access
* providers during handling setMCAccess.
*
* @param mcAccess
* @param config

View File

@ -8,27 +8,50 @@ public class RegistryHelper {
/**
* Set up a generic instance, according to settings. On success it will be
* registered with the default GenericInstanceRegistry (NoCheatPlusAPI).
*
* @param cbDedicatedNames
* @param cbReflectNames
* @param registerFor
* @param config
* @param logDebug
* @return
*/
public static <T> T setupGenericInstance(String[] cbDedicatedNames, String[] cbReflectNames, Class<T> registerFor, MCAccessConfig config) {
return setupGenericInstance(cbDedicatedNames, cbReflectNames, registerFor, config, null);
}
/**
* Set up a generic instance, according to settings. On success it will be
* registered with the default GenericInstanceRegistry (NoCheatPlusAPI).
*
* @param cbDedicatedNames
* May be null.
* @param cbReflectNames
* May be null.
* @param registerFor
* @param config
* @param fallBackInstance
* Use this as a fall back, in case none of the classes could be
* instantiated.
* @return
*/
public static <T> T setupGenericInstance(String[] cbDedicatedNames, String[] cbReflectNames,
Class<T> registerFor, MCAccessConfig config, T fallBackInstance) {
T res = null;
// Reference by class name (native access).
if (config.enableCBDedicated) {
if (config.enableCBDedicated && cbDedicatedNames != null) {
res = getFirstAvailable(cbDedicatedNames, registerFor, true);
}
// Reflection based.
if (res == null && config.enableCBReflect) {
if (res == null && config.enableCBReflect && cbReflectNames != null) {
res = getFirstAvailable(cbReflectNames, registerFor, true);
}
// Fall back.
if (res == null && fallBackInstance != null) {
res = fallBackInstance;
}
// Register / log.
RegistryHelper.registerGenericInstance(registerFor, res);
return res;