當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。