当前位置: 首页>>代码示例>>Java>>正文


Java EntityTameEvent.getEntity方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityTameEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityTameEvent.getEntity方法的具体用法?Java EntityTameEvent.getEntity怎么用?Java EntityTameEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.EntityTameEvent的用法示例。


在下文中一共展示了EntityTameEvent.getEntity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEntityTame

import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) {
    // Return if the damaged entity is not a tameable entity.
    if (!(event.getEntity() instanceof Tameable))
        return;

    Player player = (Player) event.getOwner();
    Animals animal = (Animals) event.getEntity();
    String name = animal.getType().name().toLowerCase();

    // Don't cancel if the player has the appropriate permission
    if (player.hasPermission("stablemaster.tame." + name))
        return;

    event.setCancelled(true);
    new LangString("error.cannot-tame", getAnimal(animal.getType())).send(player);
}
 
开发者ID:RobotoRaccoon,项目名称:StableMaster,代码行数:18,代码来源:EntityTameListener.java

示例2: onEntityTame

import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的package包/类
/**
 * Monitor EntityTame events.
 *
 * @param event The event to watch
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) {
    if (event instanceof FakeEntityTameEvent) {
        return;
    }

    Player player = (Player) event.getOwner();
    LivingEntity entity = event.getEntity();

    if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
        return;
    }

    entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
    UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity);
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:22,代码来源:EntityListener.java

示例3: onEntityTame

import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityTame(EntityTameEvent event){
	if(enableEventTame) {
		try {
			Player player = (Player) event.getOwner();
			
			if(!player.hasPermission("googleanalyticsplugin.ignore")) {
				Entity entity = event.getEntity();

				plugin.getTracker().TrackAction(getClientName(plugin, player), getClientId(player), getClientIP(player.getAddress().getAddress()), player.getName(), "Tamed", getEntityName(entity));
			}
		}
		catch(Exception e) {
			plugin.getLogger().warning("Event Listener Error: " + e.getMessage());
		}
	}
}
 
开发者ID:Fox32,项目名称:GoogleAnalyticsPlugin,代码行数:18,代码来源:GoogleAnalyticsEventListener.java

示例4: onTaming

import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的package包/类
@EventHandler
public void onTaming(EntityTameEvent event) {
	if (event.getOwner() instanceof Player) {
		String playerID = PlayerConverter.getID((Player) event.getOwner());
		if (!dataMap.containsKey(playerID)) {
			return;
		}
		LivingEntity entity = event.getEntity();
		TameData playerData = (TameData) dataMap.get(playerID);
		switch (type) {
		case WOLF:
			if (entity.getType().equals(EntityType.WOLF) && checkConditions(playerID)) {
				playerData.subtract();
			}
			break;
		case OCELOT:
			if (entity.getType().equals(EntityType.OCELOT) && checkConditions(playerID)) {
				playerData.subtract();
			}
			break;
		case HORSE:
			if (entity.getType().equals(EntityType.HORSE) && checkConditions(playerID)) {
				playerData.subtract();
			}
			break;
		default:
			break;
		}
		if (playerData.isZero()) {
			completeObjective(playerID);
		}
	}
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:34,代码来源:TameObjective.java

示例5: onEntityTame

import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event)
{
	AnimalTamer owner = event.getOwner();
	if (owner instanceof Player)
	{
		Player player = (Player) owner;
		if (! plugin.isDisabledWorld(player))
		{
			// XP Gain
			String mobname = FormatUtil.getFriendlyName(event.getEntity().getType());
			String article = FormatUtil.getArticle(mobname);

			String message = plugin.getPrefix() +
					FormatUtil.format(plugin.getMessage("taming_gain"), xpGain, article, mobname);
			plugin.getExperienceHandler().handleXpGain(player, xpGain, message);

			// Wolf/Ocelot's Pal
			PlayerData data = plugin.getPlayerDataCache().getData(player);

			int level = data.getLevel(50);
			if (Util.random(150 / level) == 0)
			{
				if (event.getEntity() instanceof Wolf)
				{
					Wolf wolf = (Wolf) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.WOLF);
					wolf.setOwner(player);
				}
				else if (event.getEntity() instanceof Ocelot)
				{
					Ocelot ocelot = (Ocelot) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.OCELOT);
					ocelot.setOwner(player);
				}
			}

			// Taming Bomb!
			if (Util.random(150 / level) == 0)
			{
				boolean sendMessage = false;
				List<Entity> entities = player.getNearbyEntities(10, 10, 10);
				if (entities.size() > 0)
				{
					for (Entity entity : entities)
					{
						if (entity != null && entity instanceof Tameable)
						{
							Tameable tameable = (Tameable) entity;
							if (! tameable.isTamed())
							{
								tameable.setOwner(player);
								sendMessage = true;
							}
						}
					}
				}

				if (sendMessage)
				{
					player.sendMessage(plugin.getPrefix() + FormatUtil.format(plugin.getMessage("tame_bomb")));
				}
			}
		}
	}
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:65,代码来源:Taming.java


注:本文中的org.bukkit.event.entity.EntityTameEvent.getEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。