api/events/documentation/DMGenerationSpawner

Dungeon Maze API - Events - Event Documentation - DMGenerationSpawner

The DMGenerationSpawner is called when a spawneris generated in Dungeon Maze. This event could be used to set the spawned type of the spawners, you can cancel the chest generation and you can even do other things too.

How to listen to the event

It's very easy to listen to Dungeon Maze events, the same system is used as bukkit does. Because of this, listening to an event should be extremely easy to do. If you want to listen to an event, you don't even have to hook into the Dungeon Maze api, wich makes it even easier to use. Read the paragraph bellow for an example about listening to the event.

Dungeon Maze Event Listener example - DMGenerationSpawner

We hightly recommend to create a new listener class for the Dungeon Maze API to keep your project organized, but it's up to you where you put the listener. You can add them in the same class file as your block listeners for example.

First make sure you've implemeted the DungeonMaze.jar file into your project.

Bellow you can see an example of a listener using this event:

import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import com.timvisee.DungeonMaze.event.generation.DMGenerationSpawnerEvent;

public class DungeonMazeApiListener implements Listener  {
	
	@EventHandler
	public void onDMGenerationSpawner(DMGenerationSpawnerEvent event) {
		// Set the spawned type to zombie
		event.setSpawnedType(EntityType.ZOMBIE);
	}
}

This listener changes every new generated mob spawner into a zombie spawner

Event Features

Bellow you can find a list of features this event contains.

FunctionDescription
.isCancelled();Check if the event is cancelled
.setCancelled(boolean cancelled);Set if the event will be cancelled
.getBlock();Get the block location the spawner is created
.getDMLevel();Get the level the block is on
.getWorld();Get the world the spawner is created in
.getSpawnedType();Get the spawned entity type of the spawner
.setSpawnedType(EntityType type);Set the spawned entity type of the spawner
.getCause();Get the reason the spawner was created
.getRandom();Get the random object from the Dungeon Maze generator, to add seeds support
.getHandlers()Get the handlers list
.getHandlerList();Get the handlers list
.getServer();Get the server

Comments

Posts Quoted:
Reply
Clear All Quotes