Accessing the API
ParticlePlus leverages the Bukkit ServicesManager to expose its functionality safely and efficiently.
Getting the API Instance
Use the built-in ParticlePlusProvider utility class.
import me.dominikhun250.dev.particleplus.api.ParticlePlusAPI;
import me.dominikhun250.dev.particleplus.api.ParticlePlusProvider;
public class MyEffectManager {
private ParticlePlusAPI api;
public void init() {
this.api = ParticlePlusProvider.getAPI();
if (api != null) {
System.out.println("[MyHook] Connected to ParticlePlus!");
} else {
System.err.println("[MyHook] ParticlePlus API not found!");
}
}
}Practical Examples
Creative: Blood Spatter Effect
Spawns a burst of red particles when a player is damaged.
@EventHandler
public void onDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player player)) return;
ParticleMix bloodEffect = new ParticleMix.Builder()
.setCount(15)
.setRadius(0.5)
.addRGBParticle(Color.RED, 1.0f)
.build();
api.startEntityTask(player, bloodEffect);
}Creative: Area Protection Visualizer
Uses the new Bounds feature to show particles only within a specific region.
public void markSafeZone(Location corner1, Location corner2) {
ParticleMix zoneEffect = new ParticleMix.Builder()
.setMinPosition(corner1.getX(), corner1.getY(), corner1.getZ())
.setMaxPosition(corner2.getX(), corner2.getY(), corner2.getZ())
.setCount(20)
.addParticle(Particle.GLOW)
.build();
// Start a location task at the center
api.startLocationTask(corner1, zoneEffect);
}Stopping Tasks
api.stopEntityTask(player);
api.stopLocationTask(taskId);