geforkt von Mirrors/Paper
Throw PlayerLevelChangeEvent and PlayerExpChangeEvent events. Thanks to feildmaster for the PR.
Dieser Commit ist enthalten in:
Ursprung
1f1c9c0d4b
Commit
b0f29b1755
@ -1,5 +1,7 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||||
|
|
||||||
public class EntityExperienceOrb extends Entity {
|
public class EntityExperienceOrb extends Entity {
|
||||||
|
|
||||||
public int a;
|
public int a;
|
||||||
@ -130,7 +132,7 @@ public class EntityExperienceOrb extends Entity {
|
|||||||
entityhuman.x = 2;
|
entityhuman.x = 2;
|
||||||
this.world.makeSound(this, "random.orb", 0.1F, 0.5F * ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.8F));
|
this.world.makeSound(this, "random.orb", 0.1F, 0.5F * ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.8F));
|
||||||
entityhuman.receive(this, 1);
|
entityhuman.receive(this, 1);
|
||||||
entityhuman.giveExp(this.value);
|
entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, this.value).getAmount()); // CraftBukkit - this.value to event.getAmount()
|
||||||
this.die();
|
this.die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|||||||
protected boolean J = false;
|
protected boolean J = false;
|
||||||
public float K;
|
public float K;
|
||||||
public PlayerAbilities abilities = new PlayerAbilities();
|
public PlayerAbilities abilities = new PlayerAbilities();
|
||||||
|
public int oldLevel = -1; // CraftBukkit
|
||||||
public int expLevel;
|
public int expLevel;
|
||||||
public int expTotal;
|
public int expTotal;
|
||||||
public float exp;
|
public float exp;
|
||||||
|
@ -319,6 +319,17 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|||||||
this.lastSentExp = this.expTotal;
|
this.lastSentExp = this.expTotal;
|
||||||
this.netServerHandler.sendPacket(new Packet43SetExperience(this.exp, this.expTotal, this.expLevel));
|
this.netServerHandler.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
|
||||||
}
|
}
|
||||||
|
|
||||||
public void e(int i) {
|
public void e(int i) {
|
||||||
|
@ -391,4 +391,17 @@ public class CraftEventFactory {
|
|||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerLevelChangeEvent callPlayerLevelChangeEvent(Player player, int oldLevel, int newLevel) {
|
||||||
|
PlayerLevelChangeEvent event = new PlayerLevelChangeEvent(player, oldLevel, newLevel);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerExpChangeEvent callPlayerExpChangeEvent(EntityHuman entity, int expAmount) {
|
||||||
|
Player player = (Player) entity.getBukkitEntity();
|
||||||
|
PlayerExpChangeEvent event = new PlayerExpChangeEvent(player, expAmount);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren