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


Java EntityDamageEvent.getEntity方法代码示例

本文整理汇总了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);
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:21,代码来源:DamageEvents.java

示例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);
            }
        }
    }
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:19,代码来源:DamageListener.java

示例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);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:17,代码来源:Events.java

示例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);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:20,代码来源:PlayerStaminaState.java

示例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));
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:20,代码来源:Parties.java

示例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;
		
		}
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:22,代码来源:GodModeListener.java

示例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);
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:11,代码来源:DetectionListener.java

示例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);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:15,代码来源:StuckTimer.java

示例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));
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:12,代码来源:FoodDiversityConsume.java

示例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);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:15,代码来源:EnvironmentManager.java

示例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);
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:44,代码来源:VisitorGuard.java

示例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);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:9,代码来源:GameEvents.java

示例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());
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:9,代码来源:DamageListener.java

示例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.
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:9,代码来源:Splef.java

示例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);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:LogoutTimer.java


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