Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Added the abillity to download certain vanilla version #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions mk2/servers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@


class Jar:
def __init__(self, name_long, name_short, url):
def __init__(self, name_long, name_short, url, display=True):
self.name_long = list(name_long)
self.name_short = list(name_short)
self.url = str(url)
self.display = display

for i, l in enumerate(self.name_long):
l = l.replace(' ', '-').lower()
Expand Down Expand Up @@ -108,10 +109,11 @@ def got_results(results):
o = []
m = 0
for r in results:
left = '-'.join(r.name_short)
right = ' '.join(r.name_long)
m = max(m, len(left))
o.append((left, right))
if r.display:
left = '-'.join(r.name_short)
right = ' '.join(r.name_long)
m = max(m, len(left))
o.append((left, right))

for left, right in sorted(o):
listing += " %s | %s\n" % (left.ljust(m), right)
Expand Down
6 changes: 6 additions & 0 deletions mk2/servers/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def work(self):
def handle_data(self, data):
for k, v in json.loads(data)['latest'].iteritems():
self.add(('Vanilla', k.title()), (None, None), '{0}{1}/minecraft_server.{1}.jar'.format(self.base, v))

for version in json.loads(data)['versions']:
self.add(('Vanilla Version', version['id']), ('vanilla', None), '{0}{1}/minecraft_server.{1}.jar'.format(self.base, version['id']), False)

self.add(('Vanilla,', 'Replace [version] with version'), ('vanilla', '[version]'), None)

self.commit()

ref = Vanilla