Let me preface this post by saying that I am overwhelmed by the number of people that decided to become a Patron! Your support means a lot to me and enables me to continue the development of this project.
Now let's get on with the content of this post. There have been a ton of changes since my last post on Patreon. In the last post I explained the core idea behind the API and how it will facilitate the creation of "addons" that can interact with and modify the behaviour of HKMP. What this API already offers to addons is networking, basic information about players and some events (such as players connecting etc). And that was a good start, if there was information that was still missing or some extra events were needed I could simply add them to the API retroactively. However, when I started creating and implementing the Tag addon (also discussed in the last post) I immediately noticed a core feature that was missing from the API, namely commands. Currently the Tag addon offers its interface through a "mod menu", which means that for a user to control (start and stop) the game, they needed to enter the pause menu and go through a slew of buttons. Naturally, this was less than ideal because you would want to be able to start the game more easily. This is where commands come in: commands allow users to quickly enter something that will then execute some custom behaviour. Before we delve further into this, let me take you through a chronological retelling of development events.
Having the concept of commands in mind, I started gathering the requirements in order to realize this system. Which, first of all, needed a way for users to enter commands. Given that the existing HKMP UI already featured a so-called "info box" (where messages pop up), I thought it was best to extend this with a chat bar. This bar is opened with a button press and the user can enter messages into it. For this to be implemented however, it needed a new UI designed for it. Unfortunately, the existing UI implementation was not really meant to extended to this chat bar, so I decided to rework the UI entirely. Luckily, this was already planned to happen at some point.
The UI redesign is mostly based on guidelines generously provided by Geroyuni (an active member of the HKMP discord). See the attached image. These guidelines provide information on the layout and appearance of UI elements for a good user experience. For example, buttons now provide feedback when hovering over them and when clicking them. They also have a different appearance when disabled, which is intuitive to the user that they can't be clicked anymore. Similarly, input fields need to be clicked on to be able to type in them, which is more intuitive. The client settings also got a makeover: the skin ID input will now auto-apply whenever you input something, radio buttons and checkboxes look a lot better, and the overall feel of the menu has improved. See the attached images.
So after the (slight) detour of redesigning the entire UI, the previously called "info box" is now a chat box and has a chat input component. It is also moved to the left side of the screen, which looks better since the text was already aligned on the left. The issues that some text was cut of before has also been fixed and it should now properly display any messages. Opening the chat input will also display previous message in its history. Moreover, it will allow users to send chat messages and thus communicate with other players on the server.
Now that we have the requirements for inputting commands, we can talk about how the command system works in more detail. The command system is (again) divided in a client and server-side part. Both of these are able to process commands on their respective sides, which means that when a user enters a command two things can happen: either the command is registered and processed client-side or it is not registered client-side and it will be sent to the server. This has the advantage that we can create client-side only commands, such as changing client settings, that do not concern the server at all. The managers for these commands are also exposed to the API and thus addons (both client and server addons) can register custom commands. The Tag addon, for instance, has a custom command to start/stop the game, which solves the aforementioned problem of the "mod menu".
There is one problem still with this concept that is not addressed. We don't want to have arbitrary players executing sensitive/important commands. Therefore, some form of authentication/authorization needs to take place to distinguish players with permission to do certain actions and players without that permission. The system introduced for this purpose is "authentication keys". Every player is locally equipped with a (randomly generated) authentication key that will be sent to the server upon login. Firstly, the server can then decide whether player with the authentication key is allowed to login. And secondly, the server can decide whether the player is authorized to execute commands that require higher permission.
Attached to this post I have included the latest development build of HKMP together with the latest version of the HKMP Tag addon. Keep in mind that it might be unstable and bugs may occur. The Tag addon should be placed next to the HKMP.dll and (if using the standalone server) next to HKMPServer.exe. The generated authentication key for the local player is stored in the mod settings, located at the following path:
Windows: %appdata%\..\LocalLow\Team Cherry\Hollow Knight\HkmpMod.GlobalSettings.json
Mac OS: ~/Library/Application Support/unity.Team Cherry.Hollow Knight/HkmpMod.GlobalSettings.json
Linux: ~/.config/unity3d/Team Cherry/Hollow Knight/HkmpMod.GlobalSettings.json
The following commands have been introduced to manage the server:
- "/whitelist <on|off|add|remove> [auth key]": this will manage the whitelist of the server by toggling it or adding/removing authentication keys.
- "/<auth|deauth> <auth key>": this will (de)authorize the given authentication key.
- "/set <name> [value]": will display or change the value of a server settings. For a list of available settings see the HKMP Github readme (https://github.com/Extremelyd1/HKMP/tree/hkmp-api).</name>
- "/list": will display the currently online players.
As always, feel free to shoot me a message on Patreon if you have questions about anything regarding HKMP or add me as a friend on Discord.