Use new factory approach
This commit is contained in:
parent
3a3c322c0d
commit
068eaf2a13
@ -40,7 +40,6 @@ public class PlayerSitData {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sitlocation = playersitevent.getSitLocation().clone();
|
sitlocation = playersitevent.getSitLocation().clone();
|
||||||
try {
|
|
||||||
if (plugin.notifyplayer) {
|
if (plugin.notifyplayer) {
|
||||||
player.sendMessage(plugin.msgSitting);
|
player.sendMessage(plugin.msgSitting);
|
||||||
}
|
}
|
||||||
@ -65,14 +64,10 @@ public class PlayerSitData {
|
|||||||
sitdata.sitting = true;
|
sitdata.sitting = true;
|
||||||
sit.put(player, sitdata);
|
sit.put(player, sitdata);
|
||||||
sitblock.put(blocktooccupy, player);
|
sitblock.put(blocktooccupy, player);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reSitPlayer(final Player player) {
|
public void reSitPlayer(final Player player) {
|
||||||
try {
|
|
||||||
SitData sitdata = sit.get(player);
|
SitData sitdata = sit.get(player);
|
||||||
sitdata.sitting = false;
|
sitdata.sitting = false;
|
||||||
final Entity prevarrow = sit.get(player).arrow;
|
final Entity prevarrow = sit.get(player).arrow;
|
||||||
@ -91,9 +86,6 @@ public class PlayerSitData {
|
|||||||
},
|
},
|
||||||
100
|
100
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean unsitPlayerNormal(Player player) {
|
public boolean unsitPlayerNormal(Player player) {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package com.cnaude.chairs.sitaddons;
|
package com.cnaude.chairs.sitaddons;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Damageable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.entity.ExperienceOrb;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Damageable;
|
|
||||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
import org.bukkit.event.player.PlayerExpChangeEvent;
|
||||||
import org.bukkit.event.player.PlayerLevelChangeEvent;
|
import org.bukkit.event.player.PlayerLevelChangeEvent;
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
|
@ -1,54 +1,27 @@
|
|||||||
package com.cnaude.chairs.vehiclearrow;
|
package com.cnaude.chairs.vehiclearrow;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
|
|
||||||
public class NMSAccess {
|
public class NMSAccess {
|
||||||
|
|
||||||
private Class<?> nmsArrowClass;
|
private NMSArrowFactoryInterface arrowfactory;
|
||||||
|
|
||||||
public void setupChairsArrow() throws NMSAccessException, ClassNotFoundException {
|
public void setupChairsArrow() throws NMSAccessException, ClassNotFoundException {
|
||||||
String pkgname = getClass().getPackage().getName();
|
String pkgname = getClass().getPackage().getName();
|
||||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
String nmspackageversion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
String nmspackageversion = packageName.substring(packageName.lastIndexOf('.') + 1);
|
||||||
switch (nmspackageversion) {
|
try {
|
||||||
case "v1_7_R4": {
|
arrowfactory = (NMSArrowFactoryInterface) Class.forName(pkgname+"."+nmspackageversion+".NMSArrowFactory").newInstance();
|
||||||
nmsArrowClass = Class.forName(pkgname+"."+"nmsV17R4"+".NMSChairsArrow");
|
|
||||||
return;
|
return;
|
||||||
}
|
} catch (Throwable t) {
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
throw new NMSAccessException("ChairsReloaded is not compatible with your server version");
|
throw new NMSAccessException("ChairsReloaded is not compatible with your server version");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Arrow spawnArrow(Location location) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public Arrow spawnArrow(Location location) {
|
||||||
World world = location.getWorld();
|
return arrowfactory.spawnArrow(location);
|
||||||
Constructor<?> ct = nmsArrowClass.getConstructor(world.getClass());
|
|
||||||
NMSChairsArrowInterface vehiclearrow = (NMSChairsArrowInterface) ct.newInstance(world);
|
|
||||||
vehiclearrow.setArrowLocation(location);
|
|
||||||
vehiclearrow.addToWorld();
|
|
||||||
vehiclearrow.setBukkitEntity(Bukkit.getServer());
|
|
||||||
return vehiclearrow.getBukkitArrow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
}
|
@ -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();
|
|
||||||
|
|
||||||
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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_() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user