I had an idea for simple interactions between the client and a server. The server could use the Lunar Client server API to tell the client what packets it will receive when a certain event is called. This would allow simple interactions to be instant rather than users waiting (ping * 2) seconds. This would be extremely beneficial to players with high ping because it makes their experience faster and it could help large servers because they may not need to process and send as many packets.
I understand this will be impossible for a lot of server-handled tasks like PvP.
Here is an example:
Inventory previouslyCreatedInventory = Bukkit.createInventory(null, 9, "Test Gui");
previouslyCreatedInventory.setItem(0, new ItemStack(Material.DIAMOND));
LunarClientAPI.getInstance().autoQueue((lcevent) -> {
if(lcevent instanceof LCPlayerInteractEvent) {
LCPlayerInteractEvent lcPlayerInteractEvent = (LCPlayerInteractEvent) lcevent;
if(lcPlayerInteractEvent.hasItem() && lcPlayerInteractEvent.getItem().getType().equals(Material.EMERALD)) {
LCPlayer lcplayer = lcPlayerInteractEvent.getLCPlayer();
lcplayer.openInventory(previouslyCreatedInventory);
}
} else if (lcevent instanceof LCPlayerChatEvent) {
LCPlayerChatEvent lcPlayerChatEvent = (LCPlayerChatEvent) lcevent;
if(lcPlayerChatEvent.getMessage().equals("hello")) {
LCPlayer lcplayer = lcPlayerChatEvent.getLCPlayer();
lcplayer.sendMessage("hi");
}
}
});
In this example, when the player joins the server (or when the autoQueue is updated so more up-to-date packets can be sent eg: change Material.DIAMOND to Material.REDSTONE), it will load all the autoqueued packets so that when the client interacts with an emerald, it opens an Inventory gui that was previously created, otherwise if the player sent a message, it will instantly replay with "hi".