Skip to content

Getting Started with pathetic‐bukkit

Benjamin Sommerfeld edited this page Feb 4, 2025 · 1 revision

First of all, you have to initialize Pathetic with your JavaPlugin instance in the onEnable method of your plugin.

    PatheticBukkit.initialize(this);

After this, you can use Pathetic everywhere by instantiating a PathfinderFactory which you can use to create a new Pathfinder instance for your purpose. Currently there is only the AStarPathfinderFactory.

    PathfinderFactory factory = new AStarPathfinderFactory();

Some Pathfinder need a specific initializer - and Spigot is an environment which requires one. Instantiate the Initializer like this:

    PathfinderInitializer initializer = new BukkitPathfinderInitializer();

Now we need to give the Pathfinder some rules to consider. These rules come in form of a PathfinderConfiguration. You can instantiate one by using the Builder.

    PathfinderConfiguration configuration =
        PathfinderConfiguration.builder()
            .provider(new LoadingNavigationPointProvider())
            .fallback(true)
            .build();

Here you may see something weird. What is a LoadingNavigationPointProvider? Currently there are two types of NavigationPointProvider for Bukkit.

  • FailingNavigationPointProvider
  • LoadingNavigationPointProvider

The difference between these two is, that the Loading one will load chunks if necessary and the Failing one will simply fail if it can't access the information it needs (á la a chunk is not loaded it needs to access).

Finally, we can construct our Pathfinder instance using all the components we just instantiated:

    Pathfinder reusablePathfinder = factory.createPathfinder(configuration, initializer);

So your full code may look like this.

Clone this wiki locally