Skip to main content

VirtualPlayers API

The VirtualPlayers API can be accessed through the VirtualPlayers class, by calling VirtualPlayers.api(). 

VirtualPlayer can be created using the createVirtualPlayer(String) method. A VirtualPlayer extends Bukkit's Player class, meaning all functions available to a normal Player will be available here. Keep in mind that some methods may not work as intended, since a VirtualPlayer is.. well... a virtual player at the end of the day, so functionality like sending block changes or adding them as a passenger to an entity will not work.

Within the VirtualPlayer class, you can also run addObserver(CommandSender) to observe a virtual player. You can also get a list of all observers by running getObservers().

VirtualPlayers can be removed using the removeVirtualPlayer(VirtualPlayermethod in the VirtualPlayers API class. You can also retrieve a VirtualPlayer by calling getVirtualPlayer(String), taking in the name of the VirtualPlayer.

For a full list of methods and classes offered by the API, see the VirtualPlayers Javadocs.