Skip to content

Commit ef74462

Browse files
committed
Interim restructuring
1 parent 74f1aa7 commit ef74462

File tree

12 files changed

+790
-834
lines changed

12 files changed

+790
-834
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ popd
6363
popd
6464
echo "Installation finished with no errors."
6565
```
66+
67+
## Other Important Things
68+
69+
ATTENTION - If you use an old version of this software, it might ask you for a "product key." This system has been retired, so it may confuse you. Please paste the code `4p6jgtnatqj5svb4` if it asks you for one.

changelog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
- Move self-made libraries to src
55
- Unzip libraries
66
- Move other files in src directory to scripts
7+
- Remove all references to anything monetary
8+
- Including ads, product keys, etc
9+
- Fix bug where screen spam would occur if API server was down
710
1.52.2:
811
- Add the ability to change the server's java installation
912
- Fix bugs

dofile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
echo "INFO: Shortening source file"
6262
mkdir dist
6363
#Copy code and add exec permissions
64-
cp src/craftserversetup.py dist/craftserversetup.py
64+
cp src/main.py dist/craftserversetup.py
6565
if [ "$1" = "nominify" ]; then
6666
echo INFO: Skipping script minification as you requested.
6767
else
@@ -82,7 +82,7 @@
8282
echo "INFO: Installing libraries"
8383
cp -r ./* $LIBDIR
8484
cp ../src/*.py $LIBDIR
85-
rm $LIBDIR/craftserversetup.py
85+
rm $LIBDIR/main.py
8686
#Do not copy executable to library dir
8787
popd >/dev/null
8888
if [ ! -d $ICONDIR ]; then
@@ -175,9 +175,9 @@
175175
mkdir dist
176176
#Copy code and add exec permissions
177177
#Shorten using minifier
178-
cp src/craftserversetup.py dist/craftserversetup.py
178+
cp src/main.py dist/craftserversetup.py
179179

180-
tar -xf lib/python_minifier.tar.xz -C scripts
180+
cp -r lib/python_minifier/ scripts
181181
python3 scripts/minify.py dist/craftserversetup.py dist/craftserversetup.py.tmp
182182
rm -rf scripts/python_minifier
183183
mv dist/craftserversetup.py.tmp dist/craftserversetup.py
@@ -189,11 +189,9 @@
189189

190190
pushd lib >/dev/null
191191
#Copy prebuilt python library
192-
for file in *.xz
193-
do
194-
tar -xf $file -C "../$DEBLIBFOLDER" #Extract library to custom library path
195-
done
196-
cp *.py "../$DEBLIBFOLDER" #Copy remaining custom librariespa
192+
cp -r ./* ../$DEBLIBFOLDER
193+
cp ../src/*.py "../$DEBLIBFOLDER" #Copy remaining custom librariespa
194+
rm ../$DEBLIBFOLDER/main.py
197195
popd >/dev/null
198196

199197
#Move desktop and icon files
@@ -269,7 +267,6 @@
269267
echo "Copying Files"
270268
mkdir -p $FDIR
271269
mkdir $FDIR/installer
272-
cp lib/*.py $FDIR
273270
cp src/*.py $FDIR
274271
cp assets/mc.ico $FDIR
275272
cp assets/*.bmp $FDIR
@@ -279,7 +276,7 @@
279276

280277
read -p "Write app version: " version
281278

282-
cd src
279+
cd scripts
283280
#PARANV="${version//./,}"
284281
PARANV="$(python3 version_fixer.py $version)"
285282
#echo "--> SAFE V IS $PARANV"
@@ -297,12 +294,15 @@
297294
sed -i -e '42d' crss-wine.iss
298295
sed -i "42iOutputBaseFilename=CraftServerSetup-$version-installer" crss-wine.iss
299296

297+
298+
cp vf.txt $FDIR
299+
cp crss-wine.iss $FDIR
300+
300301
cd ..
301-
cp scripts/vf.txt $FDIR
302-
cp scripts/crss-wine.iss $FDIR
303302

304303
echo "Compiling stage 1"
305304
pushd $FDIR
305+
mv main.py craftserversetup.py #Dodgy workaround
306306
wine $PYINSTALLER --icon=mc.ico --version-file=vf.txt -y craftserversetup.py
307307
echo "Waiting 5 seconds..."
308308
sleep 5

scripts/crss-wine.iss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44

5-
#define MyAppVersion "1.52.2"
5+
#define MyAppVersion "1.52.5"
66
;The above line must be on line 5!
77

88

@@ -39,7 +39,7 @@ OutputDir=C:\python\crss\installer
3939

4040

4141

42-
OutputBaseFilename=CraftServerSetup-1.52.2-installer
42+
OutputBaseFilename=CraftServerSetup-1.52.5-installer
4343
;The above line MUST be on line 42
4444

4545

scripts/vf.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ VSVersionInfo(
77
ffi=FixedFileInfo(
88
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
99
# Set not needed items to zero 0. Must always contain 4 elements.
10-
filevers=(1,52,2,0),
11-
prodvers=(1,52,2,0),
10+
filevers=(1,52,5,0),
11+
prodvers=(1,52,5,0),
1212
# Contains a bitmask that specifies the valid bits 'flags'r
1313
mask=0x3f,
1414
# Contains a bitmask that specifies the Boolean attributes of the file.
@@ -32,12 +32,12 @@ VSVersionInfo(
3232
u'040904B0',
3333
[StringStruct(u'CompanyName', u'Enderbyte Programs'),
3434
StringStruct(u'FileDescription', u'Minecraft Server Maker'),
35-
StringStruct(u'FileVersion', u'1.52.2'),
35+
StringStruct(u'FileVersion', u'1.52.5'),
3636
StringStruct(u'InternalName', u'craftserversetup'),
3737
StringStruct(u'LegalCopyright', u'© 2023-2024 Enderbyte Programs. Some rights reserved.'),
3838
StringStruct(u'OriginalFilename', u'craftserversetup.exe'),
3939
StringStruct(u'ProductName', u'CraftServerSetup'),
40-
StringStruct(u'ProductVersion', u'1.52.2')])
40+
StringStruct(u'ProductVersion', u'1.52.5')])
4141
]),
4242
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
4343
]

src/appdata.py

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
from staticflags import *
2+
import random
3+
import json
4+
import gzip
5+
6+
def compatibilize_appdata(data:dict) -> dict:
7+
"""This function ensures that appdata is brought up to the latest version. It is compatible to the beginning."""
8+
try:
9+
cver = data["version"]
10+
except:
11+
data["version"] = APP_APPDATA_VERSION
12+
13+
if not "language" in data:
14+
data["language"] = None
15+
16+
if not "settings" in data:
17+
data["settings"] = {
18+
19+
"transitions":{
20+
"display" : "Show Transitions?",
21+
"type" : "bool",
22+
"value" : True
23+
},
24+
"oldmenu":{
25+
"name" : "oldmenu",
26+
"display" : "Use legacy style menus?",
27+
"type" : "bool",
28+
"value" : False
29+
}
30+
}
31+
elif type(data["settings"]) == list:
32+
#Update data
33+
data["settings"] = {
34+
35+
"transitions":{
36+
"display" : "Show Transitions?",
37+
"type" : "bool",
38+
"value" : data["settings"][1]["value"]
39+
},
40+
"oldmenu":{
41+
"name" : "oldmenu",
42+
"display" : "Use legacy style menus?",
43+
"type" : "bool",
44+
"value" : data["settings"][2]["value"]
45+
}
46+
47+
}
48+
if not "showprog" in data["settings"]:
49+
data["settings"]["showprog"] = {
50+
"name" : "showprog",
51+
"display" : "Show progress bar startup?",
52+
"type" : "bool",
53+
"value":False
54+
}
55+
if not "editor" in data["settings"]:
56+
data["settings"]["editor"] = {
57+
"name" : "editor",
58+
"display" : "Text Editor",
59+
"type" : "str",
60+
"value" : "/usr/bin/editor %s"
61+
}
62+
if not "autoupdate" in data["settings"]:
63+
data["settings"]["autoupdate"] = {
64+
"name":"autoupdate",
65+
"display":"Update automatically",
66+
"type":"bool",
67+
"value":True
68+
}
69+
70+
if not "idata" in data:
71+
data["idata"] = {
72+
"MOTD" : "No Message Yet",
73+
"dead" : {
74+
"active" : False,
75+
"message" : "N/A"
76+
}
77+
}
78+
svri = 0
79+
for svr in data["servers"]:
80+
if type(svr) is not dict:
81+
del svr
82+
continue#I don't know how this happened
83+
if not "id" in svr:
84+
data["servers"][svri]["id"] = random.randint(1111,9999)
85+
if not "settings" in svr:
86+
data["servers"][svri]["settings"] = {}#New empty settings
87+
if data["servers"][svri]["settings"] == {}:
88+
data["servers"][svri]["settings"] = {"launchcommands":[],"exitcommands":[]}
89+
if not "legacy" in data["servers"][svri]["settings"]:
90+
data['servers'][svri]["settings"]["legacy"] = True
91+
if not "backupdir" in svr:
92+
data['servers'][svri]["backupdir"] = SERVERS_BACKUP_DIR + os.sep + str(data['servers'][svri]["id"])
93+
if data["servers"][svri]["software"] == 0:
94+
data["servers"][svri]["software"] = 5#v1.48
95+
96+
#1.49.1
97+
if not "flags" in svr["settings"]:
98+
data["servers"][svri]["settings"]["flags"] = ""
99+
100+
svri += 1
101+
102+
svk = 0
103+
for ji in data["javainstalls"]:
104+
data["javainstalls"][svk] = {"path":ji["path"].replace("\\","/").replace("//","/"),"ver":ji["ver"]}
105+
106+
svk += 1
107+
if not "license" in data:
108+
data["license"] = False
109+
110+
if not "backupprofiles" in data:
111+
#Works with glob
112+
data["backupprofiles"] = {
113+
"everything" : {
114+
"include" : [
115+
"#SD/**"
116+
],
117+
"exclude" : [
118+
119+
]
120+
}
121+
}
122+
123+
#1.49
124+
if not "reswarn" in data["settings"]:
125+
data["settings"]["reswarn"] = {
126+
"name" :"reswarn",
127+
"display" : "Give warnings for high-resource operations",
128+
"type" : "bool",
129+
"value" : True
130+
}
131+
132+
#1.53
133+
if "pkd" in data:
134+
del data["productKey"]
135+
del data["pkd"]
136+
137+
return data
138+
139+
__DEFAULTAPPDATA__ = {
140+
"servers" : [
141+
142+
],
143+
"hasCompletedOOBE" : False,
144+
"version" : APP_APPDATA_VERSION,
145+
"javainstalls" : [
146+
147+
],
148+
149+
"settings" : {
150+
"transitions":{
151+
"display" : "Show Transitions?",
152+
"type" : "bool",
153+
"value" : False
154+
},
155+
"oldmenu":{
156+
"name" : "oldmenu",
157+
"display" : "Use legacy style menus?",
158+
"type" : "bool",
159+
"value" : False
160+
},
161+
"showprog" : {
162+
"name" : "showprog",
163+
"display" : "Show progress bar on startup?",
164+
"type" : "bool",
165+
"value" : False
166+
},
167+
"reswarn" : {
168+
"name" :"reswarn",
169+
"display" : "Give warnings for high-resource operations",
170+
"type" : "bool",
171+
"value" : True
172+
}
173+
},
174+
"idata" : {
175+
"MOTD" : "No Message Yet",
176+
"dead" : {
177+
"active" : False,
178+
"message" : "N/A"
179+
}
180+
},
181+
"license" : False,
182+
"language" : None
183+
}
184+
185+
UUID_INDEX:dict = {}
186+
187+
def setup_appdata():
188+
global APPDATA
189+
global APPDATAFILE
190+
global UUIDFILE
191+
global UUID_INDEX
192+
APPDATAFILE = APPDATADIR+"/config.json"
193+
if not os.path.isfile(APPDATAFILE):
194+
with open(APPDATAFILE,"w+") as f:
195+
f.write(json.dumps(__DEFAULTAPPDATA__))
196+
APPDATA = __DEFAULTAPPDATA__
197+
else:
198+
try:
199+
with open(APPDATAFILE) as f:
200+
APPDATA = json.load(f)
201+
except:
202+
with open(APPDATAFILE,"w+") as f:
203+
f.write(json.dumps(__DEFAULTAPPDATA__))
204+
APPDATA = __DEFAULTAPPDATA__
205+
APPDATA = compatibilize_appdata(APPDATA)
206+
207+
UUIDFILE = APPDATADIR+"/uuidindex.json.gz"
208+
209+
if not os.path.isfile(UUIDFILE):
210+
with open(UUIDFILE,"wb+") as f:
211+
f.write(gzip.compress(json.dumps({}).encode()))
212+
else:
213+
try:
214+
with open(UUIDFILE,"rb") as f:
215+
UUID_INDEX = json.loads(gzip.decompress(f.read()))
216+
except:
217+
with open(UUIDFILE,"wb+") as f:
218+
f.write(gzip.compress(json.dumps({}).encode()))
219+
220+
def updateappdata():
221+
222+
global APPDATAFILE
223+
global UUID_INDEX
224+
global UUIDFILE
225+
with open(APPDATAFILE,"w+") as f:
226+
f.write(json.dumps(APPDATA,indent=2))
227+
with open(UUIDFILE,"wb+") as f:
228+
f.write(gzip.compress(json.dumps(UUID_INDEX).encode()))#Write compressed file

0 commit comments

Comments
 (0)