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.
|
* 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
|
* @param passengers the entity ids of the passengers
|
||||||
|
|
|
@ -22,21 +22,21 @@ public class TestCommand implements CommandExecutor {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (base != null) {
|
if (base != null) {
|
||||||
base.removePassenger(passenger);
|
if (base.hasPassenger(passenger)) {
|
||||||
player.sendMessage("Removed");
|
base.removePassenger(passenger);
|
||||||
return true;
|
player.sendMessage("Removed");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
base = EntityLib.createEntity(UUID.randomUUID(), EntityTypes.SHEEP);
|
base = EntityLib.createEntity(UUID.randomUUID(), EntityTypes.SHEEP);
|
||||||
passenger = EntityLib.createEntity(UUID.randomUUID(), EntityTypes.SKELETON);
|
passenger = EntityLib.createEntity(UUID.randomUUID(), EntityTypes.SKELETON);
|
||||||
|
|
||||||
Location location = SpigotConversionUtil.fromBukkitLocation(player.getLocation());
|
Location location = SpigotConversionUtil.fromBukkitLocation(player.getLocation());
|
||||||
Location pass = location.clone();
|
Location pass = new Location(location.getX() + 1, location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||||
pass.setPosition(location.getPosition().add(1, 0, 1));
|
|
||||||
base.spawn(location);
|
base.spawn(location);
|
||||||
passenger.spawn(pass);
|
passenger.spawn(pass);
|
||||||
base.addPassenger(passenger);
|
|
||||||
|
|
||||||
player.sendMessage("Spawned");
|
player.sendMessage("Spawned");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue