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


Java Animals类代码示例

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


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

示例1: onEntityTame

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

import org.bukkit.entity.Animals; //导入依赖的package包/类
/**
 * Prevents visitors picking items from riding horses or other inventories
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onHorseInventoryClick(InventoryClickEvent event) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: horse and llama inventory click");
    if (event.getInventory().getHolder() == null) {
        return;
    }
    // World check
    if (!Util.inWorld(event.getWhoClicked())) {
        return;
    }
    if (event.getInventory().getHolder() instanceof Animals) {
        if (actionAllowed((Player)event.getWhoClicked(), event.getWhoClicked().getLocation(), SettingsFlag.MOUNT_INVENTORY)) {
            return;
        }
        // Elsewhere - not allowed
        Util.sendMessage(event.getWhoClicked(), plugin.getLocale(event.getWhoClicked().getUniqueId()).get("island.protected"));
        event.setCancelled(true);
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:25,代码来源:IslandGuard.java

示例3: onFakeEntityDamageByEntityEvent

import org.bukkit.entity.Animals; //导入依赖的package包/类
@EventHandler
public void onFakeEntityDamageByEntityEvent(FakeEntityDamageByEntityEvent e){
	RedProtect.get().logger.debug("Mcmmo FakeEntityDamageByEntityEvent event.");
	
	if (e.getDamager() instanceof Player){
		Player p = (Player) e.getDamager();
		Region r = RedProtect.get().rm.getTopRegion(e.getEntity().getLocation());
		
		if (e.getEntity() instanceof Animals){
			if (r != null && !r.canInteractPassives(p)){
				RPLang.sendMessage(p, "entitylistener.region.cantpassive");
				e.setCancelled(true);
			}
		}			
		
		if (e.getEntity() instanceof Player){
			if (r != null && !r.canPVP(p, (Player)e.getEntity())){
				RPLang.sendMessage(p, "entitylistener.region.cantpvp");
				e.setCancelled(true);
			}
		}
	}		
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:24,代码来源:McMMoListener.java

示例4: onFakeEntityDamageEvent

import org.bukkit.entity.Animals; //导入依赖的package包/类
@EventHandler
public void onFakeEntityDamageEvent(FakeEntityDamageEvent e){
	RedProtect.get().logger.debug("Mcmmo FakeEntityDamageEvent event.");

	Region r = RedProtect.get().rm.getTopRegion(e.getEntity().getLocation());
	
	if (e.getEntity() instanceof Animals){
		if (r != null && !r.getFlagBool("passives")){
			e.setCancelled(true);
		}
	}			
	
	if (e.getEntity() instanceof Player){
		Player p = (Player) e.getEntity();
		if (r != null && !r.canPVP(p, null)){
			e.setCancelled(true);
		}
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:20,代码来源:McMMoListener.java

示例5: onInteractEvent

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

示例6: onEntityDamage

import org.bukkit.entity.Animals; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
   public void onEntityDamage(EntityDamageEvent e) {
	Region r = RedProtect.get().rm.getTopRegion(e.getEntity().getLocation());
   	if (r != null){
   		return;
   	}
   	Entity ent = e.getEntity();
   	if (ent instanceof LivingEntity && !(ent instanceof Monster)){
   		if (RPConfig.getGlobalFlagBool(ent.getWorld().getName()+".invincible")){
   			if (ent instanceof Animals){
   				((Animals)ent).setTarget(null);
   			}
   			e.setCancelled(true); 
       	}
   	}    	    	
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:17,代码来源:RPGlobalListener.java

示例7: onEntityDamage

import org.bukkit.entity.Animals; //导入依赖的package包/类
/**
 * Protects animals on a beacon from damage
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) {
    World world = event.getEntity().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    //getLogger().info("DEBUG: " + event.getEntityType());
    if (!(event.getEntity() instanceof Animals || event.getEntity() instanceof LeashHitch)) {
        return;
    }
    // Check beacon defense            
    BeaconObj beacon = getRegister().getBeaconAt(event.getEntity().getLocation());
    if (beacon != null) {                
        event.setCancelled(true);
    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:21,代码来源:BeaconProtectionListener.java

示例8: getCreatureType

import org.bukkit.entity.Animals; //导入依赖的package包/类
public CreatureType getCreatureType(EntityType entityType) {
    if (Monster.class.isAssignableFrom(entityType.getEntityClass())
            || WaterMob.class.isAssignableFrom(entityType.getEntityClass())
            || Slime.class.isAssignableFrom(entityType.getEntityClass())
            || Ghast.class.isAssignableFrom(entityType.getEntityClass())
            ) {
        return CreatureType.MONSTER;
    } else if (Animals.class.isAssignableFrom(entityType.getEntityClass())) {
        return CreatureType.ANIMAL;
    } else if (Villager.class.isAssignableFrom(entityType.getEntityClass())) {
        return CreatureType.VILLAGER;
    } else if (Golem.class.isAssignableFrom(entityType.getEntityClass())) {
        return CreatureType.GOLEM;
    }
    return CreatureType.UNKNOWN;
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:17,代码来源:LimitLogic.java

示例9: onHorseInventoryClick

import org.bukkit.entity.Animals; //导入依赖的package包/类
/**
 * Prevents visitors picking items from riding horses or other inventories
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onHorseInventoryClick(InventoryClickEvent event) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: horse and llama inventory click");
    if (event.getInventory().getHolder() == null) {
        return;
    }
    // World check
    if (!inWorld(event.getWhoClicked())) {
        return;
    }
    if (event.getInventory().getHolder() instanceof Animals) {
        if (actionAllowed((Player)event.getWhoClicked(), event.getWhoClicked().getLocation(), SettingsFlag.HORSE_INVENTORY)) {
            return;
        }            
        // Elsewhere - not allowed
        Util.sendMessage(event.getWhoClicked(), ChatColor.RED + plugin.myLocale(event.getWhoClicked().getUniqueId()).islandProtected);
        event.setCancelled(true);
        return;
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:26,代码来源:IslandGuard.java

示例10: handle

import org.bukkit.entity.Animals; //导入依赖的package包/类
public void handle(CommandInfo commandInfo) {
    final Player player = (Player) commandInfo.getSender();

    if (teleportQueue.containsKey(player) && teleportQueue.get(player) instanceof Animals) {

        StableMaster.commandQueue.remove(player);
        Animals animal = (Animals) teleportQueue.get(player);
        removeFromQueue(player);

        // Horses duplicate with cross world teleports...
        if (animal.getLocation().getWorld() != (player).getLocation().getWorld()) {
            new LangString("command.teleport.cross-world").send(player);
            return;
        }

        new TeleportEval(animal, player).runTask(StableMaster.getPlugin());

    } else {

        StableMaster.commandQueue.put(player, this);
        teleportQueue.put(player, true);
        new LangString("punch-animal").send(player);
    }
}
 
开发者ID:RobotoRaccoon,项目名称:StableMaster,代码行数:25,代码来源:Teleport.java

示例11: onTick

import org.bukkit.entity.Animals; //导入依赖的package包/类
@Override
public void onTick(ChunkLocation cl) {
	int ni = rand.nextInt(4);
	EntityType toSpawn = possibleToSpawn[ni];
	Entity[] ents = cl.getChunk().getEntities();
	if(ents.length > Feudalism.getConfiguration().getPastureEntityLimit()) {
		return;
	}
	for (Entity enty : ents) {
		System.out.println(enty.getType());
		if (enty instanceof Animals) {
			Location locy = enty.getLocation();
			for (int i = 1; i <= Feudalism.getConfiguration().getPastureSpawningAnimals(); i++) {
				locy.getWorld().spawnEntity(locy, toSpawn);
			}
			return;
		}
	}
}
 
开发者ID:Queexie,项目名称:Feudalism,代码行数:20,代码来源:Pasture.java

示例12: startLoveMode

import org.bukkit.entity.Animals; //导入依赖的package包/类
public void startLoveMode(Animals animal) {
    EntityAnimal entity = getEntityAnimal(animal);
    EntityHuman human = null;

    try {
        Class<?> c = EntityAnimal.class;

        Field bx = c.getDeclaredField("bx");
        bx.setAccessible(true);
        bx.setInt(entity, 600);

        Field by = c.getDeclaredField("by");
        by.setAccessible(true);
        by.set(entity, human);

        entity.breedItem = null;
        entity.world.broadcastEntityEffect(entity, (byte)18);
    } catch (Exception x) {
        throw new RuntimeException(x.toString());
    }
}
 
开发者ID:skyman,项目名称:WildSex,代码行数:22,代码来源:WildAnimalHandler.java

示例13: startLoveMode

import org.bukkit.entity.Animals; //导入依赖的package包/类
public void startLoveMode(Animals animal) {
    EntityAnimal entity = getEntityAnimal(animal);
    EntityHuman human = null;

    try {
        Class<?> c = EntityAnimal.class;

        Field bx = c.getDeclaredField("bw");
        bx.setAccessible(true);
        bx.setInt(entity, 600);

        Field by = c.getDeclaredField("bx");
        by.setAccessible(true);
        by.set(entity, human);

        entity.breedItem = null;
        entity.world.broadcastEntityEffect(entity, (byte)18);
    } catch (Exception x) {
        throw new RuntimeException(x.toString());
    }
}
 
开发者ID:skyman,项目名称:WildSex,代码行数:22,代码来源:WildAnimalHandler.java

示例14: getNmsEntityClass

import org.bukkit.entity.Animals; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static Class<? extends net.minecraft.server.v1_7_R1.Entity> getNmsEntityClass(final Class<? extends LivingEntity> entityClass) throws IllegalArgumentException {
	if(entityClass==null) throw new IllegalArgumentException("entityClass must not be null");
	if(entityClass==HumanEntity.class || entityClass==Player.class) return net.minecraft.server.v1_7_R1.EntityHuman.class;
	if(entityClass==Monster.class) return net.minecraft.server.v1_7_R1.EntityMonster.class;
	if(entityClass==Creature.class) return net.minecraft.server.v1_7_R1.EntityCreature.class;
	if(entityClass==Animals.class) return net.minecraft.server.v1_7_R1.EntityAnimal.class;
	if(entityClass==LivingEntity.class) return net.minecraft.server.v1_7_R1.EntityLiving.class;
	
	for(EntityType entityType: EntityType.values()) {
		if(entityType.getEntityClass()==null || entityType.getTypeId()==-1) continue;
		if(entityClass.equals(entityType.getEntityClass())) {
			return getNmsEntityClass(entityType);
		}
	}
	
	throw new IllegalArgumentException("Class "+entityClass.getSimpleName()+" is not resolvable to an EntityType");
}
 
开发者ID:DevCybran,项目名称:Controllable-Mobs-API,代码行数:19,代码来源:ControllableMobHelper.java

示例15: onMobSpawn

import org.bukkit.entity.Animals; //导入依赖的package包/类
/**
 * Prevents mobs spawning at spawn or in an island
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onMobSpawn(final CreatureSpawnEvent e) {
    if (DEBUG2) {
        plugin.getLogger().info("on Mob spawn" + e.getEventName());
    }
    // if grid is not loaded yet, return.
    if (plugin.getIslands() == null) {
        return;
    }
    // If not in the right world, return
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    // Deal with natural spawning
    if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) {
        if (!actionAllowed(e.getLocation(), SettingsFlag.MONSTER_SPAWN)) {
            if (DEBUG2)
                plugin.getLogger().info("Natural monster spawn cancelled.");
            // Mobs not allowed to spawn
            e.setCancelled(true);
            return;
        }
    }
    if (e.getEntity() instanceof Animals) {
        if (!actionAllowed(e.getLocation(), SettingsFlag.ANIMAL_SPAWN)) {
            // Animals are not allowed to spawn
            if (DEBUG2)
                plugin.getLogger().info("Natural animal spawn cancelled.");
            e.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:38,代码来源:IslandGuard.java


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