22
33import com .dumptruckman .minecraft .util .Logging ;
44import org .bukkit .Bukkit ;
5+ import org .bukkit .ChatColor ;
56import org .bukkit .Location ;
67import org .bukkit .OfflinePlayer ;
78import org .bukkit .attribute .Attribute ;
@@ -67,12 +68,12 @@ public static class PlayerInventoryData {
6768 public final ProfileType profileTypeUsed ;
6869
6970 // Non-inventory data
70- public final double health ;
71- public final double maxHealth ;
72- public final int level ;
73- public final float exp ;
74- public final int foodLevel ;
75- public final float saturation ;
71+ public final Double health ;
72+ public final Double maxHealth ;
73+ public final Integer level ;
74+ public final Float exp ;
75+ public final Integer foodLevel ;
76+ public final Float saturation ;
7677 public final String lastLocation ;
7778
7879 /**
@@ -94,8 +95,8 @@ public static class PlayerInventoryData {
9495 */
9596 @ ApiStatus .AvailableSince ("5.2" )
9697 public PlayerInventoryData (ItemStack [] contents , ItemStack [] armor , ItemStack offHand , InventoryStatus status ,
97- ProfileType profileTypeUsed , double health , double maxHealth , int level , float exp , int foodLevel ,
98- float saturation , String lastLocation ) {
98+ ProfileType profileTypeUsed , Double health , Double maxHealth , Integer level , Float exp , Integer foodLevel ,
99+ Float saturation , String lastLocation ) {
99100 this .contents = contents ;
100101 this .armor = armor ;
101102 this .offHand = offHand ;
@@ -198,17 +199,17 @@ private CompletableFuture<PlayerInventoryData> loadInventoryDataFromProfileStora
198199 ItemStack offHand = SingleShareReader .of (inventories , targetPlayer , worldName , profileTypeToUse , Sharables .OFF_HAND ).read ().join ();
199200
200201 // Non-inventory data
201- double storedHealth = getSharableValue (Sharables .HEALTH , targetPlayer , worldName , profileTypeToUse , 20.0 );
202- double storedMaxHealth = getSharableValue (Sharables .MAX_HEALTH , targetPlayer , worldName , profileTypeToUse , 20.0 );
203- int storedLevel = getSharableValue (Sharables .LEVEL , targetPlayer , worldName , profileTypeToUse , 0 );
204- float storedExp = getSharableValue (Sharables .EXPERIENCE , targetPlayer , worldName , profileTypeToUse , 0.0f );
205- int storedFoodLevel = getSharableValue (Sharables .FOOD_LEVEL , targetPlayer , worldName , profileTypeToUse , 20 );
206- float storedSaturationLevel = getSharableValue (Sharables .SATURATION , targetPlayer , worldName , profileTypeToUse , 5.0f );
202+ Double storedHealth = getSharableValue (Sharables .HEALTH , targetPlayer , worldName , profileTypeToUse );
203+ Double storedMaxHealth = getSharableValue (Sharables .MAX_HEALTH , targetPlayer , worldName , profileTypeToUse );
204+ Integer storedLevel = getSharableValue (Sharables .LEVEL , targetPlayer , worldName , profileTypeToUse );
205+ Float storedExp = getSharableValue (Sharables .EXPERIENCE , targetPlayer , worldName , profileTypeToUse );
206+ Integer storedFoodLevel = getSharableValue (Sharables .FOOD_LEVEL , targetPlayer , worldName , profileTypeToUse );
207+ Float storedSaturationLevel = getSharableValue (Sharables .SATURATION , targetPlayer , worldName , profileTypeToUse );
207208 String storedLastLocation ;
208209
209210 // Check if LAST_LOCATION is enabled in config
210211 if (!inventoriesConfig .getActiveOptionalShares ().contains (Sharables .LAST_LOCATION )) {
211- storedLastLocation = "Disabled in config " ;
212+ storedLastLocation = ChatColor . RED + "Disabled in Config " ;
212213 } else { // if the location is null or the world is null
213214 Location storedLocationObject = SingleShareReader .of (inventories , targetPlayer , worldName , profileTypeToUse , Sharables .LAST_LOCATION ).read ().join ();
214215 if (storedLocationObject == null || storedLocationObject .getWorld () == null ) {
@@ -265,21 +266,19 @@ private PlayerProfile loadMVInvPlayerProfile(ProfileContainer container, Offline
265266 * @param targetPlayer The OfflinePlayer.
266267 * @param worldName The world name.
267268 * @param profileType The profile type.
268- * @param defaultValue The default value to return if sharable is disabled or data is null.
269269 * @param <T> The type of the sharable value.
270270 * @return The sharable value or the default value.
271271 */
272272 private <T > T getSharableValue (@ NotNull Sharable <T > sharable ,
273273 @ NotNull OfflinePlayer targetPlayer ,
274274 @ NotNull String worldName ,
275- @ NotNull ProfileType profileType ,
276- @ NotNull T defaultValue ) {
275+ @ NotNull ProfileType profileType ) {
277276 try {
278277 T value = SingleShareReader .of (inventories , targetPlayer , worldName , profileType , sharable ).read ().join ();
279- return value != null ? value : defaultValue ;
278+ return value ;
280279 } catch (CompletionException e ) {
281280 Logging .warning ("Failed to read sharable '" + sharable .getNames ()[0 ] + "' for player " + targetPlayer .getName () + " in world " + worldName + ": " + e .getCause ().getMessage ());
282- return defaultValue ;
281+ return null ;
283282 }
284283 }
285284
0 commit comments