Skip to content

Commit 9c9cb3a

Browse files
committed
Refactor InventoryDataProvider and make all the related apis experimental
1 parent 8c92f8c commit 9c9cb3a

7 files changed

Lines changed: 94 additions & 69 deletions

File tree

src/main/java/org/mvplugins/multiverse/inventories/commands/InventoryModifyCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
import org.mvplugins.multiverse.external.jakarta.inject.Inject;
1919
import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
2020
import org.mvplugins.multiverse.inventories.MultiverseInventories;
21-
import org.mvplugins.multiverse.inventories.profile.InventoryDataProvider;
21+
import org.mvplugins.multiverse.inventories.view.InventoryDataProvider;
2222
import org.mvplugins.multiverse.inventories.view.InventoryGUIHelper;
2323
import org.mvplugins.multiverse.inventories.view.ModifiableInventoryHolder;
24+
import org.mvplugins.multiverse.inventories.view.PlayerInventoryData;
2425

2526
@Service
2627
final class InventoryModifyCommand extends InventoriesCommand {
@@ -126,7 +127,7 @@ private void createAndOpenGUI(
126127
@NotNull Player player,
127128
@NotNull OfflinePlayer targetPlayer,
128129
@NotNull String worldName,
129-
@NotNull InventoryDataProvider.PlayerInventoryData playerInventoryData
130+
@NotNull PlayerInventoryData playerInventoryData
130131
) {
131132
String title = "Modify " + targetPlayer.getName() + " @ " + worldName;
132133
Inventory inv = Bukkit.createInventory(

src/main/java/org/mvplugins/multiverse/inventories/commands/InventoryViewCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
2020
import org.mvplugins.multiverse.inventories.MultiverseInventories;
2121
import org.mvplugins.multiverse.inventories.view.InventoryGUIHelper;
22+
import org.mvplugins.multiverse.inventories.view.PlayerInventoryData;
2223
import org.mvplugins.multiverse.inventories.view.ReadOnlyInventoryHolder;
23-
import org.mvplugins.multiverse.inventories.profile.InventoryDataProvider;
24+
import org.mvplugins.multiverse.inventories.view.InventoryDataProvider;
2425

2526
@Service
2627
final class InventoryViewCommand extends InventoriesCommand {
@@ -111,7 +112,7 @@ private void createAndOpenGUI(
111112
@NotNull Player player,
112113
@NotNull OfflinePlayer targetPlayer,
113114
@NotNull String worldName,
114-
@NotNull InventoryDataProvider.PlayerInventoryData playerInventoryData
115+
@NotNull PlayerInventoryData playerInventoryData
115116
) {
116117
String title = targetPlayer.getName() + " @ " + worldName;
117118
Inventory inv = Bukkit.createInventory(new ReadOnlyInventoryHolder(),

src/main/java/org/mvplugins/multiverse/inventories/listeners/InventoryViewListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.mvplugins.multiverse.external.jakarta.inject.Inject;
1919
import org.mvplugins.multiverse.external.jetbrains.annotations.NotNull;
2020
import org.mvplugins.multiverse.inventories.MultiverseInventories;
21-
import org.mvplugins.multiverse.inventories.profile.InventoryDataProvider;
21+
import org.mvplugins.multiverse.inventories.view.InventoryDataProvider;
2222
import org.mvplugins.multiverse.inventories.profile.key.ProfileType;
2323
import org.mvplugins.multiverse.inventories.view.InventoryGUIHelper;
2424
import org.mvplugins.multiverse.inventories.view.ModifiableInventoryHolder;

src/main/java/org/mvplugins/multiverse/inventories/profile/InventoryDataProvider.java renamed to src/main/java/org/mvplugins/multiverse/inventories/view/InventoryDataProvider.java

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.mvplugins.multiverse.inventories.profile;
1+
package org.mvplugins.multiverse.inventories.view;
22

33
import com.dumptruckman.minecraft.util.Logging;
44
import org.bukkit.Bukkit;
@@ -35,6 +35,7 @@
3535
*
3636
* @since 5.2
3737
*/
38+
@ApiStatus.Experimental
3839
@ApiStatus.AvailableSince("5.2")
3940
@Service
4041
public final class InventoryDataProvider {
@@ -54,66 +55,6 @@ public final class InventoryDataProvider {
5455
this.inventoriesConfig = inventoriesConfig;
5556
}
5657

57-
/**
58-
* Represents the loaded inventory data.
59-
*
60-
* @since 5.2
61-
*/
62-
@ApiStatus.AvailableSince("5.2")
63-
public static class PlayerInventoryData {
64-
public final ItemStack[] contents;
65-
public final ItemStack[] armor;
66-
public final ItemStack offHand;
67-
public final InventoryStatus status;
68-
public final ProfileType profileTypeUsed;
69-
70-
// Non-inventory data
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;
77-
public final String lastLocation;
78-
79-
/**
80-
*
81-
* @param contents The player's main inventory contents (slots 0-35).
82-
* @param armor The player's armor contents (boots, leggings, chestplate, helmet).
83-
* @param offHand The player's off-hand item.
84-
* @param status The status of the inventory data load (e.g., LIVE, STORED, NO_DATA_FOUND).
85-
* @param profileTypeUsed The profile type that was used to retrieve the data (e.g., SURVIVAL).
86-
* @param health The player's current health.
87-
* @param maxHealth The player's maximum health.
88-
* @param level The player's current experience level.
89-
* @param exp The player's current experience progress towards the next level (0.0-1.0).
90-
* @param foodLevel The player's current food level (0-20).
91-
* @param saturation The player's current saturation level.
92-
* @param lastLocation The player's last location.
93-
*
94-
* @since 5.2
95-
*/
96-
@ApiStatus.AvailableSince("5.2")
97-
public PlayerInventoryData(ItemStack[] contents, ItemStack[] armor, ItemStack offHand, InventoryStatus status,
98-
ProfileType profileTypeUsed, Double health, Double maxHealth, Integer level, Float exp, Integer foodLevel,
99-
Float saturation, String lastLocation) {
100-
this.contents = contents;
101-
this.armor = armor;
102-
this.offHand = offHand;
103-
this.status = status;
104-
this.profileTypeUsed = profileTypeUsed;
105-
106-
// Non-inventory data
107-
this.health = health;
108-
this.maxHealth = maxHealth;
109-
this.level = level;
110-
this.exp = exp;
111-
this.foodLevel = foodLevel;
112-
this.saturation = saturation;
113-
this.lastLocation = lastLocation;
114-
}
115-
}
116-
11758
/**
11859
* Asynchronously loads a player's inventory data.
11960
* If the player is online AND in the specified world, it attempts to get their live inventory.

src/main/java/org/mvplugins/multiverse/inventories/view/InventoryGUIHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.jvnet.hk2.annotations.Service;
1515
import org.mvplugins.multiverse.external.jakarta.inject.Inject;
1616
import org.mvplugins.multiverse.inventories.MultiverseInventories;
17-
import org.mvplugins.multiverse.inventories.profile.InventoryDataProvider;
1817

1918
import java.util.List;
2019
import java.text.DecimalFormat;
@@ -27,6 +26,7 @@
2726
*
2827
* @since 5.2
2928
*/
29+
@ApiStatus.Experimental
3030
@ApiStatus.AvailableSince("5.2")
3131
@Service
3232
public final class InventoryGUIHelper {
@@ -246,7 +246,7 @@ private ItemStack getOrFillItem(ItemStack item, int slot, boolean isModifiable)
246246
*/
247247
@ApiStatus.AvailableSince("5.2")
248248
public void populateInventoryGUI(@NotNull Inventory inv,
249-
@NotNull InventoryDataProvider.PlayerInventoryData playerInventoryData,
249+
@NotNull PlayerInventoryData playerInventoryData,
250250
boolean isModifiable) {
251251
// Fill main inventory slots (0–35)
252252
if (playerInventoryData.contents != null) {

src/main/java/org/mvplugins/multiverse/inventories/profile/InventoryStatus.java renamed to src/main/java/org/mvplugins/multiverse/inventories/view/InventoryStatus.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
1-
package org.mvplugins.multiverse.inventories.profile;
1+
package org.mvplugins.multiverse.inventories.view;
22

33
import org.bukkit.ChatColor;
4+
import org.jetbrains.annotations.ApiStatus;
45
import org.jetbrains.annotations.NotNull;
56

67
/**
78
* Represents the status of an inventory data load operation.
89
* Provides a fixed set of states for clarity and type safety.
10+
*
11+
* @since 5.2
912
*/
13+
@ApiStatus.Experimental
14+
@ApiStatus.AvailableSince("5.2")
1015
public enum InventoryStatus {
1116
/**
1217
* Indicates that live inventory data from an online player was displayed.
18+
*
19+
* @since 5.2
1320
*/
21+
@ApiStatus.AvailableSince("5.2")
1422
LIVE_INVENTORY(ChatColor.GREEN + "Displaying LIVE inventory"),
1523

1624
/**
1725
* Indicates that stored inventory data from Multiverse-Inventories profiles was displayed.
26+
*
27+
* @since 5.2
1828
*/
29+
@ApiStatus.AvailableSince("5.2")
1930
STORED_INVENTORY(ChatColor.GREEN + "Displaying STORED inventory"),
2031

2132
/**
2233
* Indicates that no player data was found for the specified world/player.
34+
*
35+
* @since 5.2
2336
*/
37+
@ApiStatus.AvailableSince("5.2")
2438
NO_DATA_FOUND(ChatColor.RED + "No player data found");
2539

2640
private final String message;
@@ -35,7 +49,10 @@ public enum InventoryStatus {
3549
* @param playerName The name of the target player.
3650
* @param worldName The name of the target world.
3751
* @return The formatted status message.
52+
*
53+
* @since 5.2
3854
*/
55+
@ApiStatus.AvailableSince("5.2")
3956
public @NotNull String getFormattedMessage(@NotNull String playerName, @NotNull String worldName) {
4057
if (this == NO_DATA_FOUND) {
4158
return this.message + " for " + playerName + " in world" + worldName + ". Try checking a different world or ensure the player has played in this world.";
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package org.mvplugins.multiverse.inventories.view;
2+
3+
import org.bukkit.inventory.ItemStack;
4+
import org.jetbrains.annotations.ApiStatus;
5+
import org.mvplugins.multiverse.inventories.profile.key.ProfileType;
6+
7+
/**
8+
* Represents the loaded inventory data.
9+
*
10+
* @since 5.2
11+
*/
12+
@ApiStatus.Experimental
13+
@ApiStatus.AvailableSince("5.2")
14+
public final class PlayerInventoryData {
15+
public final ItemStack[] contents;
16+
public final ItemStack[] armor;
17+
public final ItemStack offHand;
18+
public final InventoryStatus status;
19+
public final ProfileType profileTypeUsed;
20+
21+
// Non-inventory data
22+
public final Double health;
23+
public final Double maxHealth;
24+
public final Integer level;
25+
public final Float exp;
26+
public final Integer foodLevel;
27+
public final Float saturation;
28+
public final String lastLocation;
29+
30+
/**
31+
*
32+
* @param contents The player's main inventory contents (slots 0-35).
33+
* @param armor The player's armor contents (boots, leggings, chestplate, helmet).
34+
* @param offHand The player's off-hand item.
35+
* @param status The status of the inventory data load (e.g., LIVE, STORED, NO_DATA_FOUND).
36+
* @param profileTypeUsed The profile type that was used to retrieve the data (e.g., SURVIVAL).
37+
* @param health The player's current health.
38+
* @param maxHealth The player's maximum health.
39+
* @param level The player's current experience level.
40+
* @param exp The player's current experience progress towards the next level (0.0-1.0).
41+
* @param foodLevel The player's current food level (0-20).
42+
* @param saturation The player's current saturation level.
43+
* @param lastLocation The player's last location.
44+
* @since 5.2
45+
*/
46+
@ApiStatus.AvailableSince("5.2")
47+
public PlayerInventoryData(ItemStack[] contents, ItemStack[] armor, ItemStack offHand, InventoryStatus status,
48+
ProfileType profileTypeUsed, Double health, Double maxHealth, Integer level, Float exp, Integer foodLevel,
49+
Float saturation, String lastLocation) {
50+
this.contents = contents;
51+
this.armor = armor;
52+
this.offHand = offHand;
53+
this.status = status;
54+
this.profileTypeUsed = profileTypeUsed;
55+
56+
// Non-inventory data
57+
this.health = health;
58+
this.maxHealth = maxHealth;
59+
this.level = level;
60+
this.exp = exp;
61+
this.foodLevel = foodLevel;
62+
this.saturation = saturation;
63+
this.lastLocation = lastLocation;
64+
}
65+
}

0 commit comments

Comments
 (0)