diff --git a/NCPCore/pom.xml b/NCPCore/pom.xml
index c81b1622..2be0f5d6 100644
--- a/NCPCore/pom.xml
+++ b/NCPCore/pom.xml
@@ -17,7 +17,7 @@
org.bukkit
bukkit
- 1.8.8-R0.1-SNAPSHOT
+ 1.9-R0.1-SNAPSHOT
provided
diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java
index 8cde2197..1a279c07 100644
--- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java
+++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingConfig.java
@@ -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.
diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java
index 8006468c..e9baa28d 100644
--- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java
+++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java
@@ -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);
diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java
index 41901433..c9a41c89 100644
--- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java
+++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java
@@ -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()) {
diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/util/MovingUtil.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/util/MovingUtil.java
index 62a037b6..de76f3dc 100644
--- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/util/MovingUtil.java
+++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/util/MovingUtil.java
@@ -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);
}
diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/Bridge1_9.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/Bridge1_9.java
index 15d23cad..91b0e1cf 100644
--- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/Bridge1_9.java
+++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/Bridge1_9.java
@@ -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();
}
}