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


Java EntityTameEvent类代码示例

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


EntityTameEvent类属于org.bukkit.event.entity包,在下文中一共展示了EntityTameEvent类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onTame

import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler
public void onTame(EntityTameEvent e) {
	if (e.isCancelled()) {
		return;
	}
	
	if (QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getAllowTaming()) {
		return;
	}
	
	String worldname = e.getEntity().getWorld().getName();
	if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds().contains(worldname)) {
		return;
	}
	
	if (e.getOwner() instanceof Player) {
		((Player) e.getOwner()).sendMessage(ChatColor.DARK_PURPLE + "Taming is not allowed here!" + ChatColor.RESET);
	}
	e.setCancelled(true);
	
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:22,代码来源:QuestManager.java

示例3: 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

示例4: 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

示例5: onEntityTame

import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler
public void onEntityTame(EntityTameEvent event) {
    if (!plugin.getConfig().getBoolean("events.tamed")) {
        return;
    }

    AnimalTamer owner = event.getOwner();

    if (!(owner instanceof Player)) {
        return;
    }

    Player player = (Player) owner;

    message.sendMessage(event.getEntity(), player, Message.EventType.tamed);
}
 
开发者ID:Programie,项目名称:TalkingMobs,代码行数:17,代码来源:EventListener.java

示例6: onEntityTame

import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler
public void onEntityTame(EntityTameEvent event){

	Player player = (Player)event.getOwner();
	EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId());
	List<EpicQuestTask> taskList = epicPlayer.getTasksByType(TaskTypes.TAME_MOB);
	
	for(EpicQuestTask task : taskList){
		//Check if correct entity was tamed
		String entitytamed = event.getEntityType().name();
		String entityneeded = task.getTaskID();
		
		if(entitytamed.equalsIgnoreCase(entityneeded)){	
			task.ProgressTask(1, epicPlayer, true);
		}
	}
}
 
开发者ID:Randehh,项目名称:EpicQuest,代码行数:18,代码来源:TypeTame.java

示例7: onPlayerTame

import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTame(EntityTameEvent event) {
	if (!(event.getOwner() instanceof Player)) {
		return;
	}

	Player player = (Player) event.getOwner();
	NormalAchievements category = NormalAchievements.TAMES;
	if (!shouldIncreaseBeTakenIntoAccount(player, category)) {
		return;
	}

	updateStatisticAndAwardAchievementsIfAvailable(player, category, 1);
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:15,代码来源:AchieveTameListener.java

示例8: 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

示例9: horseTameEvent

import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler
public void horseTameEvent(EntityTameEvent event){ 
     
	 if(event.getEntityType() == EntityType.HORSE){
		 Player p = (Player)event.getOwner();
		 p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GOLD + " You have succesfully protected this horse!");
		 p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.GREEN + " To unclaim your horse, use /horseunclaim");
		 
	 }	
}
 
开发者ID:ekiminatorn,项目名称:ECHorses,代码行数:11,代码来源:ECHorsesListeners.java

示例10: onEntityTame

import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityTame(EntityTameEvent event) {
    this.module.getStatSystem().increment("taming." + event.getEntity().getType().name().toLowerCase(), event.getOwner().getName());
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:5,代码来源:StatsListener.java

示例11: PoreEntityTameEvent

import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
public PoreEntityTameEvent(org.spongepowered.api.event.entity.EntityTameEvent handle) {
    super(null, null);
    this.handle = checkNotNull(handle, "handle");
    checkState(handle.getEntity() instanceof Living, "Bad entity type");
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:6,代码来源:PoreEntityTameEvent.java

示例12: getHandle

import org.bukkit.event.entity.EntityTameEvent; //导入依赖的package包/类
public org.spongepowered.api.event.entity.EntityTameEvent getHandle() {
    return this.handle;
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:4,代码来源:PoreEntityTameEvent.java

示例13: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。