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


Java CraftEventFactory.callPlayerLevelChangeEvent方法代码示例

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


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

示例1: i

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public void i() {
    try {
        super.h();

        for (int i = 0; i < this.inventory.getSize(); ++i) {
            ItemStack itemstack = this.inventory.getItem(i);

            if (itemstack != null && itemstack.getItem().h()) {
                Packet packet = ((ItemWorldMapBase) itemstack.getItem()).c(itemstack, this.world, this);

                if (packet != null) {
                    this.playerConnection.sendPacket(packet);
                }
            }
        }

        // CraftBukkit - Optionally scale health
        if (this.getHealth() != this.bQ || this.bR != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.bS) {
            this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel()));
            this.bQ = this.getHealth();
            this.bR = this.foodData.getFoodLevel();
            this.bS = this.foodData.getSaturationLevel() == 0.0F;
        }

        if (this.getHealth() + this.getAbsorptionHearts() != this.bP) {
            this.bP = this.getHealth() + this.getAbsorptionHearts();
            // CraftBukkit - Update ALL the scores!
            this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.f, this.getName(), com.google.common.collect.ImmutableList.of(this));
        }

        // CraftBukkit start - Force max health updates
        if (this.maxHealthCache != this.getMaxHealth()) {
            this.getBukkitEntity().updateScaledHealth();
        }
        // CraftBukkit end

        if (this.expTotal != this.lastSentExp) {
            this.lastSentExp = this.expTotal;
            this.playerConnection.sendPacket(new PacketPlayOutExperience(this.exp, this.expTotal, this.expLevel));
        }

        if (this.ticksLived % 20 * 5 == 0 && !this.getStatisticManager().hasAchievement(AchievementList.L)) {
            this.j();
        }

        // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent
        if (this.oldLevel == -1) {
            this.oldLevel = this.expLevel;
        }

        if (this.oldLevel != this.expLevel) {
            CraftEventFactory.callPlayerLevelChangeEvent(this.world.getServer().getPlayer((EntityPlayer) this), this.oldLevel, this.expLevel);
            this.oldLevel = this.expLevel;
        }
        // CraftBukkit end
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
        CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");

        this.a(crashreportsystemdetails);
        throw new ReportedException(crashreport);
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:64,代码来源:EntityPlayer.java

示例2: h

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public void h() {
    try {
        super.l_();

        for (int i = 0; i < this.inventory.getSize(); ++i) {
            ItemStack itemstack = this.inventory.getItem(i);

            if (itemstack != null && Item.byId[itemstack.id].f() && this.playerConnection.lowPriorityCount() <= 5) {
                Packet packet = ((ItemWorldMapBase) Item.byId[itemstack.id]).c(itemstack, this.world, this);

                if (packet != null) {
                    this.playerConnection.sendPacket(packet);
                }
            }
        }

        if (this.getHealth() != this.bP || this.bQ != this.foodData.a() || this.foodData.e() == 0.0F != this.bR) {
            // CraftBukkit - Optionally scale health
            this.playerConnection.sendPacket(new Packet8UpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.a(), this.foodData.e()));
            this.bP = this.getHealth();
            this.bQ = this.foodData.a();
            this.bR = this.foodData.e() == 0.0F;
        }

        if (this.getHealth() + this.bn() != this.bO) {
            this.bO = this.getHealth() + this.bn();
            // CraftBukkit - Update ALL the scores!
            this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.f, this.getLocalizedName(), com.google.common.collect.ImmutableList.of(this));
        }

        // CraftBukkit start - Force max health updates
        if (this.maxHealthCache != this.getMaxHealth()) {
            this.getBukkitEntity().updateScaledHealth();
        }
        // CraftBukkit end

        if (this.expTotal != this.lastSentExp) {
            this.lastSentExp = this.expTotal;
            this.playerConnection.sendPacket(new Packet43SetExperience(this.exp, this.expTotal, this.expLevel));
        }

        // CraftBukkit start
        if (this.oldLevel == -1) {
            this.oldLevel = this.expLevel;
        }

        if (this.oldLevel != this.expLevel) {
            CraftEventFactory.callPlayerLevelChangeEvent(this.world.getServer().getPlayer((EntityPlayer) this), this.oldLevel, this.expLevel);
            this.oldLevel = this.expLevel;
        }
        // CraftBukkit end
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
        CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");

        this.a(crashreportsystemdetails);
        throw new ReportedException(crashreport);
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:60,代码来源:EntityPlayer.java

示例3: onUpdateEntity

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public void onUpdateEntity()
{
    try
    {
        super.onUpdate();

        for (int i = 0; i < this.inventory.getSizeInventory(); ++i)
        {
            ItemStack itemstack = this.inventory.getStackInSlot(i);

            if (itemstack != null && itemstack.getItem().isMap())
            {
                Packet packet = ((ItemMapBase)itemstack.getItem()).func_150911_c(itemstack, this.worldObj, this);

                if (packet != null)
                {
                    this.playerNetServerHandler.sendPacket(packet);
                }
            }
        }

        // CraftBukkit - Optionally scale health
        if (this.getHealth() != this.lastHealth || this.lastFoodLevel != this.foodStats.getFoodLevel() || this.foodStats.getSaturationLevel() == 0.0F != this.wasHungry)
        {
            this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel()));
            this.lastHealth = this.getHealth();
            this.lastFoodLevel = this.foodStats.getFoodLevel();
            this.wasHungry = this.foodStats.getSaturationLevel() == 0.0F;
        }

        if (this.getHealth() + this.getAbsorptionAmount() != this.field_130068_bO)
        {
            this.field_130068_bO = this.getHealth() + this.getAbsorptionAmount();
            // CraftBukkit - Update ALL the scores!
            this.worldObj.getServer().getScoreboardManager().updateAllScoresForList(IScoreObjectiveCriteria.health, this.getCommandSenderName(), com.google.common.collect.ImmutableList.of(this));
        }

        // CraftBukkit start - Force max health updates
        if (this.maxHealthCache != this.getMaxHealth())
        {
            this.getBukkitEntity().updateScaledHealth();
        }

        // CraftBukkit end

        if (this.experienceTotal != this.lastExperience)
        {
            this.lastExperience = this.experienceTotal;
            this.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(this.experience, this.experienceTotal, this.experienceLevel));
        }

        if (this.ticksExisted % 20 * 5 == 0 && !this.func_147099_x().hasAchievementUnlocked(AchievementList.field_150961_L))
        {
            this.func_147098_j();
        }

        // CraftBukkit start
        if (this.oldLevel == -1)
        {
            this.oldLevel = this.experienceLevel;
        }

        if (this.oldLevel != this.experienceLevel)
        {
            CraftEventFactory.callPlayerLevelChangeEvent(this.worldObj.getServer().getPlayer((EntityPlayerMP) this), this.oldLevel, this.experienceLevel);
            this.oldLevel = this.experienceLevel;
        }

        // CraftBukkit end
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Ticking player");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Player being ticked");
        this.addEntityCrashInfo(crashreportcategory);
        throw new ReportedException(crashreport);
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:79,代码来源:EntityPlayerMP.java


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