當前位置: 首頁>>代碼示例>>Java>>正文


Java Ocelot類代碼示例

本文整理匯總了Java中org.bukkit.entity.Ocelot的典型用法代碼示例。如果您正苦於以下問題:Java Ocelot類的具體用法?Java Ocelot怎麽用?Java Ocelot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Ocelot類屬於org.bukkit.entity包,在下文中一共展示了Ocelot類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCommand

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
    Player p = (Player) sender;
    Ocelot cat = (Ocelot) p.getWorld().spawnEntity(p.getLocation(), EntityType.OCELOT);
    if (cat == null)
        return; // Probably in a protected area.

    cat.setCatType(Utils.randElement(Ocelot.Type.values()));
    cat.setTamed(true);
    cat.setBaby();
    cat.setVelocity(p.getEyeLocation().getDirection().multiply(2));

    Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
        cat.getWorld().createExplosion(cat.getLocation(), 0F);
        cat.remove();
    }, 20L);
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:18,代碼來源:CommandKittyCannon.java

示例2: run

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
public void run(PAUser user, String label, String... args) {
    final Ocelot o = (Ocelot) user.getLoc().getWorld().spawnEntity(user.getLoc(), EntityType.OCELOT);
    o.setCatType(Ocelot.Type.values()[r.nextInt(Ocelot.Type.values().length)]);
    o.setSitting(true);
    o.setTamed(true);
    o.setAge(r.nextInt(2));
    o.setCustomName(Utils.colorize("&dGateteeeeeee"));
    o.setCustomNameVisible(true);
    o.setNoDamageTicks(Integer.MAX_VALUE);
    o.setVelocity(user.getPlayer().getLocation().getDirection().multiply(2));

    PAServer.users.forEach(u -> u.sendSound(Sounds.CAT_MEOW));

    plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
        PAServer.users.forEach(u -> u.sendSound(Sounds.EXPLODE));
        ParticleEffect.EXPLOSION_HUGE.send(plugin.getServer().getOnlinePlayers(), o.getLocation(), 0, 0, 0, 1, 20, 50);
        o.remove();
    }, 60);
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:20,代碼來源:KittyCMD.java

示例3: OcelotMenu

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
public OcelotMenu(Plot plot, Ocelot ocelot) {
    super(plot, ocelot);

    //type
    ItemStack type = new ItemStack(Material.BONE);
    ItemMeta typeMeta = type.getItemMeta();
    typeMeta.setDisplayName(ChatColor.GREEN + "Change type");
    type.setItemMeta(typeMeta);

    insertItem(type, event -> {
        new OcelotTypeMenu(ocelot).open((Player) event.getWhoClicked());

        event.setCancelled(true);
    }, 0);
}
 
開發者ID:stefvanschie,項目名稱:buildinggame,代碼行數:19,代碼來源:OcelotMenu.java

示例4: freePet

import org.bukkit.entity.Ocelot; //導入依賴的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

示例5: throwKittyCannon

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
private void throwKittyCannon(final World world, Player player, Location hookLoc) {
    int i = random.nextInt(Ocelot.Type.values().length);
    final Ocelot cat = (Ocelot) throwMob(world, player, hookLoc, EntityType.OCELOT);
    cat.setCatType(Ocelot.Type.values()[i]);
    cat.setTamed(true);
    cat.setBaby();
    
    mainInstance.scheduleSyncDelayedTask(new Runnable() {
        @Override
        public void run() {
            final Location catLoc = cat.getLocation();
            cat.remove();
            world.createExplosion(catLoc.getX(), catLoc.getY(), catLoc.getZ(), 2.0F, false, false);
        }
    }, 20);
}
 
開發者ID:YaLTeR,項目名稱:UnexpectedFishing,代碼行數:17,代碼來源:UnexpectedFishingListener.java

示例6: run

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
	final EntityType cat = EntityType.OCELOT;
	final Ocelot ocelot = (Ocelot)user.getPlayer().getWorld().spawn(user.getPlayer().getEyeLocation(), cat.getEntityClass());
	if (ocelot == null)
	{
		return;
	}
	final int i = random.nextInt(Ocelot.Type.values().length);
	ocelot.setCatType(Ocelot.Type.values()[i]);
	ocelot.setTamed(true);
	ocelot.setVelocity(user.getPlayer().getEyeLocation().getDirection().multiply(2));
	ess.getPlugin().scheduleSyncDelayedTask(
			new Runnable()
			{
				@Override
				public void run()
				{
					final Location loc = ocelot.getLocation();
					ocelot.remove();
					loc.getWorld().createExplosion(loc, 0F);
				}
			}, 20);
}
 
開發者ID:Curtis3321,項目名稱:Essentials,代碼行數:26,代碼來源:Commandkittycannon.java

示例7: onLoad

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public void onLoad() {
    add(Ocelot.Type.WILD_OCELOT, "Wild Ocelot", "Wild", "WI", "W", "Untamed", "Default", "Def", "None");
    add(Ocelot.Type.BLACK_CAT, "Black Cat", "Black", "BL", "B");
    add(Ocelot.Type.RED_CAT, "Red Cat", "Red", "RE", "R");
    add(Ocelot.Type.SIAMESE_CAT, "Siamese Cat", "Siamese", "SI", "S", "Siam");
}
 
開發者ID:GameBoxx,項目名稱:GameBoxx,代碼行數:8,代碼來源:OcelotTypes.java

示例8: initiateEntityPet

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public void initiateEntityPet() {
    super.initiateEntityPet();
    getBukkitEntity().setTamed(true);
    getBukkitEntity().setCatType(Ocelot.Type.BLACK_CAT);
    getBukkitEntity().setOwner(getPlayerOwner());
}
 
開發者ID:TechzoneMC,項目名稱:SonarPet,代碼行數:8,代碼來源:EntityOcelotPet.java

示例9: rawset

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public void rawset(LuaValue key, LuaValue value) {
    if (key.isstring()) {
        switch (key.checkjstring()) {
            case "type":
                getOcelotTrait().setCatType(ScriptUtil.enumValue(value, Ocelot.Type.class));
                break;
        }
    }
    super.rawset(key, value);
}
 
開發者ID:leMaik,項目名稱:RpgPlus,代碼行數:12,代碼來源:OcelotEntityWrapper.java

示例10: callOfTheWild

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
/**
 * Handle the Call of the Wild ability.
 *
 * @param type The type of entity to summon.
 * @param summonAmount The amount of material needed to summon the entity
 */
private void callOfTheWild(EntityType type, int summonAmount) {
    Player player = getPlayer();

    ItemStack heldItem = player.getItemInHand();
    int heldItemAmount = heldItem.getAmount();

    if (heldItemAmount < summonAmount) {
        player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getType())));
        return;
    }

    if (!rangeCheck(type)) {
        return;
    }

    int amount = Config.getInstance().getTamingCOTWAmount(type);

    for (int i = 0; i < amount; i++) {
        LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);

        FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player);
        mcMMO.p.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            continue;
        }

        entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
        ((Tameable) entity).setOwner(player);
        entity.setRemoveWhenFarAway(false);

        switch (type) {
            case OCELOT:
                ((Ocelot) entity).setCatType(Ocelot.Type.values()[1 + Misc.getRandom().nextInt(3)]);
                break;

            case WOLF:
                entity.setMaxHealth(20.0);
                entity.setHealth(entity.getMaxHealth());
                break;

            case HORSE:
                Horse horse = (Horse) entity;

                entity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15));
                entity.setHealth(entity.getMaxHealth());
                horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
                horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
                horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
                //TODO: setSpeed, once available
                break;

            default:
                break;
        }

        if (Permissions.renamePets(player)) {
            entity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type)));
            entity.setCustomNameVisible(true);
        }
    }

    player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
    player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:72,代碼來源:TamingManager.java

示例11: OcelotAnimal

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
public OcelotAnimal(Entity entity) {
    PreCon.isValid(entity instanceof Ocelot, "org.bukkit.entity.Ocelot expected.");

    Ocelot ocelot = (Ocelot)entity;

    _type = ocelot.getCatType();
    _isSitting = ocelot.isSitting();
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:9,代碼來源:OcelotAnimal.java

示例12: apply

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public boolean apply(Entity entity) {
    PreCon.notNull(entity);
    PreCon.isValid(entity instanceof Ocelot, "org.bukkit.entity.Ocelot expected.");

    Ocelot ocelot = (Ocelot)entity;

    ocelot.setCatType(_type);
    ocelot.setSitting(_isSitting);

    return true;
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:13,代碼來源:OcelotAnimal.java

示例13: load

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
protected void load(ConfigurationSection config) {
	super.load(config);
	String catTypeName = config.getString("catType");
	try {
		catType = Ocelot.Type.valueOf(catTypeName);
	} catch (Exception e) {
	}
}
 
開發者ID:nisovin,項目名稱:Shopkeepers,代碼行數:10,代碼來源:CatShop.java

示例14: getSubItemData

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
private short getSubItemData(Ocelot.Type catType) {
	switch (catType) {
	case BLACK_CAT:
		return DyeColor.BLACK.getWoolData();
	case RED_CAT:
		return DyeColor.RED.getWoolData();
	case SIAMESE_CAT:
		return DyeColor.SILVER.getWoolData();

	case WILD_OCELOT:
	default:
		return DyeColor.ORANGE.getWoolData();
	}
}
 
開發者ID:nisovin,項目名稱:Shopkeepers,代碼行數:15,代碼來源:CatShop.java

示例15: getDefaultTargetingBehaviours

import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public BehaviourItem[] getDefaultTargetingBehaviours() {
    return new BehaviourItem[]{
            new BehaviourItem(1, new BehaviourFloat(this)),
            new BehaviourItem(2, new BehaviourSwell(this)),
            new BehaviourItem(3, new BehaviourAvoidEntity(this, Ocelot.class, 6.0F, 1.0D, 1.2D)),
            new BehaviourItem(4, new BehaviourMeleeAttack(this, false, 1.0D)),
            new BehaviourItem(5, new BehaviourRandomStroll(this, 0.8D)),
            new BehaviourItem(6, new BehaviourLookAtNearestEntity(this, HumanEntity.class, 8F)),
            new BehaviourItem(7, new BehaviourLookAtRandom(this))
    };
}
 
開發者ID:EntityAPIDev,項目名稱:EntityAPI,代碼行數:13,代碼來源:ControllableCreeperBase.java


注:本文中的org.bukkit.entity.Ocelot類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。