From 43807c42a1a122f3fca05b7724efa2943f0626c1 Mon Sep 17 00:00:00 2001 From: Roy Curtis Date: Fri, 18 Nov 2016 09:55:49 +0000 Subject: [PATCH] Implement NMS arrow for 1.11 --- .../v1_11_R1/CraftChairsArrow.java | 28 +++++++++++++++++++ .../v1_11_R1/NMSArrowFactory.java | 18 ++++++++++++ .../vehiclearrow/v1_11_R1/NMSChairsArrow.java | 21 ++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 src/com/cnaude/chairs/vehiclearrow/v1_11_R1/CraftChairsArrow.java create mode 100644 src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSArrowFactory.java create mode 100644 src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSChairsArrow.java diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/CraftChairsArrow.java new file mode 100644 index 0000000..1b9b09a --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/CraftChairsArrow.java @@ -0,0 +1,28 @@ +package com.cnaude.chairs.vehiclearrow.v1_11_R1; + +import com.cnaude.chairs.api.ChairsAPI; +import net.minecraft.server.v1_11_R1.EntityArrow; +import org.bukkit.craftbukkit.v1_11_R1.CraftServer; +import org.bukkit.craftbukkit.v1_11_R1.entity.CraftArrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; + +public class CraftChairsArrow extends CraftArrow implements Vehicle { + + public CraftChairsArrow(CraftServer server, EntityArrow entity) { + super(server, entity); + } + + @Override + public void remove() { + Entity passenger = getPassenger(); + if (passenger != null && passenger instanceof Player) { + if (ChairsAPI.isSitting((Player) passenger)) { + return; + } + } + super.remove(); + } + +} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSArrowFactory.java new file mode 100644 index 0000000..f58f5ea --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSArrowFactory.java @@ -0,0 +1,18 @@ +package com.cnaude.chairs.vehiclearrow.v1_11_R1; + +import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; +import net.minecraft.server.v1_11_R1.EntityArrow; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; +import org.bukkit.entity.Arrow; + +public class NMSArrowFactory implements NMSArrowFactoryInterface { + + @Override + public Arrow spawnArrow(Location location) { + CraftWorld world = (CraftWorld) location.getWorld(); + EntityArrow arrow = new NMSChairsArrow(world, location); + return (Arrow) arrow.getBukkitEntity(); + } + +} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSChairsArrow.java new file mode 100644 index 0000000..04119a6 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_11_R1/NMSChairsArrow.java @@ -0,0 +1,21 @@ +package com.cnaude.chairs.vehiclearrow.v1_11_R1; + +import net.minecraft.server.v1_11_R1.EntityTippedArrow; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_11_R1.CraftServer; +import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; + +public class NMSChairsArrow extends EntityTippedArrow { + + public NMSChairsArrow(CraftWorld cworld, Location location) { + super(cworld.getHandle()); + setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + world.addEntity(this); + bukkitEntity = new CraftChairsArrow((CraftServer) Bukkit.getServer(), this); + } + + @Override + public void A_() { + } +}