Last active
March 17, 2022 16:21
-
-
Save AnnikenYT/d8c3a68ca26385a2992039ee9b77d6c0 to your computer and use it in GitHub Desktop.
Json text gradient generator for minecraft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from colour import Color | |
import json | |
import pyperclip3 as pc | |
def menu(): | |
print(f""" | |
Press "c" to get the {bcolors.OKCYAN}JSON{bcolors.ENDC} as a string and {bcolors.OKBLUE}copy it{bcolors.ENDC} to the clipboard. | |
Press "s" to get the {bcolors.OKGREEN}Sign Command{bcolors.ENDC} as a string and {bcolors.OKBLUE}copy it{bcolors.ENDC} to the clipboard. | |
Press "t" to get the {bcolors.HEADER}Tellraw Command{bcolors.ENDC} as a string and {bcolors.OKBLUE}copy it{bcolors.ENDC} to the clipboard. | |
Press "q" to {bcolors.FAIL}quit{bcolors.ENDC}. | |
""") | |
choice = input("Enter your choice (cstq): ") | |
if choice in ["c", "s", "t", "q"]: | |
if choice == "c": | |
print( | |
f"{bcolors.OKGREEN}({bcolors.OKCYAN}JSON has been copied to the clipboard{bcolors.OKGREEN}){bcolors.ENDC}") | |
pc.copy(json.dumps(json_text)) | |
menu() | |
elif choice == "s": | |
print(f"{bcolors.OKGREEN}({bcolors.OKCYAN}Sign Command has been copied to the clipboard{bcolors.OKGREEN}){bcolors.ENDC}\n{bcolors.HEADER}NOTE: This might be cut of since it only uses the first line of the sign.{bcolors.ENDC}") | |
pc.copy( | |
"give @p minecraft:oak_sign{BlockEntityTag:{Text1:'" + json.dumps(json_text) + "'}}") | |
menu() | |
elif choice == "t": | |
print(f"{bcolors.OKGREEN}({bcolors.OKCYAN}Tellraw Command has been copied to the clipboard{bcolors.OKGREEN}){bcolors.ENDC}") | |
pc.copy(f"tellraw @a {json.dumps(json_text)}") | |
menu() | |
elif choice == "q": | |
print( | |
f"{bcolors.FAIL}({bcolors.OKCYAN}Quitting{bcolors.FAIL}){bcolors.ENDC}") | |
exit() | |
else: | |
print(bcolors.FAIL + "Invalid choice.") | |
menu() | |
class bcolors: | |
HEADER = '\033[95m' | |
OKBLUE = '\033[94m' | |
OKCYAN = '\033[96m' | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
BOLD = '\033[1m' | |
UNDERLINE = '\033[4m' | |
first_color = Color(str(input("Enter the first color: "))) | |
second_color = Color(str(input("Enter the second color: "))) | |
text = list(input("Enter the text: ")) | |
bold = bool(input("Bold? (y/n): ")) | |
colors = list(first_color.range_to(second_color, len(text))) | |
json_text = [] | |
for letter in text: | |
json_text.append({"text": letter, "color": colors[0].hex, "bold": bold}) | |
colors.pop(0) | |
menu() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment