mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-13 11:18:23 +01:00
Added new methods to set a players respawned level/exp/totalExp in PlayerDeathEvent. Thanks to Feildmaster for the PR.
By: Nathan Adams <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
72add08a6d
commit
a80bc820c6
1 changed files with 73 additions and 2 deletions
|
@ -12,10 +12,23 @@ import org.bukkit.inventory.ItemStack;
|
|||
public class PlayerDeathEvent extends EntityDeathEvent {
|
||||
private int newExp = 0;
|
||||
private String deathMessage = "";
|
||||
private int newLevel = 0;
|
||||
private int newTotalExp = 0;
|
||||
private boolean keepLevel = false;
|
||||
|
||||
public PlayerDeathEvent(Player player, List<ItemStack> drops, int droppedExp, String deathMessage) {
|
||||
this(player, drops, droppedExp, 0, deathMessage);
|
||||
}
|
||||
|
||||
public PlayerDeathEvent(Player player, List<ItemStack> drops, int droppedExp, int newExp, String deathMessage) {
|
||||
this(player, drops, droppedExp, newExp, 0, 0, deathMessage);
|
||||
}
|
||||
|
||||
public PlayerDeathEvent(Player player, List<ItemStack> drops, int droppedExp, int newExp, int newTotalExp, int newLevel, String deathMessage) {
|
||||
super(player, drops, droppedExp);
|
||||
this.newExp = newExp;
|
||||
this.newTotalExp = newTotalExp;
|
||||
this.newLevel = newLevel;
|
||||
this.deathMessage = deathMessage;
|
||||
}
|
||||
|
||||
|
@ -34,7 +47,7 @@ public class PlayerDeathEvent extends EntityDeathEvent {
|
|||
* @return Message to appear to other players on the server.
|
||||
*/
|
||||
public String getDeathMessage() {
|
||||
return this.deathMessage;
|
||||
return deathMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,6 +71,64 @@ public class PlayerDeathEvent extends EntityDeathEvent {
|
|||
* @get exp New EXP of the respawned player
|
||||
*/
|
||||
public void setNewExp(int exp) {
|
||||
this.newExp = exp;
|
||||
newExp = exp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Level the Player should have at respawn.
|
||||
*
|
||||
* @return New Level of the respawned player
|
||||
*/
|
||||
public int getNewLevel() {
|
||||
return newLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Level the Player should have at respawn.
|
||||
*
|
||||
* @get level New Level of the respawned player
|
||||
*/
|
||||
public void setNewLevel(int level) {
|
||||
newLevel = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Total EXP the Player should have at respawn.
|
||||
*
|
||||
* @return New Total EXP of the respawned player
|
||||
*/
|
||||
public int getNewTotalExp() {
|
||||
return newTotalExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Total EXP the Player should have at respawn.
|
||||
*
|
||||
* @get totalExp New Total EXP of the respawned player
|
||||
*/
|
||||
public void setNewTotalExp(int totalExp) {
|
||||
newTotalExp = totalExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the Player should keep all EXP at respawn.
|
||||
* <p>
|
||||
* This flag overrides other EXP settings
|
||||
*
|
||||
* @return True if Player should keep all pre-death exp
|
||||
*/
|
||||
public boolean getKeepLevel() {
|
||||
return keepLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the Player should keep all EXP at respawn.
|
||||
* <p>
|
||||
* This overrides all other EXP settings
|
||||
*
|
||||
* @param keepLevel True to keep all current value levels
|
||||
*/
|
||||
public void setKeepLevel(boolean keepLevel) {
|
||||
this.keepLevel = keepLevel;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue