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


Java EntityDamageEvent.DamageCause方法代码示例

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


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

示例1: getCausingFall

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
/**
 * Get the Fall that caused the given damage to the given player,
 * or null if the damage was not caused by a Fall.
 */
public Fall getCausingFall(Player victim, EntityDamageEvent.DamageCause damageCause) {
    Fall fall = this.falls.get(victim);

    if (fall == null || !fall.isFalling) {
        return null;
    }

    // Do an extra check to see if the fall should be cancelled
    this.checkFallCancelled(fall);
    if (!this.falls.containsKey(victim)) {
        return null;
    }

    switch (damageCause) {
        case VOID:
        case FALL:
        case LAVA:
        case SUICIDE:
            return fall;
        case FIRE_TICK:
            return fall.isInLava ? fall : null;
        default:
            return null;
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:30,代码来源:SimpleGravityKillTracker.java

示例2: notifyDied

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
public void notifyDied(String username, EntityDamageEvent.DamageCause cause) {
    webSocketServerThread.log(Level.INFO, "web user "+username+"'s entity died from "+cause);

    Channel channel = name2channel.get(username);
    if (channel != null) {
        String message = "T,You died from "+(cause == null ? "unknown causes" : cause);

        if (!dieDisconnect) {
            message += ", but remain connected to the server as a ghost";
        }

        webSocketServerThread.sendLine(channel, message);

        if (dieDisconnect) {
            channel.close();
            clientDisconnected(channel);
        }
    }
}
 
开发者ID:satoshinm,项目名称:WebSandboxMC,代码行数:20,代码来源:WebPlayerBridge.java

示例3: resolveDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@Override
public DamageInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
    // Filter out observers immediately
    if(!players.canInteract(victim)) return new NullDamageInfo();

    for(DamageResolver resolver : damageResolvers) {
        DamageInfo resolvedInfo = resolver.resolveDamage(damageType, victim, damager);
        if(resolvedInfo != null) {
            return resolvedInfo;
        }
    }

    // This should never happen
    return new NullDamageInfo();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:16,代码来源:MasterResolver.java

示例4: resolveDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@Override
public @Nullable ExplosionInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
    switch(damageType) {
        case ENTITY_EXPLOSION:
        case BLOCK_EXPLOSION:
            // Bukkit fires block explosion events with a null damager in rare situations
            return damager == null ? null : new ExplosionInfo(damager);

        default:
            return null;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:13,代码来源:ExplosionDamageResolver.java

示例5: resolveDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@Override
public @Nullable DamageInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
    if(damager instanceof DamageInfo) {
        // If the damager block/entity resolved to a DamageInfo directly, return that
        return (DamageInfo) damager;
    } else {
        return new GenericDamageInfo(damageType, damager);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:GenericDamageResolver.java

示例6: resolveDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@Override
public @Nullable FallingBlockInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
    if(damageType == EntityDamageEvent.DamageCause.FALLING_BLOCK && damager instanceof FallingBlockInfo) {
        return (FallingBlockInfo) damager;
    }
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:FallingBlockDamageResolver.java

示例7: resolveDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@Override
public @Nullable FallInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
    FallState fall = getFall(victim);

    if(fall != null) {
        switch(damageType) {
            case VOID: fall.to = FallInfo.To.VOID; break;
            case FALL: fall.to = FallInfo.To.GROUND; break;
            case LAVA: fall.to = FallInfo.To.LAVA; break;

            case FIRE_TICK:
                if(fall.isInLava) {
                    fall.to = FallInfo.To.LAVA;
                } else {
                    return null;
                }
                break;

            default: return null;
        }

        return fall;
    } else {
        switch(damageType) {
            case FALL:
                return new GenericFallInfo(FallInfo.To.GROUND, victim.getLocation(), victim.getFallDistance());
            case VOID:
                return new GenericFallInfo(FallInfo.To.VOID, victim.getLocation(), victim.getFallDistance());
        }

        return null;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:34,代码来源:FallTracker.java

示例8: resolveDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@Override
public @Nullable FireInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
    switch(damageType) {
        case FIRE_TICK:
            FireInfo info = resolveBurning(victim);
            if(info != null) return info;
            // fall through

        case FIRE:
        case LAVA:
            return new FireInfo(damager);
    }
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:FireTracker.java

示例9: onEntityDeath

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) {
    Entity entity = event.getEntity();

    String username = webPlayerBridge.entityId2Username.get(entity.getEntityId());
    if (username == null) {
        return;
    }

    EntityDamageEvent entityDamageEvent = entity.getLastDamageCause();
    // TODO: how to get killer?
    EntityDamageEvent.DamageCause damageCause = entityDamageEvent != null ? entityDamageEvent.getCause() : null;

    webPlayerBridge.notifyDied(username, damageCause);
}
 
开发者ID:satoshinm,项目名称:WebSandboxMC,代码行数:16,代码来源:EntityListener.java

示例10: on

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void on(EntityDamageEvent event){
    Entity entity = event.getEntity();
    EntityDamageEvent.DamageCause cause = event.getCause();
    if(entity instanceof Player && cause == EntityDamageEvent.DamageCause.FALL){
        if(entity.getFallDistance() < 20.0){
            event.setCancelled(true);
        }
    }
}
 
开发者ID:mikroskeem,项目名称:MiniWynn,代码行数:11,代码来源:PlayerListener.java

示例11: ImminentDeath

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
private ImminentDeath(EntityDamageEvent.DamageCause cause, Location deathLocation, @Nullable Block blockDamager, boolean damaged) {
    this.cause = cause;
    this.deathLocation = deathLocation;
    this.blockDamager = blockDamager;
    this.alreadyDamaged = damaged;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:CombatLogTracker.java

示例12: GenericDamageInfo

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
public GenericDamageInfo(EntityDamageEvent.DamageCause damageType, @Nullable PhysicalInfo damager) {
    this.damageType = checkNotNull(damageType);
    this.damager = damager;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:5,代码来源:GenericDamageInfo.java

示例13: resolveDamage

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
default DamageInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim) {
    return resolveDamage(damageType, victim, (PhysicalInfo) null);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:EventResolver.java

示例14: OMGDamageCause

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
/**
 * Use this to create custom damage causes.
 *
 * @param name Name to access cause in config
 * @param e When no args are written, this counts as a CUSTOM bukkit damage cause.
 */
public OMGDamageCause(String name, EntityDamageEvent.DamageCause... e) {
    this.name = name;
    bukkit = e.length == 0 ? new EntityDamageEvent.DamageCause[]{EntityDamageEvent.DamageCause.CUSTOM} : e;
    values.add(this);
}
 
开发者ID:BurnyDaKath,项目名称:OMGPI,代码行数:12,代码来源:OMGDamageCause.java

示例15: reset

import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
public void reset() {
	modifier = new HashMap<EntityDamageEvent.DamageCause, Integer>();
	
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:5,代码来源:VersusManager.java


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