Yep. So for some reason the players inventory is not casted to a PlayerInventory automatically, but it is always genrenteed (I believe)
PlayerInventory inventory = (PlayerInventory)player.getInventory();
After that you need to talk to the hotbar section of the players inventory
Hotbar bar = inventory.getHotbar();
After that simply set the selected index with the slot you want.
bar.setSelectedIndex(2);