add more passenger util
This commit is contained in:
parent
1aea64407c
commit
c08d27ec41
2 changed files with 23 additions and 7 deletions
|
@ -99,6 +99,22 @@ public class WrapperEntity implements Tickable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param passenger the entity id of the passenger
|
||||
* @return true if the entity has the passenger, false otherwise
|
||||
*/
|
||||
public boolean hasPassenger(int passenger) {
|
||||
return passengers.contains(passenger);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param passenger the passenger wrapper entity
|
||||
* @return true if the entity has the passenger, false otherwise
|
||||
*/
|
||||
public boolean hasPassenger(WrapperEntity passenger) {
|
||||
return hasPassenger(passenger.getEntityId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes multiple passengers from the entity. The passengers will be removed from the view of all viewers of the entity.
|
||||
* @param passengers the entity ids of the passengers
|
||||
|
|
|
@ -22,21 +22,21 @@ public class TestCommand implements CommandExecutor {
|
|||
Player player = (Player) sender;
|
||||
|
||||
if (base != null) {
|
||||
if (base.hasPassenger(passenger)) {
|
||||
base.removePassenger(passenger);
|
||||
player.sendMessage("Removed");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
base = EntityLib.createEntity(UUID.randomUUID(), EntityTypes.SHEEP);
|
||||
passenger = EntityLib.createEntity(UUID.randomUUID(), EntityTypes.SKELETON);
|
||||
|
||||
Location location = SpigotConversionUtil.fromBukkitLocation(player.getLocation());
|
||||
Location pass = location.clone();
|
||||
pass.setPosition(location.getPosition().add(1, 0, 1));
|
||||
Location pass = new Location(location.getX() + 1, location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
base.spawn(location);
|
||||
passenger.spawn(pass);
|
||||
base.addPassenger(passenger);
|
||||
|
||||
player.sendMessage("Spawned");
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue