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


Java Tameable类代码示例

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


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

示例1: onEntityTame

import org.bukkit.entity.Tameable; //导入依赖的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);
}
 
开发者ID:RobotoRaccoon,项目名称:StableMaster,代码行数:18,代码来源:EntityTameListener.java

示例2: walkToPlayer

import org.bukkit.entity.Tameable; //导入依赖的package包/类
public static void walkToPlayer(Entity e, Player p) {
    // Tamed animals already handle their own following
    if (e instanceof Tameable) {
        if (((Tameable) e).isTamed()) {
            return;
        }
    }
    if (e.getPassenger() instanceof Player) {
        return;
    }

    // Moving the dragon is too buggy
    if (e instanceof EnderDragon) {
        return;
    }
    // Once this is set we can't unset it.
    //((Creature)e).setTarget(p);

    // If the pet is too far just teleport instead of attempt navigation
    if (e.getLocation().distance(p.getLocation()) > 20) {
        e.teleport(p);
    } else {
        Navigation n = ((CraftLivingEntity) e).getHandle().getNavigation();
        n.a(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 0.30f);
    }
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:27,代码来源:Control.java

示例3: onWorldChanged

import org.bukkit.entity.Tameable; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldChanged(EntityPortalEnterEvent event) {
    if (!(event.getEntity() instanceof Tameable) || !(event.getEntity() instanceof LivingEntity)) {
        return;
    }

    OfflinePlayer player = (OfflinePlayer) ((Tameable) event.getEntity()).getOwner();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    PlayerWrapper playerWrapper = InventoryManager.get(player);
    if (event.getEntity() == playerWrapper.getPet()) {
        PetManager.respawnPet(player);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:17,代码来源:PetListener.java

示例4: onInteractEvent

import org.bukkit.entity.Tameable; //导入依赖的package包/类
@EventHandler
public void onInteractEvent(PlayerInteractEntityEvent e){
   	RedProtect.get().logger.debug("RPEntityListener - Is PlayerInteractEntityEvent");
   	if (e.isCancelled()) {
           return;
       }
	Player p = e.getPlayer();
	if (p == null){
		return;
	}
	Location l = e.getRightClicked().getLocation();
	Region r = RedProtect.get().rm.getTopRegion(l);	
	Entity et = e.getRightClicked();
	if (r != null && !r.canInteractPassives(p) && (et instanceof Animals || et instanceof Villager || et instanceof Golem)) {
		if (et instanceof Tameable){
			Tameable tam = (Tameable) et;
			if (tam.isTamed() && tam.getOwner() != null && tam.getOwner().getName().equals(p.getName())){
				return;
			}
		}
	    e.setCancelled(true);
		RPLang.sendMessage(p, "entitylistener.region.cantinteract");
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:25,代码来源:RPEntityListener.java

示例5: ownerConfliction

import org.bukkit.entity.Tameable; //导入依赖的package包/类
/**
 * Checks if there is an owner confliction in this EggTrackerEntry.
 * @param entry - The EggTrackerEntry to test.
 * @return True if a confliction is present, false if not.
 */
public boolean ownerConfliction(EggTrackerEntry entry) {
    if (entry.getEntity() instanceof Tameable) {
        Tameable tameable = (Tameable) entry.getEntity();
        
        // Order in the below statements is important. Owner override must be first, otherwise it will never be hit.
        if (tameable.getOwner() != null) {
            if (entry.getPlayer().hasPermission("SimpleEgg.owner-override")) {
                if (entry.getPlayer().hasPermission("SimpleEgg.steal")) {
                    tameable.setOwner(entry.getPlayer());
                }
                
                return false;
            }
        } else if (entry.getPlayer().hasPermission("SimpleEgg.auto-tame")) {
            tameable.setOwner(entry.getPlayer());
        }
        
        if (tameable.getOwner() != null && tameable.getOwner() != entry.getPlayer()) {
            return true;
        }
    }
    
    return false;
}
 
开发者ID:RedPanda4552,项目名称:SimpleEgg,代码行数:30,代码来源:CaptureManager.java

示例6: changeOwner

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

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

示例8: onEntityTarget

import org.bukkit.entity.Tameable; //导入依赖的package包/类
/**
 * Handle EntityTarget events.
 *
 * @param event The event to process
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event) {
    Entity entity = event.getEntity();
    Entity target = event.getTarget();

    if (!(entity instanceof Tameable) || !(target instanceof Player)) {
        return;
    }

    Player player = (Player) target;
    Tameable tameable = (Tameable) entity;

    if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
        return;
    }

    // isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
    // So we can make some assumptions here, about our casting and our check
    if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) {
        event.setCancelled(true);
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:28,代码来源:EntityListener.java

示例9: disownPets

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

示例10: handleEntityInteraction

import org.bukkit.entity.Tameable; //导入依赖的package包/类
void handleEntityInteraction(final PlayerInteractEntityEvent event, final Menu menu) {
	if (!this.module.getState().isEnabled()) { return; }
	if (Utility.getItemInHand(event.getPlayer()).isPresent() || !event.getPlayer().isSneaking()) { return; }
	if (event.getRightClicked().getType().equals(EntityType.PLAYER)) { return; }

	if (!(event.getRightClicked() instanceof Tameable)) { return; }
	final Tameable entity = (Tameable) event.getRightClicked();
	final Player player = event.getPlayer();

	if (entity.getOwner() == null) { return; }
	if (!entity.getOwner().getUniqueId().equals(player.getUniqueId())) { return; }

	menu.addItem(this.ownershipItem.build(), clickEvent -> {
		clickEvent.getPlayer().closeInventory();
		player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1.0f, 1.75f);
		this.openOwnerTransferWindow(player, entity);
	});
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:19,代码来源:OwnerTransferComponent.java

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

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

示例13: getLastDamager

import org.bukkit.entity.Tameable; //导入依赖的package包/类
private Player getLastDamager(LivingEntity entity) {
	if (entity.getLastDamageCause() instanceof EntityDamageByEntityEvent) {
		EntityDamageByEntityEvent edbee = (EntityDamageByEntityEvent) entity
				.getLastDamageCause();
		Entity damagerEntity = edbee.getDamager();
		if (damagerEntity instanceof Player) {
			return (Player) damagerEntity;
		}
		if (damagerEntity instanceof Projectile) {
			if (((Projectile) damagerEntity).getShooter() instanceof Player) {
				return (Player) ((Projectile) damagerEntity).getShooter();
			}
			return null;
		}
		if (damagerEntity instanceof Tameable) {
			if (((Tameable) damagerEntity).getOwner() instanceof Player) {
				return (Player) ((Tameable) damagerEntity).getOwner();
			}
			return null;
		}
	}
	return null;
}
 
开发者ID:jalapeno777,项目名称:MobBountyReloaded,代码行数:24,代码来源:MobBountyReloadedEntityListener.java

示例14: update

import org.bukkit.entity.Tameable; //导入依赖的package包/类
public void update() {
	if (entity != null) {
		//((CraftEntity) entity).getHandle().setEquipment(4, new net.minecraft.server.v1_5_R2.ItemStack(Item.DIAMOND_HELMET));
		//Chat.server(((CraftEntity) entity).getHandle().getEquipment().toString());
		Player owner = Bukkit.getPlayerExact(this.owner);
		if (owner == null)
			return;
        entity.setCustomName(nameColor + name);
        entity.setCustomNameVisible(true);
        if (entity instanceof Tameable) {
        	tamed = true;
        	((Tameable) entity).setTamed(true);
        	((Tameable) entity).setOwner(owner);
        }
        if (entity instanceof Ageable && age != null) {
        	if (getAge() == Age.BABY)
        		((Ageable) entity).setBaby();
        	((Ageable) entity).setAgeLock(true);
        }
        if (entity instanceof Zombie && age != null) {
        	if (getAge() == Age.BABY)
        		((Zombie) entity).setBaby(true);
        }
        if (entity instanceof Sheep && color != null) {
        	((Sheep) entity).setColor(getColor());
        }
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:29,代码来源:PetInstance.java

示例15: onCommand

import org.bukkit.entity.Tameable; //导入依赖的package包/类
@Override
protected void onCommand(CommandSender sender, String[] args) {
    sender.sendMessage(ChatColor.GREEN + "Please click on the animal you'd like to rescue.");

    Callbacks.selectEntity((Player) sender, ent -> {
            if (!(ent instanceof Tameable)) {
                sender.sendMessage(ChatColor.RED + "This entity is not tameable.");
                return;
            }

            ((Tameable) ent).setOwner(null);
            sender.sendMessage(ChatColor.GREEN + "Entity has been disowned.");
    });
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:15,代码来源:CommandRescue.java


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