Skip to content

The Minecraft plugin Challenges can be quite annoying to edit with JSON. So why not using a live GUI connected to the server?

Notifications You must be signed in to change notification settings

Lucaa8/Challenges_App

Repository files navigation

Challenges-App

This application, fully coded from scratch in .NET Core 6.0, was designed to assist in the configuration of the Minecraft plugin "Challenges," which was also created by me. The plugin is fully configured using JSON. It is highly advanced, allowing the creation of an infinite number of objects and challenges organized into different categories. However, with hundreds of lines of JSON, human error can happen quickly. That’s why a GUI application was developed (in C#) in addition to the plugin (in Java) to simplify editing and better visualize challenges when staff members need to make changes. The staff member starts an editing session from the Minecraft server and can then log into the C# application using a temporary token. The application connects to the Minecraft server via a socket, and any changes are made live.

⚠️ Usage Restrictions

This code is provided for exposition and demonstration only. You are not allowed to:

  • Download a compiled release of this project for public use.
  • Compile or use any of this code, whether for commercial or non-commercial purposes.

Important:

Any use of this code in violation of these restrictions, especially on publicly accessible servers or for paid services, constitutes a breach of the terms. If you wish to discuss a specific use case, please contact me directly.

Dependencies

Design and conception

The idea behind this application and every design concept is from me.

Implementation

I handled the implementation myself, based on what I planned during the conception. However, the application has been extensively used from start to finish by BlackT8, which greatly facilitated the testing and bug-fixing stages.

Disclamer

To fully understand the concepts covered in the application, it would be helpful for the reader to have a basic understanding of how challenges work. These concepts will not be re-explained here; only how the plugin is modified from the C# interface will be discussed. For more details about the plugin's functionality, please refer to the plugin README.

Functionalities

To summarize, the application allows for modifying the current status of challenges (active/inactive), viewing and loading any existing category or challenge on the server. It can create, modify, or delete very complex items (Enchantments, Attributes, Meta like Potions, Books, etc.). Additionally, it allows for creating a completely new challenge/category, modifying it, and deleting it. It is even possible to download the final JSON content of an item or import a challenge or category using this JSON content. All changes can be pushed directly to the server without reloading/restarting, which helps avoid excessive maintenance periods and allows for immediate in-game visualization of changes when modifications are made by staffs.

How to Connect/Disconnect

Some general information about the communication protocol between the Minecraft server and the application: only one session can be active at a time to avoid conflicts when modifying multiple categories or challenges simultaneously. I’m not going to create a Github2 to synchronize staff work, lol. The application uses a standard TCP socket connection between the client (C#) and the server (Java). Users authenticate with an access token generated by an admin on the server. All packets sent are logged both on the client and the server, making it easier to track and visualize the communication process.

Connection

When the application is launched, a form asking for an access token and an IP address will be visible. The IP address is the address of the Minecraft server (whether remote or local), and a port must be specified. This is the port on which the Minecraft server listens for connections, and it is specified in the plugin's configuration. Finally, the access token can be obtained from the game. Players with a certain permission can execute the command /cadmin editor new to ask the server to start listening on the defined port and receive a freshly generated access token.

editor_new_mc editor_new_app
An admin execute this command on the Minecraft server and copy the token The admin goes to the app and paste the token with the server's IP and port

Important The staff who generated the token must be the same staff member who enters the session in the application. When connecting with the access token, if the IP address does not match between the player in-game and the IP address of the login packet received from the application on the server, the server will immediately terminate the session, and an error message will warn the user on the application. This is a security measure to ensure that staff do not give access to sessions to players who should not have access to the application, or simply to prevent the access token from being intercepted by someone else.

Disconnection

There are two ways to disconnect. The first is simply by closing the application using the close button (the cross). The second way is from the game or the server console. Any staff member can execute the command /cadmin editor kill [optional reason]. This will terminate the current session and notify the connected person if a reason was provided.

It is important to note that if the application crashes unexpectedly or if the user presses ALT+F4, the server will terminate the session to avoid wasting resources and preventing the session from being stuck indefinitely. To achieve this, a keep-alive mechanism is in place: after 1 minute without receiving any information from the client, the server will close the session.

editor_kill_mc editor_killl_app
An admin execute this command on the Minecraft server The connected user is disconnected and see the reason specified

Main Page

When an aggregated user connects, the first thing the client will do is fetch the current state of the challenges (active, inactive?) and then retrieve the list of names of existing categories and challenges. Nothing more. It would be too time-consuming to load each category, challenge, and item individually without being sure that the user wants to modify them. The application will then update this information on the graphical interface (which is non-blocking during transfers with the server).

Challenges Editor 19_11_2024 00_35_51
Menu page

On this page, it is possible to view:

  • The current state of the challenges and modify it directly from the application (In case the staff no longer wants players to use the challenges while making major modifications).
  • Filter categories or challenges by their name
  • A button to access item management.
  • The connection status with the server (ping and time of the last packet exchange).
  • A panel displaying various actions the user performs within the application and incoming/outgoing packets with the server.
  • Finally, the list of categories and challenges currently present in the plugin.

The user can then click on an existing category or challenge, which will load the relevant information about that category or challenge from the server (such as its description, whether it is active, its icon, etc.), and display it on a dedicated page for that category or challenge. (For a detailed description of these pages, see the next sections, namely Categories and Challenges). The user can also click on "New Category" or "New Challenge," which will create a local new element. They can then modify it and send it to the server. Finally, it is possible to delete an item by right-clicking on its name.

editor_create_challenge
Create a challenge by double clicking on nouveau challenge, then you can find it in the list and edit it
editor_delete_challenge editor_del_popup
Delete an element by right clicking it (the confirmation popup did not show on the record) The confirmation popup
editor_del_challenge_fail
Cannot delete a non empty category

Items Creation

The creation of items is arguably the most complex part of the application, and it will not be possible to demonstrate everything. However, every effort will be made to help the reader understand the importance and usefulness of this section. In Minecraft, creating complex items manually can be very time-consuming and tedious, even more so in JSON configuration files. For this reason, the application includes several complete pages to quickly create specific and complex items and assign them directly to challenges.

Items are used in multiple contexts:

  • As the icon for a category or challenge.
  • As prerequisites for completing an "inventory" challenge.
  • As rewards for a challenge.

For this reason, throughout the illustrations, you will see dropdown lists that allow users to select items. When a user loads a category or a challenge, all items associated with that element are fetched from the server and added locally. This way, the user can modify or delete them if needed.

The small blue spinning button next to the dropdown lists is a refresh button that updates the list with all newly created items (locally or fetched from the server).

item_create
Create a new local item (the name you put here will appear in drop-down lists later in the app)
item_material
No need to learn by heart the 1000 Minecraft material list, this little window will help you!
item_enchants
Keep track of your item's enchantments and edit them in few clicks
item_flags
Just toggle all the existings Minecraft flags on your item by double clicking this list!
item_attributes
Add infinite attributes on your item and edit them in 2 clicks, who told you attributes are boring to create?
item_meta_1 item_meta_2
Preview your Leather armor's color just by looking the app (Yeah the item is named potion... my bad) Write a really nice book and preview the Minecraft result by toggling one checkbox, do you like Harry Potter?
item_add acacia_book
Finally! Just add your beautiful item in any challenge just by opening a dropdown-list Here is the in game result

Categories

A category contains the following information:

  • UUID: All JSON content is stored in a file named after the UUID of the category followed by .json. The UUID is chosen randomly during creation and cannot be changed.
  • Name: Can include spaces and special characters, as it is not used as an identifier.
  • Description: Similar to the name but supports color codes for styling.
  • Active Status: Indicates whether the category is active or not. Inactive categories are still visible in-game but appear grayed out.
  • Glass Pane Color: Specifies the color of the glass pane surrounding the inventory when viewing challenges.
  • Icon: An item created in the app, displayed in-game as the "logo" of the category.
  • Icon Data: Previously stored separately, now embedded directly in the item (deprecated).
  • Page and Slot: Defines where the category icon will appear within the main menu inventory.
  • List of Required Challenges: A list of challenges that must be completed to unlock this category. This should not be confused with the list of challenges hosted within the category, which is defined elsewhere.
category_page cat_demo
An example category page In game result

The "Envoyer" (Send) button is used to push the category to the server after modifications are made. The change is made instantly and everyone can see the result in game, without restarting the server.

Challenges

A challenge contains the following information:

  • UUID: All JSON content is stored in a file named after the UUID of the challenge followed by .json. The UUID is chosen randomly during creation and cannot be changed.
  • Category: Here is defined which category will host this challenge.
  • Name: Can include spaces and special characters, as it is not used as an identifier.
  • Description: Similar to the name but supports color codes for styling.
  • Type: Items (Inventory), Island, Statistics and Others, which will decides what the challenge will ask as requirements. Check the Requirements section
  • Active Status: Indicates whether the challenge is active or not. Inactive challenges are still visible in-game but appear grayed out.
  • Icon: An item created in the app, displayed in-game as the "logo" of the category.
  • Page and Slot: Defines where the category icon will appear within the main menu inventory.
  • Limit: How many time this challenge can be completed at total (not daily) by an island (not by player on island)
  • List of Required Challenges: A list of challenges that must be completed to unlock this challenge.
  • Requirements: What does the challenge needs to be considered as completed
  • Rewards: First and Next rewards. Including Items, Commands, Message, Money and Experience
challenge_page cha_demo
An example challenge page In game result

Requirements

This section will showcase the configuration of each prerequisite in a simple and quick manner, with illustrations of the application and its in-game rendering.

Inventory (or Items) Requirements
req_inv_add challenge_req_inv_proof
Adding a pickaxe efficiency 5 to the required items of the challenge In game result
Island (Blocks and/or Entities) Requirements
req_is_add challenge_req_is_proof
Adding entities and blocks to the requirements of the challenge. Only need 2 clicks by element added. In game result
Statisticals Requirements
req_stat_add challenge_req_stat_proof
Adding and editing statistics with substatistics to the requirements of the challenge. In game result
Others (Money, Experience and Island Levels) Requirements
req_others_add challenge_req_others_proof
Adding money, experience and island levels to the requirements of the challenge. In game result

Rewards

For the rewards section, we will review key elements such as the concepts of First and Next Rewards and items. Messages and commands will be set aside, as they are not particularly interesting aspects and are fairly basic. Below, you will find an illustration of creating a reward for one of our demonstration challenges, followed by its in-game rendering.

rew_add
Adding some already created items to the reward pool of our first demo challenge. Setting money and experience too. For the first completion reward and the next ones
challenge_rew_proof
Our challenge is finally ready. How beautiful ? We even got the 50% sword drop !

Conclusion

Watch this 1-minute 20-second YouTube video demonstrating the app's seamless "live" functionality, with no cuts, showcasing its integration with Minecraft: Here

Some concepts were certainly covered quickly with minimal explanations. The purpose of this README is not to serve as a comprehensive technical documentation or user guide but rather to demonstrate feasibility. If you have further questions about the concept or in general, feel free to contact me on Discord: lucaa_8.

About

The Minecraft plugin Challenges can be quite annoying to edit with JSON. So why not using a live GUI connected to the server?

Resources

Stars

Watchers

Forks

Languages