本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}