minecraft-server-creator 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcsc/__init__.py +4 -0
- mcsc/__main__.py +7 -0
- mcsc/config/settings.py +45 -0
- mcsc/config/update_files.py +24 -0
- mcsc/localization/it.py +80 -0
- mcsc/main.py +102 -0
- mcsc/modules/classes.py +115 -0
- mcsc/modules/logger.py +107 -0
- mcsc/modules/pages.py +379 -0
- mcsc/modules/servers/forge.py +175 -0
- mcsc/modules/servers/java.py +13 -0
- mcsc/modules/servers/models.py +430 -0
- mcsc/modules/servers/paper.py +109 -0
- mcsc/modules/servers/utils.py +136 -0
- mcsc/modules/translations.py +47 -0
- mcsc/modules/user_settings.py +144 -0
- mcsc/modules/utils.py +735 -0
- mcsc/static/logo.png +0 -0
- mcsc/static/style.css +249 -0
- mcsc/tasks.py +152 -0
- mcsc/telemetry.py +99 -0
- mcsc/update.py +87 -0
- mcsc/utils.py +30 -0
- minecraft_server_creator-2.0.0.dist-info/METADATA +46 -0
- minecraft_server_creator-2.0.0.dist-info/RECORD +29 -0
- minecraft_server_creator-2.0.0.dist-info/WHEEL +5 -0
- minecraft_server_creator-2.0.0.dist-info/entry_points.txt +2 -0
- minecraft_server_creator-2.0.0.dist-info/licenses/LICENSE +2 -0
- minecraft_server_creator-2.0.0.dist-info/top_level.txt +1 -0
mcsc/static/logo.png
ADDED
|
Binary file
|
mcsc/static/style.css
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/* STUFF */
|
|
2
|
+
/* width */
|
|
3
|
+
::-webkit-scrollbar {
|
|
4
|
+
width: 2px;
|
|
5
|
+
height: 2px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* Track */
|
|
9
|
+
::-webkit-scrollbar-track {
|
|
10
|
+
background: transparent !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Handle */
|
|
14
|
+
::-webkit-scrollbar-thumb {
|
|
15
|
+
background: rgba(255, 255, 255, 0.25);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Handle on hover */
|
|
19
|
+
::-webkit-scrollbar-thumb:hover {
|
|
20
|
+
background: rgba(255, 255, 255, 0.5);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* CLASSES */
|
|
24
|
+
.content {
|
|
25
|
+
color: #ffffff;
|
|
26
|
+
height: 100% !important;
|
|
27
|
+
width: 100% !important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.content-header {
|
|
31
|
+
background-color: transparent;
|
|
32
|
+
backdrop-filter: blur(10px);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.nav-bar {
|
|
36
|
+
color: #ffffff;
|
|
37
|
+
background-color: red;
|
|
38
|
+
margin: 10px;
|
|
39
|
+
border-radius: 10px;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.left-drawer {
|
|
44
|
+
text-align: left !important;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.drawer-button {
|
|
48
|
+
width: 100%;
|
|
49
|
+
border: none !important;
|
|
50
|
+
box-shadow: transparent !important;
|
|
51
|
+
color: inherit !important;
|
|
52
|
+
font-size: inherit;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
outline: none !important;
|
|
55
|
+
border-radius: 10px !important;
|
|
56
|
+
background-color: rgb(70, 70, 70) !important;
|
|
57
|
+
align-items: start !important;
|
|
58
|
+
height: 50px !important;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.drawer-button-primary {
|
|
62
|
+
background-color: rgba(15, 255, 175, 0.726) !important;
|
|
63
|
+
height: 70px !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.close-button {
|
|
67
|
+
background-color: transparent !important;
|
|
68
|
+
border: none !important;
|
|
69
|
+
border-radius: 50%;
|
|
70
|
+
box-shadow: none !important;
|
|
71
|
+
text-shadow: transparent !important;
|
|
72
|
+
color: white !important;
|
|
73
|
+
font-size: 12px !important;
|
|
74
|
+
/* Adjust icon size */
|
|
75
|
+
padding: 8px !important;
|
|
76
|
+
display: flex !important;
|
|
77
|
+
justify-content: center !important;
|
|
78
|
+
align-items: center !important;
|
|
79
|
+
position: absolute !important;
|
|
80
|
+
top: 10px !important;
|
|
81
|
+
right: 10px !important;
|
|
82
|
+
outline: transparent !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.create-server-popup {
|
|
86
|
+
/* height: 80%; */
|
|
87
|
+
width: min-content;
|
|
88
|
+
width: 40%;
|
|
89
|
+
border-radius: 10px !important;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.server-card {
|
|
93
|
+
width: 49%;
|
|
94
|
+
height: fit-content;
|
|
95
|
+
border-radius: 10px !important;
|
|
96
|
+
}
|
|
97
|
+
.server-card-link {
|
|
98
|
+
text-decoration: none;
|
|
99
|
+
font-size: 25px;
|
|
100
|
+
color: inherit;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.content-empty-state {
|
|
104
|
+
align-items: center !important;
|
|
105
|
+
display: flex !important;
|
|
106
|
+
justify-content: center !important;
|
|
107
|
+
font-size: 15px;
|
|
108
|
+
height: 80vh;
|
|
109
|
+
vertical-align: middle;
|
|
110
|
+
align-items: center;
|
|
111
|
+
text-align: center;
|
|
112
|
+
margin-top: 30vh !important;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.center-text-horizontal {
|
|
116
|
+
text-align: center !important;
|
|
117
|
+
align-items: center !important;
|
|
118
|
+
margin-left: 35% !important;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.start-button {
|
|
122
|
+
border-radius: 10px 0px 0px 10px !important;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.stop-button {
|
|
126
|
+
border-radius: 0px 10px 10px 0px !important;
|
|
127
|
+
background-color: rgb(216, 68, 68) !important;
|
|
128
|
+
width: 10px;
|
|
129
|
+
height: 10px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.create-server-input {
|
|
133
|
+
width: 48%;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.refresh-button {
|
|
137
|
+
background-color: transparent !important;
|
|
138
|
+
border: none !important;
|
|
139
|
+
border-radius: 50%;
|
|
140
|
+
box-shadow: none !important;
|
|
141
|
+
text-shadow: transparent !important;
|
|
142
|
+
color: white !important;
|
|
143
|
+
font-size: 12px !important;
|
|
144
|
+
/* Adjust icon size */
|
|
145
|
+
padding: 8px !important;
|
|
146
|
+
display: flex !important;
|
|
147
|
+
justify-content: center !important;
|
|
148
|
+
align-items: center !important;
|
|
149
|
+
outline: transparent !important;
|
|
150
|
+
margin-top: 15px !important;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.normal-secondary-button {
|
|
154
|
+
background-color: rgb(70, 70, 70) !important;
|
|
155
|
+
width: 30%;
|
|
156
|
+
border-radius: 10px !important;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.normal-primary-button {
|
|
160
|
+
background-color: rgba(15, 255, 175, 0.726) !important;
|
|
161
|
+
width: 65%;
|
|
162
|
+
border-radius: 10px !important;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.back-button {
|
|
166
|
+
background-color: transparent !important;
|
|
167
|
+
border: none !important;
|
|
168
|
+
border-radius: 50%;
|
|
169
|
+
box-shadow: none !important;
|
|
170
|
+
text-shadow: transparent !important;
|
|
171
|
+
color: white !important;
|
|
172
|
+
font-size: 12px !important;
|
|
173
|
+
/* Adjust icon size */
|
|
174
|
+
padding: 8px !important;
|
|
175
|
+
display: flex !important;
|
|
176
|
+
justify-content: center !important;
|
|
177
|
+
align-items: center !important;
|
|
178
|
+
outline: transparent !important;
|
|
179
|
+
margin-top: 15px !important;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.log-window {
|
|
183
|
+
width: 100% !important;
|
|
184
|
+
height: 580px !important;
|
|
185
|
+
border-radius: 10px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.console-input {
|
|
189
|
+
width: 100% !important;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.delete-server-popup {
|
|
193
|
+
height: min-content;
|
|
194
|
+
width: 40%;
|
|
195
|
+
border-radius: 10px !important;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.properties-editor {
|
|
199
|
+
width: 100% !important;
|
|
200
|
+
height: 80% !important;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.stat-grid {
|
|
204
|
+
width: 100% !important;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.stat-chip {
|
|
208
|
+
background-color: transparent !important;
|
|
209
|
+
border-radius: 10px !important;
|
|
210
|
+
overflow: show !important;
|
|
211
|
+
width: auto !important;
|
|
212
|
+
text-align: right !important;
|
|
213
|
+
opacity: 0.6 !important;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.circular-button {
|
|
217
|
+
background-color: transparent !important;
|
|
218
|
+
border: none !important;
|
|
219
|
+
border-radius: 50%;
|
|
220
|
+
box-shadow: none !important;
|
|
221
|
+
text-shadow: transparent !important;
|
|
222
|
+
color: white !important;
|
|
223
|
+
font-size: 12px !important;
|
|
224
|
+
/* Adjust icon size */
|
|
225
|
+
padding: 8px !important;
|
|
226
|
+
justify-content: center !important;
|
|
227
|
+
align-items: center !important;
|
|
228
|
+
outline: transparent !important;
|
|
229
|
+
margin-top: 15px !important;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.minimize-button {
|
|
233
|
+
background-color: transparent !important;
|
|
234
|
+
border: none !important;
|
|
235
|
+
border-radius: 50%;
|
|
236
|
+
box-shadow: none !important;
|
|
237
|
+
text-shadow: transparent !important;
|
|
238
|
+
color: white !important;
|
|
239
|
+
font-size: 12px !important;
|
|
240
|
+
/* Adjust icon size */
|
|
241
|
+
padding: 8px !important;
|
|
242
|
+
display: flex !important;
|
|
243
|
+
justify-content: center !important;
|
|
244
|
+
align-items: center !important;
|
|
245
|
+
position: absolute !important;
|
|
246
|
+
top: 10px !important;
|
|
247
|
+
right: 50px !important;
|
|
248
|
+
outline: transparent !important;
|
|
249
|
+
}
|
mcsc/tasks.py
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"""Handle background tasks"""
|
|
2
|
+
|
|
3
|
+
from time import sleep
|
|
4
|
+
from uuid import uuid4
|
|
5
|
+
from typing import Any, Callable
|
|
6
|
+
import threading
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
ALLOWED_ACTIONS = [
|
|
10
|
+
"call", # calls target
|
|
11
|
+
"process_output", # processed the output of target
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Task:
|
|
16
|
+
"""An activity to be handled
|
|
17
|
+
|
|
18
|
+
Available actions:
|
|
19
|
+
call: calls 'target' function
|
|
20
|
+
process_output: calls target function and processes output by passing it
|
|
21
|
+
to 'output_processor'
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
name (str, optional): name of the task. If not passed a uuid4 is generated.
|
|
25
|
+
action (str, optional): single action of the task.
|
|
26
|
+
actions(list[str], optional): multiple actions of the task.
|
|
27
|
+
target (Any, optional): target object
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
name: str = "",
|
|
33
|
+
action: str = "",
|
|
34
|
+
target: Any | Callable = None,
|
|
35
|
+
actions: list = None,
|
|
36
|
+
repeat: bool = False,
|
|
37
|
+
output_processor: Any | Callable = None,
|
|
38
|
+
tick_interval: float = 10.0,
|
|
39
|
+
args: tuple = None,
|
|
40
|
+
kwargs: dict = None,
|
|
41
|
+
):
|
|
42
|
+
# Validate
|
|
43
|
+
if not action and not actions:
|
|
44
|
+
raise ValueError(
|
|
45
|
+
"At least one parameter between 'action' and 'actions' has to be used"
|
|
46
|
+
)
|
|
47
|
+
if action and action not in ALLOWED_ACTIONS:
|
|
48
|
+
raise ValueError(f"Action '{action}' not recognized.")
|
|
49
|
+
|
|
50
|
+
actions_test = [a not in ALLOWED_ACTIONS for a in actions]
|
|
51
|
+
if actions and any(actions_test):
|
|
52
|
+
raise ValueError(
|
|
53
|
+
f"Action '{actions[actions_test.index(True)]}' not recognized."
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
action == "process_output" or "process_output" in actions
|
|
58
|
+
) and output_processor is None:
|
|
59
|
+
raise ValueError("No output processor provided.")
|
|
60
|
+
if repeat and tick_interval < 0:
|
|
61
|
+
raise ValueError("Invalid 'tick_interval' value.")
|
|
62
|
+
if action == "call" and not callable(target):
|
|
63
|
+
raise ValueError("'target' is not callable")
|
|
64
|
+
if output_processor is not None and not callable(output_processor):
|
|
65
|
+
raise ValueError("'output_processor' is not callable")
|
|
66
|
+
|
|
67
|
+
self.name = name or uuid4()
|
|
68
|
+
self.action = action
|
|
69
|
+
self.actions = actions
|
|
70
|
+
self.target = target
|
|
71
|
+
self.repeat = repeat
|
|
72
|
+
self.output_processor = output_processor
|
|
73
|
+
self.tick_interval = tick_interval
|
|
74
|
+
self.args = args
|
|
75
|
+
self.kwargs = kwargs
|
|
76
|
+
|
|
77
|
+
def tick(self):
|
|
78
|
+
"""Tick for repeated Tasks"""
|
|
79
|
+
if self.action:
|
|
80
|
+
self._process_action(self.action)
|
|
81
|
+
elif self.actions:
|
|
82
|
+
for action in self.actions:
|
|
83
|
+
self._process_action(action)
|
|
84
|
+
|
|
85
|
+
def _process_action(self, action: str):
|
|
86
|
+
"""Processes action"""
|
|
87
|
+
if action == "call":
|
|
88
|
+
self._call(self.target, self.args, self.kwargs)
|
|
89
|
+
return
|
|
90
|
+
if action == "process_output":
|
|
91
|
+
output = self._call(self.target, self.args, self.kwargs)
|
|
92
|
+
self._call(self.output_processor, (output,))
|
|
93
|
+
return
|
|
94
|
+
|
|
95
|
+
def _call(self, target: Callable, args: tuple = None, kwargs: dict = None):
|
|
96
|
+
"""Call target function/method
|
|
97
|
+
|
|
98
|
+
Returns output if any
|
|
99
|
+
"""
|
|
100
|
+
if not callable(target):
|
|
101
|
+
raise ValueError("'target' is not callable")
|
|
102
|
+
if args is None:
|
|
103
|
+
args = ()
|
|
104
|
+
if kwargs is None:
|
|
105
|
+
kwargs = {}
|
|
106
|
+
return target(*args, **kwargs)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class TaskHandler:
|
|
110
|
+
"""Handles tasks"""
|
|
111
|
+
|
|
112
|
+
tasks = []
|
|
113
|
+
active = False
|
|
114
|
+
_threads: dict[Task, threading.Thread] = {}
|
|
115
|
+
|
|
116
|
+
@classmethod
|
|
117
|
+
def start(cls):
|
|
118
|
+
"""Start the task handler"""
|
|
119
|
+
cls.active = True
|
|
120
|
+
for task in cls.tasks:
|
|
121
|
+
cls._start_task_thread(task)
|
|
122
|
+
|
|
123
|
+
@classmethod
|
|
124
|
+
def stop(cls):
|
|
125
|
+
"""Stop the task handler"""
|
|
126
|
+
cls.active = False
|
|
127
|
+
|
|
128
|
+
@classmethod
|
|
129
|
+
def _start_task_thread(cls, task: Task):
|
|
130
|
+
"""Start the task in a dedicated thread"""
|
|
131
|
+
cls._threads[task] = threading.Thread(target=cls._run, daemon=True)
|
|
132
|
+
cls._threads[task].start()
|
|
133
|
+
|
|
134
|
+
@classmethod
|
|
135
|
+
def queue_task(cls, task: Task):
|
|
136
|
+
"""Add task to queue"""
|
|
137
|
+
cls.tasks.append(task)
|
|
138
|
+
if cls.active:
|
|
139
|
+
cls._start_task_thread(task)
|
|
140
|
+
|
|
141
|
+
@classmethod
|
|
142
|
+
def _run(cls, task: Task):
|
|
143
|
+
"""Run task"""
|
|
144
|
+
if not task.repeat:
|
|
145
|
+
task.tick()
|
|
146
|
+
cls.tasks.remove(task)
|
|
147
|
+
return
|
|
148
|
+
|
|
149
|
+
# Repeated task
|
|
150
|
+
while cls.active:
|
|
151
|
+
task.tick()
|
|
152
|
+
sleep(task.tick_interval)
|
mcsc/telemetry.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Telemetry"""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import uuid
|
|
5
|
+
from datetime import datetime, timezone
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import requests
|
|
9
|
+
|
|
10
|
+
from mcsc.config.settings import TELEMETRY_DIR_PATH, TELEMETRY_API
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
ALLOWED_EVENTS = [
|
|
14
|
+
"app_start",
|
|
15
|
+
"app_close",
|
|
16
|
+
"server_create",
|
|
17
|
+
"server_delete",
|
|
18
|
+
"server_start",
|
|
19
|
+
"server_stop",
|
|
20
|
+
"settings_change",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
class TelemetryClient:
|
|
24
|
+
"""Telemetry client
|
|
25
|
+
Communicates with telemetry server sending info
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self, server_url: str = TELEMETRY_API, storage_dir: Path = TELEMETRY_DIR_PATH
|
|
30
|
+
):
|
|
31
|
+
self.server_url = server_url.rstrip("/")
|
|
32
|
+
self.storage_dir = Path(storage_dir)
|
|
33
|
+
self.storage_dir.mkdir(parents=True, exist_ok=True)
|
|
34
|
+
|
|
35
|
+
# Generate uuid
|
|
36
|
+
self.uuid_file = self.storage_dir / "client.conf"
|
|
37
|
+
if self.uuid_file.exists():
|
|
38
|
+
self.client_uuid = self.uuid_file.read_text().strip()
|
|
39
|
+
else:
|
|
40
|
+
self.client_uuid = str(uuid.uuid4())
|
|
41
|
+
self.uuid_file.write_text(self.client_uuid)
|
|
42
|
+
|
|
43
|
+
self.flush_pending()
|
|
44
|
+
|
|
45
|
+
def _save_pending(self, payload: dict):
|
|
46
|
+
"""Save payload on a file to be sent once server is available"""
|
|
47
|
+
timestamp = datetime.now(timezone.utc).strftime("%Y%m%d%H%M%S%f")
|
|
48
|
+
pending_file = self.storage_dir / f"pending_{timestamp}.json"
|
|
49
|
+
with open(pending_file, "w", encoding="utf-8") as f:
|
|
50
|
+
json.dump(payload, f)
|
|
51
|
+
|
|
52
|
+
def _load_pending(self):
|
|
53
|
+
"""Load pending payload(s)"""
|
|
54
|
+
return sorted(self.storage_dir.glob("pending_*.json"))
|
|
55
|
+
|
|
56
|
+
def _send(self, payload: dict) -> bool:
|
|
57
|
+
"""Try sending payload to telemetry server
|
|
58
|
+
Args:
|
|
59
|
+
payload (dict): the payload
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
True if sent else False"""
|
|
63
|
+
try:
|
|
64
|
+
r = requests.post(self.server_url, json=payload, timeout=5)
|
|
65
|
+
return r.status_code == 200
|
|
66
|
+
except requests.RequestException:
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
def send_event(self, event_name: str, details: dict = None):
|
|
70
|
+
"""Send an event (or save it locally if server does not answer)"""
|
|
71
|
+
# Assert parameters are valid
|
|
72
|
+
assert isinstance(event_name, str), "'event_name' is not a string"
|
|
73
|
+
if details is not None:
|
|
74
|
+
assert isinstance(details, dict), "Invalid 'details' dict"
|
|
75
|
+
assert event_name in ALLOWED_EVENTS, "'event_name' not allowed"
|
|
76
|
+
|
|
77
|
+
payload = {
|
|
78
|
+
"client_id": self.client_uuid,
|
|
79
|
+
"event_name": event_name,
|
|
80
|
+
"timestamp": datetime.now(timezone.utc).isoformat(),
|
|
81
|
+
"details": details or {},
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if not self._send(payload):
|
|
85
|
+
# If failed save to pending
|
|
86
|
+
payload["details"]["delayed"] = True
|
|
87
|
+
self._save_pending(payload)
|
|
88
|
+
|
|
89
|
+
def flush_pending(self):
|
|
90
|
+
"""Retry sending pending payload(s)"""
|
|
91
|
+
for file in self._load_pending():
|
|
92
|
+
try:
|
|
93
|
+
with open(file, "r", encoding="utf-8") as f:
|
|
94
|
+
payload = json.load(f)
|
|
95
|
+
|
|
96
|
+
if self._send(payload):
|
|
97
|
+
file.unlink() # delete if sent
|
|
98
|
+
except Exception: # pylint: disable=broad-exception-caught
|
|
99
|
+
pass
|
mcsc/update.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Update module for MCSC
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
import subprocess
|
|
7
|
+
import os
|
|
8
|
+
import importlib
|
|
9
|
+
import shutil
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
from importlib.metadata import version
|
|
12
|
+
import requests
|
|
13
|
+
|
|
14
|
+
from mcsc.config.settings import (
|
|
15
|
+
UPDATE_BRANCH,
|
|
16
|
+
GITHUB_REPO,
|
|
17
|
+
GITHUB_FILE_URL,
|
|
18
|
+
BACKUP_DIR,
|
|
19
|
+
PACKAGE_NAME,
|
|
20
|
+
)
|
|
21
|
+
from mcsc.modules.logger import RotatingLogger
|
|
22
|
+
|
|
23
|
+
logger = RotatingLogger()
|
|
24
|
+
|
|
25
|
+
BASE_URL = f"https://raw.githubusercontent.com/{GITHUB_REPO}/refs/heads/{UPDATE_BRANCH}"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def get_app_dir() -> str:
|
|
29
|
+
"""
|
|
30
|
+
Get the app directory
|
|
31
|
+
"""
|
|
32
|
+
return os.path.dirname(os.path.realpath(__file__))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_current_version() -> str:
|
|
36
|
+
"""
|
|
37
|
+
Get current version
|
|
38
|
+
"""
|
|
39
|
+
try:
|
|
40
|
+
current = version(PACKAGE_NAME)
|
|
41
|
+
except Exception: # pylint: disable=broad-exception-caught
|
|
42
|
+
current = "0.0.0"
|
|
43
|
+
|
|
44
|
+
logger.info(f"Currently running verion {current}")
|
|
45
|
+
return current
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def check_for_updates() -> bool:
|
|
49
|
+
"""
|
|
50
|
+
Check for updates
|
|
51
|
+
"""
|
|
52
|
+
logger.info("Checking for updates...")
|
|
53
|
+
current_version = get_current_version()
|
|
54
|
+
|
|
55
|
+
response = requests.get(f"https://pypi.org/pypi/{PACKAGE_NAME}/json", timeout=5)
|
|
56
|
+
if response.status_code == 200:
|
|
57
|
+
latest_version: str = response.json()["info"]["version"]
|
|
58
|
+
else:
|
|
59
|
+
logger.warning("Unable to check for updates")
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
current_version = int(current_version.replace(".", ""))
|
|
64
|
+
latest_version = int(latest_version.replace(".", ""))
|
|
65
|
+
except ValueError:
|
|
66
|
+
return False
|
|
67
|
+
|
|
68
|
+
return latest_version > current_version
|
|
69
|
+
|
|
70
|
+
# New update workflow
|
|
71
|
+
def update_mcsc():
|
|
72
|
+
"""Update the package via pip and restart the program."""
|
|
73
|
+
try:
|
|
74
|
+
# Run update
|
|
75
|
+
subprocess.check_call(
|
|
76
|
+
[sys.executable, "-m", "pip", "install", "--upgrade", PACKAGE_NAME]
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
logger.info(f"{PACKAGE_NAME} updated successfully! Restarting...")
|
|
80
|
+
|
|
81
|
+
# Restart MCSC
|
|
82
|
+
os.execv(sys.executable, [sys.executable] + sys.argv)
|
|
83
|
+
|
|
84
|
+
except subprocess.CalledProcessError:
|
|
85
|
+
logger.error(
|
|
86
|
+
f"Error: update failed. Try running 'pip install {PACKAGE_NAME} --upgrate' manually."
|
|
87
|
+
)
|
mcsc/utils.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Utils"""
|
|
2
|
+
|
|
3
|
+
from importlib import resources
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
static_dir = resources.files("mcsc") / "static"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_static_path(filename: str) -> Path:
|
|
11
|
+
"""Restituisce il path a un file statico nel package"""
|
|
12
|
+
return resources.files("mcsc.static") / filename
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def load_static_file(filename: str, mode: str = "rb"):
|
|
16
|
+
"""Carica un file statico come contenuto"""
|
|
17
|
+
path = get_static_path(filename)
|
|
18
|
+
with path.open(mode) as f:
|
|
19
|
+
return f.read()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Singleton:
|
|
23
|
+
"""Singleton class"""
|
|
24
|
+
|
|
25
|
+
_instance = None
|
|
26
|
+
|
|
27
|
+
def __new__(cls, *args, **kwargs):
|
|
28
|
+
if cls._instance is None:
|
|
29
|
+
cls._instance = super(Singleton, cls).__new__(cls)
|
|
30
|
+
return cls._instance
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: minecraft-server-creator
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Minecraft Server Creator - Manage Minecraft servers
|
|
5
|
+
Author-email: ddavidel <ddavidel@proton.me>
|
|
6
|
+
License: This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
|
|
7
|
+
See https://creativecommons.org/licenses/by-nc-sa/4.0/ for more details.
|
|
8
|
+
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: nicegui
|
|
13
|
+
Requires-Dist: requests
|
|
14
|
+
Requires-Dist: appdirs
|
|
15
|
+
Requires-Dist: pywebview
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
[](./LICENSE)
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
# MCSC - Minecraft Server Creator
|
|
22
|
+
MCSC is a user-friendly tool written in Python with a GUI that simplifies the process of creating and managing Minecraft servers. Whether you're a beginner or experienced, MCSC allows you to easily set up, run, and control multiple Minecraft servers from a single interface.
|
|
23
|
+
> **Warning**: MCSC is still in development, thus it may not be completely error free.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
- **Create Multiple Servers**: Set up and manage multiple Minecraft servers from within the app.
|
|
27
|
+
- **Start/Stop Servers**: Easily start and stop your Minecraft servers directly from the GUI.
|
|
28
|
+
- **Console Interaction**: Read the console output in real-time and send commands to the Minecraft server console.
|
|
29
|
+
- **Edit server.properties**: Customize your Minecraft server settings by editing the `server.properties` file with a built-in editor.
|
|
30
|
+
- **User-Friendly GUI**: A simple and intuitive interface designed for both beginners and experienced users.
|
|
31
|
+
- **Manage Server Instances**: Keep track of all your servers in one place.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
To install and run MCSC on your local machine:
|
|
35
|
+
1. Clone the repository:
|
|
36
|
+
`git clone https://github.com/ddavidel/minecraft-server-creator.git`
|
|
37
|
+
|
|
38
|
+
2. Navigate to the project folder and install the required dependencies:
|
|
39
|
+
`pip install -r requirements.txt`
|
|
40
|
+
|
|
41
|
+
3. Run the application by double clicking `START.bat` or with the following command:
|
|
42
|
+
`python ServerCreator.py`
|
|
43
|
+
|
|
44
|
+
## Upcoming Features
|
|
45
|
+
- **Support for more server types**: In the future updates, MCSC will support creating and managing many popular Minecraft server types.
|
|
46
|
+
- **Plugin and Mod Manager**: Easily manage plugins and mods.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
mcsc/__init__.py,sha256=DVjz26AfztvNON5Y88QTOKojeuHBFyxRLmUx6E11LIs,62
|
|
2
|
+
mcsc/__main__.py,sha256=cjaidNpcJWWVHK8ANgYigKOtVzZFoZJoqD310P4ZU4E,125
|
|
3
|
+
mcsc/main.py,sha256=Zv5jTSgyfQuU8zB51ufrJGSFv6xR6GINt_hrlAHjvRU,3500
|
|
4
|
+
mcsc/tasks.py,sha256=ZmrTQasffD6uAkDzVKBbDBW5f9L-KvSLTwV_h5RO9Wc,4701
|
|
5
|
+
mcsc/telemetry.py,sha256=71LlVp7wyPQrmCuTmGZKZDd4h5zaGh_Njci5m6-HvBs,3282
|
|
6
|
+
mcsc/update.py,sha256=Mg6SgEiK77wo9AKR9eoITnA4y4iw0LDJ5j71CkV1XdU,2229
|
|
7
|
+
mcsc/utils.py,sha256=l1Ve24ef33nKHcaqRRd-yBFFoTYlm-vUb3sCJ3_JwDc,739
|
|
8
|
+
mcsc/config/settings.py,sha256=J79-Ya2Wj3Nz8Ior6s4wMS4ZdX7VlINQOYM80Mch1lg,1894
|
|
9
|
+
mcsc/config/update_files.py,sha256=Nuz_sFJrPr7DQY28h9sBa2Any5fp3Hz25Eemskv0y1A,1001
|
|
10
|
+
mcsc/localization/it.py,sha256=2m-81GadFdz_4UFRDzFgfKQ6KkE-aig8tUmB4dmRecI,3861
|
|
11
|
+
mcsc/modules/classes.py,sha256=pB97UXuLy_le0bDI8mnHSjnS-jdrl0yTzu6Ez-HqF5U,3587
|
|
12
|
+
mcsc/modules/logger.py,sha256=0bgm4gLmkymSFdq0QuY7FI6hDxbmP7TDbEUlBJd-iNw,3143
|
|
13
|
+
mcsc/modules/pages.py,sha256=LQZgZAUgXvvHGyGY5UXqXflZXntIQjJ8dHl7Fz5KjLQ,13800
|
|
14
|
+
mcsc/modules/translations.py,sha256=C6Nqv8Ur2mOLky_fUPGxNyuM76TWI0bnT93qtRE6tUs,1106
|
|
15
|
+
mcsc/modules/user_settings.py,sha256=6gd4B986irPZpEsytSZ2K3Zg4tFndqWNTvuOBnQv-Dc,5071
|
|
16
|
+
mcsc/modules/utils.py,sha256=lFgZOjqfE0nQDhK2DJeMRY2-i5jk0vZvSlVr7CjKW9o,25451
|
|
17
|
+
mcsc/modules/servers/forge.py,sha256=fu9uMqOg75sWj7_-PrzYZ6YXPw7i-2Zvajh6nI_Zt3o,5928
|
|
18
|
+
mcsc/modules/servers/java.py,sha256=YXUMSYNtFZ6wtrqA6sI0ZCc91kn6Xa-lDaHZm_Ikc38,242
|
|
19
|
+
mcsc/modules/servers/models.py,sha256=PBNmlUnKYtJ-sBFIK8C4adHM4LZIfWp_0Gt7Hxng4zs,14968
|
|
20
|
+
mcsc/modules/servers/paper.py,sha256=LWrOkrD7I5OJXN0uJDYh8oXRPOW0RfOguyPn7lyx83I,3134
|
|
21
|
+
mcsc/modules/servers/utils.py,sha256=Tu1V-XdW-v1czT92JHWbIXm9Bp7U7gF0l6hGLx1JAh4,4159
|
|
22
|
+
mcsc/static/logo.png,sha256=enovey2R7tRZiU5xTu6mIj8y17mF8qopcnrYTJT7UWk,6750
|
|
23
|
+
mcsc/static/style.css,sha256=vtUVDjUn9g7hSwQh9eBXpE0J3pTbNUdHAvqWB6tIfTY,5817
|
|
24
|
+
minecraft_server_creator-2.0.0.dist-info/licenses/LICENSE,sha256=AdkpE0qqju_A87-zCiLUWniSpDVSI6BwPnBseirfft4,192
|
|
25
|
+
minecraft_server_creator-2.0.0.dist-info/METADATA,sha256=ERa1cgH3eymDgg0HyLMwfChhdqevDTG636DzOWuN6gM,2432
|
|
26
|
+
minecraft_server_creator-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
27
|
+
minecraft_server_creator-2.0.0.dist-info/entry_points.txt,sha256=LaAJsQ81gwXjHIyLsqrzYRgZ3RkWh6vfbyHI0RF_JTo,44
|
|
28
|
+
minecraft_server_creator-2.0.0.dist-info/top_level.txt,sha256=DQh7Ltvob-WjuvMDhLUUpExKWb4BiW2HdX8__wJUdWM,5
|
|
29
|
+
minecraft_server_creator-2.0.0.dist-info/RECORD,,
|