Skip to content

Commit

Permalink
尚未完工
Browse files Browse the repository at this point in the history
  • Loading branch information
lilingfengdev committed May 25, 2024
1 parent 542df8e commit b4fd246
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: "3.8"
architecture: 'x86'
- name: Install Dependencies
run: pip install pyyaml install-jdk psutil rtoml pyinstaller pyarmor
run: pip install pyyaml install-jdk tqdm p_tqdm psutil rtoml requests pyinstaller pyarmor
- name: Generate Bundle
run: |
python generate-bundle.py
Expand Down
68 changes: 30 additions & 38 deletions auto-install-depend.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,50 @@
import os
import urllib.request
from concurrent.futures import ThreadPoolExecutor, wait
from utils import *

script_license()
from p_tqdm import p_map

opener = urllib.request.build_opener()
opener.addheaders = [
('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0')]
urllib.request.install_opener(opener)
pool = ThreadPoolExecutor(6)
task = []


def download_task(name: str, url: str):
def _download():
print(f"开始下载{name}")
try:
urllib.request.urlretrieve(url, os.path.join(os.getcwd(), "plugins", name + ".jar"))
except Exception as e:
print(f"下载错误{e},在下载{name}")
print("重试")
_download()
else:
print(f"下载完成{name}")

task.append(pool.submit(_download))
def download_file(meta):
name, url = meta
urllib.request.urlretrieve(url, os.path.join(os.getcwd(), "plugins", name + ".jar"))


def downloads():
# 下载各个插件
download_task("ProtocolLib", "https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs"
"/ProtocolLib.jar")
download_task("Luckperms", "https://download.luckperms.net/1535/bukkit/loader/LuckPerms-Bukkit-5.4.122.jar")
download_task("PlaceholderAPI", "https://ci.extendedclip.com/job/PlaceholderAPI/193/artifact/build/libs"
"/PlaceholderAPI-2.11.6-DEV-193.jar")
download_task("PlugManx", "https://qcymc.cloud/f/QRCo/PlugManX-2.3.8.jar")
download_task("WorldEdit", "https://ci.enginehub.org/repository/download/bt10/23766:id/worldedit-bukkit-7.3.1"
"-SNAPSHOT-dist.jar?branch=version/7.3.x&guest=1")
download_task("EssentialsX", "https://qcymc.cloud/f/XBSO/EssentialsX-2.21.0-dev+81-cde7184.jar")
download_task("Multiverse-Core", "https://ci.onarandombox.com/job/Multiverse-Core/870/artifact/target/Multiverse"
"-Core-4.3.2-SNAPSHOT.jar")
download_task("ViaVersion", "https://qcymc.cloud/f/VjHg/ViaVersion-4.10.1-SNAPSHOT.jar")
download_task("ViaBackwards", "https://qcymc.cloud/f/W9ID/ViaBackwards-4.10.1-SNAPSHOT.jar")
download_task("AuthMe", "https://qcymc.cloud/f/RDF5/AuthMe-5.6.0-FORK-Universal.jar")
plugins = [
("ProtocolLib",
"https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar"),
("Luckperms", "https://download.luckperms.net/1535/bukkit/loader/LuckPerms-Bukkit-5.4.122.jar"),
("PlaceholderAPI",
"https://ci.extendedclip.com/job/PlaceholderAPI/193/artifact/build/libs/PlaceholderAPI-2.11.6-DEV-193.jar"),
("PlugManx", "https://qcymc.cloud/f/QRCo/PlugManX-2.3.8.jar"),
("WorldEdit",
"https://ci.enginehub.org/repository/download/bt10/23766:id/worldedit-bukkit-7.3.1-SNAPSHOT-dist.jar?branch"
"=version/7.3.x&guest=1"),
("EssentialsX", "https://qcymc.cloud/f/XBSO/EssentialsX-2.21.0-dev+81-cde7184.jar"),
("Multiverse-Core",
"https://ci.onarandombox.com/job/Multiverse-Core/870/artifact/target/Multiverse-Core-4.3.2-SNAPSHOT.jar"),
("ViaVersion", "https://qcymc.cloud/f/VjHg/ViaVersion-4.10.1-SNAPSHOT.jar"),
("ViaBackwards", "https://qcymc.cloud/f/W9ID/ViaBackwards-4.10.1-SNAPSHOT.jar"),
("AuthMe", "https://qcymc.cloud/f/RDF5/AuthMe-5.6.0-FORK-Universal.jar"),
("spark", "https://ci.lucko.me/job/spark/410/artifact/spark-bukkit/build/libs/spark-1.10.65-bukkit.jar"),
("SkinRestorer",
"https://ci.codemc.io/job/SkinsRestorer/job/SkinsRestorer/lastSuccessfulBuild/artifact/build/libs"
"/SkinsRestorer.jar")
]
if not os.path.exists("plugins/spark"):
download_task("spark",
"https://ci.lucko.me/job/spark/410/artifact/spark-bukkit/build/libs/spark-1.10.65-bukkit.jar")
download_task("SkinRestorer", "https://ci.codemc.io/job/SkinsRestorer/job/SkinsRestorer/lastSuccessfulBuild"
"/artifact/build/libs/SkinsRestorer.jar")
plugins.append(("spark", "https://ci.lucko.me/job/spark/410/artifact/spark-bukkit/build/libs/spark-1.10.65"
"-bukkit.jar"))

p_map(download_file, plugins, num_cpus=4)


if __name__ == "__main__":
script_license()
downloads()
wait(task)
print("完成!")
exit_()
8 changes: 2 additions & 6 deletions config-anticheat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
import os

from utils import *
import zipfile, shutil
import zipfile, shutil
import urllib.request

script_license()


def extract_zipfile():
opener = urllib.request.build_opener()
opener.addheaders = [
('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0')]
urllib.request.install_opener(opener)
urllib.request.urlretrieve("https://qcymc.cloud/f/lYAfX/temp.zip","temp.zip")
download("https://qcymc.cloud/f/lYAfX/temp.zip", "temp.zip")
zip = zipfile.ZipFile("temp.zip")
zip.extractall(os.path.join(os.getcwd(), "temp"))

Expand Down
51 changes: 51 additions & 0 deletions geyser-egg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from utils import *

script_license()


def main():
if not os.path.exists("plugins/Geyser-Spigot"):
print("Geyser和Floodgate尚未安装")
install_geyser()
print("安装完成,启动服务器,在关闭后执行此脚本")
exit_()
print("已安装Geyser和Floodgate")
setup_geyser()
setup_floodgate()
install_extend()


def install_geyser():
download("https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/spigot",
"plugins/Geyser-Spigot.jar")

download("https://download.geysermc.org/v2/projects/floodgate/versions/latest/builds/latest/downloads/spigot",
"plugins/floodgate.jar")


@handler("plugins/Geyser-Spigot/config.yml")
def setup_geyser(geyser):
prop = ServerPropLoader()
server_port = int(prop.data["port"])
geyser["remote"]["port"] = server_port
if ask("允许Geyser玩家在地狱上层(y>128)放置方块"):
geyser["above-bedrock-nether-building"] = True

if ask("开启XBox成绩获得"):
geyser["xbox-achievements-enabled"] = True


@handler("plugins/floodgate/config.yml")
def setup_floodgate(floodgate):
prefix = input("\033[33m基岩版玩家用户名前缀(默认为.,推荐BE_):\033[0m")
floodgate["username-prefix"] = prefix


def install_extend():
if ask("安装GeyserOptionalPack(推荐)"):
download("https://download.geysermc.org/v2/projects/geyseroptionalpack/versions/latest/builds/latest"
"/downloads/geyseroptionalpack", "plugins/Geyser-Spigot/packs/geyseroptionalpack.mcpack")


if __name__ == "__main__":
main()
38 changes: 32 additions & 6 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys, os
import yaml
import yaml, requests, tqdm

try:
from yaml import CLoader as Loader, CDumper as Dumper
Expand All @@ -8,10 +8,10 @@


def script_license():
print("Minecraft笨蛋脚本")
print("作者:lilingfeng")
print("仓库地址:https://github.com/lilingfengdev/NitWiki-Script")
print("未经许可,禁止用于商业用途")
print("\033[92mMinecraft笨蛋脚本\033[0m")
print("\033[92m作者:lilingfeng\033[0m")
print("\033[92m仓库地址:https://github.com/lilingfengdev/NitWiki-Script\033[0m")
print("\033[91m未经许可,禁止用于商业用途\033[0m")


def handler(filename):
Expand Down Expand Up @@ -39,7 +39,10 @@ def b():


def ask(title):
select = input(title + "(y/n):")
YELLOW = '\033[33m'
RESET = '\033[0m'
title = f"{YELLOW}{title}{RESET}"
select = input(f"{title}(y/n): ")
if select.lower().startswith("y"):
return True
return False
Expand All @@ -65,3 +68,26 @@ def save(self):
with open("server.properties", "w") as fp:
for key in self.data.keys():
fp.write(key + "=" + str(self.data[key]) + "\n")


def download(url, local_filepath):
headers = {
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/111.0.0.0 Safari/537.36"
}
with requests.get(url, stream=True, headers=headers) as r:
r.raise_for_status()
size = int(r.headers["Content-Length"])
chunk_size = 8192
with tqdm.tqdm(
unit="B",
unit_scale=True,
unit_divisor=1024,
miniters=1,
desc=f"下载文件 {local_filepath}",
total=size,
) as pbar:
with open(local_filepath, "wb") as f:
for chunk in r.iter_content(chunk_size=chunk_size):
f.write(chunk)
pbar.update(len(chunk))

0 comments on commit b4fd246

Please sign in to comment.