Skip to content

Commit a291038

Browse files
committed
Fix max health fallback when setting health
1 parent f8db8dd commit a291038

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

  • src/main/java/org/mvplugins/multiverse/inventories/share

src/main/java/org/mvplugins/multiverse/inventories/share/Sharables.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,22 +232,22 @@ public void updateProfile(ProfileData profile, Player player) {
232232
@Override
233233
public boolean updatePlayer(Player player, ProfileData profile) {
234234
Double value = profile.get(HEALTH);
235-
if (value == null) {
236-
player.setHealth(PlayerStats.HEALTH);
237-
return false;
238-
}
239235
try {
236+
if (value == null) {
237+
player.setHealth(PlayerStats.HEALTH);
238+
return false;
239+
}
240240
double maxHealth = getMaxHealth(player);
241241
// This share may handled before MAX_HEALTH.
242242
// Thus this is needed to ensure there is no loss in health stored
243243
if (value > maxHealth) {
244244
Option.of(maxHealthAttr).map(player::getAttribute)
245-
.peek(attr -> attr.setBaseValue(maxHealth));
245+
.peek(attr -> attr.setBaseValue(value));
246246
}
247247
player.setHealth(value);
248248
} catch (IllegalArgumentException e) {
249-
Logging.fine("Invalid value '" + value + "': " + e.getMessage());
250-
player.setHealth(PlayerStats.HEALTH);
249+
Logging.warning("Invalid value '" + value + "': " + e.getMessage());
250+
player.setHealth(getMaxHealth(player));
251251
return false;
252252
}
253253
return true;

0 commit comments

Comments
 (0)