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


Java DamageCause.FIRE屬性代碼示例

本文整理匯總了Java中org.bukkit.event.entity.EntityDamageEvent.DamageCause.FIRE屬性的典型用法代碼示例。如果您正苦於以下問題:Java DamageCause.FIRE屬性的具體用法?Java DamageCause.FIRE怎麽用?Java DamageCause.FIRE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.bukkit.event.entity.EntityDamageEvent.DamageCause的用法示例。


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

示例1: call

@Override
public void call(Event event) {
	if (event instanceof EntityDamageEvent) {
		final EntityDamageEvent ede = (EntityDamageEvent) event;
		final DamageCause cause = ede.getCause();

		if (cause == DamageCause.FIRE || cause == DamageCause.CONTACT) {
			final Player player = profile.getPlayer();

			if (cause == DamageCause.FIRE && player.getFoodLevel() < 20) {
				// The AntiFire cheat only works when the hunger bar is
				// full.
				return;
			}

			final double previousHealth = player.getHealth();

			// Check a little later.
			Bukkit.getScheduler().runTaskLater(Crescent.getInstance(), () -> {
				if (player.getHealth() > previousHealth - ede.getDamage()) {
					callback(true);
				}
			}, 2L);
		}
	}
}
 
開發者ID:davidm98,項目名稱:Crescent,代碼行數:26,代碼來源:AntiDamageA.java

示例2: onItemDamage

@EventHandler
public void onItemDamage(EntityDamageEvent event) {
    if (event.getEntityType() == EntityType.DROPPED_ITEM && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        Vector v = Vector.getRandom().normalize();
        v = v.setX(v.getX() - 0.5f);
        v = v.setZ(v.getZ() - 0.5f);
        v = v.multiply(0.35);
        if (v.getX() > 0 && v.getX() < 0.10)
            v.setX(0.10);
        if (v.getZ() > 0 && v.getZ() < 0.10)
            v.setZ(0.10);
        if (v.getX() < 0 && v.getX() > -0.10)
            v.setX(-0.10);
        if (v.getZ() < 0 && v.getZ() > -0.10)
            v.setZ(-0.10);
        v.setY(0.3);
        event.getEntity().setVelocity(v);
        event.setCancelled(true);
        RScheduler.schedule(plugin, () -> {
            event.getEntity().setFireTicks(0);
        }, RTicks.seconds(1));
    }
    if (event.getEntityType() == EntityType.ARMOR_STAND && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        event.setCancelled(true);
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:26,代碼來源:EnvironmentManager.java

示例3: onEntityDamage

@EventHandler
public void onEntityDamage(final EntityDamageEvent event) {

	if (event.getCause() == DamageCause.DROWNING || event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.LAVA) {

		// Ok so an entity damage event begins
		// Find the nearest gate!
		final WorldCoord entityCoord = new WorldCoord(event.getEntity().getLocation());
		final WorldCoord entityCoordUp = new WorldCoord(event.getEntity().getLocation().getBlock().getRelative(BlockFace.UP));
		final Gate nearestGate = GateUtil.nearestGate(entityCoord, false);
		final Gate nearestGateUp = GateUtil.nearestGate(entityCoordUp, false);

		if (nearestGate != null || nearestGateUp != null) {
			event.setCancelled(true);
			event.getEntity().setFireTicks(0);
		}
	}
}
 
開發者ID:NoChanceSD,項目名稱:AncientGates,代碼行數:18,代碼來源:PluginEntityListener.java

示例4: onEntityDamage

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {
	if (((event.getCause() == DamageCause.FIRE_TICK) || (event.getCause() == DamageCause.FIRE) || (event.getCause() == DamageCause.DROWNING))) {
		for (Player player : ServerPlatform.get().getMiscUtils().getNearbyPlayers(event.getEntity().getLocation(), 48, 128, 48)) {
			if (player != null) {
				Connection connection = ProtocolSupportAPI.getConnection(player);
				if (
					(connection != null) &&
					(connection.getVersion().getProtocolType() == ProtocolType.PC) &&
					connection.getVersion().isBefore(ProtocolVersion.MINECRAFT_1_12)
				) {
					connection.sendPacket(ServerPlatform.get().getPacketFactory().createEntityStatusPacket(event.getEntity(), 2));
				}
			}
		}
	}
}
 
開發者ID:ProtocolSupport,項目名稱:ProtocolSupport,代碼行數:17,代碼來源:FeatureEmulation.java

示例5: onDamageGet

@EventHandler(priority=EventPriority.MONITOR)
public void onDamageGet(EntityDamageEvent e) {
	if (!e.isCancelled()) {
		if (e instanceof EntityDamageByEntityEvent) {
			if (((EntityDamageByEntityEvent) e).getDamager() instanceof Player && SlimefunStartup.chance(100, 45)) {
				if (SlimefunManager.isItemSimiliar(((Player) ((EntityDamageByEntityEvent) e).getDamager()).getInventory().getItemInMainHand(), SlimefunItem.getItem("BLADE_OF_VAMPIRES"), true)) {
					((Player) ((EntityDamageByEntityEvent) e).getDamager()).playSound(((EntityDamageByEntityEvent) e).getDamager().getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.7F, 0.7F);
					((Player) ((EntityDamageByEntityEvent) e).getDamager()).addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1));
				}
			}
		}
		if (e.getEntity() instanceof Player) {
			if (!e.isCancelled()) {
				if (e.getCause() == DamageCause.LAVA) Talisman.checkFor(e, SlimefunItem.getByID("LAVA_TALISMAN"));
				if (e.getCause() == DamageCause.DROWNING) Talisman.checkFor(e, SlimefunItem.getByID("WATER_TALISMAN"));
				if (e.getCause() == DamageCause.FALL) Talisman.checkFor(e, SlimefunItem.getByID("ANGEL_TALISMAN"));
				if (e.getCause() == DamageCause.FIRE) Talisman.checkFor(e, SlimefunItem.getByID("FIRE_TALISMAN"));
				if (e.getCause() == DamageCause.ENTITY_ATTACK) Talisman.checkFor(e, SlimefunItem.getByID("WARRIOR_TALISMAN"));
				if (e.getCause() == DamageCause.ENTITY_ATTACK) Talisman.checkFor(e, SlimefunItem.getByID("KNIGHT_TALISMAN"));
				if (e.getCause() == DamageCause.PROJECTILE) {
					if (Talisman.checkFor(e, SlimefunItem.getByID("WHIRLWIND_TALISMAN"))) {
						if (((EntityDamageByEntityEvent) e).getDamager() instanceof Projectile) {
							Vector direction = ((Player) e.getEntity()).getEyeLocation().getDirection().multiply(2.0);
							Projectile projectile = (Projectile) e.getEntity().getWorld().spawnEntity(((LivingEntity) e.getEntity()).getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), ((EntityDamageByEntityEvent) e).getDamager().getType());
							projectile.setVelocity(direction);
							((EntityDamageByEntityEvent) e).getDamager().remove();
						}
					}
				}
			}
		}
	}
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:33,代碼來源:TalismanListener.java

示例6: getBlockDamageCause

private static DamageCause getBlockDamageCause(Block block) {
    switch(block.getType()) {
        case LAVA:
        case STATIONARY_LAVA:
            return DamageCause.LAVA;

        case FIRE:
            return DamageCause.FIRE;

        default:
            return DamageCause.CONTACT;
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:13,代碼來源:DisableDamageMatchModule.java

示例7: onDamage

@EventHandler
public void onDamage(EntityDamageEvent e) {
	if (e.getEntity() instanceof Player) {
		if (e.getCause() == DamageCause.FIRE || e.getCause() == DamageCause.FIRE_TICK) {
			Player p = (Player) e.getEntity();
			e.setDamage(e.getDamage() * (1 - EnchantmentZ.calcInventoryPieceAmount(FIRE_PROTECTION, p.getInventory()) * 0.0625));
		}
	}
}
 
開發者ID:crazyhorse961,項目名稱:NationZ,代碼行數:9,代碼來源:EnchantmentZ_FireProtection.java

示例8: toBukkit

public static DamageCause toBukkit(cn.nukkit.event.entity.EntityDamageEvent.DamageCause nukkit) {
	// TODO Direct mapping via DamageCause.valueOf?
	switch (nukkit) {
		case CONTACT:
			return DamageCause.CONTACT;
		case ENTITY_ATTACK:
			return DamageCause.ENTITY_ATTACK;
		case PROJECTILE:
			return DamageCause.PROJECTILE;
		case SUFFOCATION:
			return DamageCause.SUFFOCATION;
		case FALL:
			return DamageCause.FALL;
		case FIRE:
			return DamageCause.FIRE;
		case FIRE_TICK:
			return DamageCause.FIRE_TICK;
		case LAVA:
			return DamageCause.LAVA;
		case DROWNING:
			return DamageCause.DROWNING;
		case BLOCK_EXPLOSION:
			return DamageCause.BLOCK_EXPLOSION;
		case ENTITY_EXPLOSION:
			return DamageCause.ENTITY_EXPLOSION;
		case VOID:
			return DamageCause.VOID;
		case SUICIDE:
			return DamageCause.SUICIDE;
		case MAGIC:
			return DamageCause.MAGIC;
		case LIGHTNING:
			return DamageCause.LIGHTNING;
		case CUSTOM:
		default:
			return DamageCause.CUSTOM;
	}
}
 
開發者ID:rutgerkok,項目名稱:Pokkit,代碼行數:38,代碼來源:PokkitDamageCause.java

示例9: onEntityDamage

/**
 * On entity damage.
 *
 * @param event the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {
	
	// Check for fire cancel
	if(event.getEntity() instanceof Player && 
			(event.getCause() == DamageCause.FIRE
			|| event.getCause() == DamageCause.FIRE_TICK)) {
		
		Player player = (Player) event.getEntity();
		IPlayerConfEntry entry = playerConf.get(player);
		
		if(entry != null) {
			Location loc = player.getLocation();
			IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(loc);
			
			// Check for fire near the player
			for(Map.Entry<Location, IPlayerContainerPlayer> fireEntry : playerFireLocation.entrySet()) {
				
				if(loc.getWorld() == fireEntry.getKey().getWorld() 
						&& loc.distanceSquared(fireEntry.getKey()) < 5) {
					Block block = loc.getBlock();
					if((block.getType() == Material.FIRE || block.getType() == Material.AIR) 
							&& !isPvpValid(land, fireEntry.getValue(), entry.getPlayerContainer())) {
						
						// remove fire
						Factoid.getThisPlugin().iLog().write("Anti-pvp from " 
								+ entry.getPlayerContainer().getPlayer().getName()
								+ " to " + player.getName());
						block.setType(Material.AIR);
						player.setFireTicks(0);
						event.setDamage(0);
						event.setCancelled(true);
					}
				}
			}
		}
	}
}
 
開發者ID:Tabinol,項目名稱:Factoid,代碼行數:43,代碼來源:PvpListener.java

示例10: onEntityDamage

@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if (event.getEntity() instanceof Player) {
        if (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK) {
            event.getEntity().setFireTicks(0);
        }
        if (event.getCause() != DamageCause.VOID) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:EyeOfEnder-Ltd,項目名稱:EOEHub,代碼行數:11,代碼來源:PlayerListener.java

示例11: damageEntity

@Override
public boolean damageEntity(DamageSource source, float damage) {
    if (invulnerable || noDamageTicks > 0) {
        return false;
    }

    DamageCause cause = null;
    org.bukkit.entity.Entity bEntity = null;
    if (source instanceof EntityDamageSource) {
        Entity damager = source.getEntity();
        cause = DamageCause.ENTITY_ATTACK;
        if (source instanceof EntityDamageSourceIndirect) {
            damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
            if (damager.getBukkitEntity() instanceof ThrownPotion) {
                cause = DamageCause.MAGIC;
            } else if (damager.getBukkitEntity() instanceof Projectile) {
                cause = DamageCause.PROJECTILE;
            }
        }

        bEntity = damager.getBukkitEntity();
    } else if (source == DamageSource.FIRE)
        cause = DamageCause.FIRE;
    else if (source == DamageSource.STARVE)
        cause = DamageCause.STARVATION;
    else if (source == DamageSource.WITHER)
        cause = DamageCause.WITHER;
    else if (source == DamageSource.STUCK)
        cause = DamageCause.SUFFOCATION;
    else if (source == DamageSource.DROWN)
        cause = DamageCause.DROWNING;
    else if (source == DamageSource.BURN)
        cause = DamageCause.FIRE_TICK;
    else if (source == CraftEventFactory.MELTING)
        cause = DamageCause.MELTING;
    else if (source == CraftEventFactory.POISON)
        cause = DamageCause.POISON;
    else if (source == DamageSource.MAGIC) {
        cause = DamageCause.MAGIC;
    } else if (source == DamageSource.OUT_OF_WORLD) {
        cause = DamageCause.VOID;
    }

    if (cause != null) {
        NPCDamageEvent event = new NPCDamageEvent(npc, bEntity, cause, (double) damage);
        Bukkit.getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            return super.damageEntity(source, (float) event.getDamage());
        } else {
            return false;
        }
    }

    if (super.damageEntity(source, damage)) {
        if (bEntity != null) {
            Entity e = ((CraftEntity) bEntity).getHandle();
            double d0 = e.locX - this.locX;

            double d1;
            for (d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
                d0 = (Math.random() - Math.random()) * 0.01D;
            }

            a(e, damage, d0, d1);
        }

        return true;
    } else {
        return false;
    }
}
 
開發者ID:johnnywoof,項目名稱:NoHack,代碼行數:71,代碼來源:NPCEntity.java

示例12: damageEntity

@Override
public boolean damageEntity(DamageSource source, float damage) {
    if(godmode || noDamageTicks > 0) {
        return false;
    }

    DamageCause cause = null;
    org.bukkit.entity.Entity bEntity = null;
    if(source instanceof EntityDamageSource) {
        Entity damager = source.getEntity();
        cause = DamageCause.ENTITY_ATTACK;
        if(source instanceof EntityDamageSourceIndirect) {
            damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
            if(damager.getBukkitEntity() instanceof ThrownPotion) {
                cause = DamageCause.MAGIC;
            } else if(damager.getBukkitEntity() instanceof Projectile) {
                cause = DamageCause.PROJECTILE;
            }
        }

        bEntity = damager.getBukkitEntity();
    } else if(source == DamageSource.FIRE)
        cause = DamageCause.FIRE;
    else if(source == DamageSource.STARVE)
        cause = DamageCause.STARVATION;
    else if(source == DamageSource.WITHER)
        cause = DamageCause.WITHER;
    else if(source == DamageSource.STUCK)
        cause = DamageCause.SUFFOCATION;
    else if(source == DamageSource.DROWN)
        cause = DamageCause.DROWNING;
    else if(source == DamageSource.BURN)
        cause = DamageCause.FIRE_TICK;
    else if(source == CraftEventFactory.MELTING)
        cause = DamageCause.MELTING;
    else if(source == CraftEventFactory.POISON)
        cause = DamageCause.POISON;
    else if(source == DamageSource.MAGIC) {
        cause = DamageCause.MAGIC;
    } else if(source == DamageSource.OUT_OF_WORLD) {
        cause = DamageCause.VOID;
    }

    if(cause != null) {
        NPCDamageEvent event = new NPCDamageEvent(this, bEntity, cause, (double) damage);
        Bukkit.getPluginManager().callEvent(event);
        if(!event.isCancelled()) {
            return super.damageEntity(source, (float) event.getDamage());
        } else {
            return false;
        }
    }

    if(super.damageEntity(source, damage)) {
        if(bEntity != null) {
            Entity e = ((CraftEntity) bEntity).getHandle();
            double d0 = e.locX - this.locX;

            double d1;
            for(d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
                d0 = (Math.random() - Math.random()) * 0.01D;
            }

            a(e, damage, d0, d1);
        }

        return true;
    } else {
        return false;
    }
}
 
開發者ID:lenis0012,項目名稱:NPCFactory,代碼行數:71,代碼來源:NPCEntity.java


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