How to close Inventory with name in task
How to close Inventory with name in task
I am looking for a method to close Inventory in a task, no events etc., I would just like to close Inventory which I will show, is it possible?
public static void stopEventSystem() {
int stop = cfg.getConfig().getInt("event.stop")*1200;
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.broadcastMessage("§7Event stop");
status = false;
for(Player p : Bukkit.getOnlinePlayers()) {
//???
}
}
}, stop);
}
1 Answer
1
Take a look atplayer.closeInventory(). You can also use player.getOpenInventory() to get current open inventory, so you can check name etc. If player does not have any inventory open this will return that smaller crafting grid according to documentation.
player.closeInventory()
player.getOpenInventory()
For more methods that interact with Player, you should check the documentation:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.