Improve and fix DInstancePlayer#clearPlayerState(); resolves #809

This commit is contained in:
Daniel Saukel 2020-06-19 22:13:30 +02:00
parent 4ddfea0205
commit 5cc5073062

View File

@ -24,6 +24,7 @@ import de.erethon.dungeonsxl.api.world.InstanceWorld;
import de.erethon.dungeonsxl.config.MainConfig;
import de.erethon.dungeonsxl.util.ParsingUtil;
import org.bukkit.World;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
@ -73,9 +74,16 @@ public abstract class DInstancePlayer extends DGlobalPlayer implements InstanceP
player.getInventory().setArmorContents(null);
player.setExp(0f);
player.setLevel(0);
player.setMaxHealth(20);
player.setHealth(20);
double maxHealth;
if (is1_9) {
maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
} else {
maxHealth = player.getMaxHealth();
}
player.setHealth(maxHealth);
player.setFoodLevel(20);
player.setExp(0f);
player.setLevel(0);
for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}