-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46cc4b8
commit 2f0c958
Showing
4 changed files
with
42 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,58 @@ | ||
import json | ||
import os | ||
from multiprocessing import cpu_count | ||
import FMCLCore.System.Logging | ||
import FMCLCore.System.CoreMakeFolderTask | ||
|
||
config = os.path.abspath("config.json") | ||
import FMCLCore.System.CoreMakeFolderTask | ||
import FMCLCore.System.Logging | ||
|
||
config = os.path.abspath(".first.mcl.json") | ||
really = {} | ||
|
||
def read(): | ||
return json.load(open(config, "r+")) | ||
|
||
return json.load(open(config, "r+", encoding="utf-8")) | ||
|
||
def write(playername: str = "player", dotmc: str = ".minecraft", java: str = "java", ram: str = "1024M", | ||
threads: int = cpu_count() * 8): | ||
con = {"playername": playername, ".mc": dotmc, "java": java, "ram": ram, "threads": threads} | ||
writejson(con) | ||
def writejson(conf: dict): | ||
open(config, "w+", encoding="utf-8").write(json.dumps(conf)) | ||
|
||
def add_account(account: dict): | ||
tmp = read() | ||
tmp["Accounts"].append(account) | ||
writejson(tmp) | ||
|
||
def writejson(all: dict): | ||
open(config, "w+").write(json.dumps(all)) | ||
def delete_account(number: int): | ||
tmp = read() | ||
del tmp["Accounts"][number] | ||
writejson(tmp) | ||
|
||
def get_account(): | ||
accountlist = [] | ||
for i in read()["Accounts"]: | ||
accountlist.append("[" + i["type"] + "] " + i["name"]) | ||
return accountlist | ||
|
||
def fixdepend(): | ||
if not os.path.exists("config.json"): | ||
write() | ||
print(FMCLCore.System.Logging.showinfo("Config-Checker:\tConfig.json not found. Create config.json.")) | ||
std = {"About": "This file is very important! DO NOT EDIT OR SHARE!", ".mc": ".minecraft", "java": "java", "ram": "1024M", "threads": 64, "Language": "English", "Accounts": []} | ||
if not os.path.exists(config): | ||
writejson(std) | ||
print(FMCLCore.System.Logging.showinfo("Config-Checker:\t" + config + " not found. Create " + config + ".")) | ||
else: | ||
try: | ||
read() | ||
|
||
except json.decoder.JSONDecodeError: | ||
print(FMCLCore.System.Logging.showwarning("config.json is broken, fixing.")) | ||
write() | ||
print(FMCLCore.System.Logging.showsuccess("Successfully fixed config.json.")) | ||
print(FMCLCore.System.Logging.showwarning(config + " is broken, fixing.")) | ||
writejson(std) | ||
print(FMCLCore.System.Logging.showsuccess("Successfully fixed " + config + ".")) | ||
|
||
finally: | ||
fixed = False | ||
config_json = FMCLCore.System.CoreConfigIO.read() | ||
std = {"playername": "player", ".mc": ".minecraft", "java": "java", "ram": "1024M", "threads": 128} | ||
for i in std: | ||
if i not in config_json: | ||
print(FMCLCore.System.Logging.showwarning("Config-Checker:\tMissing object: " + i)) | ||
config_json[i] = std[i] | ||
FMCLCore.System.CoreConfigIO.writejson(config_json) | ||
fixed = True | ||
if fixed: | ||
print(FMCLCore.System.Logging.showsuccess("Config-Checker:\tSuccessfully fixed config.json!")) | ||
print(FMCLCore.System.Logging.showsuccess("Config-Checker:\tSuccessfully fixed " + config + "!")) | ||
|
||
FMCLCore.System.CoreMakeFolderTask.make_mc_dir(FMCLCore.System.CoreConfigIO.read()[".mc"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters