# load_plugins.py -rw-r--r-- 710 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
from json import load
from hashlib import sha256

print('Loading server...')

with open('config.json', 'r') as file:
    config = load(file)

if not os.path.isdir('plugins'):
    os.mkdir('plugins')

if not os.path.isfile('server.jar'):
    os.system(f'wget -O server.jar {config["server"]}')

print('Loaded server!')

print('Loading plugins...')

os.chdir('plugins')

if os.path.isfile('downloading.jar'):
    os.remove('downloading.jar')

for i in config['plugins']:
    h = sha256(i.encode()).hexdigest()[:8]
    if not os.path.isfile(f'{h}.jar'):
        os.system(f'wget \'{i}\' -O downloading.jar')
        os.rename('downloading.jar', f'{h}.jar')

os.chdir('..')

print('Loaded all plugins!')