Java 类org.bukkit.event.entity.EntityTameEvent 实例源码

项目:QuestManager    文件:QuestManager.java   
@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);

}
项目:StableMaster    文件:EntityTameListener.java   
@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);
}
项目:McMMOPlus    文件:EntityListener.java   
/**
 * 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);
}
项目:GoogleAnalyticsPlugin    文件:GoogleAnalyticsEventListener.java   
@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());
        }
    }
}
项目:TalkingMobs    文件:EventListener.java   
@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);
}
项目:EpicQuest    文件:TypeTame.java   
@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);
        }
    }
}
项目:AdvancedAchievements    文件:AchieveTameListener.java   
@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);
}
项目:BetonQuest    文件:TameObjective.java   
@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);
        }
    }
}
项目:ECHorses    文件:ECHorsesListeners.java   
@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");

     }  
}
项目:Peacecraft    文件:StatsListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityTame(EntityTameEvent event) {
    this.module.getStatSystem().increment("taming." + event.getEntity().getType().name().toLowerCase(), event.getOwner().getName());
}
项目:Pore    文件:PoreEntityTameEvent.java   
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");
}
项目:Pore    文件:PoreEntityTameEvent.java   
public org.spongepowered.api.event.entity.EntityTameEvent getHandle() {
    return this.handle;
}
项目:SwornRPG    文件:Taming.java   
@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")));
                }
            }
        }
    }
}