Java Code Examples for org.bukkit.event.entity.PlayerLeashEntityEvent#getEntity()

The following examples show how to use org.bukkit.event.entity.PlayerLeashEntityEvent#getEntity() . 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: RegionInteractListener.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPlayerLeashEntity(PlayerLeashEntityEvent event) {
	List<String> denyRiding = Config.REGION_DENYRIDING.getStringList();
	Player player = event.getPlayer();
	Entity entity = event.getEntity();
	NovaPlayer nPlayer = PlayerManager.getPlayer(player);

	if(denyRiding.contains(entity.getType().name())
			&& RegionManager.get(entity) != null
			&& (!plugin.getRegionManager().canInteract(player, entity) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(GuildPermission.MOB_LEASH)))
			&& (!(entity instanceof Vehicle) || !PlayerManager.getPlayer(player).isVehicleListed((Vehicle) event.getEntity()))) {
		event.setCancelled(true);
		Message.CHAT_REGION_DENY_LEASH.send(event.getPlayer());
	}
}
 
Example 2
Source File: MobListener.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerLeash(PlayerLeashEntityEvent event) {
	if (event.getEntity() instanceof LivingEntity) {
		if (MobLib.isMobLibEntity((LivingEntity) event.getEntity())) {
			CivMessage.sendError(event.getPlayer(), "This beast cannot be tamed.");
			event.setCancelled(true);
			return;
		}
	}
}