本文整理匯總了Java中org.bukkit.event.entity.EntityRegainHealthEvent.isCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityRegainHealthEvent.isCancelled方法的具體用法?Java EntityRegainHealthEvent.isCancelled怎麽用?Java EntityRegainHealthEvent.isCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.entity.EntityRegainHealthEvent
的用法示例。
在下文中一共展示了EntityRegainHealthEvent.isCancelled方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPlayerRegen
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerRegen(EntityRegainHealthEvent e) {
if (e.isCancelled() || !(e.getEntity() instanceof Player)) {
return;
}
Player p = (Player) e.getEntity();
if (leader.getPlayer().getUniqueId().equals(p.getUniqueId())) {
updateScoreboard(leader, (int) (p.getHealth() + e.getAmount()));
return;
}
if (!members.isEmpty())
for (QuestPlayer qp : members) {
if (qp.getPlayer().getUniqueId().equals(p.getUniqueId())) {
updateScoreboard(qp, (int) (p.getHealth() + e.getAmount()));
return;
}
}
}
示例2: heal
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
public void heal(int i, EntityRegainHealthEvent.RegainReason regainReason) {
if (this.health > 0) {
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), i, regainReason);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setHealth(this.getHealth() + event.getAmount());
}
// this.getMaxHealth() -> this.maxHealth
if (this.health > this.maxHealth) {
this.setHealth(this.maxHealth);
// CraftBukkit end
}
this.noDamageTicks = this.maxNoDamageTicks / 2;
}
}
示例3: applyHealthRegen
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void applyHealthRegen(EntityRegainHealthEvent event) {
if (event.isCancelled()) {
return;
}
if (((event.getEntity() instanceof Player)) &&
(event.getRegainReason() == EntityRegainHealthEvent.RegainReason.SATIATED)) {
event.setAmount(event.getAmount() + LoreAttributes.loreManager.getRegenBonus((LivingEntity) event.getEntity()));
if (event.getAmount() <= 0.0D)
event.setCancelled(true);
}
}
示例4: heal
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) {
float f1 = this.getHealth();
if (f1 > 0.0F) {
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setHealth((float) (this.getHealth() + event.getAmount()));
}
}
}
示例5: bJ
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
private void bJ() {
if (this.bC != null) {
if (this.bC.dead) {
if (!this.world.isStatic) {
this.a(this.bq, DamageSource.explosion((Explosion) null), 10.0F);
}
this.bC = null;
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { // CraftBukkit - this.getMaxHealth() -> this.maxHealth
// CraftBukkit start
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setHealth((float) (this.getHealth() + event.getAmount()));
}
// CraftBukkit end
}
}
if (this.random.nextInt(10) == 0) {
float f = 32.0F;
List list = this.world.a(EntityEnderCrystal.class, this.boundingBox.grow((double) f, (double) f, (double) f));
EntityEnderCrystal entityendercrystal = null;
double d0 = Double.MAX_VALUE;
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next();
double d1 = entityendercrystal1.e(this);
if (d1 < d0) {
d0 = d1;
entityendercrystal = entityendercrystal1;
}
}
this.bC = entityendercrystal;
}
}
示例6: heal
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason)
{
float f1 = this.getHealth();
if (f1 > 0.0F)
{
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason);
this.worldObj.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled())
{
this.setHealth((float)(this.getHealth() + event.getAmount()));
}
}
}
示例7: heal
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) {
float f1 = this.getHealth();
if (f1 > 0.0F) {
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setHealth((float) (this.getHealth() + event.getAmount()));
}
// CraftBukkit end
}
}
示例8: cW
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
private void cW() {
if (this.currentEnderCrystal != null) {
if (this.currentEnderCrystal.dead) {
this.currentEnderCrystal = null;
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
// CraftBukkit start
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0F, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setHealth((float) (this.getHealth() + event.getAmount()));
}
// CraftBukkit end
}
}
if (this.random.nextInt(10) == 0) {
List list = this.world.a(EntityEnderCrystal.class, this.getBoundingBox().g(32.0D));
EntityEnderCrystal entityendercrystal = null;
double d0 = Double.MAX_VALUE;
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next();
double d1 = entityendercrystal1.h(this);
if (d1 < d0) {
d0 = d1;
entityendercrystal = entityendercrystal1;
}
}
this.currentEnderCrystal = entityendercrystal;
}
}
示例9: h
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
private void h() {
if (this.bS != null) {
if (this.bS.dead) {
if (!this.world.isStatic) {
this.a(this.g, DamageSource.explosion((Explosion) null), 10);
}
this.bS = null;
} else if (this.ticksLived % 10 == 0 && this.health < this.maxHealth) { // CraftBukkit - this.getMaxHealth() -> this.maxHealth
// CraftBukkit start
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setHealth(this.getHealth() + event.getAmount());
}
// CraftBukkit end
}
}
if (this.random.nextInt(10) == 0) {
float f = 32.0F;
List list = this.world.a(EntityEnderCrystal.class, this.boundingBox.grow((double) f, (double) f, (double) f));
EntityEnderCrystal entityendercrystal = null;
double d0 = Double.MAX_VALUE;
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next();
double d1 = entityendercrystal1.e(this);
if (d1 < d0) {
d0 = d1;
entityendercrystal = entityendercrystal1;
}
}
this.bS = entityendercrystal;
}
}
示例10: onEntityRegainHealth
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityRegainHealth(EntityRegainHealthEvent event)
{
if (event.isCancelled() || event.getAmount() <= 0.0D)
return;
Entity entity = event.getEntity();
if (entity instanceof LivingEntity)
{
plugin.getHealthBarHandler().updateHealth((LivingEntity) entity);
}
}
示例11: onAction
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
@Override
public void onAction() {
//check their money
if (player.getMoney() >= cost) {
//they have enough money
//blindness for 3 seconds, title saying you're now rested?
//don't forget to restore health, hunger
//and take out some money
if (!player.getPlayer().isOnline()) {
System.out.println("Very bad InnAction error!!!!!!!!!!!!!");
return;
}
player.addMoney(-cost);
Player p = player.getPlayer().getPlayer();
double amount = p.getMaxHealth() - p.getHealth();
EntityRegainHealthEvent e = new EntityRegainHealthEvent(p, amount, RegainReason.CUSTOM);
Bukkit.getPluginManager().callEvent(e);
if (!e.isCancelled()) {
p.setHealth(p.getMaxHealth());
}
player.regenMP(-100);
p.setFoodLevel(20);
p.setExhaustion(0f);
p.setSaturation(20f);
p.addPotionEffect(
new PotionEffect(PotionEffectType.BLINDNESS, 60, 5));
new TitleObject(ChatColor.GREEN + "Sweet Dreams" + ChatColor.RESET,
ChatColor.BLUE + "Health and hunger have been restored")
.setFadeIn(20).setFadeOut(20).setStay(40).send(p);
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, .5f);
} else {
//not enough money
//show them a menu, sorrow
ChatMenu menu = new SimpleChatMenu(denial.getFormattedMessage());
menu.show(player.getPlayer().getPlayer());
}
}
示例12: bP
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
private void bP() {
if (this.bC != null) {
if (this.bC.dead) {
if (!this.world.isStatic) {
CraftEventFactory.entityDamage = this.bC; // CraftBukkit
this.a(this.bq, DamageSource.explosion((Explosion) null), 10.0F);
CraftEventFactory.entityDamage = null; // CraftBukkit
}
this.bC = null;
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
// CraftBukkit start
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setHealth((float) (this.getHealth() + event.getAmount()));
}
// CraftBukkit end
}
}
if (this.random.nextInt(10) == 0) {
float f = 32.0F;
List list = this.world.a(EntityEnderCrystal.class, this.boundingBox.grow((double) f, (double) f, (double) f));
EntityEnderCrystal entityendercrystal = null;
double d0 = Double.MAX_VALUE;
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next();
double d1 = entityendercrystal1.f(this);
if (d1 < d0) {
d0 = d1;
entityendercrystal = entityendercrystal1;
}
}
this.bC = entityendercrystal;
}
}
示例13: updateDragonEnderCrystal
import org.bukkit.event.entity.EntityRegainHealthEvent; //導入方法依賴的package包/類
private void updateDragonEnderCrystal()
{
if (this.healingEnderCrystal != null)
{
if (this.healingEnderCrystal.isDead)
{
if (!this.worldObj.isRemote)
{
CraftEventFactory.entityDamage = this.healingEnderCrystal; // CraftBukkit
this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion) null), 10.0F);
CraftEventFactory.entityDamage = null; // CraftBukkit
}
this.healingEnderCrystal = null;
}
else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth())
{
// CraftBukkit start
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
this.worldObj.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled())
{
this.setHealth((float)(this.getHealth() + event.getAmount()));
}
// CraftBukkit end
}
}
if (this.rand.nextInt(10) == 0)
{
float f = 32.0F;
List list = this.worldObj.getEntitiesWithinAABB(EntityEnderCrystal.class, this.boundingBox.expand((double)f, (double)f, (double)f));
EntityEnderCrystal entityendercrystal = null;
double d0 = Double.MAX_VALUE;
Iterator iterator = list.iterator();
while (iterator.hasNext())
{
EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal)iterator.next();
double d1 = entityendercrystal1.getDistanceSqToEntity(this);
if (d1 < d0)
{
d0 = d1;
entityendercrystal = entityendercrystal1;
}
}
this.healingEnderCrystal = entityendercrystal;
}
}