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


Java EntityDamageEvent.getCause方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityDamageEvent.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageEvent.getCause方法的具体用法?Java EntityDamageEvent.getCause怎么用?Java EntityDamageEvent.getCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.EntityDamageEvent的用法示例。


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

示例1: onDamageWhenPlayerNotLoaded

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onDamageWhenPlayerNotLoaded(EntityDamageEvent event) {
    if (event.getEntityType() != EntityType.PLAYER) {
        return;
    }

    Player player = (Player) event.getEntity();
    if (InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
        PlayerLoader.setDamageForPlayer(player, event.getFinalDamage());
    }

    event.setCancelled(true);
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:18,代码来源:PlayerListener.java

示例2: call

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@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,代码行数:27,代码来源:AntiDamageA.java

示例3: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event)
{
    event.setCancelled(true);

    if (event.getEntity().getType() != EntityType.PLAYER)
        return;

    if (event.getCause() == EntityDamageEvent.DamageCause.VOID)
    {
        if (this.hub.getParkourManager().getPlayerParkour(event.getEntity().getUniqueId()) != null)
            this.hub.getParkourManager().getPlayerParkour(event.getEntity().getUniqueId()).failPlayer((Player) event.getEntity());
        else
            event.getEntity().teleport(this.hub.getPlayerManager().getSpawn());
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:17,代码来源:PlayerListener.java

示例4: resolve

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
public @Nonnull
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    DamageInfo info = null;

    for(ResolverEntry entry : this.resolvers) {
        DamageInfo resolvedInfo = entry.resolver.resolve(entity, lifetime, damageEvent);
        if(resolvedInfo != null) {
            info = resolvedInfo;
        }
    }

    if(info == null) {
        info = new BukkitDamageInfo(damageEvent.getCause());
    }

    return info;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:18,代码来源:SimpleResolverManager.java

示例5: onPlayerDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerDamage(EntityDamageEvent event) {
    if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
        Entity entity = event.getEntity();
        if (entity instanceof Player) {
            // Allow players to die by VOID in the END
            if (entity.getWorld().getEnvironment() == World.Environment.THE_END) {
                return;
            }

            Location destination = BukkitUtils.getHighestLocation(entity.getLocation());
            if (destination == null)
                return;

            if (entity.teleport(destination, PlayerTeleportEvent.TeleportCause.PLUGIN)) {
                event.setCancelled(true);
                ((Player) entity).sendMessage(ChatColor.YELLOW + "You were saved from the void.");
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:22,代码来源:VoidGlitchFixListener.java

示例6: resolve

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent && damageEvent.getCause() == DamageCause.ENTITY_ATTACK) {
        EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) damageEvent;

        if(entityEvent.getDamager() instanceof LivingEntity) {
            LivingEntity attacker = (LivingEntity) entityEvent.getDamager();

            Material weaponMaterial;
            ItemStack held = attacker.getEquipment().getItemInMainHand();
            if(held != null) {
                weaponMaterial = held.getType();
            } else {
                weaponMaterial = Material.AIR;
            }

            return new SimpleMeleeDamageInfo(attacker, weaponMaterial);
        }
    }

    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:23,代码来源:MeleeDamageResolver.java

示例7: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if(event.getCause() == EntityDamageEvent.DamageCause.CUSTOM) return;
    if(Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().getGameState() != GameState.INGAME) {
        event.setCancelled(true);
    } else {
        if(!Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().getCurrentGame().allowPVP) event.setCancelled(true);
    }
    if(!event.isCancelled() && event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();
        if((player.getHealth()-event.getDamage()) <= 0) {
            event.setDamage(0);
            if(Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().isAlive(player)) {
                Arcadia.getPlugin(Arcadia.class).getAPI().getGameManager().setAlive(player, false);
            }
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:19,代码来源:DamageListener.java

示例8: onEvent

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
void onEvent(EntityDamageEvent event) {
    if(event.getEntity() == player.getBukkit()) {
        // Player took damage
        mutateStamina(options.mutators.injury);

    } else if(event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK &&
              event instanceof EntityDamageByEntityEvent &&
              ((EntityDamageByEntityEvent) event).getDamager() == player.getBukkit()) {

        // Player is damager and attack is melee
        swinging = false;

        for(StaminaSymptom symptom : getActiveSymptoms()) {
            symptom.onAttack(event);
        }

        mutateStamina(options.mutators.meleeHit);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:PlayerStaminaState.java

示例9: onPlayerDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDamage(EntityDamageEvent event) {
	if (!(event.getEntity() instanceof Player))
		return;
	event.setCancelled(true);
	
	if (event.getCause()==DamageCause.VOID) {
		Location l = event.getEntity().getWorld().getSpawnLocation();
		l.setX(14.5);
		l.setY(10.5);
		l.setZ(-795.5);
		l.setPitch(0.5F);
		l.setYaw(90 * RandomUtil.between(1, 4));
		event.getEntity().teleport(l);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:17,代码来源:Events.java

示例10: onDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onDamage(EntityDamageEvent evt) { // Teleport a player out if they lose.
    if (evt.getCause() == EntityDamageEvent.DamageCause.LAVA && evt.getEntity() instanceof Player) {
        evt.getEntity().playEffect(EntityEffect.HURT);
        removePlayer((Player) evt.getEntity());
        Bukkit.getScheduler().runTask(Core.getInstance(), () -> evt.getEntity().setFireTicks(0)); // Must run a tick late.
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:9,代码来源:Splef.java

示例11: resolve

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent.getCause() == DamageCause.LAVA) {
        return new SimpleLavaDamageInfo(null);
    }

    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:9,代码来源:LavaDamageResolver.java

示例12: resolve

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
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;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:11,代码来源:FallDamageResolver.java

示例13: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
	if (event.getEntity() instanceof Player) {
		Gamer g = Gamer.get((Player) event.getEntity());
		if (g.getVariable("spectator") != null)
			return;
		
		Kit kit = (Kit) g.getVariable("kit");
		if (kit.getName().equals("scout") && event.getCause() == DamageCause.FALL) {
			event.setDamage(0);
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:14,代码来源:KitEvents.java

示例14: onEntityDamageEvent

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamageEvent(EntityDamageEvent event) {
    if (event.getCause() == DamageCause.VOID && event.getEntity() instanceof Player) {
        if (lastVoid.containsKey(((Player) event.getEntity()).getName()) && System.currentTimeMillis() - lastVoid.get(((Player) event.getEntity()).getName()) < 5000)
            return;
        ((Player) event.getEntity()).sendMessage(ChatColor.RED + "Woah! Careful there, pal!");
        event.getEntity().setFallDistance(0);
        event.getEntity().teleport(event.getEntity().getWorld().getSpawnLocation());
        event.getEntity().setFallDistance(0);
    } else if (event.getCause() == DamageCause.VOID && MobManager.spawnedMobs.get(event.getEntity().getUniqueId()) != null) {
        MobData md = MobManager.spawnedMobs.get(event.getEntity().getUniqueId());
        event.getEntity().teleport(md.ai.originalLoc);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:15,代码来源:EnvironmentManager.java

示例15: onEntityDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
/**
 * Set Potion Effect SLOWNESS I when player takes fall damage
 * @param event Entity Damage Event
 */
@EventHandler
public void onEntityDamage(EntityDamageEvent event)
{
    if (event.getEntity() instanceof Player && event.getCause() == EntityDamageEvent.DamageCause.FALL && !event.isCancelled())
        ((Player) event.getEntity()).addPotionEffect(PotionEffectType.SLOW.createEffect((int) this.moduleConfiguration.get("penalty-time") * 20, 1));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:11,代码来源:CrippleModule.java


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