org.spongepowered.api.event.entity.SpawnEntityEvent Java Examples

The following examples show how to use org.spongepowered.api.event.entity.SpawnEntityEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildPermListener.java    From Nations with MIT License 6 votes vote down vote up
@Listener(order=Order.FIRST, beforeModifications = true)
public void onEntitySpawn(SpawnEntityEvent event, @First Player player)
{
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	if (event.getCause().contains(SpawnTypes.PLACEMENT))
	{
		try {
			if (!ConfigHandler.getNode("worlds").getNode(event.getEntities().get(0).getWorld().getName()).getNode("enabled").getBoolean())
				return;
			if (!ConfigHandler.isWhitelisted("spawn", event.getEntities().get(0).getType().getId())
					&& !DataHandler.getPerm("build", player.getUniqueId(), event.getEntities().get(0).getLocation()))
				event.setCancelled(true);
		} catch (IndexOutOfBoundsException e) {}
	}
}
 
Example #2
Source File: MobSpawningListener.java    From Nations with MIT License 5 votes vote down vote up
@Listener
public void onEntitySpawn(SpawnEntityEvent event)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	event.filterEntities(e -> !(e instanceof Monster) || DataHandler.getFlag("mobs", e.getLocation()));
}
 
Example #3
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onEntitySpawn(SpawnEntityEvent event) {
    notifyHooks(WebHookService.WebHookType.ENTITY_SPAWN, event);
}