Skip to content

Jaffe2718/Command-Debug-DevKit

Repository files navigation

Command Debug DevKit

icon Stars Forks Issues Licence

by Jaffe2718

Introduction 📖

This project is written for debugging Minecraft commands. In this project, there are serveral subprojects:

  • fabric: The mod for Fabric and Quilt, used to be a connection kit for IDE. It can create two socket server to provide code completion and code execution service.
  • ide-debug-tool: This is a command line tool which can connect to the socket server opened by the mod. It can send code to the server and get the result. It can be a debug tool for IDE or a command line tool to execute *.mcfunction file directly.
  • idea-plugin: This is a plugin for IntelliJ IDEA. It can connect to the socket server opened by the mod. It provides code completion and code execution service for IDE. The plugin contains a compiled ide-debug-tool so you don't need to install it manually.

Setup 🛠️

Mods

follows latestVersion mcVersion modDownloads
Modrinth

Fabric/Quilt Mod

  1. Install Minecraft withFabric/Quilt Loader and Fabric-API or Quilted Fabric APIfor your Minecraft version.
  2. Download the mod from release-page or Modrinth.
  3. Put the mod into your mods folder.

IDE Debug Tool

release-page doc

  • The tool is a jar file, you can just download it from release-page and you can use it without any installation steps.
  • For more information, please see IDE Debug Tool.

Idea Plugin

Version Downloads Plugin
Marketplace

  1. Download the tool from release-page or JetBrains Marketplace, choose the version suitable for the mod.
  2. Install the plugin in your IDEA: click File -> Settings -> Plugins -> ⚙️ -> Install Plugin from Disk... -> choose the downloaded file, or install it directly from JetBrains Marketplace inside IDE.

Usage 📖

Note: The Author's most recommended way to use this mod is to use the plugin.

Mod

  • The mod creates 3 socket servers to provide code completion, code execution service and datapack management service.
  • The mod should work with other tools like IDE Debug Tool or IDEA Plugin or other tools you write by yourself.

IDEA Plugin

Create a New Datapack Project

  1. Setup a new datapack project in IDEA.

    1. At the welcome page of IDEA, click New Project;

    2. Choose Minecraft Datapack;

    3. Fill in the metadata of the datapack project;

      create new project fill in metadata
    4. Click Create, and the project will be automatically created with the default structure, and it will create data/<namespace>/functions/demo.mcfunction as example.

      fill in metadata The new datapack project
  2. Import an existing datapack as a project.

    1. At the welcome page of IDEA, click New Project;
    2. Choose Import Minecraft Datapack;
    3. Choose the datapack you want to import and fill the project name and extract path;
      import existing project Choose the datapack you want to import
      import existing project Filling the project name and extract path

    Note: The plugin will automatically check if the datapack is valid by these rules:
        1. The datapack must be a zip file;
        2. The zip file must contain a pack.mcmeta file;
        3. The zip file must contain a data folder.
    If the datapack is invalid, the plugin will prevent you from importing it.

    import existing project The plugin will prevent you from importing an invalid datapack

    1. Click Create, and the datapack will be automatically imported as a project.
      import existing project The new project based on the imported datapack

Edit & Debug Minecraft Function

  1. Open or create a project;

  2. Open or create a Minecraft function file;

    open or create a function file create a Minecraft function file
  3. Start the Minecraft game with the mod installed, and open the world you want to debug;

  4. Start edit the *.mcfunction file, connect to the socket servers and start debug;

    start debug Click the function buttons at the toolbar of the editor to get debug services
    start debug Connect to the code execution service
    start debug Connect to the completion service
  5. Now you can start edit the *.mcfunction file and get code completion and code execution service.

    import existing project Code completion
  6. You can click Execute Without Log to execute the command without logging the result to the console.

    execute without log Execute the command without logging
  7. You can click Execute to execute the command and log the result to the console.

    execute Execute the command and log the result to the console

    Note: Remember to configure the project JDK. Click File -> Project Structure to choose the JDK you want to use.

    configure project JDK Congigure the project JDK

Custom Syntax Highlighting

  • Click File -> Settings -> Editor -> Color Scheme -> Minecraft Function to customize the syntax highlighting.
    custom syntax highlighting Click File -> Settings -> Editor -> Color Scheme -> Minecraft Function to customize the syntax highlighting

Minecraft Command Console

  1. Launch the Minecraft game with the mod installed, and open the world you want to debug;

  2. Click Tools -> Minecraft Command DecKit -> Minecraft Command Console and fill the host and port of the command execution socket server.

    open console Click Tools -> Minecraft Command DecKit -> Minecraft Command Console to open the console
    open console Fill the host and port of the command execution socket server
  3. You can write your commands line by line press Enter to execute the command.

    open console Write your commands line by line press Enter to execute the command

Generate Minecraft Datapack

  1. There are two ways to start the task to generate a datapack:

    • Right click the project view and click Minecraft Command DevKit -> Generate Minecraft Datapack in the context menu.

      generate datapack Right click the project view and click Generate Minecraft Datapack in the context menu
    • Click Tools -> Minecraft Command DecKit -> Generate Minecraft Datapack from the main menu bar:

      generate datapack Click Generate Minecraft Datapack from the main menu bar
  2. Click Generate to start the task, and the datapack will be generated in the build folder of the project named <project_name>.zip.

    generate datapack Click Generate to start the task

    Tips: Generate and Import/Link Datapact to Minecraft are similar to Generate Minecraft Datapack, but they require the user to fill in the host and port of the Datapack Management Service socket server. For Import, the generated datapack will be copied to the current world's datapack folder, and for Link, the generated datapack will be linked to the current world's datapack folder and expired when the world is closed.

Datapack Management

  1. There are two ways to start the task to manage the datapack:

    • Click Tools -> Minecraft Command DecKit -> Datapack Management from the main menu bar:

      manage datapack Click Manage Datapack from the main menu bar
    • Right click the project view and click Minecraft Command DevKit -> Datapack Managment in the context menu.

      manage datapack Right click the project view and click Manage Datapack in the context menu
  2. Input the host and port of Datapack Management Service socket server shown in the Minecraft game.

    manage datapack Input the host and port of Datapack Management Service socket server
  3. Do your operations.

    1. Right-click the item in Datapacks -> Status -> Enabled and click Disable to disable the datapack.
    2. Right-click the item in Datapacks -> Status -> Available and click Enable to enable the datapack.
    3. Right-click Datapacks -> Type -> Common and click Import... to import a datapack.
    4. Right-click Datapacks -> Type -> Common and click Link... to link a datapack.
    manage datapack Datapack Management View

    Tips:
        This feature is with the requirement 3.x version of the mod.
        Only the world is opened, the Datapack Management Service socket server will be valid.
        The linked datapack will be expired when the world is closed, and the imported datapack will be copied to the world's datapack folder.

    • For more info, please visit DEV.md.

Command Line Tool

  • You can also use the IDE Debug Tool to connect to the socket server and execute the code.
    command line tool Command Line Tool

Warning ⚠️

When you use this mod, you should be careful. Because it can execute any command. Do not send the host and port to any untrusted program to avoid being attacked. Do not install this mod on your multiplayer server to avoid being attacked by DDOS or other attacks.

Development 🔧

Overview

This is the document for developers. We will introduce how to develop external tools to work with this mod. Programing language is not limited, you can use any language you like, the only thing you need to do is make your tool has the ability to connect to the socket server and interact with it.

Concepts

  • For 3.x version, the mod will create 3 socket servers, for code completion, code execution and datapack management.

    Server Type Description Accepted Message Returned Message
    Code Completion Socket Server The server for code completion single line command or unfinished command multiple line result
    Code Execution Socket Server The server for command execution in Minecraft single line command execution feedbacks
    Datapack Management Socket Server The server for receive datapack from client json string without \n like { "name": "[name].zip", "data": "[base64 encoded data]", "flag": "import" } None
  • Tips: the message sent is a single line of text, you should add \n at the end of the message or auto flush the buffer to send the message to the server.

More Information

For more information, please visit https://img.shields.io/badge/DEV%20%7c%20README%2Emd-000000.svg?logo=markdown&logoColor=50AAFF.

License 📜

Licence
This project is licensed under the MIT License. You can use this project for any purpose for free. See the Licence file for details.

Update and Cooperation 🤝

Currently, this project is still in development. If you have any idea or suggestion, please open an issue or pull request. And the plugin is only for IntelliJ Platform IDEs, if you want to use other IDEs such as Eclipse and VS Code, you can create a plugin for it and pull request to this project. What's more, the mod is only for Fabric and Quilt currently, you can rewrite it for Forge or other mod loaders and pull request to this project. I will be very grateful if you can help me to improve this project.