mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-27 14:13:11 +02: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>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
<version>1.9-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -358,7 +358,7 @@ public class MovingConfig extends ACheckConfig {
|
|||||||
// TODO: INCONSISTENT.
|
// TODO: INCONSISTENT.
|
||||||
return modelGameMode;
|
return modelGameMode;
|
||||||
}
|
}
|
||||||
if (Bridge1_9.isWearingElytra(player)) {
|
if (Bridge1_9.isWearingElytra(player)) { // Defensive: don't demand isGliding.
|
||||||
return flyingModelElytra;
|
return flyingModelElytra;
|
||||||
}
|
}
|
||||||
// Default by game mode.
|
// 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.
|
// Default margin: Allow slightly less than the previous speed.
|
||||||
final double defaultAmount = lastMove.hDistance * (1.0 + Magic.FRICTION_MEDIUM_AIR) / 2.0;
|
final double defaultAmount = lastMove.hDistance * (1.0 + Magic.FRICTION_MEDIUM_AIR) / 2.0;
|
||||||
// Test for exceptions.
|
// 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).
|
// 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.)
|
// (Doesn't seem to be overly effective.)
|
||||||
final MoveData pastMove1 = data.moveData.get(1);
|
final MoveData pastMove1 = data.moveData.get(1);
|
||||||
|
@ -1850,6 +1850,7 @@ public class SurvivalFly extends Check {
|
|||||||
tags.add("lowfoodsprint");
|
tags.add("lowfoodsprint");
|
||||||
}
|
}
|
||||||
if (Bridge1_9.isWearingElytra(player)) {
|
if (Bridge1_9.isWearingElytra(player)) {
|
||||||
|
// Just wearing (not isGliding).
|
||||||
tags.add("elytra_off");
|
tags.add("elytra_off");
|
||||||
}
|
}
|
||||||
if (!tags.isEmpty()) {
|
if (!tags.isEmpty()) {
|
||||||
|
@ -56,7 +56,7 @@ public class MovingUtil {
|
|||||||
&& (cc.ignoreAllowFlight || !player.getAllowFlight())
|
&& (cc.ignoreAllowFlight || !player.getAllowFlight())
|
||||||
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY)
|
&& !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY)
|
||||||
&& (Bridge1_9.getLevitationAmplifier(player) == Double.NEGATIVE_INFINITY || fromLocation.isInLiquid())
|
&& (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);
|
&& !player.hasPermission(Permissions.MOVING_SURVIVALFLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ public class Bridge1_9 {
|
|||||||
private static final Material ELYTRA = Material.getMaterial("ELYTRA");
|
private static final Material ELYTRA = Material.getMaterial("ELYTRA");
|
||||||
|
|
||||||
private static Method getItemInOffHand = ReflectionUtil.getMethodNoArgs(PlayerInventory.class, "getItemInOffHand", ItemStack.class);
|
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() {
|
public static boolean hasLevitation() {
|
||||||
return LEVITATION != null;
|
return LEVITATION != null;
|
||||||
@ -37,6 +40,14 @@ public class Bridge1_9 {
|
|||||||
return getItemInOffHand != null;
|
return getItemInOffHand != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasGetItemInMainHand() {
|
||||||
|
return getItemInMainHand != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasIsGliding() {
|
||||||
|
return isGliding != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for the 'levitation' potion effect.
|
* Test for the 'levitation' potion effect.
|
||||||
*
|
*
|
||||||
@ -50,6 +61,15 @@ public class Bridge1_9 {
|
|||||||
return PotionUtil.getPotionEffectAmplifier(player, LEVITATION);
|
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
|
* 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.
|
* player may or may not be holding an end rod in either hand.
|
||||||
@ -86,9 +106,15 @@ public class Bridge1_9 {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static ItemStack getItemInMainHand(final Player player) {
|
public static ItemStack getItemInMainHand(final Player player) {
|
||||||
|
if (getItemInMainHand == null) {
|
||||||
return player.getItemInHand(); // As long as feasible (see: CraftInventoryPlayer).
|
return player.getItemInHand(); // As long as feasible (see: CraftInventoryPlayer).
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return player.getInventory().getItemInMainHand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the off hand item.
|
* Get the off hand item.
|
||||||
@ -101,7 +127,16 @@ public class Bridge1_9 {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
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