本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}