mirror of
https://gerrit.hackerspace.pl/hscloud
synced 2025-02-16 09:46:45 +00:00
*: remove java/minecraft
Change-Id: Id2b1e69dcad240d7ef8a80b844531ef862e27dd2 Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1582 Reviewed-by: q3k <q3k@hackerspace.pl>
This commit is contained in:
parent
dc03494c2c
commit
7631880620
26 changed files with 0 additions and 2326 deletions
53
WORKSPACE
53
WORKSPACE
|
@ -220,59 +220,6 @@ http_file(
|
|||
],
|
||||
)
|
||||
|
||||
# minecraft spigot/bukkit deps
|
||||
# this uses rules_jvm_external vs gerrit's maven_jar because we need SNAPSHOT support
|
||||
|
||||
http_archive(
|
||||
name = "io_grpc_grpc_java",
|
||||
sha256 = "446ad7a2e85bbd05406dbf95232c7c49ed90de83b3b60cb2048b0c4c9f254d29",
|
||||
strip_prefix = "grpc-java-1.29.0",
|
||||
url = "https://github.com/grpc/grpc-java/archive/v1.29.0.zip",
|
||||
)
|
||||
|
||||
RULES_JVM_EXTERNAL_TAG = "3.0"
|
||||
|
||||
RULES_JVM_EXTERNAL_SHA = "62133c125bf4109dfd9d2af64830208356ce4ef8b165a6ef15bbff7460b35c3a"
|
||||
|
||||
http_archive(
|
||||
name = "rules_jvm_external",
|
||||
sha256 = RULES_JVM_EXTERNAL_SHA,
|
||||
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
|
||||
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
|
||||
)
|
||||
|
||||
load("@rules_jvm_external//:defs.bzl", "maven_install")
|
||||
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
|
||||
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
|
||||
|
||||
maven_install(
|
||||
artifacts = [
|
||||
"org.spigotmc:spigot-api:1.15.2-R0.1-20200624.001023-124",
|
||||
"io.grpc:grpc-netty-shaded:1.29.0",
|
||||
"io.grpc:grpc-services:1.29.0",
|
||||
] + IO_GRPC_GRPC_JAVA_ARTIFACTS,
|
||||
generate_compat_repositories = True,
|
||||
maven_install_json = "//third_party/java:maven_install.json",
|
||||
override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS,
|
||||
repositories = [
|
||||
"https://hub.spigotmc.org/nexus/content/repositories/snapshots",
|
||||
"https://oss.sonatype.org/content/repositories/snapshots",
|
||||
"https://repo1.maven.org/maven2/",
|
||||
],
|
||||
)
|
||||
|
||||
load("@maven//:defs.bzl", "pinned_maven_install")
|
||||
|
||||
pinned_maven_install()
|
||||
|
||||
load("@maven//:compat.bzl", "compat_repositories")
|
||||
|
||||
compat_repositories()
|
||||
|
||||
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
|
||||
|
||||
grpc_java_repositories()
|
||||
|
||||
# Gerrit OWNERS plugins external repositories
|
||||
|
||||
git_repository(
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
FROM ubuntu:20.04
|
||||
|
||||
RUN set -e -x ;\
|
||||
export DEBIAN_FRONTEND=noninteractive ;\
|
||||
apt-get -y update ;\
|
||||
apt-get -y upgrade ;\
|
||||
apt-get -y install git openjdk-8-jre-headless wget unzip
|
||||
|
||||
RUN set -e -x ;\
|
||||
export DEBIAN_FRONTEND=noninteractive ;\
|
||||
apt-get -y install build-essential python3-dev python3-pil python3-numpy ;\
|
||||
mkdir overviewer ;\
|
||||
cd overviewer ;\
|
||||
wget --quiet https://overviewer.org/builds/src/152/overviewer-0.15.77.tar.gz ;\
|
||||
tar xvf *.tar.gz ;\
|
||||
cd Minecraft-Overviewer* ;\
|
||||
python3 setup.py build ;\
|
||||
python3 setup.py install ;\
|
||||
cd ../.. ;\
|
||||
rm -rf overviewer ;\
|
||||
apt-get -y purge python3-dev build-essential
|
||||
|
||||
|
||||
RUN set -e -x ;\
|
||||
useradd -rm minecraft
|
||||
|
||||
USER minecraft
|
||||
WORKDIR /home/minecraft
|
||||
ARG VERSION=1.16.5
|
||||
|
||||
RUN set -e -x ;\
|
||||
wget --quiet https://papermc.io/api/v1/paper/${VERSION}/latest/download ;\
|
||||
mv download server.jar
|
||||
|
||||
ADD worldedit-bukkit-7.2.0-beta-01.jar .
|
||||
ADD worldguard-bukkit-7.0.4-beta1.jar .
|
||||
|
||||
RUN set -e -x ;\
|
||||
mkdir -p /home/minecraft/.minecraft/versions/${VERSION}/ ;\
|
||||
wget --quiet https://overviewer.org/textures/${VERSION} -O /home/minecraft/.minecraft/versions/${VERSION}/${VERSION}.jar
|
|
@ -1,46 +0,0 @@
|
|||
FROM ubuntu:20.04
|
||||
|
||||
RUN set -e -x ;\
|
||||
export DEBIAN_FRONTEND=noninteractive ;\
|
||||
apt-get -y update ;\
|
||||
apt-get -y upgrade ;\
|
||||
apt-get -y install git openjdk-8-jre-headless wget
|
||||
|
||||
RUN set -e -x ;\
|
||||
export DEBIAN_FRONTEND=noninteractive ;\
|
||||
apt-get -y install build-essential python3-dev python3-pil python3-numpy ;\
|
||||
mkdir overviewer ;\
|
||||
cd overviewer ;\
|
||||
wget --quiet https://overviewer.org/builds/src/152/overviewer-0.15.77.tar.gz ;\
|
||||
tar xvf *.tar.gz ;\
|
||||
cd Minecraft-Overviewer* ;\
|
||||
python3 setup.py build ;\
|
||||
python3 setup.py install ;\
|
||||
cd ../.. ;\
|
||||
rm -rf overviewer ;\
|
||||
apt-get -y purge python3-dev build-essential
|
||||
|
||||
|
||||
RUN set -e -x ;\
|
||||
useradd -rm minecraft
|
||||
|
||||
USER minecraft
|
||||
WORKDIR /home/minecraft
|
||||
ARG VERSION=1.16.1
|
||||
|
||||
RUN set -e -x ;\
|
||||
mkdir build ;\
|
||||
cd build ;\
|
||||
wget --quiet https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar ;\
|
||||
java -jar BuildTools.jar --rev 1.16.1 ;\
|
||||
cp spigot*jar .. ;\
|
||||
cd .. ;\
|
||||
rm -rf build ;\
|
||||
mv spigot*.jar server.jar
|
||||
|
||||
ADD worldedit-bukkit-7.2.0-beta-01.jar .
|
||||
ADD worldguard-bukkit-7.0.4-beta1.jar .
|
||||
|
||||
RUN set -e -x ;\
|
||||
mkdir -p /home/minecraft/.minecraft/versions/${VERSION}/ ;\
|
||||
wget --quiet https://overviewer.org/textures/${VERSION} -O /home/minecraft/.minecraft/versions/${VERSION}/${VERSION}.jar
|
|
@ -1,16 +0,0 @@
|
|||
FROM ubuntu:20.04
|
||||
|
||||
RUN set -e -x ;\
|
||||
export DEBIAN_FRONTEND=noninteractive ;\
|
||||
apt-get -y update ;\
|
||||
apt-get -y upgrade ;\
|
||||
apt-get -y install git openjdk-8-jre-headless wget unzip
|
||||
|
||||
RUN set -e -x ;\
|
||||
useradd -rm minecraft
|
||||
|
||||
USER minecraft
|
||||
WORKDIR /home/minecraft
|
||||
|
||||
RUN set -e -x ;\
|
||||
wget --quiet -O server.jar https://launcher.mojang.com/v1/objects/1b557e7b033b583cd9f66746b7a9ab1ec1673ced/server.jar
|
|
@ -1,7 +0,0 @@
|
|||
WorldEdit and WorldGuard are licensed under the terms of the GNU Lesser General
|
||||
Public License v3.
|
||||
|
||||
Full license texts are available at:
|
||||
|
||||
* WorldEdit: https://github.com/EngineHub/WorldEdit/blob/7.1.0/LICENSE.txt
|
||||
* WorldGuard: https://github.com/EngineHub/WorldGuard/blob/7.0.2/LICENSE.txt
|
|
@ -1,14 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["genpluginyml.go"],
|
||||
importpath = "code.hackerspace.pl/personal/q3k/minecraft/plugins/genpluginyml",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "genpluginyml",
|
||||
embed = [":go_default_library"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -1,64 +0,0 @@
|
|||
load("//bzl:rules.bzl", copy_binary="copy_go_binary")
|
||||
|
||||
def _plugin_yml_gen_impl(ctx):
|
||||
ctx.actions.run(
|
||||
mnemonic = "PluginYmlGen",
|
||||
progress_message = "Generating plugin.yml",
|
||||
|
||||
inputs = [ctx.info_file],
|
||||
outputs = [ctx.outputs.out],
|
||||
executable = ctx.executable._genpluginyml,
|
||||
arguments = [
|
||||
"-name", ctx.label.name,
|
||||
"-author", ctx.attr.author,
|
||||
"-main", ctx.attr.main,
|
||||
"-version", ctx.attr.version,
|
||||
"-status_file", ctx.info_file.path,
|
||||
"-out_file", ctx.outputs.out.path,
|
||||
],
|
||||
)
|
||||
|
||||
plugin_yml_gen = rule(
|
||||
implementation = _plugin_yml_gen_impl,
|
||||
attrs = {
|
||||
"main": attr.string(mandatory = True),
|
||||
"version": attr.string(default = ""),
|
||||
"author": attr.string(default = "bazel"),
|
||||
"_genpluginyml": attr.label(
|
||||
default = Label("//personal/q3k/minecraft/plugin:genpluginyml"),
|
||||
cfg = "host",
|
||||
executable = True,
|
||||
allow_files = True,
|
||||
),
|
||||
},
|
||||
outputs = {
|
||||
"out": "plugin.yml",
|
||||
},
|
||||
)
|
||||
|
||||
def bukkit_plugin(name, srcs, deps, main, author="", version=""):
|
||||
ymlname = name + "-yml"
|
||||
plugin_yml_gen(
|
||||
name = ymlname,
|
||||
author = author,
|
||||
version = version,
|
||||
main = main,
|
||||
)
|
||||
|
||||
jarname = name + "-jar"
|
||||
native.java_binary(
|
||||
name = jarname,
|
||||
create_executable = False,
|
||||
srcs = srcs,
|
||||
deps = deps,
|
||||
classpath_resources = [":" + ymlname],
|
||||
)
|
||||
|
||||
copy_binary(
|
||||
name = name + ".jar",
|
||||
src = ":" + jarname + "_deploy.jar",
|
||||
)
|
||||
native.alias(
|
||||
name = name,
|
||||
actual = ":" + name + ".jar",
|
||||
)
|
|
@ -1,11 +0,0 @@
|
|||
load("//personal/q3k/minecraft/plugin:defs.bzl", "bukkit_plugin")
|
||||
bukkit_plugin(
|
||||
name = "example",
|
||||
main = "hscloud.personal.q3k.minecraft.plugin.example.Main",
|
||||
srcs = [
|
||||
"Main.java"
|
||||
],
|
||||
deps = [
|
||||
"@maven//:org_spigotmc_spigot_api",
|
||||
],
|
||||
)
|
|
@ -1,15 +0,0 @@
|
|||
package hscloud.personal.q3k.minecraft.plugin.example;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
System.out.println("enabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
System.out.println("disabled");
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
flagName string
|
||||
flagAuthor string
|
||||
flagMain string
|
||||
flagVersion string
|
||||
|
||||
flagStatusFile string
|
||||
flagOutFile string
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.StringVar(&flagName, "name", "", "plugin name")
|
||||
flag.StringVar(&flagAuthor, "author", "", "plugin author")
|
||||
flag.StringVar(&flagMain, "main", "", "plugin main class")
|
||||
flag.StringVar(&flagVersion, "version", "", "plugin version, if not given, workspace status will be used")
|
||||
flag.StringVar(&flagStatusFile, "status_file", "", "path to workspace status file for version generation")
|
||||
flag.StringVar(&flagOutFile, "out_file", "plugin.yml", "path to output plugin.yml")
|
||||
flag.Parse()
|
||||
|
||||
if flagVersion == "" {
|
||||
status, err := ioutil.ReadFile(flagStatusFile)
|
||||
if err != nil {
|
||||
log.Fatalf("ReadFile(%q): %v", flagStatusFile, err)
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(string(status), "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
parts := strings.Fields(line)
|
||||
if len(parts) != 2 {
|
||||
continue
|
||||
}
|
||||
if parts[0] == "STABLE_GIT_VERSION" {
|
||||
flagVersion = fmt.Sprintf("hscloud-git-%s", parts[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if flagVersion == "" {
|
||||
log.Fatalf("could not determine version from status")
|
||||
}
|
||||
|
||||
// a yaml is a json, a json is a yaml
|
||||
yml := struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Author string `json:"author"`
|
||||
Main string `json:"main"`
|
||||
APIVersion string `json:"api-version"`
|
||||
}{
|
||||
Name: flagName,
|
||||
Version: flagVersion,
|
||||
Author: flagAuthor,
|
||||
Main: flagMain,
|
||||
APIVersion: "1.15",
|
||||
}
|
||||
|
||||
out, err := json.Marshal(&yml)
|
||||
if err != nil {
|
||||
log.Fatalf("marshal: %v", err)
|
||||
}
|
||||
err = ioutil.WriteFile(flagOutFile, out, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("WriteFile(%q): %v", out, err)
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
load("//personal/q3k/minecraft/plugin:defs.bzl", "bukkit_plugin")
|
||||
|
||||
bukkit_plugin(
|
||||
name = "hscloud",
|
||||
main = "hscloud.personal.q3k.minecraft.plugin.hscloud.Main",
|
||||
author = "q3k",
|
||||
srcs = [
|
||||
"Main.java",
|
||||
"StateSynchronizer.java",
|
||||
],
|
||||
deps = [
|
||||
"//personal/q3k/minecraft/plugin/hscloud/proto:hscloud_java_grpc",
|
||||
"//personal/q3k/minecraft/plugin/hscloud/proto:hscloud_java_proto",
|
||||
"@maven//:org_spigotmc_spigot_api",
|
||||
"@io_grpc_grpc_java//api",
|
||||
"@io_grpc_grpc_java//stub",
|
||||
"@maven//:io_grpc_grpc_netty_shaded",
|
||||
"@maven//:io_grpc_grpc_services",
|
||||
],
|
||||
)
|
|
@ -1,108 +0,0 @@
|
|||
package hscloud.personal.q3k.minecraft.plugin.hscloud;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import io.grpc.Server;
|
||||
import io.grpc.ServerBuilder;
|
||||
import io.grpc.protobuf.services.ProtoReflectionService;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import hscloud.personal.q3k.minecraft.plugin.hscloud.proto.IntrospectorGrpc;
|
||||
import hscloud.personal.q3k.minecraft.plugin.hscloud.proto.Proto;
|
||||
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
private Server server_;
|
||||
private static final Logger logger_ = Logger.getLogger(Main.class.getName());
|
||||
private static final int port_ = 2137;
|
||||
|
||||
public StateSynchronizer synchronizer_;
|
||||
|
||||
public Main() {
|
||||
synchronizer_ = new StateSynchronizer();
|
||||
server_ = ServerBuilder
|
||||
.forPort(port_)
|
||||
.addService(new IntrospectorService(synchronizer_))
|
||||
.addService(ProtoReflectionService.newInstance())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
BukkitScheduler scheduler = getServer().getScheduler();
|
||||
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<StateSynchronizer.Player> players = new ArrayList<StateSynchronizer.Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
StateSynchronizer.Player pp = new StateSynchronizer.Player(p.getPlayerListName(), p.getUniqueId().toString());
|
||||
players.add(pp);
|
||||
}
|
||||
synchronizer_.setPlayers(players.toArray(new StateSynchronizer.Player[0]));
|
||||
|
||||
World world = Bukkit.getWorld("world");
|
||||
if (world != null) {
|
||||
synchronizer_.setTime(world.getTime());
|
||||
}
|
||||
}
|
||||
}, 0, 20L);
|
||||
|
||||
try {
|
||||
server_.start();
|
||||
} catch (IOException e) {
|
||||
logger_.severe("could not start gRPC");
|
||||
e.printStackTrace(System.err);
|
||||
return;
|
||||
}
|
||||
logger_.info("gRPC started, listening on " + port_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (server_ != null) {
|
||||
try {
|
||||
server_.shutdown().awaitTermination(30, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
logger_.severe("could not stop gRPC");
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
server_ = null;
|
||||
}
|
||||
|
||||
public static class IntrospectorService extends IntrospectorGrpc.IntrospectorImplBase {
|
||||
private StateSynchronizer synchronizer_;
|
||||
|
||||
public IntrospectorService(StateSynchronizer synchronizer) {
|
||||
synchronizer_ = synchronizer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void status(Proto.StatusRequest request, StreamObserver<Proto.StatusResponse> responseObserver) {
|
||||
StateSynchronizer.Player[] players = synchronizer_.getPlayers();
|
||||
|
||||
Proto.StatusResponse.Builder builder = Proto.StatusResponse.newBuilder();
|
||||
builder.setTime(synchronizer_.getTime());
|
||||
for (StateSynchronizer.Player p : players) {
|
||||
builder.addPlayers(Proto.Player.newBuilder()
|
||||
.setUsername(p.getName())
|
||||
.setUuid(p.getUUID())
|
||||
.build());
|
||||
|
||||
|
||||
}
|
||||
responseObserver.onNext(builder.build());
|
||||
responseObserver.onCompleted();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package hscloud.personal.q3k.minecraft.plugin.hscloud;
|
||||
|
||||
public class StateSynchronizer {
|
||||
private Player[] players_;
|
||||
private long time_;
|
||||
private Object lock_ = new Object();
|
||||
|
||||
public void setPlayers(Player[] players) {
|
||||
synchronized(lock_) {
|
||||
players_ = players;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
synchronized(lock_) {
|
||||
time_ = time;
|
||||
}
|
||||
}
|
||||
|
||||
public Player[] getPlayers() {
|
||||
synchronized(lock_) {
|
||||
return players_;
|
||||
}
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
synchronized(lock_) {
|
||||
return time_;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Player {
|
||||
private String name_;
|
||||
private String uuid_;
|
||||
|
||||
public Player(String name, String uuid) {
|
||||
name_ = name;
|
||||
uuid_ = uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name_;
|
||||
}
|
||||
|
||||
public String getUUID() {
|
||||
return uuid_;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
load("@io_bazel_rules_docker//container:container.bzl", "container_image")
|
||||
load("@io_bazel_rules_docker//container:container.bzl", "container_push")
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importpath = "code.hackerspace.pl/hscloud/personal/q3k/minecraft/plugin/hscloud/bridge",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//personal/q3k/minecraft/plugin/hscloud/proto:go_default_library",
|
||||
"@org_golang_google_grpc//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "bridge",
|
||||
embed = [":go_default_library"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
container_image(
|
||||
name = "bridge_container",
|
||||
base = "@prodimage-bionic//image",
|
||||
files = [":bridge"],
|
||||
directory = "/personal/q3k/minecraft/plugin/hscloud/bridge",
|
||||
entrypoint = "/personal/q3k/minecraft/plugin/hscloud/bridge/bridge",
|
||||
)
|
||||
|
||||
container_push(
|
||||
name = "bridge_container_push",
|
||||
image = ":bridge_container",
|
||||
format = "Docker",
|
||||
registry = "registry.k0.hswaw.net",
|
||||
repository = "q3k/minecraft-hscloud-bridge",
|
||||
tag = "20200518c",
|
||||
)
|
|
@ -1,48 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
pb "code.hackerspace.pl/hscloud/personal/q3k/minecraft/plugin/hscloud/proto"
|
||||
)
|
||||
|
||||
var (
|
||||
flagPlugin string
|
||||
flagListen string
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.StringVar(&flagPlugin, "plugin", "minecraft.wypierdolzpolski.pl:2137", "address of gRPC plugin")
|
||||
flag.StringVar(&flagListen, "listen", "0.0.0.0:8081", "address to listen at")
|
||||
flag.Parse()
|
||||
|
||||
conn, err := grpc.Dial(flagPlugin, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
log.Fatalf("Dial(%q): %v", flagPlugin, err)
|
||||
}
|
||||
|
||||
client := pb.NewIntrospectorClient(conn)
|
||||
|
||||
http.HandleFunc("/metrics", func(w http.ResponseWriter, r *http.Request) {
|
||||
res, err := client.Status(r.Context(), &pb.StatusRequest{})
|
||||
if err != nil {
|
||||
http.Error(w, "internal server error", 500)
|
||||
log.Printf("Status error: %v", err)
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "# HELP minecraft_players_online Total number of players online.\n")
|
||||
fmt.Fprintf(w, "# TYPE minecraft_players_online gauge\n")
|
||||
fmt.Fprintf(w, "minecraft_players_online %d\n", len(res.Players))
|
||||
})
|
||||
|
||||
log.Printf("Listening on %s", flagListen)
|
||||
err = http.ListenAndServe(flagListen, nil)
|
||||
if err != nil {
|
||||
log.Fatalf("ListenAndServe: %v", err)
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")
|
||||
|
||||
java_proto_library(
|
||||
name = "hscloud_java_proto",
|
||||
deps = [":hscloud_proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
java_grpc_library(
|
||||
name = "hscloud_java_grpc",
|
||||
srcs = [":hscloud_proto"],
|
||||
deps = [":hscloud_java_proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "hscloud_proto",
|
||||
srcs = ["hscloud.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_proto_library(
|
||||
name = "hscloud_go_proto",
|
||||
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
|
||||
importpath = "code.hackerspace.pl/hscloud/personal/q3k/minecraft/plugin/hscloud/proto",
|
||||
proto = ":hscloud_proto",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
embed = [":hscloud_go_proto"],
|
||||
importpath = "code.hackerspace.pl/hscloud/personal/q3k/minecraft/plugin/hscloud/proto",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -1 +0,0 @@
|
|||
package proto
|
|
@ -1,22 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package hscloud.personal.q3k.minecraft.plugin.hscloud;
|
||||
option java_package = "hscloud.personal.q3k.minecraft.plugin.hscloud.proto";
|
||||
option java_outer_classname = "Proto";
|
||||
option go_package = "hscloud";
|
||||
|
||||
service Introspector {
|
||||
rpc Status(StatusRequest) returns (StatusResponse);
|
||||
}
|
||||
|
||||
message StatusRequest {
|
||||
}
|
||||
|
||||
message StatusResponse {
|
||||
repeated Player players = 1;
|
||||
int64 time = 2;
|
||||
}
|
||||
|
||||
message Player {
|
||||
string username = 1;
|
||||
string uuid = 2;
|
||||
}
|
|
@ -1,260 +0,0 @@
|
|||
local kube = import "../../../kube/kube.libsonnet";
|
||||
local defaultWorldguardConfig = import "worldguard.libsonnet";
|
||||
|
||||
{
|
||||
local minecraft = self,
|
||||
versions:: {
|
||||
"spigot-1.16.1": "registry.k0.hswaw.net/q3k/minecraft:spigot-1.16.1-r2",
|
||||
"paper-1.16.1": "registry.k0.hswaw.net/q3k/minecraft:paper-1.16.1-r2",
|
||||
"paper-1.16.4": "registry.k0.hswaw.net/q3k/minecraft:paper-1.16.4-r1",
|
||||
"paper-1.16.5": "registry.k0.hswaw.net/q3k/minecraft:paper-1.16.5-r2",
|
||||
"vanilla-1.16.5": "registry.k0.hswaw.net/enleth/minectaft:vanilla-1.16.5",
|
||||
},
|
||||
server(name, version):: {
|
||||
local server = self,
|
||||
name:: name,
|
||||
version:: version,
|
||||
image:: minecraft.versions[server.version],
|
||||
worldedit:: true,
|
||||
overviewer:: true,
|
||||
|
||||
metadata:: {
|
||||
namespace: "minecraft",
|
||||
},
|
||||
|
||||
componentName(component):: "%s-%s" % [server.name, component],
|
||||
|
||||
properties:: {
|
||||
"spawn-protection": 16,
|
||||
"max-tick-time": 60000,
|
||||
"query.port": 25565,
|
||||
"generator-settings": "",
|
||||
"force-gamemode": false,
|
||||
"allow-nether": true,
|
||||
"enforce-whitelist": false,
|
||||
"gamemode": "survival",
|
||||
"broadcast-console-to-ops": true,
|
||||
"enable-query": false,
|
||||
"player-idle-timeout": 0,
|
||||
"difficulty": "easy",
|
||||
"broadcast-rcon-to-ops": true,
|
||||
"spawn-monsters": true,
|
||||
"op-permission-level": 4,
|
||||
"pvp": true,
|
||||
"snooper-enabled": true,
|
||||
"level-type": "default",
|
||||
"hardcore": false,
|
||||
"enable-command-block": false,
|
||||
"network-compression-threshold": 256,
|
||||
"max-players": 20,
|
||||
"max-world-size": 29999984,
|
||||
"resource-pack-sha1": "",
|
||||
"function-permission-level": 2,
|
||||
"rcon.port": 25575,
|
||||
"server-port": 25565,
|
||||
"debug": false,
|
||||
"server-ip": "",
|
||||
"spawn-npcs": true,
|
||||
"allow-flight": false,
|
||||
"level-name": "world",
|
||||
"view-distance": 10,
|
||||
"resource-pack": "",
|
||||
"spawn-animals": true,
|
||||
"white-list": false,
|
||||
"rcon.password": "",
|
||||
"generate-structures": true,
|
||||
"online-mode": true,
|
||||
"max-build-height": 256,
|
||||
"level-seed": "",
|
||||
"prevent-proxy-connections": false,
|
||||
"use-native-transport": true,
|
||||
"motd": "A Minecraft Server",
|
||||
"enable-rcon": false,
|
||||
},
|
||||
|
||||
worldguardConfig:: defaultWorldguardConfig,
|
||||
|
||||
startSteps:: [
|
||||
] + (if server.worldedit then [
|
||||
"mkdir -p plugins/WorldGuard",
|
||||
"cp /home/minecraft/worldedit-*.jar plugins",
|
||||
"cp /home/minecraft/worldguard-*.jar plugins",
|
||||
"cp /home/minecraft/config/worldguard_config.yaml plugins/WorldGuard/config.yml",
|
||||
] else []),
|
||||
|
||||
startsh:: |||
|
||||
#!/usr/bin/env bash
|
||||
cd /home/minecraft/world
|
||||
cp /home/minecraft/config/server.properties .
|
||||
cp /home/minecraft/server.jar .
|
||||
echo "eula=true" > eula.txt
|
||||
%s
|
||||
|
||||
bash /home/minecraft/config/overviewer.sh &
|
||||
exec java -Xmx4G -Xms4G -jar server.jar
|
||||
||| % [std.join("\n", server.startSteps)],
|
||||
|
||||
overviewersh:: |||
|
||||
#!/usr/bin/env bash
|
||||
mkdir -p overviewer/world
|
||||
sleep 60
|
||||
while true; do
|
||||
echo "Rendering Overviewer map..."
|
||||
overviewer.py -p 1 --rendermodes=normal,lighting,smooth-lighting,cave world overviewer/world
|
||||
echo "Done."
|
||||
sleep 900
|
||||
done
|
||||
|||,
|
||||
|
||||
secretProperties: kube.Secret(server.componentName("properties")) {
|
||||
metadata+: server.metadata,
|
||||
data: {
|
||||
local properties = std.join("\n", ["%s=%s" % [k, std.toString(server.properties[k])] for k in std.objectFields(server.properties)]),
|
||||
"server.properties": std.base64(properties),
|
||||
"start.sh": std.base64(server.startsh),
|
||||
} + (if server.worldedit then {
|
||||
local worldguardConfig = std.manifestYamlDoc(server.worldguardConfig),
|
||||
"worldguard_config.yaml": std.base64(worldguardConfig),
|
||||
} else {} )+ (if server.overviewer then {
|
||||
"overviewer.sh": std.base64(server.overviewersh),
|
||||
} else {}),
|
||||
},
|
||||
|
||||
worldVolume: kube.PersistentVolumeClaim(server.componentName("world")) {
|
||||
metadata+: server.metadata,
|
||||
spec+: {
|
||||
storageClassName: "waw-hdd-redundant-3",
|
||||
accessModes: ["ReadWriteOnce"],
|
||||
resources: {
|
||||
requests: {
|
||||
storage: "10Gi",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
deploy: kube.Deployment(server.componentName("deploy")) {
|
||||
metadata+: server.metadata,
|
||||
spec+: {
|
||||
template+: {
|
||||
spec+: {
|
||||
volumes_: {
|
||||
config: kube.SecretVolume(server.secretProperties),
|
||||
world: kube.PersistentVolumeClaimVolume(server.worldVolume),
|
||||
},
|
||||
containers_: {
|
||||
default: kube.Container("default") {
|
||||
image: server.image,
|
||||
command: [
|
||||
"bash", "/home/minecraft/config/start.sh",
|
||||
],
|
||||
volumeMounts_: {
|
||||
config: { mountPath: "/home/minecraft/config" },
|
||||
world: { mountPath: "/home/minecraft/world" },
|
||||
},
|
||||
ports_: {
|
||||
minecraft: { containerPort: 25565 },
|
||||
grpc: { containerPort: 2137 },
|
||||
},
|
||||
resources: {
|
||||
requests: {
|
||||
memory: "6G",
|
||||
cpu: "2",
|
||||
},
|
||||
limits: {
|
||||
memory: "6G",
|
||||
cpu: "4",
|
||||
},
|
||||
},
|
||||
},
|
||||
bridge: kube.Container("bridge") {
|
||||
image: "registry.k0.hswaw.net/q3k/minecraft-hscloud-bridge:20200518c",
|
||||
command: [
|
||||
"/personal/q3k/minecraft/plugin/hscloud/bridge/bridge",
|
||||
"-plugin", "127.0.0.1:2137",
|
||||
],
|
||||
ports_: {
|
||||
bridge: { containerPort: 8081 },
|
||||
},
|
||||
},
|
||||
} + (if server.overviewer then {
|
||||
overviewer: kube.Container("overviewer") {
|
||||
image: "halverneus/static-file-server:v1.8.0",
|
||||
env_: {
|
||||
FOLDER: "/home/minecraft/world/overviewer/world",
|
||||
},
|
||||
volumeMounts_: {
|
||||
world: { mountPath: "/home/minecraft/world" },
|
||||
},
|
||||
ports_: {
|
||||
web: { containerPort: 8080 },
|
||||
},
|
||||
},
|
||||
} else {}),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
svc: kube.Service(server.componentName("svc")) {
|
||||
metadata+: server.metadata,
|
||||
target_pod:: server.deploy.spec.template,
|
||||
spec+: {
|
||||
ports: [
|
||||
{ name: "minecraft", port: 25565, targetPort: 25565, protocol: "TCP" },
|
||||
{ name: "web", port: 80, targetPort: 8080, protocol: "TCP" },
|
||||
{ name: "bridge", port: 8080, targetPort: 8081, protocol: "TCP" },
|
||||
{ name: "grpc", port: 2137, targetPort: 2137, protocol: "TCP" },
|
||||
],
|
||||
type: "LoadBalancer",
|
||||
externalTrafficPolicy: "Local",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
ns: kube.Namespace("minecraft"),
|
||||
|
||||
admins: minecraft.ns.Contain(kube.RoleBinding("admins")) {
|
||||
roleRef: {
|
||||
apiGroup: "rbac.authorization.k8s.io",
|
||||
kind: "ClusterRole",
|
||||
name: "system:admin-namespace",
|
||||
},
|
||||
subjects: [
|
||||
kube.User("enleth@hackerspace.pl"),
|
||||
],
|
||||
},
|
||||
|
||||
q3k: {
|
||||
"nova-arcana": minecraft.server("q3k-nova-arcana", "vanilla-1.16.5") {
|
||||
overviewer: false,
|
||||
worldedit: false,
|
||||
properties+: {
|
||||
motd: "Nova Arcana V1.1.4",
|
||||
//"enforce-whitelist": true,
|
||||
"enable-rcon": "true",
|
||||
"rcon.password": "dupa.8",
|
||||
"enable-command-block": true,
|
||||
},
|
||||
startSteps+: [
|
||||
|||
|
||||
if [ ! -e world/map-installed.txt ]; then
|
||||
set -e -x
|
||||
mkdir -p world
|
||||
cd world
|
||||
rm -rf *
|
||||
wget https://object.ceph-waw3.hswaw.net/q3k-personal/f1a73ad0518a2629a5bed072a7de4e4534a3c89705d6cea2f203a05cccd01634.zip -O map.zip
|
||||
unzip -o map.zip
|
||||
mv Untold*/* .
|
||||
rm -rf Untold*
|
||||
rm map.zip
|
||||
touch map-installed.txt
|
||||
ls -la
|
||||
cd ..
|
||||
set +e +x
|
||||
fi
|
||||
|||
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,190 +0,0 @@
|
|||
{
|
||||
regions: {
|
||||
"uuid-migration": {
|
||||
"perform-on-next-start": false,
|
||||
"keep-names-that-lack-uuids": true,
|
||||
},
|
||||
"use-creature-spawn-event": true,
|
||||
sql: {
|
||||
use: false,
|
||||
dsn: "jdbc:mysql://localhost/worldguard",
|
||||
username: "worldguard",
|
||||
password: "worldguard",
|
||||
"table-prefix": "",
|
||||
},
|
||||
"use-paper-entity-origin": false,
|
||||
enable: true,
|
||||
"invincibility-removes-mobs": false,
|
||||
"cancel-chat-without-recipients": true,
|
||||
"nether-portal-protection": false,
|
||||
"fake-player-build-override": true,
|
||||
"explosion-flags-block-entity-damage": true,
|
||||
"high-frequency-flags": false,
|
||||
"protect-against-liquid-flow": false,
|
||||
wand: "minecraft:leather",
|
||||
"max-claim-volume": 30000,
|
||||
"claim-only-inside-existing-regions": false,
|
||||
"location-flags-only-inside-regions": false,
|
||||
"max-region-count-per-player": {
|
||||
default: 7,
|
||||
},
|
||||
},
|
||||
"auto-invincible": false,
|
||||
"auto-invincible-group": false,
|
||||
"auto-no-drowning-group": false,
|
||||
"use-player-move-event": true,
|
||||
"use-player-teleports": true,
|
||||
"use-particle-effects": true,
|
||||
security: {
|
||||
"deop-everyone-on-join": false,
|
||||
"block-in-game-op-command": false,
|
||||
"host-keys-allow-forge-clients": false,
|
||||
},
|
||||
"host-keys": {},
|
||||
"summary-on-start": true,
|
||||
"op-permissions": true,
|
||||
"build-permission-nodes": {
|
||||
enable: false,
|
||||
"deny-message": "&eSorry, but you are not permitted to do that here.",
|
||||
},
|
||||
"event-handling": {
|
||||
"block-entity-spawns-with-untraceable-cause": false,
|
||||
"interaction-whitelist": [],
|
||||
"emit-block-use-at-feet": [],
|
||||
"ignore-hopper-item-move-events": false,
|
||||
},
|
||||
protection: {
|
||||
"item-durability": true,
|
||||
"remove-infinite-stacks": false,
|
||||
"disable-xp-orb-drops": false,
|
||||
"disable-obsidian-generators": false,
|
||||
},
|
||||
gameplay: {
|
||||
"block-potions": [],
|
||||
"block-potions-overly-reliably": false,
|
||||
"disable-conduit-effects": false,
|
||||
},
|
||||
simulation: {
|
||||
sponge: {
|
||||
enable: false,
|
||||
radius: 3,
|
||||
redstone: false,
|
||||
},
|
||||
},
|
||||
default: {
|
||||
"pumpkin-scuba": false,
|
||||
"disable-health-regain": false,
|
||||
},
|
||||
physics: {
|
||||
"no-physics-gravel": false,
|
||||
"no-physics-sand": false,
|
||||
"vine-like-rope-ladders": false,
|
||||
"allow-portal-anywhere": false,
|
||||
"disable-water-damage-blocks": [],
|
||||
},
|
||||
ignition: {
|
||||
"block-tnt": false,
|
||||
"block-tnt-block-damage": false,
|
||||
"block-lighter": false,
|
||||
},
|
||||
fire: {
|
||||
"disable-lava-fire-spread": false,
|
||||
"disable-all-fire-spread": false,
|
||||
"disable-fire-spread-blocks": [],
|
||||
"lava-spread-blocks": [],
|
||||
},
|
||||
mobs: {
|
||||
"block-creeper-explosions": false,
|
||||
"block-creeper-block-damage": false,
|
||||
"block-wither-explosions": false,
|
||||
"block-wither-block-damage": false,
|
||||
"block-wither-skull-explosions": false,
|
||||
"block-wither-skull-block-damage": false,
|
||||
"block-enderdragon-block-damage": false,
|
||||
"block-enderdragon-portal-creation": false,
|
||||
"block-fireball-explosions": false,
|
||||
"block-fireball-block-damage": false,
|
||||
"anti-wolf-dumbness": false,
|
||||
"allow-tamed-spawns": true,
|
||||
"disable-enderman-griefing": false,
|
||||
"disable-snowman-trails": false,
|
||||
"block-painting-destroy": false,
|
||||
"block-item-frame-destroy": false,
|
||||
"block-armor-stand-destroy": false,
|
||||
"block-plugin-spawning": true,
|
||||
"block-above-ground-slimes": false,
|
||||
"block-other-explosions": false,
|
||||
"block-zombie-door-destruction": false,
|
||||
"block-creature-spawn": [],
|
||||
},
|
||||
"player-damage": {
|
||||
"disable-fall-damage": false,
|
||||
"disable-lava-damage": false,
|
||||
"disable-fire-damage": false,
|
||||
"disable-lightning-damage": false,
|
||||
"disable-drowning-damage": false,
|
||||
"disable-suffocation-damage": false,
|
||||
"disable-contact-damage": false,
|
||||
"teleport-on-suffocation": false,
|
||||
"disable-void-damage": false,
|
||||
"teleport-on-void-falling": false,
|
||||
"reset-fall-on-void-teleport": false,
|
||||
"disable-explosion-damage": false,
|
||||
"disable-mob-damage": false,
|
||||
"disable-death-messages": false,
|
||||
},
|
||||
"chest-protection": {
|
||||
enable: false,
|
||||
"disable-off-check": false,
|
||||
},
|
||||
crops: {
|
||||
"disable-creature-trampling": false,
|
||||
"disable-player-trampling": false,
|
||||
},
|
||||
weather: {
|
||||
"prevent-lightning-strike-blocks": [],
|
||||
"disable-lightning-strike-fire": false,
|
||||
"disable-thunderstorm": false,
|
||||
"disable-weather": false,
|
||||
"disable-pig-zombification": false,
|
||||
"disable-villager-witchification": false,
|
||||
"disable-powered-creepers": false,
|
||||
"always-raining": false,
|
||||
"always-thundering": false,
|
||||
},
|
||||
dynamics: {
|
||||
"disable-mushroom-spread": false,
|
||||
"disable-ice-melting": false,
|
||||
"disable-snow-melting": false,
|
||||
"disable-snow-formation": false,
|
||||
"disable-ice-formation": false,
|
||||
"disable-leaf-decay": false,
|
||||
"disable-grass-growth": false,
|
||||
"disable-mycelium-spread": false,
|
||||
"disable-vine-growth": false,
|
||||
"disable-crop-growth": false,
|
||||
"disable-soil-dehydration": false,
|
||||
"snow-fall-blocks": [],
|
||||
},
|
||||
blacklist: {
|
||||
"use-as-whitelist": false,
|
||||
logging: {
|
||||
console: {
|
||||
enable: true,
|
||||
},
|
||||
database: {
|
||||
enable: false,
|
||||
dsn: "jdbc:mysql://localhost:3306/minecraft",
|
||||
user: "root",
|
||||
pass: "",
|
||||
table: "blacklist_events",
|
||||
},
|
||||
file: {
|
||||
enable: false,
|
||||
path: "worldguard/logs/%Y-%m-%d.log",
|
||||
"open-files": 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
"custom-metrics-charts": true,
|
||||
}
|
0
third_party/java/BUILD
vendored
0
third_party/java/BUILD
vendored
1211
third_party/java/maven_install.json
vendored
1211
third_party/java/maven_install.json
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue