Skip to content

Commit

Permalink
switch case!
Browse files Browse the repository at this point in the history
- yes ik, this should have always been implemented (dont bully me)
  • Loading branch information
SirDank committed Feb 20, 2024
1 parent 0b23364 commit 056f069
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 341 deletions.
13 changes: 6 additions & 7 deletions __modules__/dank.browser-backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,21 @@ def main():
choice = input(clr(" > Enter choice: ") + red)
if choice.isdigit() and int(choice) > 0 and int(choice) <= int(len(browsers)):
choice = browsers[int(choice)-1]; break
else: rm_line()
rm_line()

#print("")
#while True:
# password = input(clr(" > Enter backup password: ") + red)
# if password: break
# else: rm_line()
# rm_line()

print("")
while True:
compression_level = input(clr(f" > {translate('Compression level (Fast/Best)')} [1/2]: ") + red).lower()
if compression_level in ('1', 'fast'):
compression_level = 0; break
elif compression_level in ('2', 'best'):
compression_level = 9; break
else: rm_line()
match compression_level:
case '1' | 'fast': compression_level = 0; break
case '2' | 'best': compression_level = 9; break
rm_line()

# backup

Expand Down
39 changes: 18 additions & 21 deletions __modules__/dank.chatroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def chatroom_login():
if len(username.replace(' ','')) < 3:
err_msg = f" [{red}too short!]"
rm_line(); rm_line(); continue
elif len(username.strip()) > 15:
if len(username.strip()) > 15:
err_msg = f" [{red}too long!]"
rm_line(); rm_line(); continue
err_msg = ""
Expand All @@ -48,28 +48,25 @@ def chatroom_login():
try: response = session.post(url, headers=headers, data=data); break
except: input(clr("\n > Failed to create user! Make sure you are connected to the internet! Press [ENTER] to try again... ",2))

if response.status_code == 400: # failed to create user
err_msg = f" [{red}{response.content.decode()}]"
rm_line(); rm_line()
elif response.status_code == 401: # unauthorized
err_msg = f" [{red}Unauthorized! Try again in a minute!]"
rm_line(); rm_line()
elif response.status_code == 200: # successfully created user
cls(); print(clr(align(f"\n<---|[ Welcome [{username}]! ]|--->\n")))
break
match response.status_code:
case 400: # failed to create user
err_msg = f" [{red}{response.content.decode()}]"
rm_line(); rm_line()
case 401: # unauthorized
err_msg = f" [{red}Unauthorized! Try again in a minute!]"
rm_line(); rm_line()
case 200: # successfully created user
cls(); print(clr(align(f"\n<---|[ Welcome [{username}]! ]|--->\n")))
break
break

# user already registered

if response.status_code == 200:
username = response.content.decode()
cls(); print(clr(align(f"\n<---|[ Welcome Back [{username}]! ]|--->\n")))
break

# unauthorized

if response.status_code == 401:
cls(); input(clr("\n > Unauthorized! Try again in a minute! Press [ENTER] to try again... ",2))
match response.status_code:
case 200: # user already registered
username = response.content.decode()
cls(); print(clr(align(f"\n<---|[ Welcome Back [{username}]! ]|--->\n")))
break
case 401: # unauthorized
cls(); input(clr("\n > Unauthorized! Try again in a minute! Press [ENTER] to try again... ",2))

def chat_grabber():

Expand Down
35 changes: 17 additions & 18 deletions __modules__/dank.game.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,24 +208,23 @@ def create_entity(pos, vertices):

if _ > leaves_level_start:

if leaves_level_current == 1:

back_2 = entity.back + entity.back
forward_2 = entity.forward + entity.forward
left_2 = entity.left + entity.left
right_2 = entity.right + entity.right

for _pos in [entity.back + left_2, left_2, entity.forward + left_2, back_2 + entity.left, forward_2 + entity.left, back_2, forward_2, back_2 + entity.right, forward_2 + entity.right, entity.back + right_2, right_2, entity.forward + right_2]:
entity = Entity(model="cube", texture=tree_leaves, position=next_pos + _pos, rotation=(x_rot,y_rot,z_rot), ignore=True)
entity.collision = False
terrain[pos]['entities'].append(entity)

elif leaves_level_current == 2:

for _pos in [entity.back + entity.left, entity.left, entity.forward + entity.left, entity.back, entity.forward, entity.back + entity.right, entity.right, entity.forward + entity.right]:
entity = Entity(model="cube", texture=tree_leaves, position=next_pos + _pos, rotation=(x_rot,y_rot,z_rot), ignore=True)
entity.collision = False
terrain[pos]['entities'].append(entity)
match leaves_level_current:
case 1:
back_2 = entity.back + entity.back
forward_2 = entity.forward + entity.forward
left_2 = entity.left + entity.left
right_2 = entity.right + entity.right

for _pos in [entity.back + left_2, left_2, entity.forward + left_2, back_2 + entity.left, forward_2 + entity.left, back_2, forward_2, back_2 + entity.right, forward_2 + entity.right, entity.back + right_2, right_2, entity.forward + right_2]:
entity = Entity(model="cube", texture=tree_leaves, position=next_pos + _pos, rotation=(x_rot,y_rot,z_rot), ignore=True)
entity.collision = False
terrain[pos]['entities'].append(entity)

case 2:
for _pos in [entity.back + entity.left, entity.left, entity.forward + entity.left, entity.back, entity.forward, entity.back + entity.right, entity.right, entity.forward + entity.right]:
entity = Entity(model="cube", texture=tree_leaves, position=next_pos + _pos, rotation=(x_rot,y_rot,z_rot), ignore=True)
entity.collision = False
terrain[pos]['entities'].append(entity)

leaves_level_current += 1

Expand Down
14 changes: 8 additions & 6 deletions __modules__/dank.minecraft-server-builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@ def main_one():
print("")
while True:
cracked = input(clr(f" > {translate('Allow Cracked Players?')} [ y / n ]: ") + red).lower()
if 'y' in cracked: cracked = True; break
if 'n' in cracked: cracked = False; break
match cracked:
case 'y': cracked = True; break
case 'n': cracked = False; break
rm_line()

print("")
while True:
install_Via = input(clr(f" > {translate('Download ViaVersion & ViaBackwards?')} [ y / n ]: ") + red).lower()
if 'y' in install_Via: install_Via = True; break
if 'n' in install_Via: install_Via = False; break
match install_Via:
case 'y': install_Via = True; break
case 'n': install_Via = False; break
rm_line()

# setting extra flags
Expand All @@ -131,7 +133,7 @@ def main_one():
patched = True
break

if not patched:
if not patched:
for _ in ("1.7", "1.8", "1.9", "1.10", "1.11"):
if version.startswith(_):
extra_flag = "-Dlog4j.configurationFile=log4j2_17-111.xml "
Expand Down Expand Up @@ -793,7 +795,7 @@ def config_updater(path):
if input(clr(f"\n > {translate('Open port forwarding tutorial on youtube?')} [ y / n ]: ") + red).lower() == "y":
sys_open('https://youtu.be/X75GbRaGzu8')

tmp_path = f'{dir_name}\\autoplug\\updater.yml'
tmp_path = f'{dir_name}\\autoplug\\updater.yml'
string = f'''
- {translate(f'If you would like to transfer the server to a linux system and run it there, set "build-id: 0" inside "{tmp_path}"')}
Expand Down
21 changes: 11 additions & 10 deletions __modules__/dank.minecraft-server-scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def check(ip, server):

if server_type == "java":
to_print = f"{ip} | java | {status.version.name} | {status.players.online}/{status.players.max} online | {int(status.latency)}ms | {server_info} | {status.description}".replace('\n',' ').replace('ü','u')
elif server_type == "bedrock":
else:
to_print = f"{ip} | bedrock | {status.version.name} | {status.gamemode} | Map: {status.map_name} | {status.players.online}/{status.players.max} online | {int(status.latency)}ms | {server_info} | {status.motd.raw}".replace('\n',' ')

for _ in ('§0', '§1', '§2', '§3', '§4', '§5', '§6', '§7', '§8', '§9', '§a', '§b', '§c', '§d', '§e', '§f', '§l', '§n', '§o', '§m', '§k', '§r'):
Expand Down Expand Up @@ -130,22 +130,23 @@ def main():
title("𝚍𝚊𝚗𝚔.𝚖𝚒𝚗𝚎𝚌𝚛𝚊𝚏𝚝-𝚜𝚎𝚛𝚟𝚎𝚛-𝚜𝚌𝚊𝚗𝚗𝚎𝚛"); banner = '\n\n _ _ \n | | | | \n _ | | ____ ____ | | _ ____ ____ ___ ___ ____ ____ ____ ____ ____ ____ \n / || |/ _ | _ \\| | / ) | \\ / ___|___)___)/ ___) _ | _ \\| _ \\ / _ )/ ___)\n( (_| ( ( | | | | | |< ( _| | | ( (___ |___ ( (__( ( | | | | | | | ( (/ /| | \n \\____|\\_||_|_| |_|_| \\_|_)_|_|_|\\____) (___/ \\____)_||_|_| |_|_| |_|\\____)_| \n \n'
cls(); print(align(clr(banner,4,colours=(red, red_dim))))
print(clr(f"\n - Java Server List: https://dank-site.onrender.com/minecraft-java-servers\n\n - Bedrock Server List: https://dank-site.onrender.com/minecraft-bedrock-servers\n\n - {translate('You can use the above links to get a list of servers that have been found by the users of this tool')}!"))
choice = input(clr("\n - 1: Open Java Server List | 2: Open Bedrock Server List | ENTER: Skip\n\n > Choice [1/2/ENTER]: ") + red)
if choice == "1": os.system("start https://dank-site.onrender.com/minecraft-java-servers")
elif choice == "2": os.system("start https://dank-site.onrender.com/minecraft-bedrock-servers")
match input(clr("\n - 1: Open Java Server List | 2: Open Bedrock Server List | ENTER: Skip\n\n > Choice [1/2/ENTER]: ") + red):
case "1": os.system("start https://dank-site.onrender.com/minecraft-java-servers")
case "2": os.system("start https://dank-site.onrender.com/minecraft-bedrock-servers")

cls(); print(align(clr(banner,4,colours=(red, red_dim))))
print(clr(f"\n - {translate('Start with 100 threads and note the performance impact')}.\n\n - {translate('Generally should be smooth upto 500 threads, you might notice some performance impact above this value')}!\n\n - {translate('Test it for the first time with 50000 IPs, it will take a few seconds to generate')}."))

print("")
while True:
server_type = input(clr(" > Server Type [java/bedrock]: ") + red).lower()
if server_type == "java":
port = 25565
break
if server_type == "bedrock":
port = 19132
break
match server_type:
case "java":
port = 25565
break
case "bedrock":
port = 19132
break
rm_line()

print("")
Expand Down
44 changes: 23 additions & 21 deletions __modules__/dank.winget.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ def handle_response(cmd, results, mode):
results['mode'] = mode; print()
console.print(Panel(title="[red1]> [bright_white][b]R E S U L T S[/b] [red1]<", title_align="center", renderable=Columns(user_renderables, expand=True), style="red", expand=True))

if mode == 'search':
print(clr("\n - Type number to install.\n"))
elif mode == 'installed':
print(clr("\n - Type number to display info.\n"))
elif mode == 'updates':
print(clr("\n - Type number to update.\n"))
match mode:
case 'search':
print(clr("\n - Type number to install.\n"))
case 'installed':
print(clr("\n - Type number to display info.\n"))
case 'updates':
print(clr("\n - Type number to update.\n"))

def print_info(id):
cmd = subprocess.run(['winget', 'show', '--id', id], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down Expand Up @@ -109,25 +110,26 @@ def main():
cmd = int(cmd)
if cmd in results:

if results['mode'] == 'search':
if input(clr("\n > Display info? [y/n]: ") + green_bright).lower().startswith('y'):
match results['mode']:
case 'search':
if input(clr("\n > Display info? [y/n]: ") + green_bright).lower().startswith('y'):
print_info(results[cmd]['id'])
else: rm_line(); rm_line()
if input(clr("\n > Install? [y/n]: ") + green_bright).lower().startswith('y'):
print()
os.system(f"winget install --interactive --id {results[cmd]['id']}")
print()
else: rm_line()

case 'installed':
print_info(results[cmd]['id'])
else: rm_line(); rm_line()
if input(clr("\n > Install? [y/n]: ") + green_bright).lower().startswith('y'):

case 'updates':
print()
os.system(f"winget install --interactive --id {results[cmd]['id']}")
os.system(f"winget upgrade --interactive --id {results[cmd]['id']}")
print()
else: rm_line()

elif results['mode'] == 'installed':
print_info(results[cmd]['id'])

elif results['mode'] == 'updates':
print()
os.system(f"winget upgrade --interactive --id {results[cmd]['id']}")
print()

else: rm_line()
case _: rm_line()
else: rm_line()
else: rm_line()

Expand Down
Loading

0 comments on commit 056f069

Please sign in to comment.