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


Java AnimalTamer类代码示例

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


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

示例1: changeOwner

import org.bukkit.entity.AnimalTamer; //导入依赖的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

示例2: freePet

import org.bukkit.entity.AnimalTamer; //导入依赖的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

示例3: disownPets

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
public static void disownPets(String animalTamer) {
    for (TameableModel wrapper : findByTamer(animalTamer)) {
        if (wrapper.getEntity() == null) continue;
        ((Tameable) wrapper.getEntity()).setOwner(new AnimalTamer() {
            @Override
            public String getName() {
                return "Disowned";
            }

            @Override
            public UUID getUniqueId() {
                return null;
            }
        });
    }
}
 
开发者ID:DemigodsRPG,项目名称:Stoa,代码行数:17,代码来源:TameableUtil.java

示例4: onEntityTame

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
@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);
}
 
开发者ID:Programie,项目名称:TalkingMobs,代码行数:17,代码来源:EventListener.java

示例5: setOwner

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
@Override
public void setOwner(AnimalTamer owner) {
    if (owner != null) {
        setTamed(true);
        getHandle().setPathToEntity(null);
        setOwnerUUID(owner.getUniqueId());
    } else {
        setTamed(false);
        setOwnerUUID(null);
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:12,代码来源:CraftHorse.java

示例6: getOwner

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
public AnimalTamer getOwner() {
    if (getOwnerUUID() == null) {
        return null;
    }

    AnimalTamer owner = getServer().getPlayer(getOwnerUUID());
    if (owner == null) {
        owner = getServer().getOfflinePlayer(getOwnerUUID());
    }

    return owner;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:13,代码来源:CraftTameableAnimal.java

示例7: setOwner

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
public void setOwner(AnimalTamer tamer) {
    if (tamer != null) {
        setTamed(true);
        getHandle().setPathToEntity(null);
        setOwnerUUID(tamer.getUniqueId());
    } else {
        setTamed(false);
        setOwnerUUID(null);
}
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:11,代码来源:CraftTameableAnimal.java

示例8: alarm

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
@Override
public void alarm(Integer key) {
	// kill our summon
	Entity e = getEntity();
	
	if (e == null) {
		QuestManagerPlugin.logger.warning("Unable to locate and remove "
			+ "summon!");
	} else {
		
		if (entity instanceof Tameable) {
			Tameable me = (Tameable) entity;
			AnimalTamer tamer = me.getOwner();
			
			if (tamer instanceof Player) {
				QuestPlayer qp = QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(
						(Player) tamer);
				if (qp.getOptions().getOption(PlayerOptions.Key.CHAT_PET_DISMISSAL)) {
					((Player) tamer).sendMessage(DEATH_MESSAGE);
				}
			}
		}
		
		e.getLocation().getChunk().load();
		e.remove();
		
		playDeathEffect(e.getLocation());
	}
	
	effect.stop();
	
	QuestManagerPlugin.questManagerPlugin.getSummonManager().unregisterSummon(this);
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:34,代码来源:Summon.java

示例9: onEntityDeath

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
	if (e.getEntity().getUniqueId().equals(entityID)) {
		//is summon entity
		effect.stop();
		
		if (Alarm.getScheduler().unregister(this)) {
			QuestManagerPlugin.questManagerPlugin.getSummonManager().unregisterSummon(this);
		
			if (entity instanceof Tameable) {
				Tameable me = (Tameable) entity;
				AnimalTamer tamer = me.getOwner();
				
				if (tamer instanceof Player) {
					QuestPlayer qp = QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(
							(Player) tamer);
					if (qp.getOptions().getOption(PlayerOptions.Key.CHAT_PET_DISMISSAL)) {
						((Player) tamer).sendMessage(DEATH_MESSAGE);
					}
				}
			}
		}
		
		return;
	}
	
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:28,代码来源:Summon.java

示例10: setOwner

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
@Override
public void setOwner(AnimalTamer owner) {
    if (owner != null) {
        setTamed(true);
        getHandle().setPathEntity(null);
        setOwnerUUID(owner.getUniqueId());
    } else {
        setTamed(false);
        setOwnerUUID(null);
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:12,代码来源:CraftHorse.java

示例11: setOwner

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
public void setOwner(AnimalTamer tamer) {
    if (tamer != null) {
        setTamed(true);
        getHandle().setPathEntity(null);
        setOwnerUUID(tamer.getUniqueId());
    } else {
        setTamed(false);
        setOwnerUUID(null);
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:11,代码来源:CraftTameableAnimal.java

示例12: setOwner

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
@Override
public void setOwner(AnimalTamer owner) {
    if (owner != null) {
        setTamed(true);
        getHandle().setGoalTarget(null, null, false);
        setOwnerUUID(owner.getUniqueId());
    } else {
        setTamed(false);
        setOwnerUUID(null);
    }
}
 
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:12,代码来源:CraftHorse.java

示例13: setOwner

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
public void setOwner(AnimalTamer tamer) {
    if (tamer != null) {
        setTamed(true);
        getHandle().setGoalTarget(null, null, false);
        setOwnerUUID(tamer.getUniqueId());
    } else {
        setTamed(false);
        setOwnerUUID(null);
    }
}
 
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:11,代码来源:CraftTameableAnimal.java

示例14: onPlayerInteractEntityEvent

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
	// On Minecraft versions from 1.9 onwards, this event is fired twice, one for each hand. Need additional check.
	if (version >= 9 && event.getHand() != EquipmentSlot.HAND) {
		return;
	}

	if (!(event.getRightClicked() instanceof Tameable) || ((Tameable) event.getRightClicked()).getOwner() == null
			|| !plugin.getEnableDisableCommand().isEnabled()) {
		return;
	}

	AnimalTamer currentOwner = ((Tameable) event.getRightClicked()).getOwner();
	// Has the player clicked on one of his own pets?
	boolean isOwner = event.getPlayer().getName().equals(currentOwner.getName());
	// Retrieve new owner from the map and delete corresponding entry.
	Player newOwner = plugin.getSetOwnerCommand().collectPendingSetOwnershipRequest(event.getPlayer());
	// Has the player requested to free one of his pets?
	boolean freePet = plugin.getFreeCommand().collectPendingFreeRequest(event.getPlayer());

	// Cannot change ownership or free pet if not owner and no bypass permission.
	if ((newOwner != null || freePet) && !isOwner && !event.getPlayer().hasPermission("petmaster.admin")) {
		event.getPlayer().sendMessage(plugin.getChatHeader() + plugin.getPluginLang()
				.getString("not-owner", "You do not own this pet!").replace("PLAYER", event.getPlayer().getName()));
		return;
	}

	if (newOwner != null) {
		changeOwner(event, currentOwner, newOwner);
	} else if (freePet) {
		freePet(event, currentOwner);
	} else if ((displayToOwner || !isOwner) && event.getPlayer().hasPermission("petmaster.showowner")) {
		displayHologramAndMessage(event, currentOwner);
	}
}
 
开发者ID:PyvesB,项目名称:PetMaster,代码行数:36,代码来源:PlayerInteractListener.java

示例15: setOwner

import org.bukkit.entity.AnimalTamer; //导入依赖的package包/类
@Override
public void setOwner(AnimalTamer owner) {
    if (owner != null && !"".equals(owner.getName())) {
        setTamed(true);
        getHandle().setPathEntity(null);
        setOwnerName(owner.getName());
    } else {
        setTamed(false);
        setOwnerName("");
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:12,代码来源:CraftHorse.java


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