本文整理汇总了Java中org.bukkit.event.entity.EntityDamageEvent.DamageCause.FALL属性的典型用法代码示例。如果您正苦于以下问题:Java DamageCause.FALL属性的具体用法?Java DamageCause.FALL怎么用?Java DamageCause.FALL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.event.entity.EntityDamageEvent.DamageCause
的用法示例。
在下文中一共展示了DamageCause.FALL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Stomper
@EventHandler
public void Stomper(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
if (Kit.getKit(p).getName().equalsIgnoreCase("stomper")) {
if (e.getCause() == DamageCause.FALL) {
List<Entity> nearbyEntities = e.getEntity()
.getNearbyEntities(5, 5, 5);
for (Entity target : nearbyEntities) {
if (target instanceof Player) {
Player t = (Player) target;
if (Team.getTeam(p) == Team.getTeam(t))
continue;
if (t.isSneaking())
t.damage(e.getDamage() / 2, e.getEntity());
else
t.damage(e.getDamage(), e.getEntity());
}
}
e.setDamage(0);
}
}
}
}
示例2: onCancell
@EventHandler
public void onCancell(EntityDamageEvent event){
Entity e = event.getEntity();
if(!(e instanceof Player)){
return;
}
Player p = (Player)e;
Arena a = new ArenaManager().getArena(p);
if(a==null){
event.setCancelled(true);
return;
}
if(a.isEnd()){
event.setCancelled(true);
}
if(a.fallMode()==true){
if(event.getCause() == DamageCause.FALL||event.getCause() == DamageCause.VOID){
event.setCancelled(true);
}
}
}
示例3: test
@Test
public void test() {
final Object[] random = {
// Java
(byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37,
"String",
// Skript
Color.BLACK, StructureType.RED_MUSHROOM, WeatherType.THUNDER,
new Date(System.currentTimeMillis()), new Timespan(1337), new Time(12000), new Timeperiod(1000, 23000),
new Experience(15), new Direction(0, Math.PI, 10), new Direction(new double[] {0, 1, 0}),
new EntityType(new SimpleEntityData(HumanEntity.class), 300), new CreeperData(), new SimpleEntityData(Snowball.class), new HorseData(Variant.SKELETON_HORSE), new WolfData(), new XpOrbData(50),
// Bukkit - simple classes only
GameMode.ADVENTURE, Biome.EXTREME_HILLS, DamageCause.FALL,
// there is also at least one variable for each class on my test server which are tested whenever the server shuts down.
};
for (final Object o : random) {
Classes.serialize(o); // includes a deserialisation test
}
}
示例4: onEntityDamage
@SuppressWarnings("deprecation")
public void onEntityDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player) {
if (event.getCause() == DamageCause.FALL) {
Location l = event.getEntity().getLocation().add(0, -1, 0);
Material mBelow = l.getBlock().getType();
if (mBelow == Material.SPONGE) {
event.setCancelled(true);
Player player = (Player) event.getEntity();
if (!player.isSneaking()) {
player.setVelocity(new Vector(player.getVelocity().getX(), 1.3D, player.getVelocity().getZ()));
if (player.hasPermission("customplugin.crazytramp") || l.getBlock().getData() == (byte) 1)
player.setVelocity(new Vector(player.getVelocity().getX(), 10D, player.getVelocity().getZ()));
player.getWorld().playEffect(l, Effect.STEP_SOUND, 19);
}
}
}
}
}
示例5: onDamage
@EventHandler
public void onDamage(EntityDamageEvent event)
{
if (!(event.getEntity() instanceof Player))
return;
BytecraftPlayer player = plugin.getPlayer((Player) event.getEntity());
if (event.getCause() == DamageCause.FALL) {
event.setCancelled(false);
return;
}
if (player.getRank().isImmortal()) {
if (!player.hasFlag(Flag.IMMORTAL)) {
return;
}
event.setCancelled(true);
}
}
示例6: onPlayerFall
@EventHandler(priority = EventPriority.HIGHEST)
private void onPlayerFall(EntityDamageEvent event) {
if (event.getCause() != DamageCause.FALL)
return;
if (!(event.getEntity() instanceof Player))
return;
IArenaPlayer player = ArenaPlayer.get((Player) event.getEntity());
if (player == null)
return;
IArena arena = player.getArena();
if (arena == null)
return;
IContextSettings settings = player.getContextSettings();
if (settings == null)
return;
if (!settings.hasFallDamage()) {
event.setDamage(0.0D);
event.setCancelled(true);
}
}
示例7: onPlayerFall
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerFall(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
Player player = (Player) e.getEntity();
if (e.getCause() == DamageCause.FALL) {
PlayerInventory inv = player.getInventory();
int heldSlot = inv.getHeldItemSlot();
ItemStack sourceStack = inv.getItem(heldSlot);
if (sourceStack == null || sourceStack.getType() == Material.SNOW_BALL) {
InventorySlice slice = InventorySlice.fromSlot(player, heldSlot).skip(1);
if (slice.getBottomItem().getType() == Material.FIREWORK) {
player.setFallDistance(0);
e.setCancelled(true);
//if we have the jetpack engaged, we're free from any fall damage.
}
}
}
return;
} else {
return;
}
}
示例8: onPlayerDamage
@EventHandler
public void onPlayerDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
Player player = (Player) e.getEntity();
if (e.getCause() == DamageCause.FALL) {
boolean noDamage = false;
for (Projectile proj : plugin.airship) {
if (proj.getShooter() == player) {
noDamage = true;
break;
}
}
if (noDamage || plugin.noFallDamage.contains(player.getUniqueId())) {
e.setDamage(0);
e.setCancelled(true);
plugin.noFallDamage.remove(player.getUniqueId());
}
}
}
}
示例9: PlayerDamage
@EventHandler
public void PlayerDamage(EntityDamageEvent event){
PluginManager pm = Bukkit.getServer().getPluginManager();
if(event.getEntity() instanceof Player){
Player player = (Player)event.getEntity();
if(userManager.getUser(player.getUniqueId()).isGod()){
event.setCancelled(true);
}
if (event.getCause() == DamageCause.FALL) {
double dmg = event.getDamage();
int count =1;
while(dmg>count){
count++;
}
SkillXPGainEvent skillevent = new SkillXPGainEvent(player.getUniqueId(), SkillType.ACROBATICS, count);
pm.callEvent(skillevent);
event.setDamage(damageUtil.getFallDamage(player, event.getDamage()));
}
}
}
示例10: onDamage
@EventHandler(priority = EventPriority.HIGH)
public void onDamage(EntityDamageEvent event) {
if (event.getCause() != DamageCause.FALL) {
return;
}
if (!(event.getEntity() instanceof Player)) {
return;
}
Player player = (Player) event.getEntity();
if (!game.isPlayerTurn(player)) {
return;
}
if (!(arena.isIn(player.getWorld()) && arena.getSurroundingRegion()
.contains(player))) {
return;
}
game.onJumpFail(player);
event.setCancelled(true);
}
示例11: onEntityDamageLowest
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamageLowest(EntityDamageEvent event)
{
if (event.isCancelled() || event.getDamage() <= 0 || ! gracefulRollEnabled)
return;
if (event.getCause() != DamageCause.FALL)
return;
Entity entity = event.getEntity();
if (plugin.isDisabledWorld(entity))
return;
if (entity instanceof Player)
{
if (Util.random(gracefulRollOdds) == 0)
{
event.setDamage(0);
Player player = (Player) entity;
player.sendMessage(plugin.getPrefix() + FormatUtil.format(plugin.getMessage("graceful_roll")));
}
}
}
示例12: onEntityDamage
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player)) {
return;
}
if (event.getCause() == DamageCause.FALL) {
final Player player = (Player) event.getEntity();
final Behaviour behaviour = Profile.getProfile(player.getUniqueId()).getBehaviour();
behaviour.getMotion().setLastY(player.getLocation().getY());
}
}
示例13: resolve
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
if(damageEvent.getCause() == DamageCause.FALL) {
float fallDistance = Math.max(0, entity.getFallDistance());
return new SimpleFallDamageInfo(null, fallDistance);
}
return null;
}
示例14: entityDamageEvent
@EventHandler
public void entityDamageEvent(final EntityDamageEvent event) {
if (this.isPet(event.getEntity())) {
final PetBlock petBlock = this.getPet(event.getEntity());
if (petBlock == null)
return;
if (event.getCause() != DamageCause.FALL)
petBlock.damage(event.getFinalDamage());
else if (event.getCause() == DamageCause.FALL)
petBlock.damage(-2.0);
event.setCancelled(true);
}
}
示例15: onEntityDamage
@EventHandler
public void onEntityDamage(EntityDamageEvent e) {
if(e.getEntity() instanceof ArmorStand || e.getEntity() instanceof Item)
e.setCancelled(true);
if(e.getEntity() instanceof Player) {
e.setCancelled(true);
if(e.getCause() == DamageCause.FALL) {
GamePlayer player = Absorption.getPlayer((Player) e.getEntity());
if(player == null) return;
player.damage((int) e.getDamage());
}
}
}