hello
how i can do a inventories refresh ?
Are you talking about Bukkit’s deprecated player.updateInventory()
method? That’s not at all needed from our end since all ItemStack
s are transactional and thus changes are always re-synced between server and client.
okey but when i offer an item to a player they does give this item now the player need to click on the air to show it in they inventorie
Can you post a small plugin that shows how to trigger this (e.g. a command which reproduces it)?
As a side note, while the core of the Inventory API is implemented, many parts of it are not. While you’ll be able to interact with a player’s inventory, you won’t be able to interact with the inventories of other entities, TileEntities, or custom inventories in general (until more of it is implemented).
[code]import java.nio.file.Path;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import org.slf4j.Logger;
import org.spongepowered.api.Game;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.args.GenericArguments;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.config.DefaultConfig;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.text.Text;
import com.google.inject.Inject;
@Plugin(id = “LootCrate”, name = “LootCrate Project”, version = “1.0”)
public class MainLootCase {
@Inject
private Logger logger;
@Inject
private Game game;
public Logger getLogger() {
return logger;
}
@Listener
public void onServerStart(GameStartedServerEvent event) {
}
@Listener
public void onUse(InteractBlockEvent.Secondary event) {
Cause cause = event.getCause();
Optional<Player> firstPlayer = cause.first(Player.class);
firstPlayer.get().getInventory().offer(Sponge.getRegistry()
.createBuilder(ItemStack.Builder.class)
.itemType(ItemTypes.CHEST)
.build());
}
}[/code]example this do the same
Had the same problem and already opened an issue for it: