本文整理汇总了Java中org.bukkit.event.entity.EntityDamageEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDamageEvent.getEntity方法的具体用法?Java EntityDamageEvent.getEntity怎么用?Java EntityDamageEvent.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityDamageEvent
的用法示例。
在下文中一共展示了EntityDamageEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (event instanceof EntityDamageByEntityEvent)
return;
if (event.getEntity() instanceof Player == false)
return;
Player t = (Player) event.getEntity();
if (!damages.containsKey(t.getName()))
damages.put(t.getName(), new ArrayList<PlayerDamageEvent>());
PlayerDamageEvent callMe = new PlayerDamageEvent(t, event.getCause());
Bukkit.getPluginManager().callEvent(callMe);
event.setCancelled(callMe.isCancelled());
if (event.isCancelled() == false)
damages.get(t.getName()).add(callMe);
}
示例2: 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);
}
}
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: onPlayerDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true) // Prevent players from being damaged in the party world unless in a game.
public void onPlayerDamage(EntityDamageEvent evt) {
if (!isParty(evt.getEntity()))
return;
if (!(evt.getEntity() instanceof LivingEntity))
evt.setCancelled(true); // Default to no damage, if the entity isn't alive.
if (!(evt.getEntity() instanceof Player))
return; // If the damaged isn't a player, ignore this next bit that may uncancel it.
Player p = (Player) evt.getEntity();
evt.setCancelled(!checkParty(p, PartyGame::allowDamage));
if (evt instanceof EntityDamageByEntityEvent) { // Handle combat differently.
EntityDamageByEntityEvent dmg = (EntityDamageByEntityEvent) evt;
boolean isMob = evt.getEntity() instanceof Creature;
boolean isPlayer = dmg.getEntity() instanceof Player && dmg.getDamager() instanceof Player;
evt.setCancelled((!checkParty(p, PartyGame::allowMobCombat) && isMob) || (!checkParty(p, PartyGame::allowPlayerCombat) && isPlayer));
}
}
示例6: onDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onDamage(EntityDamageEvent e) {
if(e.getEntity() instanceof Player) {
Player player = (Player) e.getEntity();
KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(player);
switch (p.getSettingsProfile().getGodMode()) {
case FAKEDAMAGE:
e.setDamage(0);
p.heal();
break;
case NODAMAGE:
e.setCancelled(true);
break;
case NOGOD:
return;
default:
return;
}
}
}
示例7: onEntityDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player)) {
return;
}
final Player player = (Player) event.getEntity();
getCheckVersion(player, CheckType.ANTIDAMAGE, "A").call(event);
}
示例8: onPlayerDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerDamage(EntityDamageEvent event)
{
Entity entity = event.getEntity();
if ((entity instanceof Player))
{
Player player = (Player)entity;
if (getRemaining(player) > 0L)
{
player.sendMessage(ChatColor.RED + "You were damaged, " + getDisplayName() + ChatColor.RED + " timer ended.");
clearCooldown(player);
}
}
}
示例9: onDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onDamage(EntityDamageEvent e)
{
if(e.isCancelled()) return;
if(e.getEntity() instanceof Player)
{
Player player = (Player)e.getEntity();
e.setDamage(e.getDamage() * addMultiplier(player));
}
}
示例10: 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);
}
}
示例11: onVisitorReceiveDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
/**
* Prevents visitors from getting damage if invinciblevisitors option is set to TRUE
* @param e
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onVisitorReceiveDamage(EntityDamageEvent e){
if(!Settings.invincibleVisitor) return;
if(!(e.getEntity() instanceof Player)) return;
Player p = (Player) e.getEntity();
if (!Util.inWorld(p) || plugin.getIslands().locationIsOnIsland(p, p.getLocation())) return;
if (Settings.invincibleVisitorOptions.contains(e.getCause())) e.setCancelled(true);
else if(e.getCause().equals(DamageCause.VOID)) {
if(plugin.getPlayers().hasIsland(p.getUniqueId())) {
Location safePlace = plugin.getIslands().getSafeHomeLocation(p.getUniqueId(), 1);
if (safePlace != null) {
p.teleport(safePlace);
// Set their fall distance to zero otherwise they crash onto their island and die
p.setFallDistance(0);
e.setCancelled(true);
return;
}
}
// No island, or no safe spot on island
if (plugin.getIslands().getSpawn() != null) {
p.teleport(plugin.getIslands().getSpawnPoint());
// Set their fall distance to zero otherwise they crash onto their island and die
p.setFallDistance(0);
e.setCancelled(true);
return;
}
// No island spawn, try regular spawn
if (!p.performCommand("spawn")) {
// If this command doesn't work, let them die otherwise they may get trapped in the void forever
return;
}
// Set their fall distance to zero otherwise they crash onto their island and die
p.setFallDistance(0);
e.setCancelled(true);
}
}
示例12: onPlayerDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player) {
Gamer g = Gamer.get((Player) event.getEntity());
if (g.isInvisible())
event.setCancelled(true);
}
}
示例13: onArrowHit
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
public void onArrowHit(EntityDamageEvent e)
{
if((e.getEntity() instanceof Player) && e.getCause() == org.bukkit.event.entity.EntityDamageEvent.DamageCause.FALL && Variables.damage.containsKey(e.getEntity().getUniqueId()))
{
e.setCancelled(true);
Variables.damage.remove(e.getEntity().getUniqueId());
}
}
示例14: 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.
}
}
示例15: onPlayerDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDamage(EntityDamageEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
Player player = (Player) entity;
if (getRemaining(player) > 0L) {
player.sendMessage(ChatColor.RED + "You were damaged, " + getDisplayName() + ChatColor.RED + " timer ended.");
clearCooldown(player);
}
}
}