本帖最后由 Занима 于 2024-8-22 12:37 编辑
使用Python编写的一个类似Minecraft指令的程序,没有实际意义,仅供娱乐.
Beta版:
Version 1.0.0
Version 1.0.1
密码(All files) : 0000
更新内容:
1.在1.0.0的基础上添加了一些指令
2.删除了无用的东西
3.修复了已知bug
#如果有bug请发邮箱给:
username_73@outlook.com
感谢您指出bug
示例:
| 图片:
一些内容
|
Проекты с открытым исходным кодом (!)
源代码(仅提供最新的):
主程序:
- import time
- from colorama import init
- from os import system, chdir
- from os.path import exists
- import configparser
- from pygame import mixer
- from ctypes import windll, c_wchar_p
- from random import sample
- mixer.init()
- init(autoreset=True)
- bgsound = mixer.Sound('_sounds\\background.mcs')
- bgsound.play(-1)
- system('cls')
- Custom_titles = 'Minecraft Command[imitate]'
- windll.kernel32.SetConsoleTitleW(c_wchar_p(Custom_titles))
- try:
- cfg = configparser.ConfigParser()
- cfg.read('.cfg')
- try:
- BGS = cfg.get('gamerule', 'backgroundSound')
- gC = cfg.get('gamerule', 'globalColor')
- Vn = cfg.get('version', 'versionNumber')
- Vt = cfg.get('version', 'versionType')
- lF = cfg.get('choice', 'langFile')
- lC = cfg.get('choice', 'langCode')
- except:
- print('\033[31m\n ERROR!')
- time.sleep(2)
- exit()
- except:
- print('文件自动修复启动中...')
- time.sleep(2)
- cfg = configparser.ConfigParser()
- cfg['var'] = {
- }
- cfg['gamerule'] = {
- 'backgroundSound' : 'true',
- 'globalColor' : 'false'
- }
- cfg['encrypt'] = {
- }
- cfg['version'] = {
- 'versionNumber' : '1.0.1',
- 'versionType' : 'Beta'
- }
- with open('.cfg', 'w') as f:
- cfg.write(f)
- cfg['choice'] = {
- 'langFile' : 'zh_cn.lang',
- 'langType' : 'zh_cn'
- }
- print('已完成,正在退出...')
- time.sleep(2)
- exit()
- try:
- cfg.read('_language\\' + lF, encoding='utf-8')
- langhelp1 = cfg.get(lC, 'mcc.help.lang.1')
- langhelp2 = cfg.get(lC, 'mcc.help.lang.2')
- langhelp3 = cfg.get(lC, 'mcc.help.lang.3')
- langhelp4 = cfg.get(lC, 'mcc.help.lang.4')
- langhelp5 = cfg.get(lC, 'mcc.help.lang.5')
- langhelp6 = cfg.get(lC, 'mcc.help.lang.6')
- helphelp11 = cfg.get(lC, 'mcc.help.help.11')
- error8 = cfg.get(lC, 'mcc.error.8')
- error9 = cfg.get(lC, 'mcc.error.9')
- except:
- while True:
- lan = input('language[If you can speak English:en_us] : ')
- sL = str(lan)
- if len(sL) == 5:
- if sL == 'en_us':
- input('The language file has just been corrupted!Press any key to exit...')
- exit()
- elif sL == 'zh_cn':
- input('语言文件刚才损坏!按任意键退出...')
- exit()
- elif sL == 'ru_ru':
- input('Языковой файл был поврежден только что! Нажмите любую клавишу, чтобы выйти...')
- mixer.Sound('Sound\\it.mcs').play()
- text = ['Италия : У нас есть супер линкоры!',
- 'Япония: А?',
- 'Италия: В ...... у нас есть храбрая и хорошая армия!',
- 'Советы: А??',
- 'Италия: Этот ...... В этот ......, у нас, у нас все еще есть мощные Имперские ВВС!',
- 'Человек из Германии: Хм???',
- 'Италия: Хорошо...... Ну, мы ничего не можем сделать, мы просто сдадимся, ладно, вы довольны, верно?',
- 'Человек из Франции: Хм???']
- for i in text:
- print(i)
-
- exit()
- else:
- ('This language does not exist or is not supported!')
- list_02 = ['Minecraft Command [Version ' + str(Vn) + ' ' + Vt + ']',
- '']
- def rulemain():
- if BGS == 'true':
- bgsound.set_volume(0.6)
- else:
- bgsound.set_volume(0)
- rulemain()
- for i in list_02:
- print(i)
- time.sleep(0.02)
- def printf(text, color):
- for i in text:
- if color == 'liyellow':
- print('\033[33;1m' + i, end='', flush=True)
- time.sleep(0.02)
- init(autoreset=True)
- while True:
- if gC == 'false':
- lang = input('\033[1;32mMinecraft_command:\033[0m')
- else:
- lang = input('Minecraft_command:')
- sR = str(lang)
- if str(lang)[0:1] == '/':
- #加密
- if str(lang)[1:8] == 'encrypt':
- if sR[7:9] == 't ' and sR[9:10] == '' or sR[7:12] == 't add' and sR[12:13] == '' or sR[7:15] == 't seeAll' and sR[15:16] != '' or sR[7:12] == 't add' and sR[12:14] == ' ':
- print("\033[31m[Error 03]Invalidity\033[0m")
- elif sR[7:9] == 't ' and sR[9:12] == 'add' and sR[11:13] == 'd ':
- string = sample('abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 5)
- def loop():
- global string
- string = ''.join(sample('abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' * 5, 5))
- if string in cfg.options('encrypt'):
- loop()
- else:
- cfg.set('encrypt', str(string) ,str(sR[13:]))
- print('\033[38;2;255;165;0mAdded \033[0m' + string + ' : ' + sR[13:])
- return
- loop()
- with open('.cfg', 'w') as f:
- cfg.write(f)
- f.close()
- elif sR[7:15] == 't getAll' and sR[15:16] == '':
- var = cfg.options('encrypt')
- i = cfg.items('encrypt')
- for i, var in zip(i, var):
- print(str(var) + ' : ' + str(i)[11:-2])
- time.sleep(0.02)
- elif sR[11:13] == 'l ' and sR[18:19] != '' or sR[11:13] == 't ' and sR[18:19] != '':
- print("\033[31m[Error 07]The maximum number of encrypted characters stored is only 5 digits")
- elif sR[7:9] == 't ' and sR[9:12] == 'del' and sR[11:13] == 'l ':
- if sR[11:16] == 'l all' and sR[16:17] == '':
- for i in cfg.options('encrypt'):
- cfg.remove_option('encrypt', i)
- print('已删除:' + i, end='\b'*12, flush=True)
- time.sleep(0.2)
- cfg.remove_option('encrypt', str(sR[13:18]))
- with open('.cfg', 'w') as f:
- cfg.write(f)
- f.close()
- print('\033[34;1m[Hint]Successfully deleted')
- elif sR[7:13] == 't help' and sR[13:14] == '':
- list_07 = ['此命令的用法如下:',
- ' /encrypt <label> <text>',
- ' /encrypt help*可以获得帮助(我知道你知道可以help)[这段...]',
- 'example:',
- ' /encrypt add 1*可以加密“1”',
- 'label:',
- ' add --添加一个加密内容',
- ' del --删除一个加密内容',
- ' ┖ all --删除所有',
- ' get --解密一个加密内容',
- ' getAll --查看所有加密内容']
- for i in list_07:
- print(i)
- time.sleep(0.02)
- elif sR[7:9] == 't ' and sR[9:12] == 'get' and sR[11:13] == 't ' and len(sR[13:18]) == 5:
- try:
- print(str(cfg.get('encrypt', str(sR[13:18]))))
- except:
- print("\033[31m[Error 01]The " + "'" + str(lang)[13:18] + "'" +" command does not exist LABEL\033[0m")
- elif sR[18:19] != '':
- print('\033[31m[Error 05]There are extra spaces!')
- else:
- print('\033[31m[Error 04]unkonw error.\033[0m')
- elif sR[1:7] == '114514' and sR[7:8] == '':
- if exists('_sounds\\bin\\hello_world.exe'):
- system('start _sounds\\bin\\hello_world.exe')
- else:
- system('start _sounds\\bin\\hello_world.py')
- exit()
- #语言
- elif sR[1:9] == 'language':
- if sR[9:14] == ' help' and sR[14:15] != '':
- print('\033[31m[Error 05]There are extra spaces!')
- elif sR[9:14] == ' add ' and sR[16:17] == '_' and sR[19:25] == '.lang ' and sR[14:19] != sR[25:30]:
- print('\033[31m[Error 8]' + error8)
- elif sR[9:14] == ' help' and sR[14:15] == '':
- list_08 = [langhelp1,
- ' /language <FileName> <LangCode>',
- langhelp2,
- ' LangCode' + langhelp3,
- langhelp4,
- ' /language zh_cn.lang zh_cn ' + langhelp5,
- langhelp6,
- ' /language deft <zh_cn/en_us>']
- for i in list_08:
- print(i)
- time.sleep(0.02)
- elif sR[9:15] == ' deft ':
- if sR[15:20] == 'zh_cn':
- cfg.set('choice', 'langFile', 'zh_cn.lang')
- cfg.set('choice', 'langCode', 'zh_cn')
- with open('.cfg', 'w') as f:
- cfg.write(f)
- f.close()
- elif sR[15:20] == 'en_us':
- cfg.set('choice', 'langFile', 'en_us.lang')
- cfg.set('choice', 'langCode', 'en_us')
- with open('.cfg', 'w') as f:
- cfg.write(f)
- f.close()
- else:
- print('\033[31m[Error 09]' + error9)
- elif sR[9:14] == ' add ' and sR[16:17] == '_' and sR[19:25] == '.lang ' and sR[14:19] == sR[25:30]:
- cfg.set('choice', 'langFile', sR[14:24])
- cfg.set('choice', 'langCode', sR[25:30])
- with open('.cfg', 'w') as f:
- cfg.write(f)
- f.close()
- print('\033[34;1m[Hint]This setting needs to be restarted for it to take effect')
- elif sR[9:14] == ' test' and sR[14:15] == '':
- lan = input('\033[31mlanguage[If you can speak English:en_us] : \033[0m')
- sL = str(lan)
- if len(sL) == 5:
- if sL == 'en_us':
- input('The language file has just been corrupted!Press any key to exit...')
- elif sL == 'zh_cn':
- input('语言文件刚才损坏!按任意键退出...')
- elif sL == 'ru_ru':
- input('Языковой файл был поврежден только что! Нажмите любую клавишу, чтобы выйти...')
- mixer.Sound('_sounds\\it.mcs').play()
- print('')
- text = ['\033[38;2;255;255;0mИталия: \033[0mУ нас есть супер линкоры!',
- '\033[31;1mЯпония: \033[0mА?',
- '\033[38;2;255;255;0mИталия: \033[0mВ ...... у нас есть храбрая и хорошая армия!',
- '\033[32mСоветы: \033[0mА??',
- '\033[38;2;255;255;0mИталия: \033[0mЭтот ...... В этот ......, у нас, у нас все еще есть мощные Имперские ВВС!',
- '\033[34mЧеловек из Германии: \033[0mХм???',
- '\033[38;2;255;255;0mИталия: \033[0mХорошо...... Ну, мы ничего не можем сделать, мы просто сдадимся, ладно, вы довольны, верно?',
- '\033[36mЧеловек из Франции: \033[0mХм???']
- for i in text:
- print(i)
- time.sleep(0.02)
- else:
- print('\033[31;1mThis language does not exist or is not supported And only languages "xx_xx" formats are supported!')
- else:
- print('\033[31m[Error 03]Invalidity')
- #help
- elif str(lang)[1:5] == 'help':
- if str(lang)[5:6] == '':
- list_02 = ['/help --用于显示所有现有命令',
- '/encrypt --用于加密文字(除汉字以外)[离线仅供个人使用]',
- '/compute --用于计算具体请键入/compute help',
- '/title --用于更改标题',
- '/version --用于显示版本',
- '/var --用于设置变量(没有太大用处)[有了encrypt后这个没有太大用处]',
- '/gamerule --用于改变程序的一些设置',
- '/clear --用于清屏',
- '/kill --退出',
- '/reboot --重启',
- helphelp11,
- '错误可参照.\\Error.txt 或键入 /error'
- ]
- for i in list_02:
- print(i)
- time.sleep(0.02)
- elif str(lang)[5:6] == ' ':
- print("\033[31m[Error 01]The " + "'" + str(lang)[6:] + "'" +" command does not exist LABEL\033[0m")
- else:
- print("\033[31m[Error 01]The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
- #clear
- elif sR[1:6] == 'clear' and sR[6:7] == '':
- system('cls')
- #设置
- elif str(lang)[1:9] == 'gamerule':
- if sR[8:11] == 'e h' and sR[10:14] == 'help' and sR[14:15] == '':
- list_03 = ['此命令的语法如下:',
- ' /gamerule <RuleItems> <true/false>',
- 'Rule items:',
- ' backgroundSound --背景音乐',
- ' globalColor --全局颜色(指每次打印后颜色不重置)[不完全]']
- for i in list_03:
- print(i)
- time.sleep(0.02)
- elif sR[8:25] == 'e backgroundSound':
- if sR[24:30] == 'd true':
- cfg.set('gamerule', 'backgroundSound', 'true')
- bgsound.set_volume(0.6)
- print('\033[34;1m[Hint]Setup complete')
- elif sR[24:31] == 'd false':
- cfg.set('gamerule', 'backgroundSound', 'false')
- bgsound.set_volume(0)
- elif sR[8:21] == 'e globalColor':
- if sR[20:26] == 'r true':
- cfg.set('gamerule', 'globalColor', 'true')
- print('\033[34;1m[Hint]This setting needs to be restarted for it to take effect')
- elif sR[20:27] == 'r false':
- cfg.set('gamerule', 'globalColor', 'false')
- bgsound.set_volume(0)
- print('\033[34;1m[Hint]This setting needs to be restarted for it to take effect')
- else:
- print('\033[31m[Error 04]unkonw error.\033[0m')
- with open('.cfg', 'w') as f:
- cfg.write(f)
- #定义变量
- elif str(lang)[1:4] == 'var':
- if str(lang)[4:5] == ' ' and str(lang)[5:6] == 'help':
- list_06 = ['The syntax for this command is:\n',
- ' /compute <Pruss> <var> <name>\n',
- '/var']
- for i in list_06:
- print(i)
- time.sleep(0.02)
- #版本
- elif str(lang)[1:8] == 'version':
- if str(lang)[8:9] == '':
- system('cls')
- list_02 = ['Minecraft Command [Version ' + str(Vn) + ' ' + Vt + ']','']
- for i in list_02:
- print(i)
- time.sleep(0.02)
- elif str(lang)[8:9] == ' ':
- print("\033[31m[Error 01]The " + "'" + str(lang)[9:] + "'" +" command does not exist LABEL\033[0m")
- else:
- print("\033[31m[Error 01]The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
- #title
- elif str(lang)[1:6] == 'title':
- if str(lang)[6:11] == ' help':
- print('The syntax for this command is:')
- print(' /title <text>')
- elif str(lang)[6:7] == ' ':
- Custom_titles = sR[7:]
- windll.kernel32.SetConsoleTitleW(c_wchar_p(Custom_titles))
- else:
- print("\033[31m[Error 03]Invalidity\033[0m")
- #计算
- elif str(lang)[1:8] == 'compute':
- try:
- list_01 = str(lang)[9:-2].split()
- except:
- pass
- if str(lang)[8:13] == ' help':
- list_04 = ['The syntax for this command is:',
- ' /compute <Calculation> <first> <second>',
- ' example:',
- ' /compute 1 1 2',
- ' Suce:',
- ' 0',
- ' The symbols you can use are:',
- ' +[1] -[2] *[3] /[4]',
- 'Only two numbers are supported and decimals are not supported',
- 'Otherwise it will crash!']
- for i in list_04:
- print(i)
- time.sleep(0.02)
- elif sR[8:10] == ' ':
- print('\033[31m[Error 05]There are extra spaces!')
- elif int(''.join(list_01[0:1])) > 32768 or int(''.join(list_01[1:2])) > 32768:
- print("\033[31m[Error 06]The value is too large, and the maximum value is 32768\033[0m")
- elif str(lang)[8:9] == ' ' and str(lang)[-2:] == ' 1':
- try:
- num = int(''.join(list_01[0:1])) + int(''.join(list_01[1:2]))
- print(str(num))
- except:
- print("\033[31m[Error 02]Can't calculate\033[0m")
- elif str(lang)[8:9] == ' ' and str(lang)[-2:] == ' 2':
- try:
- num = int(''.join(list_01[0:1])) - int(''.join(list_01[1:2]))
- print(str(num))
- except:
- print("\033[31m[Error 02]Can't calculate\033[0m")
- elif str(lang)[8:9] == ' ' and str(lang)[-2:] == ' 3':
- try:
- num = int(''.join(list_01[0:1])) * int(''.join(list_01[1:2]))
- print(str(num))
- except:
- print("\033[31m[Error 02]Can't calculate\033[0m")
- elif str(lang)[8:9] == ' ' and str(lang)[-2:] == ' 4':
- try:
- num = int(''.join(list_01[0:1])) / int(''.join(list_01[1:2]))
- print(str(num))
- except:
- print("\033[31m[Error 02]Can't calculate\033[0m")
- else:
- print("\033[31m[Error 03]Invalidity\033[0m")
- elif str(lang)[1:5] == 'kill' and sR[5:6] == '':
- system('cls')
- print('\033[31mAdministrator:\033[0m', end='')
- print('You died!')
- time.sleep(2)
- exit()
- elif sR[1:7] == 'reboot':
- if sR[7:8] == '':
- system('cls')
- if exists('Minecraft_Command.exe') == True:
- system('start Minecraft_Command.exe')
- else:
- system('start Minecraft_Command.py')
- exit()
- elif sR[7:8] == ' ':
- print("\033[31m[Error 01]The " + "'" + str(lang)[8:] + "'" +" command does not exist LABEL\033[0m")
- else:
- print("\033[31m[Error 01]The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
- elif sR[1:6] == 'error':
- if sR[6:7] == ' ':
- print("\033[31m[Error 01]The " + "'" + str(lang)[7:] + "'" +" command does not exist LABEL\033[0m")
- elif sR[6:7] == '':
- list_05 = ['[Error 01]不存在此标签或命令',
- '[Error 02]无法计算',
- '[Error 03]无效',
- '[Error 04]未知错误',
- '[Error 05]存在多余空格',
- '[Error 06]数值过大',
- '[Error 07]储存加密字符最大只有5位',
- '[Error 08]' + error8,
- '[Error 09]' + error9]
- for line in list_05:
- print(line)
- time.sleep(0.02)
- else:
- print("\033[31m[Error 01]The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
- else:
- print("\033[31m[Error 01]The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
-
- elif str(lang) == '':
- pass
- else:
- if '§k' in sR or '§m' in sR:
- print('\033[34;1m[Hint]Please wait for the technology to improve,the "§k" or "§m" is not exist now!')
- text = (
- sR.replace('§0', '\033[30m')
- .replace('§1', '\033[38;2;0;0;170m')
- .replace('§2', '\033[38;2;0;170;0m')
- .replace('§3', '\033[38;2;0;170;170m')
- .replace('§4', '\033[38;2;170;0;0m')
- .replace('§5', '\033[35m')
- .replace('§6', '\033[38;2;255;170;0m')
- .replace('§7', '\033[38;2;170;170;170m')
- .replace('§8', '\033[38;2;85;85;85m')
- .replace('§9', '\033[34m')
- .replace('§a', '\033[32m')
- .replace('§b', '\033[38;2;85;255;255m')
- .replace('§c', '\033[31m')
- .replace('§d', '\033[38;2;255;85;255m')
- .replace('§e', '\033[33m')
- .replace('§f', '\033[37m')
- .replace('§l', '\033[1m')
- .replace('§n', '\033[4m')
- .replace('§r', '\033[0m')
- .replace('\\n', '\n')
- #自定义额外
- .replace('§o', '\033[8m')#变淡
- .replace('§s', '\033[7m')#反显
- .replace('§t', '\033[5m')#闪烁
- )
- if gC == 'false':
- print(str(text) + '\033[0m')
- else:
- print(str(text))
复制代码
|
如果你支持此程序可以将ID发给我, 在彩蛋里会出现你的名字哦! 最后更新时间:24\8\22
|