MCPcopy Create free account
hub / github.com/MCSLTeam/MCSL2 / _MinecraftEULA

Class _MinecraftEULA

MCSL2Lib/ServerControllers/processCreator.py:224–259  ·  view source on GitHub ↗

有关Mojang Eula的部分。

Source from the content-addressed store, hash-verified

222
223
224class _MinecraftEULA:
225 """有关Mojang Eula的部分。"""
226
227 def __init__(self, name):
228 self.serverDir = f"./Servers/{name}"
229 self.name = name
230
231 def checkEula(self) -> bool:
232 """检查Eula"""
233 self.__init__(self.name)
234 try:
235 # with open(f"{self.serverDir}/eula.txt", "r", encoding="utf-8") as Eula:
236 # EulaText = Eula.readlines()
237 # for line in EulaText:
238 # line = line.strip()
239 # if line.startswith("eula"):
240 # if "true" in line:
241 # return True
242 # else:
243 # return False
244 # else:
245 # continue
246 t = readFile(f"{self.serverDir}/eula.txt")
247 if "eula=true" in t:
248 return True
249 else:
250 return False
251 except FileNotFoundError:
252 return False
253
254 def acceptEula(self):
255 """同意Eula"""
256 writeFile(
257 f"{self.serverDir}/eula.txt",
258 f"# By changing the setting below to TRUE you are indicating your agreement to Mojang EULA (https://aka.ms/MinecraftEULA).\n# Generated by MCSL2. Time: {str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))}\neula=true", # noqa: E501
259 )
260
261
262class ServerLauncher:

Callers 2

runMethod · 0.90
startMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected