From 3224bbeb4f9074e58da3b7298890fb439551607e Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Fri, 14 Apr 2023 01:02:11 -0400 Subject: [PATCH] Fix `setOrFetch` on 0 values --- src/main/java/emu/grasscutter/game/player/Player.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index a34b9374a..9c888a51b 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -535,9 +535,10 @@ public class Player { * @param defaultValue The value to apply if the property doesn't exist. */ private void setOrFetch(PlayerProperty property, int defaultValue) { - this.setProperty(property, - this.properties.containsKey(property.getId()) ? - this.getProperty(property) : defaultValue, false); + var exists = this.properties.containsKey(property.getId()); + if (exists) exists = this.getProperty(property) != 0; + this.setProperty(property, exists ? this.getProperty(property) + : defaultValue, false); } public int getPrimogems() {