本文整理汇总了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;
}
}
示例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);
}
}
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例12: GenericDamageInfo
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
public GenericDamageInfo(EntityDamageEvent.DamageCause damageType, @Nullable PhysicalInfo damager) {
this.damageType = checkNotNull(damageType);
this.damager = damager;
}
示例13: resolveDamage
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
default DamageInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim) {
return resolveDamage(damageType, victim, (PhysicalInfo) null);
}
示例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);
}
示例15: reset
import org.bukkit.event.entity.EntityDamageEvent; //导入方法依赖的package包/类
public void reset() {
modifier = new HashMap<EntityDamageEvent.DamageCause, Integer>();
}