Little update to fix elytra glide state on 1.9.2 and 1.10

This commit is contained in:
TheBukor 2016-07-01 22:18:18 -03:00
parent ca8518d432
commit 9b1d08bdb8
8 changed files with 67 additions and 7 deletions

View File

@ -1,6 +1,6 @@
name: SkStuff name: SkStuff
author: TheBukor author: TheBukor
description: A Skript addon which adds extra functionalities such as NBT and extended WorldEdit support. 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 main: me.TheBukor.SkStuff.SkStuff
softdepend: [Skript, WorldEdit, VanishNoPacket] softdepend: [Skript, WorldEdit, VanishNoPacket]

View File

@ -2,7 +2,6 @@ package me.TheBukor.SkStuff.expressions;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event; 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.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean; import ch.njol.util.Kleenean;
import ch.njol.util.coll.CollectionUtils; import ch.njol.util.coll.CollectionUtils;
import net.minecraft.server.v1_9_R1.EntityLiving; import me.TheBukor.SkStuff.SkStuff;
public class ExprGlideState extends SimpleExpression<Boolean> { public class ExprGlideState extends SimpleExpression<Boolean> {
private Expression<LivingEntity> entity; private Expression<LivingEntity> entity;
@ -43,8 +42,7 @@ public class ExprGlideState extends SimpleExpression<Boolean> {
@Nullable @Nullable
protected Boolean[] get(Event e) { protected Boolean[] get(Event e) {
LivingEntity ent = entity.getSingle(e); LivingEntity ent = entity.getSingle(e);
EntityLiving nmsEntity = ((CraftLivingEntity) ent).getHandle(); return new Boolean[] { SkStuff.getNMSMethods().getElytraGlideState(ent) };
return new Boolean[] { nmsEntity.getFlag(7) };
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -60,10 +58,9 @@ public class ExprGlideState extends SimpleExpression<Boolean> {
@Override @Override
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) { public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
LivingEntity ent = entity.getSingle(e); LivingEntity ent = entity.getSingle(e);
EntityLiving nmsEntity = ((CraftLivingEntity) ent).getHandle();
if (mode == ChangeMode.SET) { if (mode == ChangeMode.SET) {
boolean newValue = (boolean) delta[0]; boolean newValue = (boolean) delta[0];
nmsEntity.setFlag(7, newValue); SkStuff.getNMSMethods().setElytraGlideState(ent, newValue);
} }
} }
} }

View File

@ -89,4 +89,7 @@ public interface NMSInterface {
public void setEntityStepLength(Entity entity, float length); public void setEntityStepLength(Entity entity, float length);
public boolean getElytraGlideState(Entity entity);
public void setElytraGlideState(Entity entity, boolean glide);
} }

View File

@ -20,6 +20,7 @@ import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack; 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.entity.Entity;
import org.bukkit.inventory.ItemStack; 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.PathfinderGoalSelector;
import net.minecraft.server.v1_10_R1.TileEntity; import net.minecraft.server.v1_10_R1.TileEntity;
import net.minecraft.server.v1_10_R1.World; import net.minecraft.server.v1_10_R1.World;
import net.minecraft.server.v1_9_R1.EntityLiving;
public class NMS_v1_10_R1 implements NMSInterface { 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(); net.minecraft.server.v1_10_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.P = length; 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);
}
} }

View File

@ -657,4 +657,14 @@ public class NMS_v1_7_R4 implements NMSInterface {
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) entity).getHandle(); net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.V = length; 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!!");
}
} }

View File

@ -14,6 +14,7 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; 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(); net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.S = length; 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!!");
}
} }

View File

@ -19,6 +19,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld; 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.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -34,6 +35,7 @@ import ch.njol.util.coll.CollectionUtils;
import ch.njol.yggdrasil.Fields; import ch.njol.yggdrasil.Fields;
import net.minecraft.server.v1_9_R1.BlockPosition; import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.EntityInsentient; 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.IBlockData;
import net.minecraft.server.v1_9_R1.Item; import net.minecraft.server.v1_9_R1.Item;
import net.minecraft.server.v1_9_R1.MinecraftKey; 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(); net.minecraft.server.v1_9_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.P = length; 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);
}
} }

View File

@ -17,6 +17,7 @@ import javax.annotation.Nullable;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; 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.CraftWorld;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack; 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.skript.registrations.Classes;
import ch.njol.util.coll.CollectionUtils; import ch.njol.util.coll.CollectionUtils;
import ch.njol.yggdrasil.Fields; 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.BlockPosition;
import net.minecraft.server.v1_9_R2.EntityInsentient; import net.minecraft.server.v1_9_R2.EntityInsentient;
import net.minecraft.server.v1_9_R2.IBlockData; 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(); net.minecraft.server.v1_9_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.P = length; 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);
}
} }