-
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
lilingfengdev
committed
May 25, 2024
1 parent
542df8e
commit b4fd246
Showing
5 changed files
with
116 additions
and
51 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
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_() |
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 |
---|---|---|
@@ -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() |
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