Skip to content

Commit

Permalink
Fix restoration of health; resolves #239, resolves #271, resolves #373
Browse files Browse the repository at this point in the history
  • Loading branch information
Sataniel98 committed Apr 26, 2018
1 parent 6282dea commit 147fd36
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,7 @@ If you want to learn how to use DungeonsXL step by step, please have a look at t

## Compatibility
### Server
DungeonsXL works with 1.7.8 and higher. However, support for 1.12 / 1.11.x / 1.10.x / 1.9.x has a higher priority than support for 1.8.x and lower. See [here](../../wiki/legacy-support) for detailed information. Some cosmetic features require the Spigot API and will therefore not work with CraftBukkit.

Older versions of DungeonsXL support versions since Minecraft 1.3.x, but of course, they are completely unsupported.
* [1.7.8-1.12.2](../../tree/master)
* [1.7.5](../../tree/50f772d14281bfe278dba2559d1758cc459c1a30)
* [1.7.2](../../tree/eccf82b7335dfb0723e3cd37a57df1a968ea7842)
* [1.6.4](../../tree/780145cf783ea76fe1bfee04cf89216bd4f92e1d)
* [1.6.2](../../tree/fcc27ca35caccb2b849c8f9de4ae212d875dc9a9)
* [1.5.2](../../tree/08a8b31da0c88e6c4d4f3f4cce5b38cd0f72f447)
* [1.5.1](../../tree/992542ec0f307ddfd48861c5391feb40610c4f20)
* [1.4.7](../../tree/90a625cae0acc8a2ce57d0856a8e731a81f02729)
* [1.4.6](../../tree/bf34312f30ccab48d64bce03ed7979863a8151cf)
* [1.4.x](../../tree/3cf96c5f25eada06a434db7753ec22a34ffa4d78)
* [1.3.x](../../tree/15effb1071b3c36bca68352c5ddb6469bcbead10)
DungeonsXL works with 1.8.3 and higher. However, support for 1.12.x / 1.11.x / 1.10.x / 1.9.x has a higher priority than support for 1.8.x and lower. See [here](../../wiki/legacy-support) for detailed information. Some cosmetic features require the Spigot API and will therefore not work with CraftBukkit.

### Building information and dependencies
Building DungeonsXL from source requires [Apache Maven](https://maven.apache.org/).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import de.erethon.commons.chat.MessageUtil;
import de.erethon.commons.compatibility.CompatibilityHandler;
import de.erethon.commons.compatibility.Internals;
import de.erethon.commons.compatibility.Version;
import de.erethon.commons.player.PlayerUtil;
import de.erethon.commons.player.PlayerWrapper;
Expand All @@ -32,6 +33,7 @@
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
Expand Down Expand Up @@ -331,8 +333,10 @@ public void reset(boolean keepInventory) {
}
player.setLevel(data.getOldLevel());
player.setExp(data.getOldExp());
player.setMaxHealth(data.getOldMaxHealth());
player.setHealth(data.getOldHealth());
if (Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals())) {
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(data.getOldMaxHealth());
}
player.setHealth(data.getOldHealth() <= data.getOldMaxHealth() ? data.getOldHealth() : data.getOldMaxHealth());
player.setFoodLevel(data.getOldFoodLevel());
player.setGameMode(data.getOldGameMode());
player.setFireTicks(data.getOldFireTicks());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
Expand Down Expand Up @@ -430,7 +431,9 @@ public void savePlayerState(Player player) {
oldGameMode = player.getGameMode();
oldFireTicks = player.getFireTicks();
oldFoodLevel = player.getFoodLevel();
oldMaxHealth = player.getMaxHealth();
if (is1_9) {
oldMaxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
}
oldHealth = player.getHealth();
oldExp = player.getExp();
oldLvl = player.getLevel();
Expand Down

0 comments on commit 147fd36

Please sign in to comment.