mirror of
https://github.com/taoneill/war.git
synced 2024-11-14 06:17:01 +01:00
Closes gh-348. Levels and exp are stored at warzone entry and restored at exit, like the rest of the player's state.
This commit is contained in:
parent
668285ac97
commit
a4a3ced0e5
@ -436,13 +436,6 @@ public class Warzone {
|
||||
return this.monuments;
|
||||
}
|
||||
|
||||
// public void setLifePool(int lifePool) {
|
||||
// this.lifePool = lifePool;
|
||||
// for (Team team : this.teams) {
|
||||
// team.setRemainingLives(lifePool);
|
||||
// }
|
||||
// }
|
||||
|
||||
public boolean hasPlayerState(String playerName) {
|
||||
return this.playerStates.containsKey(playerName);
|
||||
}
|
||||
@ -468,23 +461,27 @@ public class Warzone {
|
||||
player.getSaturation(),
|
||||
player.getFoodLevel(),
|
||||
potionEffects,
|
||||
playerTitle));
|
||||
playerTitle,
|
||||
player.getLevel(),
|
||||
player.getExp()));
|
||||
}
|
||||
|
||||
public void restorePlayerState(Player player) {
|
||||
PlayerState originalContents = this.playerStates.remove(player.getName());
|
||||
PlayerState originalState = this.playerStates.remove(player.getName());
|
||||
PlayerInventory playerInv = player.getInventory();
|
||||
if (originalContents != null) {
|
||||
this.playerInvFromInventoryStash(playerInv, originalContents);
|
||||
player.setGameMode(originalContents.getGamemode());
|
||||
player.setHealth(originalContents.getHealth());
|
||||
player.setExhaustion(originalContents.getExhaustion());
|
||||
player.setSaturation(originalContents.getSaturation());
|
||||
player.setFoodLevel(originalContents.getFoodLevel());
|
||||
PotionEffect.restorePotionEffects(player, originalContents.getPotionEffects());
|
||||
if (originalState != null) {
|
||||
this.playerInvFromInventoryStash(playerInv, originalState);
|
||||
player.setGameMode(originalState.getGamemode());
|
||||
player.setHealth(originalState.getHealth());
|
||||
player.setExhaustion(originalState.getExhaustion());
|
||||
player.setSaturation(originalState.getSaturation());
|
||||
player.setFoodLevel(originalState.getFoodLevel());
|
||||
PotionEffect.restorePotionEffects(player, originalState.getPotionEffects());
|
||||
player.setLevel(originalState.getLevel());
|
||||
player.setExp(originalState.getExp());
|
||||
|
||||
if (War.war.isSpoutServer()) {
|
||||
SpoutManager.getPlayer(player).setTitle(originalContents.getPlayerTitle());
|
||||
SpoutManager.getPlayer(player).setTitle(originalState.getPlayerTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,10 @@ public class PlayerState {
|
||||
private final GameMode gamemode;
|
||||
private final List<PotionEffect> potionEffects;
|
||||
private final String playerTitle;
|
||||
private final float exp;
|
||||
private final int level;
|
||||
|
||||
public PlayerState(GameMode gamemode, ItemStack[] contents, ItemStack helmet, ItemStack chest, ItemStack legs, ItemStack feet, int health, float exhaustion, float saturation, int foodLevel, List<PotionEffect> potionEffects, String playerTitle) {
|
||||
public PlayerState(GameMode gamemode, ItemStack[] contents, ItemStack helmet, ItemStack chest, ItemStack legs, ItemStack feet, int health, float exhaustion, float saturation, int foodLevel, List<PotionEffect> potionEffects, String playerTitle, int level, float exp) {
|
||||
this.gamemode = gamemode;
|
||||
this.health = health;
|
||||
this.exhaustion = exhaustion;
|
||||
@ -28,6 +30,8 @@ public class PlayerState {
|
||||
this.foodLevel = foodLevel;
|
||||
this.potionEffects = potionEffects;
|
||||
this.playerTitle = playerTitle;
|
||||
this.level = level;
|
||||
this.exp = exp;
|
||||
this.setContents(contents);
|
||||
this.setHelmet(helmet);
|
||||
this.setChest(chest);
|
||||
@ -103,4 +107,12 @@ public class PlayerState {
|
||||
return playerTitle;
|
||||
}
|
||||
|
||||
public float getExp() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user