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


Java Tameable.setTamed方法代码示例

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


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

示例1: freePet

import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
/**
 * Frees a pet; it will no longer be tamed.
 * 
 * @param event
 * @param oldOwner
 */
private void freePet(PlayerInteractEntityEvent event, AnimalTamer oldOwner) {
	if (chargePrice(event.getPlayer(), freePetPrice)) {
		Tameable tameableAnimal = (Tameable) event.getRightClicked();
		// Free pet.
		tameableAnimal.setTamed(false);
		// Make freed pet stand up.
		if (version >= 12 && tameableAnimal instanceof Sittable) {
			((Sittable) tameableAnimal).setSitting(false);
		} else if (tameableAnimal instanceof Wolf) {
			((Wolf) tameableAnimal).setSitting(false);
		} else if (tameableAnimal instanceof Ocelot) {
			((Ocelot) tameableAnimal).setSitting(false);
		}

		event.getPlayer().sendMessage(plugin.getChatHeader()
				+ plugin.getPluginLang().getString("pet-freed", "Say goodbye: this pet returned to the wild!"));

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

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

示例3: onPlayerInteractEntity

import org.bukkit.entity.Tameable; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    if (event.getRightClicked() instanceof Horse) {
        Horse horse = (Horse) event.getRightClicked();
        if (horse.isTamed()) {
            if (horse.getOwner() != event.getPlayer()) {
                event.setCancelled(true);
            }
        }
    }
    if (plugin.isUntaming(event.getPlayer())) {
        if (event.getRightClicked() instanceof Tameable) {
            Tameable tameable = (Tameable) event.getRightClicked();
            if (tameable.getOwner() == event.getPlayer() || event.getPlayer().hasPermission("wayward.travel.untame.any")) {
                tameable.setTamed(false);
                event.getPlayer().sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Your tameable creature was untamed.");
            } else {
                event.getPlayer().sendMessage(plugin.getPrefix() + ChatColor.RED + "That tameable creature is not yours!");
            }
        } else {
            event.getPlayer().sendMessage(plugin.getPrefix() + ChatColor.RED + "That entity is not tameable!");
        }
        plugin.setUntaming(event.getPlayer(), false);
    }
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:26,代码来源:HorsePlayerInteractEntityListener.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: 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

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


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