diff --git a/src/com/cnaude/chairs/core/PlayerSitData.java b/src/com/cnaude/chairs/core/PlayerSitData.java index bf48943..4f20c4f 100644 --- a/src/com/cnaude/chairs/core/PlayerSitData.java +++ b/src/com/cnaude/chairs/core/PlayerSitData.java @@ -40,60 +40,52 @@ public class PlayerSitData { return false; } sitlocation = playersitevent.getSitLocation().clone(); - try { - if (plugin.notifyplayer) { - player.sendMessage(plugin.msgSitting); - } - SitData sitdata = new SitData(); - Location arrowloc = sitlocation.getBlock().getLocation().add(0.5, 0 , 0.5); - Entity arrow = plugin.getNMSAccess().spawnArrow(arrowloc); - sitdata.arrow = arrow; - sitdata.teleportloc = player.getLocation(); - int task = Bukkit.getScheduler().scheduleSyncRepeatingTask( - plugin, - new Runnable() { - @Override - public void run() { - reSitPlayer(player); - } - }, - 1000, 1000 - ); - sitdata.resittask = task; - player.teleport(sitlocation); - arrow.setPassenger(player); - sitdata.sitting = true; - sit.put(player, sitdata); - sitblock.put(blocktooccupy, player); - } catch (Exception e) { - e.printStackTrace(); + if (plugin.notifyplayer) { + player.sendMessage(plugin.msgSitting); } + SitData sitdata = new SitData(); + Location arrowloc = sitlocation.getBlock().getLocation().add(0.5, 0 , 0.5); + Entity arrow = plugin.getNMSAccess().spawnArrow(arrowloc); + sitdata.arrow = arrow; + sitdata.teleportloc = player.getLocation(); + int task = Bukkit.getScheduler().scheduleSyncRepeatingTask( + plugin, + new Runnable() { + @Override + public void run() { + reSitPlayer(player); + } + }, + 1000, 1000 + ); + sitdata.resittask = task; + player.teleport(sitlocation); + arrow.setPassenger(player); + sitdata.sitting = true; + sit.put(player, sitdata); + sitblock.put(blocktooccupy, player); return true; } public void reSitPlayer(final Player player) { - try { - SitData sitdata = sit.get(player); - sitdata.sitting = false; - final Entity prevarrow = sit.get(player).arrow; - player.eject(); - Entity arrow = plugin.getNMSAccess().spawnArrow(prevarrow.getLocation()); - arrow.setPassenger(player); - sitdata.arrow = arrow; - sitdata.sitting = true; - Bukkit.getScheduler().scheduleSyncDelayedTask( - plugin, - new Runnable() { - @Override - public void run() { - prevarrow.remove(); - } - }, - 100 - ); - } catch (Exception e) { - e.printStackTrace(); - } + SitData sitdata = sit.get(player); + sitdata.sitting = false; + final Entity prevarrow = sit.get(player).arrow; + player.eject(); + Entity arrow = plugin.getNMSAccess().spawnArrow(prevarrow.getLocation()); + arrow.setPassenger(player); + sitdata.arrow = arrow; + sitdata.sitting = true; + Bukkit.getScheduler().scheduleSyncDelayedTask( + plugin, + new Runnable() { + @Override + public void run() { + prevarrow.remove(); + } + }, + 100 + ); } public boolean unsitPlayerNormal(Player player) { @@ -174,7 +166,7 @@ public class PlayerSitData { } private class SitData { - + private boolean sitting; private Entity arrow; private Location teleportloc; diff --git a/src/com/cnaude/chairs/sitaddons/ChairEffects.java b/src/com/cnaude/chairs/sitaddons/ChairEffects.java index d951db0..d90e440 100644 --- a/src/com/cnaude/chairs/sitaddons/ChairEffects.java +++ b/src/com/cnaude/chairs/sitaddons/ChairEffects.java @@ -1,11 +1,11 @@ package com.cnaude.chairs.sitaddons; import org.bukkit.Bukkit; +import org.bukkit.entity.Damageable; import org.bukkit.entity.Entity; import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.Item; import org.bukkit.entity.Player; -import org.bukkit.entity.Damageable; import org.bukkit.event.player.PlayerExpChangeEvent; import org.bukkit.event.player.PlayerLevelChangeEvent; import org.bukkit.event.player.PlayerPickupItemEvent; diff --git a/src/com/cnaude/chairs/vehiclearrow/NMSAccess.java b/src/com/cnaude/chairs/vehiclearrow/NMSAccess.java index ed408ad..00d341e 100644 --- a/src/com/cnaude/chairs/vehiclearrow/NMSAccess.java +++ b/src/com/cnaude/chairs/vehiclearrow/NMSAccess.java @@ -1,54 +1,27 @@ package com.cnaude.chairs.vehiclearrow; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.entity.Arrow; public class NMSAccess { - private Class nmsArrowClass; + private NMSArrowFactoryInterface arrowfactory; public void setupChairsArrow() throws NMSAccessException, ClassNotFoundException { String pkgname = getClass().getPackage().getName(); String packageName = Bukkit.getServer().getClass().getPackage().getName(); String nmspackageversion = packageName.substring(packageName.lastIndexOf('.') + 1); - switch (nmspackageversion) { - case "v1_7_R4": { - nmsArrowClass = Class.forName(pkgname+"."+"nmsV17R4"+".NMSChairsArrow"); - return; - } - case "v1_7_R3": { - nmsArrowClass = Class.forName(pkgname+"."+"nmsV17R3"+".NMSChairsArrow"); - return; - } - case "v1_7_R2": { - nmsArrowClass = Class.forName(pkgname+"."+"nmsV17R2"+".NMSChairsArrow"); - return; - } - case "v1_7_R1": { - nmsArrowClass = Class.forName(pkgname+"."+"nmsV17R1"+".NMSChairsArrow"); - return; - } - case "v1_6_R3": { - nmsArrowClass = Class.forName(pkgname+"."+"nmsV16R3"+".NMSChairsArrow"); - return; - } + try { + arrowfactory = (NMSArrowFactoryInterface) Class.forName(pkgname+"."+nmspackageversion+".NMSArrowFactory").newInstance(); + return; + } catch (Throwable t) { } throw new NMSAccessException("ChairsReloaded is not compatible with your server version"); } - public Arrow spawnArrow(Location location) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - World world = location.getWorld(); - Constructor ct = nmsArrowClass.getConstructor(world.getClass()); - NMSChairsArrowInterface vehiclearrow = (NMSChairsArrowInterface) ct.newInstance(world); - vehiclearrow.setArrowLocation(location); - vehiclearrow.addToWorld(); - vehiclearrow.setBukkitEntity(Bukkit.getServer()); - return vehiclearrow.getBukkitArrow(); + public Arrow spawnArrow(Location location) { + return arrowfactory.spawnArrow(location); } } diff --git a/src/com/cnaude/chairs/vehiclearrow/NMSArrowFactoryInterface.java b/src/com/cnaude/chairs/vehiclearrow/NMSArrowFactoryInterface.java new file mode 100644 index 0000000..74d9c3b --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/NMSArrowFactoryInterface.java @@ -0,0 +1,10 @@ +package com.cnaude.chairs.vehiclearrow; + +import org.bukkit.Location; +import org.bukkit.entity.Arrow; + +public interface NMSArrowFactoryInterface { + + public Arrow spawnArrow(Location location); + +} diff --git a/src/com/cnaude/chairs/vehiclearrow/NMSChairsArrowInterface.java b/src/com/cnaude/chairs/vehiclearrow/NMSChairsArrowInterface.java deleted file mode 100644 index 1f9d308..0000000 --- a/src/com/cnaude/chairs/vehiclearrow/NMSChairsArrowInterface.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.cnaude.chairs.vehiclearrow; - -import org.bukkit.Location; -import org.bukkit.Server; -import org.bukkit.entity.Arrow; - -public interface NMSChairsArrowInterface { - - public void setBukkitEntity(Server server); - - public Arrow getBukkitArrow(); - - public void setArrowLocation(Location location); - - public void addToWorld(); - -} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_6_R3/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_6_R3/CraftChairsArrow.java new file mode 100644 index 0000000..22200df --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_6_R3/CraftChairsArrow.java @@ -0,0 +1,30 @@ +package com.cnaude.chairs.vehiclearrow.v1_6_R3; + +import net.minecraft.server.v1_6_R3.EntityArrow; + +import org.bukkit.craftbukkit.v1_6_R3.CraftServer; +import org.bukkit.craftbukkit.v1_6_R3.entity.CraftArrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; + +import com.cnaude.chairs.api.ChairsAPI; + +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_6_R3/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_6_R3/NMSArrowFactory.java new file mode 100644 index 0000000..39bb602 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_6_R3/NMSArrowFactory.java @@ -0,0 +1,20 @@ +package com.cnaude.chairs.vehiclearrow.v1_6_R3; + +import net.minecraft.server.v1_6_R3.EntityArrow; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.CraftWorld; +import org.bukkit.entity.Arrow; + +import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; + +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_6_R3/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_6_R3/NMSChairsArrow.java new file mode 100644 index 0000000..a386329 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_6_R3/NMSChairsArrow.java @@ -0,0 +1,23 @@ +package com.cnaude.chairs.vehiclearrow.v1_6_R3; + +import net.minecraft.server.v1_6_R3.EntityArrow; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_6_R3.CraftServer; +import org.bukkit.craftbukkit.v1_6_R3.CraftWorld; + +public class NMSChairsArrow extends EntityArrow { + + 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 l_() { + } + +} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_7_R1/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R1/CraftChairsArrow.java new file mode 100644 index 0000000..3856118 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R1/CraftChairsArrow.java @@ -0,0 +1,30 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R1; + +import net.minecraft.server.v1_7_R1.EntityArrow; + +import org.bukkit.craftbukkit.v1_7_R1.CraftServer; +import org.bukkit.craftbukkit.v1_7_R1.entity.CraftArrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; + +import com.cnaude.chairs.api.ChairsAPI; + +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_7_R1/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R1/NMSArrowFactory.java new file mode 100644 index 0000000..5997891 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R1/NMSArrowFactory.java @@ -0,0 +1,20 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R1; + +import net.minecraft.server.v1_7_R1.EntityArrow; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R1.CraftWorld; +import org.bukkit.entity.Arrow; + +import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; + +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_7_R1/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R1/NMSChairsArrow.java new file mode 100644 index 0000000..8f45c84 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R1/NMSChairsArrow.java @@ -0,0 +1,23 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R1; + +import net.minecraft.server.v1_7_R1.EntityArrow; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R1.CraftServer; +import org.bukkit.craftbukkit.v1_7_R1.CraftWorld; + +public class NMSChairsArrow extends EntityArrow { + + 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 h() { + } + +} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_7_R2/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R2/CraftChairsArrow.java new file mode 100644 index 0000000..0e90bda --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R2/CraftChairsArrow.java @@ -0,0 +1,30 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R2; + +import net.minecraft.server.v1_7_R2.EntityArrow; + +import org.bukkit.craftbukkit.v1_7_R2.CraftServer; +import org.bukkit.craftbukkit.v1_7_R2.entity.CraftArrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; + +import com.cnaude.chairs.api.ChairsAPI; + +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_7_R2/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R2/NMSArrowFactory.java new file mode 100644 index 0000000..d777440 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R2/NMSArrowFactory.java @@ -0,0 +1,20 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R2; + +import net.minecraft.server.v1_7_R2.EntityArrow; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R2.CraftWorld; +import org.bukkit.entity.Arrow; + +import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; + +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_7_R2/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R2/NMSChairsArrow.java new file mode 100644 index 0000000..8b79a69 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R2/NMSChairsArrow.java @@ -0,0 +1,23 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R2; + +import net.minecraft.server.v1_7_R2.EntityArrow; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R2.CraftServer; +import org.bukkit.craftbukkit.v1_7_R2.CraftWorld; + +public class NMSChairsArrow extends EntityArrow { + + 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 h() { + } + +} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_7_R3/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R3/CraftChairsArrow.java new file mode 100644 index 0000000..37f3e92 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R3/CraftChairsArrow.java @@ -0,0 +1,30 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R3; + +import net.minecraft.server.v1_7_R3.EntityArrow; + +import org.bukkit.craftbukkit.v1_7_R3.CraftServer; +import org.bukkit.craftbukkit.v1_7_R3.entity.CraftArrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; + +import com.cnaude.chairs.api.ChairsAPI; + +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_7_R3/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R3/NMSArrowFactory.java new file mode 100644 index 0000000..37ecd7c --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R3/NMSArrowFactory.java @@ -0,0 +1,20 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R3; + +import net.minecraft.server.v1_7_R3.EntityArrow; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R3.CraftWorld; +import org.bukkit.entity.Arrow; + +import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; + +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_7_R3/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R3/NMSChairsArrow.java new file mode 100644 index 0000000..4b0520c --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R3/NMSChairsArrow.java @@ -0,0 +1,23 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R3; + +import net.minecraft.server.v1_7_R3.EntityArrow; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R3.CraftServer; +import org.bukkit.craftbukkit.v1_7_R3.CraftWorld; + +public class NMSChairsArrow extends EntityArrow { + + 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 h() { + } + +} diff --git a/src/com/cnaude/chairs/vehiclearrow/v1_7_R4/CraftChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R4/CraftChairsArrow.java new file mode 100644 index 0000000..5b5b9ec --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R4/CraftChairsArrow.java @@ -0,0 +1,30 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R4; + +import net.minecraft.server.v1_7_R4.EntityArrow; + +import org.bukkit.craftbukkit.v1_7_R4.CraftServer; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Vehicle; + +import com.cnaude.chairs.api.ChairsAPI; + +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_7_R4/NMSArrowFactory.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R4/NMSArrowFactory.java new file mode 100644 index 0000000..efd1f33 --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R4/NMSArrowFactory.java @@ -0,0 +1,20 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R4; + +import net.minecraft.server.v1_7_R4.EntityArrow; + +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.entity.Arrow; + +import com.cnaude.chairs.vehiclearrow.NMSArrowFactoryInterface; + +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_7_R4/NMSChairsArrow.java b/src/com/cnaude/chairs/vehiclearrow/v1_7_R4/NMSChairsArrow.java new file mode 100644 index 0000000..c5b3e9e --- /dev/null +++ b/src/com/cnaude/chairs/vehiclearrow/v1_7_R4/NMSChairsArrow.java @@ -0,0 +1,23 @@ +package com.cnaude.chairs.vehiclearrow.v1_7_R4; + +import net.minecraft.server.v1_7_R4.EntityArrow; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_7_R4.CraftServer; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; + +public class NMSChairsArrow extends EntityArrow { + + 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 h() { + } + +}