api/Ships 5

This API is not fully released, there maybe API you need that is in Ships 5 that isnt on this page.

Version: Ships


Getting a Vessel

getting a Vessel could not be any simpler. Get the vessel by 'Ships sign,' block or name of the vessel.

import MoseShips.StillShips.Vessel.Vessel;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;

Vessel vessel = Vessel.getVessel(String name);
//rescanning is much slower but it gets the latest update, if rescan is now set to true, then it will check the vessels structures for the block (much quicker and less stress on the server)
Vessel vessel = Vessel.getVessel(Block block, boolean rescan);
Vessel vessel = Vessel.getVessel(Sign sign);

getting a VesselType

there are a few ways to get a vesselType as shown below.

import MoseShips.ShipTypes.VesselType;
import MoseShips.StillShip.Vessel.Vessel;

//This way will come with the changed variables (such as speed) 
Vessel vessel;
VesselType type = vessel.getVesselType();

//This way is the way to get a default type with all default variables.
//replace AIRSHIP with the vesseltype you wish 
VesselType type = VesselTypes.AIRSHIP.get().clone();

//This way is the way to get custom vessel type (that should have defaults), this method also gets normal vessels
VesselType type = VesselType.getTypeByName("vesselName").clone();

//then there are these ways
//get all the vesseltypes that are not custom
VesselType[] types = VesselTypes.values();

//get all the vesseltypes that are custom
List<VesselType> types = VesselType.customValues();

//gets all the vesseltypes
List<VesselType> types = values();

display all the info to a player

This is a very simple thing but should not be missed

vessel.displayInfo(Player player);

getting the Ships size

getting the total amount of blocks is below, but here is some other methods you could use that might help

vessel.getHeight(boolean updateStructure);  //this is Y axis
vessel.getWidth(boolean updateStructure); //this is Z axis
vessel.getLength(boolean updateStructure); //this is X axis

getting the ships blocks

With ships 5 blocks are broken down into three sections. Priority, Special and standard, these groups are used inside Ships 5 to move the vessel but this should not matter to you.

Vessel vessel;
List<Block> blocks = vessel.getStructure().getAllBlocks();

//If you wish to get the moving blocks of the structure here is how (vessel must be moving/sub moving)

Structure structure = vessel.getStruture();
If (structure instanceof MovingStructure){
    MovingStructure stru = structure;

Moving a vessel

This is a little tricky at times because the move method uses a engm called MovementMethod that moves the vessel forward, backward, left, right, rotate left, rotate right, up and down. meaning you need to know the direction the vessel is facing. luckily there is a easy way to do it.

Vessel vessel;
BlockFace vesseldirection = vessel.getFacingDirection();

//MovementMethod = the direction of the ships movement
//speed = amount of blocks the vessel moves in the chosen motion (if rotating, the speed should be set to 0)
//player = the player who receives all the messages
vessel.safeMove(MovementMethod method, int speed, @Nullable OfflinePlayer player);

//i may work on a move method that uses BlockFace instead of MovementMethod, but your stuck with one option so far

If you wish the vessel to move towards a location, you now can

vessel.syncSafelyMoveTowardsLocation(Location loc, int speed, @Nullable OfflinePlayer player);

If you wish to move the vessel to a new location without the steps inbetween, try teleporting the vessel

//the location will be the licence signs new location
vessel.forceTeleport(Location loc);

//this version is not forced so it will check if the location is safe to teleport to
vessel.teleportVessel(Location loc, @Nullable OfflinePlayer player)

Removing a vessel

//assuming you already have the vessel as a variable


all events are cancel-able

Create Vessel

You can get the following from this event

  • Player (player who created the vessel. AKA owner)
  • Sign (The vessels licence sign. The sign will be blank)
  • MovingVessel (The vessel that was created)
public static void createVessel(ShipCreateEvent event){

About to move

This is not triggered if the trigger to move the vessel is forceMove() or forceTeleport()

you can get the following from the event

  • Player (the player who triggered the vessel to move - can be null)
  • Vessel (the moving vessel)
  • MovementMethod (the movement the vessel is making)
  • OfflinePlayer (the player who triggered the vessel to move - can be null)
public static void shipAboutToMove(ShipAboutToMoveEvent event){

Move Vessel

This is not triggered if the trigger to move the vessel is forceMove() or forceTeleport()

you can get the following from the event

  • Player (the player who triggered the vessel to move - can be null)
  • Vessel (the moving vessel)
  • MovementMethod (the movement the vessel is making)
  • MovingStructure (the vessels moving structure)
  • OfflinePlayer (the player who triggered the vessel to move - can be null)
public static void shipMove(ShipMovingEvent event){

Ship finished moving event

This event IS triggered when the vessel is moving in may means including forced.

you can get the following from the event

  • Vessel (the target vessel)

Ships Sign Creation

You can get the following from this event

  • JavaPlugin (this plugin that called the event)
  • Player (the player who created the sign)
  • String[] (The text that the sign has on it)
  • String[] (The text the user typed on the sign)
  • String[] (The text that will end up on the sign after the event is finished)
  • Sign (The sign the user placed)
public static void ShipsSignCreation(ShipsSignCreation event){

Vessel attempt to load

This is fired when a Vessel is attempting to load (as in converting from a file to a Vessel object)

what you can get from the event

  • File (the vessels file it is trying to read)
public static void onVesselLoad(VesselAttemptToLoadEvent event){


Creating your own Ships command

public class className extends CommandLauncher{
        //extend CommandLauncher
	public className() {
		super("<command Name>", "<command arguments>", "<description>", "<permission - null if no permission required>", boolean player command, boolean console command);

	public void playerCommand(Player player, String[] args) {
            //add your player code here. Note, this will only be ran if the command is yours, therefore you dont need to bother checking if the command is your

	public void consoleCommand(ConsoleCommandSender sender, String[] args) {
	    //same as player command only for console

once you have done that all you need to do is have the following 1 line of code

    new className();

Creating your own VesselType

Ships 5 allows you to create your own vessel types with its own rules

try some of these implementations, Ships uses these to display more info when a user is getting info of the vessel.

public class example implements Fuel, RequiredMaterial, Cell, ClassicVessel{

if you get confused, take a look at the github page for these vessels for inspiration.

public class Example extends VesselType{

	public Example() {
                //Sets some of the default values
		super(String name, ArrayList<Material> movein, int speed, int boost, boolean isAutoPilot);

	public boolean checkRequirements(MovableVessel vessel, MovementMethod move, List<MovingBlock> blocks, Player player) {
		// put the requirements for the vessel here, if it returns false then the vessel will not move.
		return false;

	public boolean shouldFall(ProtectedVessel vessel) {
		// In later versions of Ships, Vessels will fall, it will call this method if Ships thinks it should fall, return false if you wish to cancel the fall
		return false;

	public File getTypeFile() {
		// the file location of the config for your vessel type
		return null;

	public VesselType clone() {
		//this will create a exact copy of this vesselType. This will stop multiple vessels changing data when only 1 should change
		return null;

	public void loadVesselFromFiveFile(ProtectedVessel vessel, File file) {
		// This loads the vessel from a data file

	public void createConfig() {
		// This will create the config for your vesselType

	public void loadDefault() {
		// This loads the default data for your vesselType

	public void save(ProtectedVessel vessel) {
		// This creates a vesselData file under your vesseltype


Posts Quoted:
Clear All Quotes