-
I have this code to open an inventory on the player login event (see line 16) globalEventHandler.addListener(EventListener.builder(PlayerLoginEvent::class.java).filter {
return@filter MinecraftServer.getConnectionManager().onlinePlayers.isNotEmpty()
}.handler {
val inventory = Inventory(InventoryType.CHEST_6_ROW, "Pick a game")
games.forEachIndexed { i, game ->
inventory.setItemStack(
i,
ItemStack.of(game.icon).withDisplayName(game.displayName).withLore(listOf(game.displayDescription))
)
inventory.addInventoryCondition { _, slot, _, inventoryConditionResult ->
if (slot != i) return@addInventoryCondition
game.start()
inventoryConditionResult.isCancel = false
}
}
it.player.openInventory(inventory).let { res -> it.player.sendMessage(res.toString()) }
}.build()) And I get sent true, suggesting that it was supposed to open, however the inventory does not open. |
Beta Was this translation helpful? Give feedback.
Answered by
mworzala
Jun 30, 2023
Replies: 1 comment
-
The player login event is too early to open a GUI, they are not in the play state. Try doing it on the spawn event. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Nuckerr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The player login event is too early to open a GUI, they are not in the play state. Try doing it on the spawn event.