mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-26 02:17:42 +01:00
[BLEEDING] Adapt to health changes + set NCPCore dependency to 1.6.1.
This commit is contained in:
parent
ccc9c74a76
commit
a8d1aded59
@ -17,6 +17,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||||
|
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
|
||||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
|
import fr.neatmonster.nocheatplus.compat.blocks.BlockPropertiesSetup;
|
||||||
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
|
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
|
||||||
@ -130,9 +131,9 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealFallDamage(final Player player, final int damage) {
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
// TODO: account for armor, other.
|
// TODO: account for armor, other.
|
||||||
player.damage(damage);
|
player.damage((int) Math.round(damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -143,7 +144,7 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
|
|||||||
@Override
|
@Override
|
||||||
public boolean shouldBeZombie(final Player player) {
|
public boolean shouldBeZombie(final Player player) {
|
||||||
// Not sure :) ...
|
// Not sure :) ...
|
||||||
return player.getHealth() <= 0 && !player.isDead();
|
return BridgeHealth.getHealth(player) <= 0.0 && !player.isDead();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,8 +123,8 @@ public class MCAccessCB2511 implements MCAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealFallDamage(final Player player, final int damage) {
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, damage);
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (int) Math.round(damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,8 +121,8 @@ public class MCAccessCB2512 implements MCAccess{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealFallDamage(final Player player, final int damage) {
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, damage);
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (int) Math.round(damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,8 +121,8 @@ public class MCAccessCB2545 implements MCAccess{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealFallDamage(final Player player, final int damage) {
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, damage);
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (int) Math.round(damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -122,8 +122,8 @@ public class MCAccessCB2602 implements MCAccess{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealFallDamage(final Player player, final int damage) {
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, damage);
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (int) Math.round(damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,8 +123,8 @@ public class MCAccessCB2645 implements MCAccess{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealFallDamage(final Player player, final int damage) {
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, damage);
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (int) Math.round(damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,8 +123,8 @@ public class MCAccessCB2691 implements MCAccess{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealFallDamage(final Player player, final int damage) {
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, damage);
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (int) Math.round(damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,8 +123,8 @@ public class MCAccessCB2763 implements MCAccess{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealFallDamage(final Player player, final int damage) {
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, damage);
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (int) Math.round(damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,8 +123,8 @@ public class MCAccessCBDev implements MCAccess{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dealFallDamage(final Player player, final int damage) {
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, damage);
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (int) Math.round(damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.5.2-R1.0</version>
|
<version>1.6.1-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.neatmonster</groupId>
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
@ -282,7 +282,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
|
|||||||
// It requested to "cancel" the players invulnerability, so set his noDamageTicks to 0.
|
// It requested to "cancel" the players invulnerability, so set his noDamageTicks to 0.
|
||||||
damagedPlayer.setNoDamageTicks(0);
|
damagedPlayer.setNoDamageTicks(0);
|
||||||
}
|
}
|
||||||
if (damagedPlayer.getHealth() == damagedPlayer.getMaxHealth()){
|
if (BridgeHealth.getHealth(damagedPlayer) == BridgeHealth.getMaxHealth(damagedPlayer)){
|
||||||
// TODO: Might use the same FightData instance for GodMode.
|
// TODO: Might use the same FightData instance for GodMode.
|
||||||
if (damagedData.fastHealBuffer < 0){
|
if (damagedData.fastHealBuffer < 0){
|
||||||
// Reduce negative buffer with each full health.
|
// Reduce negative buffer with each full health.
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
|
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
|
||||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||||
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
import fr.neatmonster.nocheatplus.utilities.TickTask;
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public class GodMode extends Check {
|
|||||||
final int dNDT = data.lastNoDamageTicks - noDamageTicks;
|
final int dNDT = data.lastNoDamageTicks - noDamageTicks;
|
||||||
final int delta = dTick - dNDT;
|
final int delta = dTick - dNDT;
|
||||||
|
|
||||||
final double health = player.getHealth();
|
final double health = BridgeHealth.getHealth(player);
|
||||||
|
|
||||||
// TODO: Adjust to double values.
|
// TODO: Adjust to double values.
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ public class GodMode extends Check {
|
|||||||
|
|
||||||
// Check if reduced more than expected or new/count down fully.
|
// Check if reduced more than expected or new/count down fully.
|
||||||
// TODO: Mostly workarounds.
|
// TODO: Mostly workarounds.
|
||||||
if (delta <= 0 || data.lastNoDamageTicks <= player.getMaximumNoDamageTicks() / 2 || dTick > data.lastNoDamageTicks || damage > player.getLastDamage() || damage == 0){
|
if (delta <= 0 || data.lastNoDamageTicks <= player.getMaximumNoDamageTicks() / 2 || dTick > data.lastNoDamageTicks || damage > BridgeHealth.getLastDamage(player)|| damage == 0){
|
||||||
// Not resetting acc.
|
// Not resetting acc.
|
||||||
legit = set = true;
|
legit = set = true;
|
||||||
}
|
}
|
||||||
@ -181,8 +182,8 @@ public class GodMode extends Check {
|
|||||||
public void death(final Player player) {
|
public void death(final Player player) {
|
||||||
// TODO: Is this still relevant ?
|
// TODO: Is this still relevant ?
|
||||||
// First check if the player is really dead (e.g. another plugin could have just fired an artificial event).
|
// First check if the player is really dead (e.g. another plugin could have just fired an artificial event).
|
||||||
if (player.getHealth() <= 0 && player.isDead())
|
if (BridgeHealth.getHealth(player) <= 0 && player.isDead()){
|
||||||
try {
|
try {
|
||||||
// Schedule a task to be executed in roughly 1.5 seconds.
|
// Schedule a task to be executed in roughly 1.5 seconds.
|
||||||
// TODO: Get plugin otherwise !?
|
// TODO: Get plugin otherwise !?
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("NoCheatPlus"), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("NoCheatPlus"), new Runnable() {
|
||||||
@ -198,5 +199,6 @@ public class GodMode extends Check {
|
|||||||
}
|
}
|
||||||
}, 30);
|
}, 30);
|
||||||
} catch (final Exception e) {}
|
} catch (final Exception e) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1218,7 +1218,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
|||||||
final double maxD = NoFall.getDamage(Math.max(yDiff, Math.max(data.noFallFallDistance, fallDistance))) + (allowReset ? 0 : 3);
|
final double maxD = NoFall.getDamage(Math.max(yDiff, Math.max(data.noFallFallDistance, fallDistance))) + (allowReset ? 0 : 3);
|
||||||
if (maxD > damage){
|
if (maxD > damage){
|
||||||
// TODO: respect dealDamage ?
|
// TODO: respect dealDamage ?
|
||||||
event.setDamage((int) Math.round(maxD)); // TODO: Byte code compatibility !?
|
BridgeHealth.setDamage(event, maxD);
|
||||||
if (cc.debug){
|
if (cc.debug){
|
||||||
System.out.println(player.getName() + " Adjust fall damage to: " + maxD);
|
System.out.println(player.getName() + " Adjust fall damage to: " + maxD);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|||||||
|
|
||||||
import fr.neatmonster.nocheatplus.checks.Check;
|
import fr.neatmonster.nocheatplus.checks.Check;
|
||||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||||
|
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
|
||||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||||
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||||
|
|
||||||
@ -77,14 +78,13 @@ public class NoFall extends Check {
|
|||||||
|
|
||||||
|
|
||||||
private void dealFallDamage(final Player player, final double damage) {
|
private void dealFallDamage(final Player player, final double damage) {
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
// TODO: Byte code compatibility ?
|
// TODO: Byte code compatibility ?
|
||||||
final EntityDamageEvent event = new EntityDamageEvent(player, DamageCause.FALL, (int) Math.round(damage));
|
final EntityDamageEvent event = BridgeHealth.getEntityDamageEvent(player, DamageCause.FALL, damage);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()){
|
if (!event.isCancelled()){
|
||||||
// TODO: account for no damage ticks etc.
|
// TODO: account for no damage ticks etc.
|
||||||
player.setLastDamageCause(event);
|
player.setLastDamageCause(event);
|
||||||
mcAccess.dealFallDamage(player, (int) Math.round(event.getDamage())); // TODO: Adjust signature to double (!).
|
mcAccess.dealFallDamage(player, BridgeHealth.getDamage(event));
|
||||||
}
|
}
|
||||||
// TODO: let this be done by the damage event (!).
|
// TODO: let this be done by the damage event (!).
|
||||||
// data.clearNoFallData(); // -> currently done in the damage eventhandling method.
|
// data.clearNoFallData(); // -> currently done in the damage eventhandling method.
|
||||||
|
@ -3,8 +3,10 @@ package fr.neatmonster.nocheatplus.compat;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
|
|
||||||
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
import fr.neatmonster.nocheatplus.logging.LogUtil;
|
||||||
@ -12,6 +14,9 @@ import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class with static access methods to bridge compatibility issues, such as arising from changes in Bukkit from MC 1.5.2 to 1.6.1.
|
* Utility class with static access methods to bridge compatibility issues, such as arising from changes in Bukkit from MC 1.5.2 to 1.6.1.
|
||||||
|
* <br>NOTES:
|
||||||
|
* <li>To simplify code IncompatibleClassChangeError is caught instead of AbstractMethodError and NoSuchMethodError etc.</li>
|
||||||
|
* <li>TODO: Since API dependency is now 1.6.1+, some things can be simplified to just call the "int-methods".</li>
|
||||||
* @author mc_dev
|
* @author mc_dev
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -55,13 +60,13 @@ public class BridgeHealth {
|
|||||||
* Get the amount of health added with the event.
|
* Get the amount of health added with the event.
|
||||||
* @param event
|
* @param event
|
||||||
* @return
|
* @return
|
||||||
* @throws RuntimeException, in case of an AbstractMethodError without success on recovery attempts.
|
* @throws RuntimeException, in case of an IncompatibleClassChangeError without success on recovery attempts.
|
||||||
*/
|
*/
|
||||||
public static double getAmount(final EntityRegainHealthEvent event){
|
public static double getAmount(final EntityRegainHealthEvent event){
|
||||||
try{
|
try{
|
||||||
return event.getAmount();
|
return event.getAmount();
|
||||||
}
|
}
|
||||||
catch(AbstractMethodError e){
|
catch(IncompatibleClassChangeError e){
|
||||||
return getDoubleOrInt(event, "getAmount", e);
|
return getDoubleOrInt(event, "getAmount", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,28 +75,44 @@ public class BridgeHealth {
|
|||||||
* Get the damage from an EntityDamageEvent.
|
* Get the damage from an EntityDamageEvent.
|
||||||
* @param event
|
* @param event
|
||||||
* @return
|
* @return
|
||||||
* @throws RuntimeException, in case of an AbstractMethodError without success on recovery attempts.
|
* @throws RuntimeException, in case of an IncompatibleClassChangeError without success on recovery attempts.
|
||||||
*/
|
*/
|
||||||
public static double getDamage(final EntityDamageEvent event){
|
public static double getDamage(final EntityDamageEvent event){
|
||||||
try{
|
try{
|
||||||
return event.getDamage();
|
return event.getDamage();
|
||||||
}
|
}
|
||||||
catch(AbstractMethodError e){
|
catch(IncompatibleClassChangeError e){
|
||||||
return getDoubleOrInt(event, "getDamage", e);
|
return getDoubleOrInt(event, "getDamage", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the damage from an EntityDamageEvent.
|
||||||
|
* @param event
|
||||||
|
* @param damage
|
||||||
|
* @return
|
||||||
|
* @throws RuntimeException, in case of an IncompatibleClassChangeError without success on recovery attempts.
|
||||||
|
*/
|
||||||
|
public static void setDamage(final EntityDamageEvent event, final double damage){
|
||||||
|
try{
|
||||||
|
event.setDamage(damage);
|
||||||
|
}
|
||||||
|
catch(IncompatibleClassChangeError e){
|
||||||
|
invokeVoid(event, "setDamage", (int) Math.round(damage), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the health for an entity (LivingEntity).
|
* Get the health for an entity (LivingEntity).
|
||||||
* @param entity
|
* @param entity
|
||||||
* @return
|
* @return
|
||||||
* @throws RuntimeException, in case of an AbstractMethodError without success on recovery attempts.
|
* @throws RuntimeException, in case of an IncompatibleClassChangeError without success on recovery attempts.
|
||||||
*/
|
*/
|
||||||
public static double getHealth(final LivingEntity entity){
|
public static double getHealth(final LivingEntity entity){
|
||||||
try{
|
try{
|
||||||
return entity.getHealth();
|
return entity.getHealth();
|
||||||
}
|
}
|
||||||
catch(AbstractMethodError e){
|
catch(IncompatibleClassChangeError e){
|
||||||
return getDoubleOrInt(entity, "getHealth", e);
|
return getDoubleOrInt(entity, "getHealth", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,15 +121,77 @@ public class BridgeHealth {
|
|||||||
* Get the maximum health for an entity (LivingEntity).
|
* Get the maximum health for an entity (LivingEntity).
|
||||||
* @param entity
|
* @param entity
|
||||||
* @return
|
* @return
|
||||||
* @throws RuntimeException, in case of an AbstractMethodError without success on recovery attempts.
|
* @throws RuntimeException, in case of an IncompatibleClassChangeError without success on recovery attempts.
|
||||||
*/
|
*/
|
||||||
public static double getMaxHealth(final LivingEntity entity){
|
public static double getMaxHealth(final LivingEntity entity){
|
||||||
try{
|
try{
|
||||||
return entity.getMaxHealth();
|
return entity.getMaxHealth();
|
||||||
}
|
}
|
||||||
catch(AbstractMethodError e){
|
catch(IncompatibleClassChangeError e){
|
||||||
return getDoubleOrInt(entity, "getMaxHealth", e);
|
return getDoubleOrInt(entity, "getMaxHealth", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the last damage for an entity (LivingEntity).
|
||||||
|
* @param entity
|
||||||
|
* @return
|
||||||
|
* @throws RuntimeException, in case of an IncompatibleClassChangeError without success on recovery attempts.
|
||||||
|
*/
|
||||||
|
public static double getLastDamage(final LivingEntity entity){
|
||||||
|
try{
|
||||||
|
return entity.getLastDamage();
|
||||||
|
}
|
||||||
|
catch(IncompatibleClassChangeError e){
|
||||||
|
return getDoubleOrInt(entity, "getLastDamage", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the health for an entity (LivingEntity).
|
||||||
|
* @param entity
|
||||||
|
* @param health
|
||||||
|
* @return
|
||||||
|
* @throws RuntimeException, in case of an IncompatibleClassChangeError without success on recovery attempts.
|
||||||
|
*/
|
||||||
|
public static void setHealth(final LivingEntity entity, final double health){
|
||||||
|
try{
|
||||||
|
entity.setHealth(health);
|
||||||
|
}
|
||||||
|
catch(IncompatibleClassChangeError e){
|
||||||
|
invokeVoid(entity, "setHealth", (int) Math.round(health), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static EntityDamageEvent getEntityDamageEvent(final Entity entity, final DamageCause damageCause, final double damage){
|
||||||
|
try{
|
||||||
|
return new EntityDamageEvent(entity, damageCause, damage);
|
||||||
|
}
|
||||||
|
catch(IncompatibleClassChangeError e){
|
||||||
|
return new EntityDamageEvent(entity, damageCause, (int) Math.round(damage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intended for faster compatibility methods for defined scenarios. Transforms any exception to a RuntimeException.
|
||||||
|
* @param obj
|
||||||
|
* @param methodName
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public static void invokeVoid(final Object obj, final String methodName, final int value, final Throwable reason){
|
||||||
|
if (reason != null){
|
||||||
|
final String tag = obj.getClass().getName() + "." + methodName;
|
||||||
|
if (failures.add(tag)){
|
||||||
|
// New entry.
|
||||||
|
LogUtil.logWarning("[NoCheatPlus] API incompatibility detected: " + tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
obj.getClass().getMethod(methodName, int.class).invoke(obj, value);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new RuntimeException("Could not invoke " + methodName + " with one argument (int) on: " + obj.getClass().getName(), reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public interface MCAccess {
|
|||||||
|
|
||||||
public void setInvulnerableTicks(Player player, int ticks);
|
public void setInvulnerableTicks(Player player, int ticks);
|
||||||
|
|
||||||
public void dealFallDamage(Player player, int damage);
|
public void dealFallDamage(Player player, double damage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This may well be removed, if possible to check with Bukkit.
|
* This may well be removed, if possible to check with Bukkit.
|
||||||
|
Loading…
Reference in New Issue
Block a user