Example Addon

The source code for the example addon can be found here

Creating the project

Create a new project and add Dimensions.jar to your build path

Creating the main class

package me.xxastaspastaxx.dimensions.addons.exampleaddon;

import org.bukkit.event.Listener;

import me.xxastaspastaxx.dimensions.addons.DimensionsAddon;
import me.xxastaspastaxx.dimensions.addons.DimensionsAddonPriority;

public class DimensionsExampleAddonMain extends DimensionsAddon implements Listener {

	public DimensionsExampleAddonMain() {
		super(addonName, addonVersion, addonDescription, addonPriority); //Replace with whatever you want
	}
	
}

Registering listener

Now we want to register our addon as a listener when the addon is being enabled so we add onEnable

@Override
public void onEnable(Dimensions pl) {
	Bukkit.getPluginManager().registerEvents(this, pl);
}

CustomPortalIgniteEvent

And finally we want to listen to the CustomPortalIgniteEvent so we can summon the explosion particles. We use the EventHandler like we would in any other case.

	
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void postPortalIgnite(CustomPortalIgniteEvent e) {
		//We check if the entity is a player, if its not we skip
		//If the player does not have permission, we also skip
		if (!(e.getEntity() instanceof Player) || !e.getEntity().hasPermission("dimensions.exampleaddon.explosion")) return;
		
		//Everything looks fine so we summon the explosion
		CompletePortal complete = e.getCompletePortal(); //We get the complete portal
		Location location = complete.getCenter(); //We get the center of the portal
		
		//We summon the particles
		location.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, location, 5);
}
	

Finishing up

Now that we are done with coding, we have to let Dimensions know about our addon otherwise its not going to load it.

You need to create a few folders and files inside our src folder.

src
└───main
    └───java
        └───META-INF
            └───services

Inside the services folder we need to create a new file named:

me.xxastaspastaxx.dimensions.addons.DimensionsAddon

Finally, inside the file, enter the path to your main class as you would with plugin.yml

for example in this case it would be

me.xxastaspastaxx.dimensions.addons.exampleaddon.DimensionsExampleAddonMain

This last part is required by ServiceLoader in order to load the addons properly

Done

Now you can put the addon you made inside ./plugins/Dimensions/Addons/ and restart your server.

Last updated