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


Java Wolf類代碼示例

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


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

示例1: getPlayerDamager

import org.bukkit.entity.Wolf; //導入依賴的package包/類
/**
 * Gets the damager or indirect damager from any projectile.
 * @return The damager player
 */
public Player getPlayerDamager() {
	Player damager = null;
	if (event.getCombuster() instanceof Player) {
		damager = (Player) event.getCombuster();
	} else if (event.getCombuster() instanceof Wolf) {
		Wolf wolf = (Wolf) event.getCombuster();
		if (wolf.getOwner() instanceof Player) {
			damager = (Player) wolf.getOwner();
		}
	} else if (event.getCombuster() instanceof Projectile) {
		Projectile projectile = (Projectile) event.getCombuster();
		if (projectile.getShooter() instanceof Player) {
			damager = (Player) projectile.getShooter();
		}
	}
	return damager;
}
 
開發者ID:DevotedMC,項目名稱:ExilePearl,代碼行數:22,代碼來源:EntityCombustEventWrapper.java

示例2: getPlayerDamager

import org.bukkit.entity.Wolf; //導入依賴的package包/類
/**
 * Gets the damager or indirect damager from any projectile.
 * @return The damager player
 */
public Player getPlayerDamager() {
	Player damager = null;
	if (event.getDamager() instanceof Player) {
		damager = (Player) event.getDamager();
	} else if (event.getDamager() instanceof Wolf) {
		Wolf wolf = (Wolf) event.getDamager();
		if (wolf.getOwner() instanceof Player) {
			damager = (Player) wolf.getOwner();
		}
	} else if (event.getDamager() instanceof Projectile) {
		Projectile projectile = (Projectile) event.getDamager();
		if (projectile.getShooter() instanceof Player) {
			damager = (Player) projectile.getShooter();
		}
	}
	return damager;
}
 
開發者ID:DevotedMC,項目名稱:ExilePearl,代碼行數:22,代碼來源:EntityDamageEventWrapper.java

示例3: testWolfDamage

import org.bukkit.entity.Wolf; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@Test
public void testWolfDamage() {
	dut.start();

	List<Player> damagers = dut.getSortedDamagers(player);
	assertEquals(0, damagers.size());
	
	Wolf wolf = mock(Wolf.class);
	
	EntityDamageByEntityEvent damageEvent = new EntityDamageByEntityEvent(wolf, player, null, 5);
	dut.onEntityDamageByEntity(damageEvent);
	damagers = dut.getSortedDamagers(player);
	assertEquals(0, damagers.size());
	
	when(wolf.getOwner()).thenReturn(d1);
	dut.onEntityDamageByEntity(damageEvent);
	damagers = dut.getSortedDamagers(player);
	assertEquals(1, damagers.size());
	assertEquals(d1, damagers.get(0));
}
 
開發者ID:DevotedMC,項目名稱:ExilePearl,代碼行數:22,代碼來源:CoreDamageLoggerTest.java

示例4: ColorSelectionMenu

import org.bukkit.entity.Wolf; //導入依賴的package包/類
/**
 * Constructs a new Gui
 *
 * @param entity the entity to change the color of
 */
public ColorSelectionMenu(Creature entity) {
    super(null, 18, ChatColor.GREEN + "Select a color", 1);

    for (DyeColor dyeColor : DyeColor.values())
        addItem(new Wool(dyeColor).toItemStack(1), event -> {
            if (entity instanceof Colorable)
                ((Colorable) entity).setColor(dyeColor);
            else if (entity instanceof Wolf) {
                Wolf wolf = (Wolf) entity;

                wolf.setTamed(true);
                wolf.setCollarColor(dyeColor);
            }

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

示例5: freePet

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

示例6: processTamingCombat

import org.bukkit.entity.Wolf; //導入依賴的package包/類
private static void processTamingCombat(LivingEntity target, Player master, Wolf wolf, EntityDamageByEntityEvent event) {
    double initialDamage = event.getDamage();
    double finalDamage = initialDamage;

    McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
    TamingManager tamingManager = mcMMOPlayer.getTamingManager();

    if (tamingManager.canUseFastFoodService()) {
        tamingManager.fastFoodService(wolf, event.getDamage());
    }

    if (tamingManager.canUseSharpenedClaws()) {
        finalDamage += tamingManager.sharpenedClaws();
    }

    if (tamingManager.canUseGore()) {
        finalDamage += tamingManager.gore(target, initialDamage);
    }

    applyScaledModifiers(initialDamage, finalDamage, event);
    startGainXp(mcMMOPlayer, target, SkillType.TAMING);
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:23,代碼來源:CombatUtils.java

示例7: set

import org.bukkit.entity.Wolf; //導入依賴的package包/類
@Override
	public void set(final Wolf entity) {
		if (angry != 0)
			entity.setAngry(angry == 1);
		if (tamed != 0)
			entity.setTamed(tamed == 1);
//		if (owner != null) {
//			if (owner.isEmpty())
//				entity.setOwner(null);
//			else
//				entity.setOwner(Bukkit.getOfflinePlayer(owner));
//		}
	}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:14,代碼來源:WolfData.java

示例8: onTamedWolfDamage

import org.bukkit.entity.Wolf; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onTamedWolfDamage(EntityDamageEvent evt) {
	if (evt.getEntity() instanceof Wolf) {
		Wolf wolf = (Wolf)evt.getEntity();
		
		if (wolf.isTamed()) {
			evt.setDamage(evt.getDamage() / 2);
		}
	}
}
 
開發者ID:Allov,項目名稱:world-of-icerealm,代碼行數:11,代碼來源:MansBestFriendPerk.java

示例9: onTamedWolfAttack

import org.bukkit.entity.Wolf; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onTamedWolfAttack(EntityDamageByEntityEvent evt) {
	if (evt.getDamager() instanceof Wolf) {
		Wolf wolf = (Wolf)evt.getDamager();
		
		if (wolf.isTamed()) {
			evt.setDamage(evt.getDamage() * 2);
		}
	}
}
 
開發者ID:Allov,項目名稱:world-of-icerealm,代碼行數:11,代碼來源:MansBestFriendPerk.java

示例10: sitWolves

import org.bukkit.entity.Wolf; //導入依賴的package包/類
/**
 * Commands player's wolves to sit down
 * @return
 */
public int sitWolves() {
	int count = 0;
	for (Wolf w : this.getWolves()) {
		if (!w.isSitting()) {
			w.setSitting(true);
			count++;
		}
	}
	return count;
}
 
開發者ID:Cameri,項目名稱:WolfCommand,代碼行數:15,代碼來源:WolfPlayer.java

示例11: standWolves

import org.bukkit.entity.Wolf; //導入依賴的package包/類
/**
 * Commands player's wolves to stand up
 * @return
 */
public int standWolves() {
	int count = 0;
	for (Wolf w : this.getWolves()) {
		if (w.isSitting()) {
			w.setSitting(false);
			count++;
		}
	}
	return count;
}
 
開發者ID:Cameri,項目名稱:WolfCommand,代碼行數:15,代碼來源:WolfPlayer.java

示例12: getWolves

import org.bukkit.entity.Wolf; //導入依賴的package包/類
/**
 * Gets player's tamed wolves
 * @return
 */
public List<Wolf> getWolves() {
	List<Wolf> entities = new ArrayList<Wolf>();
	for (Entity e : player.getNearbyEntities(ATTACK_RANGE, ATTACK_RANGE, ATTACK_RANGE)) {
		if (e instanceof Wolf && e instanceof Tameable) {
			Tameable t = (Tameable) e;
			if (t.isTamed() && t.getOwner() == this.player) {
				entities.add((Wolf) e);
			}
		}
	}
	return entities;
}
 
開發者ID:Cameri,項目名稱:WolfCommand,代碼行數:17,代碼來源:WolfPlayer.java

示例13: setTarget

import org.bukkit.entity.Wolf; //導入依賴的package包/類
/**
 * Sets player's wolves target
 * @param target 
 */
public void setTarget(LivingEntity target) {
	for (Wolf w : this.getWolves()) {
		if (!w.isSitting()) {
			w.setTarget(target);
		}
	}
}
 
開發者ID:Cameri,項目名稱:WolfCommand,代碼行數:12,代碼來源:WolfPlayer.java

示例14: playHeartEffect

import org.bukkit.entity.Wolf; //導入依賴的package包/類
/**
 * Play heart particles at the given location.
 * <p>
 * <i>Implementation note:</i> This method accomplishes the desired behavior by spawning a wolf, playing the {@linkplain EntityEffect#WOLF_HEARTS wolf heart} effect, and removing the wolf.
 * Event handlers at the highest priority level are registered that will uncancel the spawn of this wolf.
 * </p>
 * @param location The location at which to play the heart effect.
 */
public static void playHeartEffect(@Nonnull Location location){
	Validate.notNull(location, "The location of the effect must not be null.");
	Validate.notNull(location.getWorld(), "The location must not have a null world.");

	_eventListener.getWolfSpawnLocSet().add(location);
	Wolf o = location.getWorld().spawn(location, Wolf.class);
	o.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, (int) Constants.TICKS_PER_MINUTE, 0));
	o.playEffect(EntityEffect.WOLF_HEARTS);
	o.remove();
}
 
開發者ID:glen3b,項目名稱:BukkitLib,代碼行數:19,代碼來源:Utilities.java

示例15: playWolfHearts

import org.bukkit.entity.Wolf; //導入依賴的package包/類
public void playWolfHearts(Location loc) {
    World world = loc.getWorld();
    Wolf wo = (Wolf) world.spawn(loc, Wolf.class);
    wo.remove();
    net.minecraft.server.v1_6_R3.World nmsWorld = ((CraftWorld) world).getHandle();
    net.minecraft.server.v1_6_R3.EntityWolf nmsWolf = (EntityWolf) ((CraftEntity) wo).getHandle();
    nmsWorld.broadcastEntityEffect(nmsWolf, (byte) 7);
}
 
開發者ID:Esaych,項目名稱:DDCustomPlugin,代碼行數:9,代碼來源:Chat.java


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