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


Java RegainReason类代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason的典型用法代码示例。如果您正苦于以下问题:Java RegainReason类的具体用法?Java RegainReason怎么用?Java RegainReason使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: call

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof EntityRegainHealthEvent) {
		EntityRegainHealthEvent erhe = (EntityRegainHealthEvent) event;

		if (erhe.getRegainReason() == RegainReason.SATIATED) {
			/*
			 * Player is regenerating health because their hunger is full.
			 */

			final double health = profile.getPlayer().getHealth();

			if (!isAcceptable(health, erhe.getAmount())) {
				callback(true);
			}

			lastTime = System.currentTimeMillis();
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:21,代码来源:FastHealA.java

示例2: applyInstantEffect

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void applyInstantEffect(EntityLiving entityliving, EntityLiving entityliving1, int i, double d0, EntityPotion potion) {
    // CraftBukkit end
    int j;

    if ((this.id != HEAL.id || entityliving1.aR()) && (this.id != HARM.id || !entityliving1.aR())) {
        if (this.id == HARM.id && !entityliving1.aR() || this.id == HEAL.id && entityliving1.aR()) {
            j = (int) (d0 * (double) (6 << i) + 0.5D);
            if (entityliving == null) {
                entityliving1.damageEntity(DamageSource.MAGIC, (float) j);
            } else {
                // CraftBukkit - The "damager" needs to be the potion
                entityliving1.damageEntity(DamageSource.b(potion != null ? potion : entityliving1, entityliving), (float) j);
            }
        }
    } else {
        j = (int) (d0 * (double) (4 << i) + 0.5D);
        entityliving1.heal((float) j, RegainReason.MAGIC); // CraftBukkit
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:20,代码来源:MobEffectList.java

示例3: tick

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void tick(EntityLiving entityliving, int i) {
    if (this.id == REGENERATION.id) {
        if (entityliving.getHealth() < entityliving.getMaxHealth()) {
            entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
        }
    } else if (this.id == POISON.id) {
        if (entityliving.getHealth() > 1.0F) {
            entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
        }
    } else if (this.id == WITHER.id) {
        entityliving.damageEntity(DamageSource.WITHER, 1.0F);
    } else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) {
        ((EntityHuman) entityliving).a(0.025F * (float) (i + 1));
    } else if (this.id == SATURATION.id && entityliving instanceof EntityHuman) {
        if (!entityliving.world.isStatic) {
            ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F);
        }
    } else if ((this.id != HEAL.id || entityliving.aM()) && (this.id != HARM.id || !entityliving.aM())) {
        if (this.id == HARM.id && !entityliving.aM() || this.id == HEAL.id && entityliving.aM()) {
            entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
        }
    } else {
        entityliving.heal((float) Math.max(4 << i, 0), RegainReason.MAGIC); // CraftBukkit
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:26,代码来源:MobEffectList.java

示例4: applyInstantEffect

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void applyInstantEffect(EntityLiving entityliving, EntityLiving entityliving1, int i, double d0, EntityPotion potion) {
    // CraftBukkit end
    int j;

    if ((this.id != HEAL.id || entityliving1.aM()) && (this.id != HARM.id || !entityliving1.aM())) {
        if (this.id == HARM.id && !entityliving1.aM() || this.id == HEAL.id && entityliving1.aM()) {
            j = (int) (d0 * (double) (6 << i) + 0.5D);
            if (entityliving == null) {
                entityliving1.damageEntity(DamageSource.MAGIC, (float) j);
            } else {
                // CraftBukkit - The "damager" needs to be the potion
                entityliving1.damageEntity(DamageSource.b(potion != null ? potion : entityliving1, entityliving), (float) j);
            }
        }
    } else {
        j = (int) (d0 * (double) (4 << i) + 0.5D);
        entityliving1.heal((float) j, RegainReason.MAGIC);
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:20,代码来源:MobEffectList.java

示例5: onEntityRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
/**
 * On entity regain health.
 *
 * @param event the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
	
	Entity entity = event.getEntity();
	Player player;
	IPlayerConfEntry entry;
	
	if(entity != null && event.getEntity() instanceof Player
			&& (event.getRegainReason() == RegainReason.REGEN
			|| event.getRegainReason() == RegainReason.SATIATED)
			&& (entry = playerConf.get((player = (Player) event.getEntity()))) != null
			&& !entry.isAdminMod()) {
	
		IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(player.getLocation());
		
		if (!checkPermission(land, player, PermissionList.FOOD_HEAL.getPermissionType())) {
			event.setCancelled(true);
		}
	}
}
 
开发者ID:Tabinol,项目名称:Factoid,代码行数:26,代码来源:PlayerListener.java

示例6: onEntityRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
    if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) {
        Player player = (Player) event.getEntity();
        if (getCheckManager().willCheck(player, CheckType.FAST_HEAL)) {
            CheckResult result = getBackend().checkFastHeal(player);
            if (result.failed()) {
                event.setCancelled(!silentMode());
                log(result.getMessage(), player, CheckType.FAST_HEAL);
            } else {
                decrease(player);
                getBackend().logHeal(player);
            }
        }
    }

    AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
}
 
开发者ID:Obsidian-Realm,项目名称:AntiCheat-COMPAT,代码行数:19,代码来源:EntityListener.java

示例7: applyInstantEffect

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void applyInstantEffect(@Nullable Entity entity, @Nullable Entity entity1, EntityLiving entityliving, int i, double d0) {
    int j;

    if ((this != MobEffects.HEAL || entityliving.bQ()) && (this != MobEffects.HARM || !entityliving.bQ())) {
        if (this == MobEffects.HARM && !entityliving.bQ() || this == MobEffects.HEAL && entityliving.bQ()) {
            j = (int) (d0 * (double) (6 << i) + 0.5D);
            if (entity == null) {
                entityliving.damageEntity(DamageSource.MAGIC, (float) j);
            } else {
                entityliving.damageEntity(DamageSource.b(entity, entity1), (float) j);
            }
        }
    } else {
        j = (int) (d0 * (double) (4 << i) + 0.5D);
        entityliving.heal((float) j, RegainReason.MAGIC); // CraftBukkit
    }

}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:19,代码来源:MobEffectList.java

示例8: onEntityRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
	if (!(event.getEntity() instanceof Player)) {
		return;
	}
	
	if (event.getRegainReason() != RegainReason.SATIATED) {
		return;
	}
	
	Player player = (Player) event.getEntity();
	int proteinValue = plugin.getValueManager().getValue(FoodType.PROTEIN, player);
	
	Random ran = new Random();
	if (proteinValue <= -7) {
		if (ran.nextInt(2) == 0) {
			event.setCancelled(true);
		}
	} else if (proteinValue <= -6) {
		if (ran.nextInt(4) > 0) {
			event.setCancelled(true);
		}
	}
	
}
 
开发者ID:SugarCaney,项目名称:FoodBalance,代码行数:26,代码来源:RegenListener.java

示例9: onEnderDragonRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
/**
 * Handle EnderDragon regen
 *
 * @param event an EntityRegainHealthEvent
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEnderDragonRegainHealth(final EntityRegainHealthEvent event) {
    if (event.getEntityType() == EntityType.ENDER_DRAGON && event.getRegainReason() == RegainReason.ENDER_CRYSTAL) {
        final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getEntity().getLocation().getWorld().getName()));
        if (handler != null) {
            final float rate = handler.getConfig().getEcHealthRegainRate();
            if (rate < 1.0) {
                if (RANDOM.nextFloat() >= rate) {
                    event.setCancelled(true);
                }
            } else if (rate > 1.0) {
                event.setAmount((int)(rate * event.getAmount()));
            }
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:22,代码来源:EnderDragonListener.java

示例10: tick

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void tick(EntityLiving entityliving, int i) {
    if (this.id == REGENERATION.id) {
        if (entityliving.getHealth() < entityliving.maxHealth) { // CraftBukkit - .getMaxHealth() -> .maxHealth
            entityliving.heal(1, RegainReason.MAGIC_REGEN); // CraftBukkit
        }
    } else if (this.id == POISON.id) {
        if (entityliving.getHealth() > 1) {
            entityliving.damageEntity(CraftEventFactory.POISON, 1); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
        }
    } else if (this.id == WITHER.id) {
        entityliving.damageEntity(DamageSource.WITHER, 1);
    } else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) {
        ((EntityHuman) entityliving).j(0.025F * (float) (i + 1));
    } else if ((this.id != HEAL.id || entityliving.bD()) && (this.id != HARM.id || !entityliving.bD())) {
        if (this.id == HARM.id && !entityliving.bD() || this.id == HEAL.id && entityliving.bD()) {
            entityliving.damageEntity(DamageSource.MAGIC, 6 << i);
        }
    } else {
        entityliving.heal(6 << i, RegainReason.MAGIC); // CraftBukkit
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:22,代码来源:MobEffectList.java

示例11: applyInstantEffect

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void applyInstantEffect(EntityLiving entityliving, EntityLiving entityliving1, int i, double d0, EntityPotion potion) {
    // CraftBukkit end
    int j;

    if ((this.id != HEAL.id || entityliving1.bD()) && (this.id != HARM.id || !entityliving1.bD())) {
        if (this.id == HARM.id && !entityliving1.bD() || this.id == HEAL.id && entityliving1.bD()) {
            j = (int) (d0 * (double) (6 << i) + 0.5D);
            if (entityliving == null) {
                entityliving1.damageEntity(DamageSource.MAGIC, j);
            } else {
                // CraftBukkit - The "damager" needs to be the potion
                entityliving1.damageEntity(DamageSource.b(potion != null ? potion : entityliving1, entityliving), j);
            }
        }
    } else {
        j = (int) (d0 * (double) (6 << i) + 0.5D);
        entityliving1.heal(j, RegainReason.MAGIC); // CraftBukkit
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:20,代码来源:MobEffectList.java

示例12: onEntityRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityRegainHealth(final EntityRegainHealthEvent event)
{

	if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player)
	{

		final ISettings settings = ess.getSettings();

		final IUser user = ess.getUserMap().getUser((Player)event.getEntity());
		if (user.getData().isAfk() && settings.getData().getCommands().getAfk().isFreezeAFKPlayers())
		{
			event.setCancelled(true);
		}
	}
}
 
开发者ID:Curtis3321,项目名称:Essentials,代码行数:17,代码来源:EssentialsEntityListener.java

示例13: healthRegen

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler
public void healthRegen(EntityRegainHealthEvent event){
	if(event.getRegainReason().equals(RegainReason.SATIATED)){
		event.setCancelled(true);
	}
	if(event.getRegainReason().equals(RegainReason.REGEN)){
		event.setCancelled(true);
	}
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:10,代码来源:EventCanceller.java

示例14: onEntityRegainHealth

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false)
public void onEntityRegainHealth(cn.nukkit.event.entity.EntityRegainHealthEvent event) {
	if (canIgnore(PlayerInteractEvent.getHandlerList())) {
		return;
	}

	int reason = event.getRegainReason();
	RegainReason bukkitReason = RegainReason.EATING;

	switch (reason) {
	case cn.nukkit.event.entity.EntityRegainHealthEvent.CAUSE_MAGIC:
		bukkitReason = RegainReason.MAGIC;
		break;
	case cn.nukkit.event.entity.EntityRegainHealthEvent.CAUSE_CUSTOM:
		bukkitReason = RegainReason.CUSTOM;
		break;
	case cn.nukkit.event.entity.EntityRegainHealthEvent.CAUSE_EATING:
		bukkitReason = RegainReason.EATING;
		break;
	case cn.nukkit.event.entity.EntityRegainHealthEvent.CAUSE_REGEN:
		bukkitReason = RegainReason.REGEN;
		break;
	}

	EntityRegainHealthEvent bukkitEvent = new EntityRegainHealthEvent(PokkitEntity.toBukkit(event.getEntity()), event.getAmount(), bukkitReason);

	callCancellable(event, bukkitEvent);
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:29,代码来源:EntityEvents.java

示例15: tick

import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; //导入依赖的package包/类
public void tick(EntityLiving entityliving, int i) {
    if (this.id == REGENERATION.id) {
        if (entityliving.getHealth() < entityliving.getMaxHealth()) {
            entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
        }
    } else if (this.id == POISON.id) {
        if (entityliving.getHealth() > 1.0F) {
            entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
        }
    } else if (this.id == WITHER.id) {
        entityliving.damageEntity(DamageSource.WITHER, 1.0F);
    } else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) {
        ((EntityHuman) entityliving).applyExhaustion(0.025F * (float) (i + 1));
    } else if (this.id == SATURATION.id && entityliving instanceof EntityHuman) {
        if (!entityliving.world.isStatic) {
            // CraftBukkit start
            EntityHuman entityhuman = (EntityHuman) entityliving;
            int oldFoodLevel = entityhuman.getFoodData().foodLevel;

            org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, i + 1 + oldFoodLevel);

            if (!event.isCancelled()) {
                entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
            }

            ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
            // CraftBukkit end
        }
    } else if ((this.id != HEAL.id || entityliving.aR()) && (this.id != HARM.id || !entityliving.aR())) {
        if (this.id == HARM.id && !entityliving.aR() || this.id == HEAL.id && entityliving.aR()) {
            entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
        }
    } else {
        entityliving.heal((float) Math.max(4 << i, 0), RegainReason.MAGIC); // CraftBukkit
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:37,代码来源:MobEffectList.java


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