From 9b1d08bdb86bfa1513efa23440d934370a73f15c Mon Sep 17 00:00:00 2001 From: TheBukor Date: Fri, 1 Jul 2016 22:18:18 -0300 Subject: [PATCH] Little update to fix elytra glide state on 1.9.2 and 1.10 --- plugin.yml | 2 +- .../SkStuff/expressions/ExprGlideState.java | 9 +++------ src/me/TheBukor/SkStuff/util/NMSInterface.java | 3 +++ src/me/TheBukor/SkStuff/util/NMS_v1_10_R1.java | 13 +++++++++++++ src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java | 10 ++++++++++ src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java | 11 +++++++++++ src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java | 13 +++++++++++++ src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java | 13 +++++++++++++ 8 files changed, 67 insertions(+), 7 deletions(-) diff --git a/plugin.yml b/plugin.yml index 2bb0dbc..d32d8b6 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: SkStuff author: TheBukor description: A Skript addon which adds extra functionalities such as NBT and extended WorldEdit support. -version: 1.6.3.4 +version: 1.6.3.5 main: me.TheBukor.SkStuff.SkStuff softdepend: [Skript, WorldEdit, VanishNoPacket] \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/expressions/ExprGlideState.java b/src/me/TheBukor/SkStuff/expressions/ExprGlideState.java index db74d15..116426a 100644 --- a/src/me/TheBukor/SkStuff/expressions/ExprGlideState.java +++ b/src/me/TheBukor/SkStuff/expressions/ExprGlideState.java @@ -2,7 +2,6 @@ package me.TheBukor.SkStuff.expressions; import javax.annotation.Nullable; -import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Event; @@ -12,7 +11,7 @@ import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import ch.njol.util.coll.CollectionUtils; -import net.minecraft.server.v1_9_R1.EntityLiving; +import me.TheBukor.SkStuff.SkStuff; public class ExprGlideState extends SimpleExpression { private Expression entity; @@ -43,8 +42,7 @@ public class ExprGlideState extends SimpleExpression { @Nullable protected Boolean[] get(Event e) { LivingEntity ent = entity.getSingle(e); - EntityLiving nmsEntity = ((CraftLivingEntity) ent).getHandle(); - return new Boolean[] { nmsEntity.getFlag(7) }; + return new Boolean[] { SkStuff.getNMSMethods().getElytraGlideState(ent) }; } @SuppressWarnings("unchecked") @@ -60,10 +58,9 @@ public class ExprGlideState extends SimpleExpression { @Override public void change(Event e, @Nullable Object[] delta, ChangeMode mode) { LivingEntity ent = entity.getSingle(e); - EntityLiving nmsEntity = ((CraftLivingEntity) ent).getHandle(); if (mode == ChangeMode.SET) { boolean newValue = (boolean) delta[0]; - nmsEntity.setFlag(7, newValue); + SkStuff.getNMSMethods().setElytraGlideState(ent, newValue); } } } diff --git a/src/me/TheBukor/SkStuff/util/NMSInterface.java b/src/me/TheBukor/SkStuff/util/NMSInterface.java index 7f3bd7d..07a1143 100644 --- a/src/me/TheBukor/SkStuff/util/NMSInterface.java +++ b/src/me/TheBukor/SkStuff/util/NMSInterface.java @@ -89,4 +89,7 @@ public interface NMSInterface { public void setEntityStepLength(Entity entity, float length); + public boolean getElytraGlideState(Entity entity); + + public void setElytraGlideState(Entity entity, boolean glide); } \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_10_R1.java b/src/me/TheBukor/SkStuff/util/NMS_v1_10_R1.java index 04d5dcd..2c24d5a 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_10_R1.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_10_R1.java @@ -20,6 +20,7 @@ import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity; import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; @@ -54,6 +55,7 @@ import net.minecraft.server.v1_10_R1.PathfinderGoal; import net.minecraft.server.v1_10_R1.PathfinderGoalSelector; import net.minecraft.server.v1_10_R1.TileEntity; import net.minecraft.server.v1_10_R1.World; +import net.minecraft.server.v1_9_R1.EntityLiving; public class NMS_v1_10_R1 implements NMSInterface { @@ -700,4 +702,15 @@ public class NMS_v1_10_R1 implements NMSInterface { net.minecraft.server.v1_10_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle(); nmsEntity.P = length; } + + @Override + public boolean getElytraGlideState(Entity entity) { + EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle(); + return nmsEntity.getFlag(7); + } + + public void setElytraGlideState(Entity entity, boolean glide) { + EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle(); + nmsEntity.setFlag(7, glide); + } } \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java b/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java index 0a2bbf5..d01ab05 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_7_R4.java @@ -657,4 +657,14 @@ public class NMS_v1_7_R4 implements NMSInterface { net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) entity).getHandle(); nmsEntity.V = length; } + + @Override + public boolean getElytraGlideState(Entity entity) { + Bukkit.getLogger().warning("Executed \"Elytra Glide State\" code on 1.7! How the hell did this even happen!!"); + return false; + } + + public void setElytraGlideState(Entity entity, boolean glide) { + Bukkit.getLogger().warning("Executed \"Elytra Glide State\" code on 1.7! How the hell did this even happen!!"); + } } \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java b/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java index dfe2dab..971e9a0 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_8_R3.java @@ -14,6 +14,7 @@ import java.util.List; import javax.annotation.Nullable; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -664,4 +665,14 @@ public class NMS_v1_8_R3 implements NMSInterface { net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle(); nmsEntity.S = length; } + + @Override + public boolean getElytraGlideState(Entity entity) { + Bukkit.getLogger().warning("Executed \"Elytra Glide State\" code on 1.8! How the hell did this even happen!!"); + return false; + } + + public void setElytraGlideState(Entity entity, boolean glide) { + Bukkit.getLogger().warning("Executed \"Elytra Glide State\" code on 1.8! How the hell did this even happen!!"); + } } \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java index a642355..e204164 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R1.java @@ -19,6 +19,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_9_R1.CraftWorld; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.inventory.ItemStack; @@ -34,6 +35,7 @@ import ch.njol.util.coll.CollectionUtils; import ch.njol.yggdrasil.Fields; import net.minecraft.server.v1_9_R1.BlockPosition; import net.minecraft.server.v1_9_R1.EntityInsentient; +import net.minecraft.server.v1_9_R1.EntityLiving; import net.minecraft.server.v1_9_R1.IBlockData; import net.minecraft.server.v1_9_R1.Item; import net.minecraft.server.v1_9_R1.MinecraftKey; @@ -700,4 +702,15 @@ public class NMS_v1_9_R1 implements NMSInterface { net.minecraft.server.v1_9_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle(); nmsEntity.P = length; } + + @Override + public boolean getElytraGlideState(Entity entity) { + EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle(); + return nmsEntity.getFlag(7); + } + + public void setElytraGlideState(Entity entity, boolean glide) { + EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle(); + nmsEntity.setFlag(7, glide); + } } \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java index 2cf6bce..b9d7f73 100644 --- a/src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java +++ b/src/me/TheBukor/SkStuff/util/NMS_v1_9_R2.java @@ -17,6 +17,7 @@ import javax.annotation.Nullable; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack; @@ -32,6 +33,7 @@ import ch.njol.skript.lang.ParseContext; import ch.njol.skript.registrations.Classes; import ch.njol.util.coll.CollectionUtils; import ch.njol.yggdrasil.Fields; +import net.minecraft.server.v1_9_R1.EntityLiving; import net.minecraft.server.v1_9_R2.BlockPosition; import net.minecraft.server.v1_9_R2.EntityInsentient; import net.minecraft.server.v1_9_R2.IBlockData; @@ -700,4 +702,15 @@ public class NMS_v1_9_R2 implements NMSInterface { net.minecraft.server.v1_9_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle(); nmsEntity.P = length; } + + @Override + public boolean getElytraGlideState(Entity entity) { + EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle(); + return nmsEntity.getFlag(7); + } + + public void setElytraGlideState(Entity entity, boolean glide) { + EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle(); + nmsEntity.setFlag(7, glide); + } } \ No newline at end of file