.
This commit is contained in:
parent
2ea2eb5d1e
commit
ad2717b6d2
48 changed files with 255 additions and 252 deletions
35
dev-server/BUILD
Normal file
35
dev-server/BUILD
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
load(":minecraft.bzl", "dev_server", "fetch_file")
|
||||
|
||||
dev_server(
|
||||
name = "dev",
|
||||
server_jar = ":papermc",
|
||||
plugins = [
|
||||
":luckperms",
|
||||
":viaversion",
|
||||
":viabackwards",
|
||||
],
|
||||
local_plugins = [
|
||||
"//core-bukkit:plugin",
|
||||
],
|
||||
)
|
||||
|
||||
fetch_file(
|
||||
name = "papermc",
|
||||
filename = "paper.jar",
|
||||
url = "https://fill-data.papermc.io/v1/objects/5953a1f1deaa3572be420c3a5b18406c4b752412a78be4acab7c8b467633caed/paper-26.2-100.jar",
|
||||
)
|
||||
fetch_file(
|
||||
name = "luckperms",
|
||||
filename = "LuckPerms.jar",
|
||||
url = "https://download.luckperms.net/1652/bukkit/loader/LuckPerms-Bukkit-5.5.65.jar",
|
||||
)
|
||||
fetch_file(
|
||||
name = "viaversion",
|
||||
filename = "ViaVersion.jar",
|
||||
url = "https://hangarcdn.papermc.io/plugins/ViaVersion/ViaVersion/versions/5.11.0/PAPER/ViaVersion-5.11.0.jar"
|
||||
)
|
||||
fetch_file(
|
||||
name = "viabackwards",
|
||||
filename = "ViaBackwards.jar",
|
||||
url = "https://hangarcdn.papermc.io/plugins/ViaVersion/ViaBackwards/versions/5.11.0/PAPER/ViaBackwards-5.11.0.jar"
|
||||
)
|
||||
61
dev-server/minecraft.bzl
Normal file
61
dev-server/minecraft.bzl
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
def _dev_server_impl(ctx):
|
||||
script = ctx.actions.declare_file(ctx.label.name + "_runner")
|
||||
content = """
|
||||
#!/bin/sh
|
||||
set -eux
|
||||
|
||||
echo hi\n
|
||||
cp -f '%s' server.jar
|
||||
printf eula=true > eula.txt
|
||||
mkdir -p plugins
|
||||
rm -f plugins/*.jar
|
||||
for plugin in %s
|
||||
do
|
||||
cp -v \"$plugin\" plugins/
|
||||
done
|
||||
exec java -jar server.jar --nogui %s
|
||||
""" % (
|
||||
ctx.file.server_jar.short_path,
|
||||
" ".join([p.short_path for p in ctx.files.plugins]),
|
||||
" ".join(["--add-plugin %s" % p.short_path for p in ctx.files.local_plugins]),
|
||||
)
|
||||
ctx.actions.write(
|
||||
output = script,
|
||||
content = content,
|
||||
is_executable = True,
|
||||
)
|
||||
return DefaultInfo(
|
||||
executable = script,
|
||||
runfiles = ctx.runfiles(files = [ctx.file.server_jar] + ctx.files.plugins + ctx.files.local_plugins)
|
||||
)
|
||||
|
||||
dev_server = rule(
|
||||
implementation = _dev_server_impl,
|
||||
executable = True,
|
||||
attrs = {
|
||||
"server_jar": attr.label(allow_single_file = True, mandatory = True),
|
||||
"plugins": attr.label_list(),
|
||||
"local_plugins": attr.label_list(),
|
||||
},
|
||||
)
|
||||
|
||||
def _fetch_plugin_impl(ctx):
|
||||
out_file = ctx.actions.declare_file(ctx.attr.filename)
|
||||
ctx.actions.run_shell(
|
||||
outputs = [out_file],
|
||||
command = "curl -Lso \"$1\" \"$2\"",
|
||||
arguments = [out_file.path, ctx.attr.url],
|
||||
execution_requirements = {
|
||||
"requires-network": "1",
|
||||
},
|
||||
progress_message = "Downloading plugin %s" % ctx.attr.filename,
|
||||
)
|
||||
return [DefaultInfo(files = depset([out_file]))]
|
||||
|
||||
fetch_file = rule(
|
||||
implementation = _fetch_plugin_impl,
|
||||
attrs = {
|
||||
"url": attr.string(mandatory = True),
|
||||
"filename": attr.string(mandatory = True),
|
||||
},
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue