mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-03-11 22:20:52 +01:00
[BLEEDING] Use 1.9 API to detect actually using elytra.
This commit is contained in:
parent
8353bdbfbe
commit
677622ac66
@ -17,7 +17,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
<version>1.9-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -358,7 +358,7 @@ public class MovingConfig extends ACheckConfig {
|
||||
// TODO: INCONSISTENT.
|
||||
return modelGameMode;
|
||||
}
|
||||
if (Bridge1_9.isWearingElytra(player)) {
|
||||
if (Bridge1_9.isWearingElytra(player)) { // Defensive: don't demand isGliding.
|
||||
return flyingModelElytra;
|
||||
}
|
||||
// Default by game mode.
|
||||
|
@ -950,7 +950,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
|
||||
// Default margin: Allow slightly less than the previous speed.
|
||||
final double defaultAmount = lastMove.hDistance * (1.0 + Magic.FRICTION_MEDIUM_AIR) / 2.0;
|
||||
// Test for exceptions.
|
||||
if (thisMove.hDistance > defaultAmount && Bridge1_9.isWearingElytra(player)) {
|
||||
if (thisMove.hDistance > defaultAmount && Bridge1_9.isGlidingWithElytra(player)) {
|
||||
// Allowing the same speed won't always work on elytra (still increasing, differing modeling on client side with motXYZ).
|
||||
// (Doesn't seem to be overly effective.)
|
||||
final MoveData pastMove1 = data.moveData.get(1);
|
||||
|
@ -1850,6 +1850,7 @@ public class SurvivalFly extends Check {
|
||||
tags.add("lowfoodsprint");
|
||||
}
|
||||
if (Bridge1_9.isWearingElytra(player)) {
|
||||
// Just wearing (not isGliding).
|
||||
tags.add("elytra_off");
|
||||
}
|
||||
if (!tags.isEmpty()) {
|
||||
|
@ -56,7 +56,7 @@ public class MovingUtil {
|
||||
&& (cc.ignoreAllowFlight || !player.getAllowFlight())
|
||||
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY)
|
||||
&& (Bridge1_9.getLevitationAmplifier(player) == Double.NEGATIVE_INFINITY || fromLocation.isInLiquid())
|
||||
&& (!Bridge1_9.isWearingElytra(player) || fromLocation.isOnGroundOrResetCond())
|
||||
&& (!Bridge1_9.isGlidingWithElytra(player) || fromLocation.isOnGroundOrResetCond())
|
||||
&& !player.hasPermission(Permissions.MOVING_SURVIVALFLY);
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,9 @@ public class Bridge1_9 {
|
||||
private static final Material ELYTRA = Material.getMaterial("ELYTRA");
|
||||
|
||||
private static Method getItemInOffHand = ReflectionUtil.getMethodNoArgs(PlayerInventory.class, "getItemInOffHand", ItemStack.class);
|
||||
private static Method getItemInMainHand = ReflectionUtil.getMethodNoArgs(PlayerInventory.class, "getItemInMainHand", ItemStack.class);
|
||||
|
||||
private static Method isGliding = ReflectionUtil.getMethodNoArgs(Player.class, "isGliding", boolean.class);
|
||||
|
||||
public static boolean hasLevitation() {
|
||||
return LEVITATION != null;
|
||||
@ -37,6 +40,14 @@ public class Bridge1_9 {
|
||||
return getItemInOffHand != null;
|
||||
}
|
||||
|
||||
public static boolean hasGetItemInMainHand() {
|
||||
return getItemInMainHand != null;
|
||||
}
|
||||
|
||||
public static boolean hasIsGliding() {
|
||||
return isGliding != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for the 'levitation' potion effect.
|
||||
*
|
||||
@ -50,6 +61,15 @@ public class Bridge1_9 {
|
||||
return PotionUtil.getPotionEffectAmplifier(player, LEVITATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gliding + wearing elytra.
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static boolean isGlidingWithElytra(final Player player) {
|
||||
return isGliding(player) && isWearingElytra(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Just test if the player has elytra equipped in the chest plate slot. The
|
||||
* player may or may not be holding an end rod in either hand.
|
||||
@ -86,8 +106,14 @@ public class Bridge1_9 {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ItemStack getItemInMainHand(final Player player) {
|
||||
return player.getItemInHand(); // As long as feasible (see: CraftInventoryPlayer).
|
||||
if (getItemInMainHand == null) {
|
||||
return player.getItemInHand(); // As long as feasible (see: CraftInventoryPlayer).
|
||||
}
|
||||
else {
|
||||
return player.getInventory().getItemInMainHand();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,7 +127,16 @@ public class Bridge1_9 {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return(ItemStack) ReflectionUtil.invokeMethodNoArgs(getItemInOffHand, player.getInventory());
|
||||
return player.getInventory().getItemInOffHand();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isGliding(final Player player) {
|
||||
if (isGliding == null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return player.isGliding();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user