有趣的程序
本帖最后由 Занима 于 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'
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 : ')
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 ',
'']
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) == '/':
#加密
if str(lang) == 'encrypt':
if sR == 't ' and sR == '' or sR == 't add' and sR == '' or sR == 't seeAll' and sR != '' or sR == 't add' and sR == ' ':
print("\033Invalidity\033[0m")
elif sR == 't ' and sR == 'add' and sR == '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))
print('\033)
return
loop()
with open('.cfg', 'w') as f:
cfg.write(f)
f.close()
elif sR == 't getAll' and sR == '':
var = cfg.options('encrypt')
i = cfg.items('encrypt')
for i, var in zip(i, var):
print(str(var) + ' : ' + str(i))
time.sleep(0.02)
elif sR == 'l ' and sR != '' or sR == 't ' and sR != '':
print("\033The maximum number of encrypted characters stored is only 5 digits")
elif sR == 't ' and sR == 'del' and sR == 'l ':
if sR == 'l all' and sR == '':
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))
with open('.cfg', 'w') as f:
cfg.write(f)
f.close()
print('\033Successfully deleted')
elif sR == 't help' and sR == '':
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 == 't ' and sR == 'get' and sR == 't ' and len(sR) == 5:
try:
print(str(cfg.get('encrypt', str(sR))))
except:
print("\033The " + "'" + str(lang) + "'" +" command does not exist LABEL\033[0m")
elif sR != '':
print('\033There are extra spaces!')
else:
print('\033unkonw error.\033[0m')
elif sR == '114514' and sR == '':
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 == 'language':
if sR == ' help' and sR != '':
print('\033There are extra spaces!')
elif sR == ' add ' and sR == '_' and sR == '.lang ' and sR != sR:
print('\033' + error8)
elif sR == ' help' and sR == '':
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 == ' deft ':
if sR == '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 == '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' + error9)
elif sR == ' add ' and sR == '_' and sR == '.lang ' and sR == sR:
cfg.set('choice', 'langFile', sR)
cfg.set('choice', 'langCode', sR)
with open('.cfg', 'w') as f:
cfg.write(f)
f.close()
print('\033This setting needs to be restarted for it to take effect')
elif sR == ' test' and sR == '':
lan = input('\033 : \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
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('\033Invalidity')
#help
elif str(lang) == 'help':
if str(lang) == '':
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) == ' ':
print("\033The " + "'" + str(lang) + "'" +" command does not exist LABEL\033[0m")
else:
print("\033The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
#clear
elif sR == 'clear' and sR == '':
system('cls')
#设置
elif str(lang) == 'gamerule':
if sR == 'e h' and sR == 'help' and sR == '':
list_03 = ['此命令的语法如下:',
' /gamerule <RuleItems> <true/false>',
'Rule items:',
' backgroundSound --背景音乐',
' globalColor --全局颜色(指每次打印后颜色不重置)[不完全]']
for i in list_03:
print(i)
time.sleep(0.02)
elif sR == 'e backgroundSound':
if sR == 'd true':
cfg.set('gamerule', 'backgroundSound', 'true')
bgsound.set_volume(0.6)
print('\033Setup complete')
elif sR == 'd false':
cfg.set('gamerule', 'backgroundSound', 'false')
bgsound.set_volume(0)
elif sR == 'e globalColor':
if sR == 'r true':
cfg.set('gamerule', 'globalColor', 'true')
print('\033This setting needs to be restarted for it to take effect')
elif sR == 'r false':
cfg.set('gamerule', 'globalColor', 'false')
bgsound.set_volume(0)
print('\033This setting needs to be restarted for it to take effect')
else:
print('\033unkonw error.\033[0m')
with open('.cfg', 'w') as f:
cfg.write(f)
#定义变量
elif str(lang) == 'var':
if str(lang) == ' ' and str(lang) == '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) == 'version':
if str(lang) == '':
system('cls')
list_02 = ['Minecraft Command ','']
for i in list_02:
print(i)
time.sleep(0.02)
elif str(lang) == ' ':
print("\033The " + "'" + str(lang) + "'" +" command does not exist LABEL\033[0m")
else:
print("\033The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
#title
elif str(lang) == 'title':
if str(lang) == ' help':
print('The syntax for this command is:')
print(' /title <text>')
elif str(lang) == ' ':
Custom_titles = sR
windll.kernel32.SetConsoleTitleW(c_wchar_p(Custom_titles))
else:
print("\033Invalidity\033[0m")
#计算
elif str(lang) == 'compute':
try:
list_01 = str(lang).split()
except:
pass
if str(lang) == ' 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:',
' + - * /',
'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 == '':
print('\033There are extra spaces!')
elif int(''.join(list_01)) > 32768 or int(''.join(list_01)) > 32768:
print("\033The value is too large, and the maximum value is 32768\033[0m")
elif str(lang) == ' ' and str(lang)[-2:] == ' 1':
try:
num = int(''.join(list_01)) + int(''.join(list_01))
print(str(num))
except:
print("\033Can't calculate\033[0m")
elif str(lang) == ' ' and str(lang)[-2:] == ' 2':
try:
num = int(''.join(list_01)) - int(''.join(list_01))
print(str(num))
except:
print("\033Can't calculate\033[0m")
elif str(lang) == ' ' and str(lang)[-2:] == ' 3':
try:
num = int(''.join(list_01)) * int(''.join(list_01))
print(str(num))
except:
print("\033Can't calculate\033[0m")
elif str(lang) == ' ' and str(lang)[-2:] == ' 4':
try:
num = int(''.join(list_01)) / int(''.join(list_01))
print(str(num))
except:
print("\033Can't calculate\033[0m")
else:
print("\033Invalidity\033[0m")
elif str(lang) == 'kill' and sR == '':
system('cls')
print('\033[31mAdministrator:\033[0m', end='')
print('You died!')
time.sleep(2)
exit()
elif sR == 'reboot':
if sR == '':
system('cls')
if exists('Minecraft_Command.exe') == True:
system('start Minecraft_Command.exe')
else:
system('start Minecraft_Command.py')
exit()
elif sR == ' ':
print("\033The " + "'" + str(lang) + "'" +" command does not exist LABEL\033[0m")
else:
print("\033The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
elif sR == 'error':
if sR == ' ':
print("\033The " + "'" + str(lang) + "'" +" command does not exist LABEL\033[0m")
elif sR == '':
list_05 = ['不存在此标签或命令',
'无法计算',
'无效',
'未知错误',
'存在多余空格',
'数值过大',
'储存加密字符最大只有5位',
'' + error8,
'' + error9]
for line in list_05:
print(line)
time.sleep(0.02)
else:
print("\033The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
else:
print("\033The " + "'" + str(lang) + "'" +" command does not exist\033[0m")
elif str(lang) == '':
pass
else:
if '§k' in sR or '§m' in sR:
print('\033Please 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
怎末没人啊? 真的一个人也没有? 有人的啊 @鸡蛋. 你算是支持了jidan163
页: [1]