Skip to content

Commit 2f73a09

Browse files
committed
1.54.5
1 parent 1e1300b commit 2f73a09

6 files changed

Lines changed: 91 additions & 49 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
craftserversetup.tar.xz
33
*.deb
44
*.zst
5-
deb/usr/
5+
deb/
66
dev/
77
dist/
88
*.pyc

assets/control

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Package: craftserversetup
2-
Version: 1.54.4
2+
Version: 1.54.5
33
Maintainer: Enderbyte Programs <enderbyte09@gmail.com>
44
Homepage: https://github.com/Enderbyte-Programs/CraftServerSetup
55
Architecture: all
66
Depends: python3
7-
Installed-Size: 3848
7+
Installed-Size: 3852
88
Description: A TUI Minecraft Server Maker
99
CraftServerSetup is a computer program to make and manage many different types of Minecraft server. CraftServerSetup supports vanilla, spigot, purpur, and paper formats. It is a user-friendly command line app so it can be installed on servers and used over SSH.
1010

changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.54.5:
2+
- Correct serious bug where some areas would treat server software = 0 to mean bedrock, others Unknown
3+
- Fix bedrock link getting algorithm
4+
- Unregistered directories no longer get deleted
5+
- Fix several serious bugs in bedrock
16
1.54.4:
27
- Fix bug where exec directory would be printed to the screen
38
- Fix bug where new users could not start

src/bedrocklinks.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""
2+
A program to handle link fetching for bedrock
3+
"""
4+
import requests
5+
import cursesplus
6+
import urllib.request
7+
import staticflags
8+
import uicomponents
9+
import os
10+
import zipfile
11+
import dirstack
12+
13+
BEDROCK_REQUEST = "https://net-secondary.web.minecraft-services.net/api/v1.0/download/links"
14+
15+
def get_raw_links() -> dict:
16+
r = requests.get(BEDROCK_REQUEST).json()
17+
18+
for link in r["result"]["links"]:
19+
r[link["downloadType"]] = link["downloadUrl"]
20+
21+
return r
22+
23+
def get_links() -> list[str]:
24+
"""Return a list[normal, preview] for the OS the user is on"""
25+
26+
raw_links = get_raw_links()
27+
if staticflags.ON_WINDOWS:
28+
return [raw_links["serverBedrockWindows"],raw_links["serverBedrockPreviewWindows"]]
29+
else:
30+
return [raw_links["serverBedrockLinux"],raw_links["serverBedrockPreviewLinux"]]
31+
32+
def download_bedrock_software(installdir:str,selectedlink:str) -> None:
33+
urllib.request.urlretrieve(selectedlink,installdir+"/server.zip")
34+
dirstack.pushd(installdir)#Make install easier
35+
zf = zipfile.ZipFile(installdir+"/server.zip")
36+
zf.extractall(installdir)
37+
zf.close()
38+
os.remove(installdir+"/server.zip")
39+
if not staticflags.ON_WINDOWS:
40+
os.chmod(installdir+"/bedrock_server",0o777)
41+
42+
def ui_download_bedrock_software(stdscr,p:cursesplus.ProgressBar,installdir:str) -> list:
43+
"""Returns link, ispreview"""
44+
mx = uicomponents.menu(stdscr,["Latest Bedrock Version","Latest Preview Bedrock Version"],"Please select a version")
45+
l2d = get_links()[mx]
46+
p.step("Downloading server file")
47+
urllib.request.urlretrieve(l2d,installdir+"/server.zip")
48+
p.step("Extracting server file")
49+
dirstack.pushd(installdir)#Make install easier
50+
zf = zipfile.ZipFile(installdir+"/server.zip")
51+
zf.extractall(installdir)
52+
zf.close()
53+
p.step("Removing excess files")
54+
os.remove(installdir+"/server.zip")
55+
p.step("Preparing exec")
56+
if not staticflags.ON_WINDOWS:
57+
os.chmod(installdir+"/bedrock_server",0o777)
58+
59+
return [l2d,mx == 1]

src/dirstack.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import os
22

33
DIR_LIST = [os.getcwd()]
4+
5+
def clean_dir_list():
6+
global DIR_LIST
7+
DIR_LIST = [d for d in DIR_LIST if os.path.isdir(d)]
8+
49
def pushd(directory:str):
510
global DIR_LIST
611
os.chdir(directory)
712
DIR_LIST.insert(0,directory)
813
def popd():
914
global DIR_LIST
10-
DIR_LIST.pop(0)
11-
os.chdir(DIR_LIST[0])
15+
try:
16+
DIR_LIST.pop(0)
17+
18+
os.chdir(DIR_LIST[0])
19+
except:
20+
DIR_LIST = [os.getcwd()]
21+
os.chdir(DIR_LIST[0])

src/main.py

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#type: ignore
33
#Early load variables
44
APP_VERSION = 1#The API Version.
5-
APP_UF_VERSION = "1.54.4"
5+
APP_UF_VERSION = "1.54.5"
66
#The semver version
77
print(f"CraftServerSetup by Enderbyte Programs v{APP_UF_VERSION} (c) 2023-2025, some rights reserved")
88

@@ -103,6 +103,7 @@
103103
import renaminghandler #MC rename namdler
104104
import texteditor #Text editor handler
105105
import logutils #Load logs
106+
import bedrocklinks #Load bedrock files
106107

107108
del WINDOWS
108109
del DEBUG
@@ -776,31 +777,10 @@ def setup_bedrock_server(stdscr):
776777
S_INSTALL_DIR = SERVERSDIR+"/"+servername
777778
p = cursesplus.ProgressBar(stdscr,10,cursesplus.ProgressBarTypes.SmallProgressBar,cursesplus.ProgressBarLocations.BOTTOM,message="Setting up bedrock server")
778779
p.step("Getting download information")
779-
availablelinks = [g for g in extract_links_from_page(requests.get("https://www.minecraft.net/en-us/download/server/bedrock",headers={"User-Agent":MODRINTH_USER_AGENT}).text) if "bedrock" in g]
780-
link_win_normal = get_by_list_contains(availablelinks,"win/")
781-
link_lx_normal = get_by_list_contains(availablelinks,"linux/")
782-
link_win_preview = get_by_list_contains(availablelinks,"win-preview/")
783-
link_lx_preview = get_by_list_contains(availablelinks,"linux-preview/")
784-
if ON_WINDOWS:
785-
availablelinks = [link_win_normal,link_win_preview]
786-
else:
787-
availablelinks = [link_lx_normal,link_lx_preview]
788-
789-
l2d = availablelinks[uicomponents.menu(stdscr,["Latest Version","Latest Preview Version"],"Please select a version")]
790-
p.step("Downloading server file")
791-
urllib.request.urlretrieve(l2d,S_INSTALL_DIR+"/server.zip")
792-
p.step("Extracting server file")
793-
dirstack.pushd(S_INSTALL_DIR)#Make install easier
794-
zf = zipfile.ZipFile(S_INSTALL_DIR+"/server.zip")
795-
zf.extractall(S_INSTALL_DIR)
796-
zf.close()
797-
p.step("Removing excess files")
798-
os.remove(S_INSTALL_DIR+"/server.zip")
799-
p.step("Preparing exec")
800-
if not ON_WINDOWS:
801-
os.chmod(S_INSTALL_DIR+"/bedrock_server",0o777)
802-
780+
dlinfo = bedrocklinks.ui_download_bedrock_software(stdscr,p,S_INSTALL_DIR)
803781

782+
l2d:str = dlinfo[0]
783+
804784
sd = {
805785
"name" : servername,
806786
"javapath" : "",
@@ -817,7 +797,7 @@ def setup_bedrock_server(stdscr):
817797
},
818798
"script" : S_INSTALL_DIR+"/bedrock_server",
819799
"linkused" : l2d,
820-
"ispreview" : l2d == link_lx_preview or l2d == link_win_preview
800+
"ispreview" : dlinfo[1]
821801
}
822802
try:
823803
shutil.copyfile(ASSETSDIR+"/defaulticon.png",S_INSTALL_DIR+"/server-icon.png")
@@ -834,7 +814,7 @@ def setup_bedrock_server(stdscr):
834814
bedrock_manage_server(stdscr,servername,appdata.APPDATA["servers"].index(sd)+1)
835815

836816
def bedrock_do_update(stdscr,chosenserver,availablelinks):
837-
l2d = availablelinks[uicomponents.menu(stdscr,["Latest Version","Latest Preview Version"],"Please select a version")]
817+
l2d = bedrocklinks.get_links()[uicomponents.menu(stdscr,["Latest Version","Latest Preview Version"],"Please select a version")]
838818
#Remember: Don't overwrite server.properties or allowlist.json
839819
p = cursesplus.ProgressBar(stdscr,5)
840820
cursesplus.displaymsg(stdscr,["Updating server","Please be patient."],False)
@@ -879,22 +859,16 @@ def bedrock_do_update(stdscr,chosenserver,availablelinks):
879859
def bedrock_manage_server(stdscr,servername,chosenserver):
880860
curver = appdata.APPDATA["servers"][chosenserver-1]["linkused"]
881861
cursesplus.displaymsg(stdscr,["Checking for Bedrock updates"],False)
882-
availablelinks = [g for g in extract_links_from_page(requests.get("https://www.minecraft.net/en-us/download/server/bedrock",headers={"User-Agent":MODRINTH_USER_AGENT}).text) if "bedrock" in g]
883-
link_win_normal = get_by_list_contains(availablelinks,"win/")
884-
link_lx_normal = get_by_list_contains(availablelinks,"linux/")
885-
link_win_preview = get_by_list_contains(availablelinks,"win-preview/")
886-
link_lx_preview = get_by_list_contains(availablelinks,"linux-preview/")
887-
if ON_WINDOWS:
888-
availablelinks = [link_win_normal,link_win_preview]
889-
else:
890-
availablelinks = [link_lx_normal,link_lx_preview]
862+
863+
availablelinks = bedrocklinks.get_links()
891864

892865
if appdata.APPDATA["servers"][chosenserver-1]["ispreview"]:
893866
sel = 1
894867
else:
895868
sel = 0
896869

897870
latestlink = availablelinks[sel]
871+
#cursesplus.messagebox.showinfo(stdscr,[latestlink,curver])
898872
if curver != latestlink:
899873
if cursesplus.messagebox.askyesno(stdscr,["A bedrock update has been detected.","If you don't install it, devices can't connect.","Do you want to install this update?"]):
900874
bedrock_do_update(stdscr,chosenserver,availablelinks)
@@ -1340,12 +1314,6 @@ def prune_servers():
13401314
dirstack.pushd(SERVERSDIR)
13411315
appdata.APPDATA["servers"] = [a for a in appdata.APPDATA["servers"] if os.path.isdir(a["dir"])]
13421316
#Look for unregistered directories
1343-
serverdirs = [f for f in os.listdir(SERVERSDIR) if os.path.isdir(f)]
1344-
registereddirs = [a["dir"] for a in appdata.APPDATA["servers"]]
1345-
for serverdir in serverdirs:
1346-
if not serverdir in registereddirs:
1347-
if not os.path.isfile(serverdir+"/exdata.json") and not os.path.isfile(serverdir+"/server.properties"):
1348-
shutil.rmtree(serverdir)
13491317
dirstack.popd()
13501318
appdata.updateappdata()
13511319

@@ -1707,7 +1675,7 @@ def svr_mod_mgr(stdscr,SERVERDIRECTORY: str,serverversion,servertype):
17071675
cursesplus.messagebox.showerror(stdscr,["This plugin does not have a config file"])
17081676

17091677
def generate_script(svrdict: dict) -> str:
1710-
if svrdict["software"] == 0:
1678+
if svrdict["software"] == 5:
17111679
if ON_WINDOWS:
17121680
__SCRIPT__ = svrdict["dir"]+"/bedrock_server.exe"
17131681
else:
@@ -3278,7 +3246,7 @@ def manage_server(stdscr,_sname: str,chosenserver: int):
32783246

32793247
if appdata.APPDATA["settings"]["transitions"]["value"]:
32803248
cursesplus.transitions.vertical_bars(stdscr)
3281-
if appdata.APPDATA["servers"][chosenserver-1]["software"] == 0:
3249+
if appdata.APPDATA["servers"][chosenserver-1]["software"] == 5:
32823250
bedrock_manage_server(stdscr,_sname,chosenserver)
32833251
return
32843252
#Manager server

0 commit comments

Comments
 (0)