From 56f217c9f2ab3db180a5e4fdf478d0cb4b75ebdc Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 20 Mar 2016 11:42:16 +0100 Subject: [PATCH] Log in survivalfly, if the player is wearing elytra, but no end rod. --- .../checks/moving/SurvivalFly.java | 4 +++ .../nocheatplus/compat/Bridge1_9.java | 26 +++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) 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 038ec134..9696d4e3 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 @@ -22,6 +22,7 @@ import fr.neatmonster.nocheatplus.checks.moving.magic.MagicLiquid; import fr.neatmonster.nocheatplus.checks.moving.model.LiftOffEnvelope; import fr.neatmonster.nocheatplus.checks.moving.model.MoveData; 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.blocks.BlockChangeTracker; import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker.Direction; @@ -2205,6 +2206,9 @@ public class SurvivalFly extends Check { // Exception: does not take into account latency. tags.add("lowfoodsprint"); } + if (Bridge1_9.isWearingElytra(player)) { + tags.add("elytra_off"); + } if (!tags.isEmpty()) { builder.append("\n" + " tags: " + StringUtil.join(tags, "+")); } 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 84eef01c..ecf1d4ac 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 @@ -58,20 +58,20 @@ public class Bridge1_9 { * @return */ public static boolean isReadyForElytra(final Player player) { - // TODO: Off-hand testing needs to be supported, pass an instance for access. // TODO: Generic jet-pack / potion support (triggers + model configs). - if (END_ROD == null || ELYTRA == null) { - return false; - } - ItemStack stack = player.getInventory().getChestplate(); - if (stack == null || stack.getType() != ELYTRA) { - return false; - } - if (!hasItemInAnyHand(player, END_ROD)) { - return false; - } - // Possible to use elytra. - return true; + return END_ROD != null && ELYTRA != null && isWearingElytra(player) && hasItemInAnyHand(player, END_ROD); + } + + /** + * 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. + * + * @param player + * @return + */ + public static boolean isWearingElytra(final Player player) { + final ItemStack stack = player.getInventory().getChestplate(); + return stack != null && stack.getType() == ELYTRA; } /**