API help (v: 4.2.1), Inventory save problem #98
Answered
by
Jikoo
GregorSomething
asked this question in
Q&A
-
I have openinvapi version 4.2.1 as a dependnecy. <!-- OpenInv -->
<dependency>
<groupId>com.github.jikoo.OpenInv</groupId>
<artifactId>openinvapi</artifactId>
<version>4.2.1</version>
<scope>provided</scope>
</dependency> I want to move items from one player to other, but i can not save the modification that i have made. private IOpenInv api;
public void transferItems(UUID from, UUID to) { // TODO Test
Player fromPlayer = this.api.loadPlayer(Bukkit.getOfflinePlayer(from));
Player toPlayer = this.api.loadPlayer(Bukkit.getOfflinePlayer(to));
try {
ISpecialPlayerInventory invFrom = this.api.getSpecialInventory(fromPlayer, false);
ISpecialPlayerInventory invTo = this.api.getSpecialInventory(toPlayer, false);
for (ItemStack item : invFrom.getBukkitInventory().getStorageContents()) {
if (item != null) {
invTo.getBukkitInventory().addItem(item);
}
}
invFrom.getBukkitInventory().clear();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} I have tested it multiple times, but can not find save method. |
Beta Was this translation helpful? Give feedback.
Answered by
Jikoo
Aug 28, 2022
Replies: 1 comment 3 replies
-
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#saveData() |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
GregorSomething
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#saveData()