Skip to main content

JSONTextMC converts legacy color codes to the modern JSON format.

Project description

JSONTextMC

JSONTextMC is a tool for converting old Minecraft formatting codes to the modern JSON format.

Table of Contents

Prerequisites

Installation

Use the package manager pip to install JSONTextMC.

python3 -m pip install jsontextmc

See the package page on PyPi here.

Usage

As a module

import jsontextmc

# returns '["", {"text": "", "color": "red"}, {"text": "Red in Bold", "color": "red", "bold": true}]'
jsontextmc.translate("&c&lRed in Bold", strict=False)

# returns '["", {"text": "Gold, ", "color": "gold"}, {"text": "Gold in Bold, ", "color": "gold", "bold": true}, {"text": "RESET to nothing"}]'
jsontextmc.translate("§6Gold, §lGold in Bold, §rRESET to nothing", sep="§", strict=False) 

# use 1.16 hexidecimal strings
jsontextmc.translate("&#f00000Not quite red.")

# returns a list of all the formatting codes, and their values
print(jsontextmc.CODES)

# returns a list of all the formatting codes, but only the codes themselves
print(jsontextmc.ALL_CODES)

As a script

python3 -m jsontextmc "&c&lRed in Bold" --strict false
python3 -m jsontextmc "§6gold, §lgold in bold, §rreset to nothing" --sep "§" --strict false
python3 -m jsontextmc "!^FFAABB!cNice!" --sep "!" --hexchar "^"

Use the output in any place where a JsonTextComponent is accepted (eg. /tellraw, /title, .json files).

Support

Supports all Vanilla Minecraft formatting codes:

  • Color Codes
    • 0 through 9
    • A through F
  • Obfuscated
    • K
  • Bold
    • L
  • Strikethrough
    • M
  • Underlined
    • N
  • Italic
    • O
  • Reset
    • R
  • Hexidecimal
    • 0 through 9
    • A through F
    • Must be 6-wide
    • Must be in the form of #RRGGBB, where R, G, B are red, green, blue, respectively.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

If there is an individual issue you would like to bring attention to, please open one here.

License

Distributed under the GPLv3 license. (visit GNU's website)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsontextmc-2.0.2.tar.gz (5.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page