Fix restoration of health; resolves #239, resolves #271, resolves #373

This commit is contained in:
Daniel Saukel 2018-04-27 01:13:47 +02:00
parent 6282deaf3c
commit 147fd36204
3 changed files with 11 additions and 17 deletions

View File

@ -48,20 +48,7 @@ If you want to learn how to use DungeonsXL step by step, please have a look at t
## Compatibility ## Compatibility
### Server ### 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. 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.
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)
### Building information and dependencies ### Building information and dependencies
Building DungeonsXL from source requires [Apache Maven](https://maven.apache.org/). Building DungeonsXL from source requires [Apache Maven](https://maven.apache.org/).

View File

@ -18,6 +18,7 @@ package io.github.dre2n.dungeonsxl.player;
import de.erethon.commons.chat.MessageUtil; import de.erethon.commons.chat.MessageUtil;
import de.erethon.commons.compatibility.CompatibilityHandler; import de.erethon.commons.compatibility.CompatibilityHandler;
import de.erethon.commons.compatibility.Internals;
import de.erethon.commons.compatibility.Version; import de.erethon.commons.compatibility.Version;
import de.erethon.commons.player.PlayerUtil; import de.erethon.commons.player.PlayerUtil;
import de.erethon.commons.player.PlayerWrapper; import de.erethon.commons.player.PlayerWrapper;
@ -32,6 +33,7 @@ import java.io.File;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -331,8 +333,10 @@ public class DGlobalPlayer implements PlayerWrapper {
} }
player.setLevel(data.getOldLevel()); player.setLevel(data.getOldLevel());
player.setExp(data.getOldExp()); player.setExp(data.getOldExp());
player.setMaxHealth(data.getOldMaxHealth()); if (Internals.andHigher(Internals.v1_9_R1).contains(CompatibilityHandler.getInstance().getInternals())) {
player.setHealth(data.getOldHealth()); player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(data.getOldMaxHealth());
}
player.setHealth(data.getOldHealth() <= data.getOldMaxHealth() ? data.getOldHealth() : data.getOldMaxHealth());
player.setFoodLevel(data.getOldFoodLevel()); player.setFoodLevel(data.getOldFoodLevel());
player.setGameMode(data.getOldGameMode()); player.setGameMode(data.getOldGameMode());
player.setFireTicks(data.getOldFireTicks()); player.setFireTicks(data.getOldFireTicks());

View File

@ -34,6 +34,7 @@ import java.util.Map;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -430,7 +431,9 @@ public class DPlayerData extends DREConfig {
oldGameMode = player.getGameMode(); oldGameMode = player.getGameMode();
oldFireTicks = player.getFireTicks(); oldFireTicks = player.getFireTicks();
oldFoodLevel = player.getFoodLevel(); oldFoodLevel = player.getFoodLevel();
oldMaxHealth = player.getMaxHealth(); if (is1_9) {
oldMaxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
}
oldHealth = player.getHealth(); oldHealth = player.getHealth();
oldExp = player.getExp(); oldExp = player.getExp();
oldLvl = player.getLevel(); oldLvl = player.getLevel();