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


Java Tameable.setOwner方法代码示例

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


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

示例1: ownerConfliction

import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
/**
 * Checks if there is an owner confliction in this EggTrackerEntry.
 * @param entry - The EggTrackerEntry to test.
 * @return True if a confliction is present, false if not.
 */
public boolean ownerConfliction(EggTrackerEntry entry) {
    if (entry.getEntity() instanceof Tameable) {
        Tameable tameable = (Tameable) entry.getEntity();
        
        // Order in the below statements is important. Owner override must be first, otherwise it will never be hit.
        if (tameable.getOwner() != null) {
            if (entry.getPlayer().hasPermission("SimpleEgg.owner-override")) {
                if (entry.getPlayer().hasPermission("SimpleEgg.steal")) {
                    tameable.setOwner(entry.getPlayer());
                }
                
                return false;
            }
        } else if (entry.getPlayer().hasPermission("SimpleEgg.auto-tame")) {
            tameable.setOwner(entry.getPlayer());
        }
        
        if (tameable.getOwner() != null && tameable.getOwner() != entry.getPlayer()) {
            return true;
        }
    }
    
    return false;
}
 
开发者ID:RedPanda4552,项目名称:SimpleEgg,代码行数:30,代码来源:CaptureManager.java

示例2: changeOwner

import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
/**
 * Change the owner of a pet.
 * 
 * @param event
 * @param oldOwner
 * @param newOwner
 */
private void changeOwner(PlayerInteractEntityEvent event, AnimalTamer oldOwner, Player newOwner) {
	if (chargePrice(event.getPlayer(), changeOwnerPrice)) {
		Tameable tameableAnimal = (Tameable) event.getRightClicked();
		// Change owner.
		tameableAnimal.setOwner(newOwner);
		event.getPlayer().sendMessage(plugin.getChatHeader()
				+ plugin.getPluginLang().getString("owner-changed", "This pet was given to a new owner!"));
		newOwner.sendMessage(plugin.getChatHeader()
				+ plugin.getPluginLang().getString("new-owner", "Player PLAYER gave you ownership of a pet!")
						.replace("PLAYER", event.getPlayer().getName()));

		// Create new event to allow other plugins to be aware of the ownership change.
		PlayerChangeAnimalOwnershipEvent playerChangeAnimalOwnershipEvent = new PlayerChangeAnimalOwnershipEvent(
				oldOwner, newOwner, tameableAnimal);
		Bukkit.getServer().getPluginManager().callEvent(playerChangeAnimalOwnershipEvent);
	}
}
 
开发者ID:PyvesB,项目名称:PetMaster,代码行数:25,代码来源:PlayerInteractListener.java

示例3: apply

import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@Override
public boolean apply(Entity entity) {
    PreCon.notNull(entity);
    PreCon.isValid(entity instanceof Tameable, "entity meust be an instance of Tameable");

    Tameable tameable = (Tameable)entity;

    tameable.setTamed(_isTamed);

    if (_ownerId != null) {
        Player player = PlayerUtils.getPlayer(_ownerId);
        tameable.setOwner(player);
    }
    else {
        tameable.setOwner(null);
    }

    return true;
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:20,代码来源:TameableAnimal.java

示例4: restoreTameable

import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
private void restoreTameable(final Tameable entity) {
    if (this.tamed.tamed) {
        if (this.tamed.owner != null) {
            entity.setTamed(true);
            entity.setOwner(this.tamed.owner);
        }
    }
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:9,代码来源:EntityWrapper.java

示例5: handleInteract

import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
public void handleInteract(Stable stable, Player player, Tameable animal) {
    OfflinePlayer newOwner = giveQueue.get(player);
    removeFromQueue(player);

    if (animal instanceof AbstractHorse) {
        AbstractHorse horse = (AbstractHorse) animal;
        Stable newStable = StableMaster.getStable(newOwner);
        stable.removeHorse(horse);
        newStable.addHorse(horse);
    }

    animal.setOwner(newOwner);
    new LangString("command.give.given", getAnimal(((Animals) animal).getType()), newOwner.getName()).send(player);
}
 
开发者ID:RobotoRaccoon,项目名称:StableMaster,代码行数:15,代码来源:Give.java

示例6: restoreTameable

import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
private void restoreTameable(Tameable entity) {
    if (this.tamed.tamed) {
        if (this.tamed.owner != null) {
            entity.setTamed(true);
            entity.setOwner(this.tamed.owner);
        }
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:9,代码来源:EntityWrapper.java

示例7: apply

import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@Override
public void apply(Entity e, MagicUser cause) {
	if (!(cause.getEntity() instanceof AnimalTamer)) {
		QuestManagerPlugin.logger.warning("Unable to summon tamed "
				+ "entity to caster, because they aren't an AnimalTamer: " + cause.getEntity().getCustomName());
		return;
	}
	
	SummonManager manager = QuestManagerPlugin.questManagerPlugin.getSummonManager();
	
	Location tmp = e.getLocation().clone();
	tmp.add(0, 1.5, 0);
	tmp.add(e.getLocation().getDirection().normalize().multiply(2));
	Entity ent = tmp.getWorld().spawnEntity(tmp, type);
	if (!(ent instanceof Tameable)) {
		QuestManagerPlugin.logger.warning("Unable to summon tamed"
				+ " entity, as entity type is not tameable: [" + type + "]");
		ent.remove();
		return;
	}
	Summon s = new Summon(cause.getEntity().getUniqueId(), ent, duration);
	
	if (cause instanceof Player) {
		if (!manager.registerSummon((Player) cause, s)) {
			s.remove();
			cause.getEntity().sendMessage(SUMMON_DENIAL);
			return;
		}
	} else {
		manager.registerSummon(s);
	}
	
	Tameable tame = (Tameable) ent;
	tame.setTamed(true);
	tame.setOwner((AnimalTamer) cause.getEntity());
	
	ent.setCustomName(cause.getEntity().getName() + "'s " + name);
	ent.setCustomNameVisible(true);
	
	
	if (ent instanceof LivingEntity) {
		LivingEntity live = (LivingEntity) ent;
		live.setRemoveWhenFarAway(false);
		if (hp > 0) {
				live.setMaxHealth(hp);
				live.setHealth(hp);
		}

	}
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:51,代码来源:SummonTamedEffect.java

示例8: onEntityTame

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