本文整理汇总了Java中org.bukkit.event.entity.EntityTameEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityTameEvent.getEntity方法的具体用法?Java EntityTameEvent.getEntity怎么用?Java EntityTameEvent.getEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityTameEvent
的用法示例。
在下文中一共展示了EntityTameEvent.getEntity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) {
// Return if the damaged entity is not a tameable entity.
if (!(event.getEntity() instanceof Tameable))
return;
Player player = (Player) event.getOwner();
Animals animal = (Animals) event.getEntity();
String name = animal.getType().name().toLowerCase();
// Don't cancel if the player has the appropriate permission
if (player.hasPermission("stablemaster.tame." + name))
return;
event.setCancelled(true);
new LangString("error.cannot-tame", getAnimal(animal.getType())).send(player);
}
示例2: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的package包/类
/**
* Monitor EntityTame events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) {
if (event instanceof FakeEntityTameEvent) {
return;
}
Player player = (Player) event.getOwner();
LivingEntity entity = event.getEntity();
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
return;
}
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity);
}
示例3: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityTame(EntityTameEvent event){
if(enableEventTame) {
try {
Player player = (Player) event.getOwner();
if(!player.hasPermission("googleanalyticsplugin.ignore")) {
Entity entity = event.getEntity();
plugin.getTracker().TrackAction(getClientName(plugin, player), getClientId(player), getClientIP(player.getAddress().getAddress()), player.getName(), "Tamed", getEntityName(entity));
}
}
catch(Exception e) {
plugin.getLogger().warning("Event Listener Error: " + e.getMessage());
}
}
}
示例4: onTaming
import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的package包/类
@EventHandler
public void onTaming(EntityTameEvent event) {
if (event.getOwner() instanceof Player) {
String playerID = PlayerConverter.getID((Player) event.getOwner());
if (!dataMap.containsKey(playerID)) {
return;
}
LivingEntity entity = event.getEntity();
TameData playerData = (TameData) dataMap.get(playerID);
switch (type) {
case WOLF:
if (entity.getType().equals(EntityType.WOLF) && checkConditions(playerID)) {
playerData.subtract();
}
break;
case OCELOT:
if (entity.getType().equals(EntityType.OCELOT) && checkConditions(playerID)) {
playerData.subtract();
}
break;
case HORSE:
if (entity.getType().equals(EntityType.HORSE) && checkConditions(playerID)) {
playerData.subtract();
}
break;
default:
break;
}
if (playerData.isZero()) {
completeObjective(playerID);
}
}
}
示例5: onEntityTame
import org.bukkit.event.entity.EntityTameEvent; //导入方法依赖的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")));
}
}
}
}
}