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


Java Bat类代码示例

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


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

示例1: onEntityDeath

import org.bukkit.entity.Bat; //导入依赖的package包/类
/**
 * Upon a bat's death, drops a golden apple the majority of the time, with a small chance of instantly killing the
 * player.
 *
 * @param event The event
 */
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
  Entity entity = event.getEntity();
  Player player = event.getEntity().getKiller();
  if (entity instanceof Bat && player != null) {
    if (0.01 > Math.random()) {
      player.damage(Integer.MAX_VALUE, entity);
    } else {
      entity.getWorld().dropItem(entity.getLocation(), new ItemStack(Material.GOLDEN_APPLE));
    }
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:19,代码来源:Bats.java

示例2: run

import org.bukkit.entity.Bat; //导入依赖的package包/类
@Override
public void run()
{
	for (Bat bat : spawnedBats)
	{
		bat.remove();
	}
	
	spawnedBats.clear();
}
 
开发者ID:leonardosnt,项目名称:OldBukkit,代码行数:11,代码来源:RemoveBatsRunnable.java

示例3: onEntityExplode

import org.bukkit.entity.Bat; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityExplode(BlockExplodeEvent event) {
    if (event == null || ChunkManager.getInstance().getDisabledWorlds().contains(event.getBlock().getLocation().getWorld().getName())) {
        return; // do not do anything in case explosions get cancelled
    }

    final Block detonatorBlock = event.getBlock();

    if (detonatorBlock == null) {
        return;
    }
    if (detonatorBlock.hasMetadata("ObbyEntity")) {
        return;
    }
    if (event.getYield() <= 0) {
        return;
    }

    // feeling batty?! Spawn a bat to tie onto the EntityExplodeEvent.
    try {
        Bat bat = (Bat) Bukkit.getWorld(detonatorBlock.getWorld().getName()).spawnEntity(detonatorBlock.getLocation(), EntityType.BAT);
        if (bat != null) {
            bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100, 1), true);
        }
        // Construct a new event but don't call it.
        EntityExplodeEvent entityExplodeEvent = new EntityExplodeEvent(bat, event.getBlock().getLocation(), event.blockList(), event.getYield());
        ChunkManager.getInstance().handleExplosion(entityExplodeEvent, event.getBlock().getLocation());
        if (bat != null) {
            bat.remove(); // bye
        }
    } catch (Exception e) {
        ObsidianDestroyer.debug(e.toString());
    }
}
 
开发者ID:drtshock,项目名称:ObsidianDestroyer,代码行数:35,代码来源:SpigotListener.java

示例4: setMito

import org.bukkit.entity.Bat; //导入依赖的package包/类
public static void setMito(String playerName)
{
	
	Player newMito = Bukkit.getPlayer(playerName);
	String oldMito = getMito();
	
	if (newMito != null)
	{
		NewMitoEvent newMitoEvent = new NewMitoEvent(newMito, oldMito);
		
		Bukkit.getPluginManager().callEvent(newMitoEvent);
		
		if (ConfigDefaults.spawnBats)
		{
			HashSet<Bat> spawnedBats = new HashSet<>();
			
			for (int i = 0; i < ConfigDefaults.batsAmout; i++)
			{
				Bat bat = newMito.getWorld().spawn(newMito.getLocation().add(0, .5, 0), Bat.class);
				
				if (ConfigDefaults.enableBatName)
				{
					bat.setCustomNameVisible(true);
					bat.setCustomName(ConfigDefaults.batName.replaceAll("(?i)\\{player\\}", newMito == null ? playerName : newMito.getName()));
				}
				
				spawnedBats.add(bat);
			}
			
			Bukkit.getScheduler().scheduleSyncDelayedTask(LsMitoPlugin.getPlugin(), new RemoveBatsRunnable(spawnedBats), ConfigDefaults.batsDespawnDelay * 20);
		}

		if (ConfigDefaults.spawnLightningEffect)
		{
			Vector[] vectors = {new Vector(1.5, 0, 0), new Vector(-1.5, 0, 0), new Vector(0, 0, 1.5), new Vector(0, 0, -1.5)};
			
			for (Vector vec : vectors)
			{
				newMito.getWorld().strikeLightningEffect(newMito.getLocation().add(vec));
			}
		}
	}
	
	if (ConfigDefaults.enableRunCommands)
	{
		for (String command : ConfigDefaults.runCommands)
		{
			if (oldMito == null && command.matches(".*(?i)\\{oldmito\\}.*")) continue;
			
			Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replaceAll("(?i)\\{oldmito\\}", oldMito).replaceAll("(?i)\\{newmito\\}", newMito == null ? playerName : newMito.getName()));
		}
	}
	
	Bukkit.getScheduler().runTask(LsMitoPlugin.getPlugin(), new UpdateMitoRunnable());
	Bukkit.broadcastMessage(ConfigDefaults.newMitoMessage.replaceAll("(?i)\\{player\\}", newMito == null ? playerName : newMito.getName()));
	DBFile.setMito(newMito == null ? playerName : newMito.getName());
}
 
开发者ID:leonardosnt,项目名称:OldBukkit,代码行数:58,代码来源:LsMito.java

示例5: RemoveBatsRunnable

import org.bukkit.entity.Bat; //导入依赖的package包/类
public RemoveBatsRunnable(HashSet<Bat> spawnedBats) 
{
	this.spawnedBats = spawnedBats;
}
 
开发者ID:leonardosnt,项目名称:OldBukkit,代码行数:5,代码来源:RemoveBatsRunnable.java

示例6: getBukkitEntity

import org.bukkit.entity.Bat; //导入依赖的package包/类
@Override
public Bat getBukkitEntity() {
    return (Bat) super.getBukkitEntity();
}
 
开发者ID:TechzoneMC,项目名称:SonarPet,代码行数:5,代码来源:EntityBatPet.java

示例7: BatEntityWrapper

import org.bukkit.entity.Bat; //导入依赖的package包/类
BatEntityWrapper(RpgPlusEntity<Bat> entity, EntityEventManager entityEventManager) {
    super(entity, entityEventManager);
}
 
开发者ID:leMaik,项目名称:RpgPlus,代码行数:4,代码来源:BatEntityWrapper.java

示例8: onSpawn

import org.bukkit.entity.Bat; //导入依赖的package包/类
@Override
public void onSpawn() {
    Bat bat = (Bat) getNPC().getEntity();
    bat.setAwake(isAwake);
}
 
开发者ID:leMaik,项目名称:RpgPlus,代码行数:6,代码来源:BatTrait.java

示例9: setAwake

import org.bukkit.entity.Bat; //导入依赖的package包/类
public void setAwake(boolean awake) {
    isAwake = awake;
    if (getNPC().isSpawned()) ((Bat) getNPC().getEntity()).setAwake(awake);
}
 
开发者ID:leMaik,项目名称:RpgPlus,代码行数:5,代码来源:BatTrait.java

示例10: CanaryBat

import org.bukkit.entity.Bat; //导入依赖的package包/类
public CanaryBat(net.canarymod.api.entity.living.animal.Bat entity) {
    super(entity);
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:4,代码来源:CanaryBat.java

示例11: getHandle

import org.bukkit.entity.Bat; //导入依赖的package包/类
@Override
protected net.canarymod.api.entity.living.animal.Bat getHandle() {
    return (net.canarymod.api.entity.living.animal.Bat) super.getHandle();
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:5,代码来源:CanaryBat.java

示例12: RemoteBat

import org.bukkit.entity.Bat; //导入依赖的package包/类
public RemoteBat(int inID, EntityManager inManager)
{
	super(inID, RemoteEntityType.Bat, inManager);
}
 
开发者ID:MeRPG2,项目名称:EndHQ-Libraries,代码行数:5,代码来源:RemoteBat.java


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