mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-29 22:23:54 +01:00
Use attribute base value instead of 20 when setting player health.
The previous hardcoded value of `20.0` works in most cases, but if a server uses a base health higher than 20, players don't get a full heal. Worse, if the base health is lower than 20, MobArena crashes when it tries to set the health to 20, which is now out of range. This commit introduces the Attribute enum to MobArena's code base and uses it to get the base value for player max health. This should fix the aforementioned issues. Fixes #513
This commit is contained in:
parent
afcc526a71
commit
93af93d5a0
@ -14,6 +14,7 @@ These changes will (most likely) be included in the next version.
|
||||
- MobArena no longer touches the `flySpeed` player attribute when players join an arena. This should fix issues where a crash would result in players being "locked in the air" when trying to fly outside of the arena. It also introduces compatibility with plugins that use flight to augment player abilities.
|
||||
- Fixed a bug introduced by a breaking API change in Spigot where a player with a nearly full inventory might cause item rewards to change stack amounts.
|
||||
- MobArena no longer uncancels teleport events that occur outside of its own context when players have the `mobarena.admin.teleport` permission. This fixes a bug where the permission could override the cancellation of events that weren't related to MobArena.
|
||||
- When resetting player health, MobArena now uses the player max health attribute base value rather than a fixed value of 20. This fixes crashes associated with max health values lower than 20, and ensures that players always get a full heal with values higher than 20.
|
||||
|
||||
Thanks to:
|
||||
- minoneer for help with fixing and testing the teleport bug
|
||||
|
@ -35,6 +35,7 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -834,7 +835,9 @@ public class ArenaImpl implements Arena
|
||||
return;
|
||||
}
|
||||
|
||||
p.setHealth(20.0);
|
||||
double full = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
|
||||
p.setHealth(full);
|
||||
|
||||
plugin.getServer().getScheduler()
|
||||
.scheduleSyncDelayedTask(plugin, () -> revivePlayer(p));
|
||||
endArena();
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.garbagemule.MobArena.steps;
|
||||
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
class SetHealth extends PlayerStep {
|
||||
private static final double FULL_HEALTH = 20.0;
|
||||
private static final int NORMAL_FIRE = -20;
|
||||
private static final int NORMAL_AIR = 300;
|
||||
|
||||
@ -23,7 +23,9 @@ class SetHealth extends PlayerStep {
|
||||
|
||||
player.setRemainingAir(NORMAL_AIR);
|
||||
player.setFireTicks(NORMAL_FIRE);
|
||||
player.setHealth(FULL_HEALTH);
|
||||
|
||||
double full = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
|
||||
player.setHealth(full);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user