當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。