本文整理汇总了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));
}
}
}
示例2: run
import org.bukkit.entity.Bat; //导入依赖的package包/类
@Override
public void run()
{
for (Bat bat : spawnedBats)
{
bat.remove();
}
spawnedBats.clear();
}
示例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());
}
}
示例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());
}
示例5: RemoveBatsRunnable
import org.bukkit.entity.Bat; //导入依赖的package包/类
public RemoveBatsRunnable(HashSet<Bat> spawnedBats)
{
this.spawnedBats = spawnedBats;
}
示例6: getBukkitEntity
import org.bukkit.entity.Bat; //导入依赖的package包/类
@Override
public Bat getBukkitEntity() {
return (Bat) super.getBukkitEntity();
}
示例7: BatEntityWrapper
import org.bukkit.entity.Bat; //导入依赖的package包/类
BatEntityWrapper(RpgPlusEntity<Bat> entity, EntityEventManager entityEventManager) {
super(entity, entityEventManager);
}
示例8: onSpawn
import org.bukkit.entity.Bat; //导入依赖的package包/类
@Override
public void onSpawn() {
Bat bat = (Bat) getNPC().getEntity();
bat.setAwake(isAwake);
}
示例9: setAwake
import org.bukkit.entity.Bat; //导入依赖的package包/类
public void setAwake(boolean awake) {
isAwake = awake;
if (getNPC().isSpawned()) ((Bat) getNPC().getEntity()).setAwake(awake);
}
示例10: CanaryBat
import org.bukkit.entity.Bat; //导入依赖的package包/类
public CanaryBat(net.canarymod.api.entity.living.animal.Bat entity) {
super(entity);
}
示例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();
}
示例12: RemoteBat
import org.bukkit.entity.Bat; //导入依赖的package包/类
public RemoteBat(int inID, EntityManager inManager)
{
super(inID, RemoteEntityType.Bat, inManager);
}