Skip to content

Commit

Permalink
start on rewriting the linking server to be a plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
onebeastchris committed Jan 5, 2025
1 parent 4b10b9e commit a45ff2a
Show file tree
Hide file tree
Showing 22 changed files with 112 additions and 1,563 deletions.
20 changes: 3 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
application
alias(libs.plugins.indra)
alias(libs.plugins.indra.licenser.spotless)
}
Expand All @@ -8,26 +7,17 @@ group = "org.geysermc.globallinkserver"

dependencies {
implementation(libs.gson) // newer version required for record support
implementation(libs.fastutil.common)

implementation(libs.bundles.protocol)
implementation(libs.mcprotocollib) {
exclude("io.netty", "netty-all")
}
implementation(libs.bundles.fastutil)

// mcprotocollib won't work without this
implementation(libs.netty.handler)
compileOnly(libs.spigot.api)
compileOnly(libs.geyser.api)

implementation(libs.adventure.text.legacy)
implementation(libs.mariadb.client)

compileOnly(libs.checker.qual)
}

application {
mainClass.set("org.geysermc.globallinkserver.GlobalLinkServer")
}

indra {
github("GeyserMC", "GlobalLinkServer") {
ci(true)
Expand Down Expand Up @@ -57,8 +47,4 @@ tasks.jar {
archiveBaseName = "GlobalLinkServer"
archiveVersion = ""
archiveClassifier = ""

manifest {
attributes["Main-Class"] = application.mainClass
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.0-SNAPSHOT
version=2.0-SNAPSHOT
22 changes: 10 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
[versions]
gson = "2.10.1"
protocol = "3.0.0.Beta5-20241022.154658-14"
netty = "4.1.110.Final"
fastutil = "8.5.2"
mcprotocollib = "86903ec" # Revert from jitpack after release
adventure-text = "4.15.0-20231207.074016-23" # Match version to MCPL
mariadb-client = "2.7.3"
checker-qual = "3.21.1"
indra = "3.1.2"

spigot-api = "1.16.5-R0.1-SNAPSHOT"

[libraries]
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
protocol-codec = { module = "org.cloudburstmc.protocol:bedrock-codec", version.ref = "protocol" }
protocol-connection = { module = "org.cloudburstmc.protocol:bedrock-connection", version.ref = "protocol" }
protocol-common = { module = "org.cloudburstmc.protocol:common", version.ref = "protocol" }
spigot-api = { group = "org.spigotmc", name = "spigot-api", version.ref = "spigot-api" }
geyser-api = { group = "org.geysermc.geyser", name = "api", version = "2.6.0-SNAPSHOT" }

netty-handler = { group = "io.netty", name = "netty-handler", version.ref = "netty" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }

fastutil-common = { module = "com.nukkitx.fastutil:fastutil-common", version.ref = "fastutil" }
mcprotocollib = { module = "com.github.GeyserMC:mcprotocollib", version.ref = "mcprotocollib" }
adventure-text-legacy = { module = "net.kyori:adventure-text-serializer-legacy", version.ref = "adventure-text" }
fastutil-int-int-maps = { group = "com.nukkitx.fastutil", name = "fastutil-int-int-maps", version.ref = "fastutil" }
fastutil-int-object-maps = { group = "com.nukkitx.fastutil", name = "fastutil-int-object-maps", version.ref = "fastutil" }
fastutil-object-int-maps = { group = "com.nukkitx.fastutil", name = "fastutil-object-int-maps", version.ref = "fastutil" }
fastutil-object-object-maps = { group = "com.nukkitx.fastutil", name = "fastutil-object-object-maps", version.ref = "fastutil" }
mariadb-client = { module = "org.mariadb.jdbc:mariadb-java-client", version.ref = "mariadb-client" }

checker-qual = { module = "org.checkerframework:checker-qual", version.ref = "checker-qual" }
Expand All @@ -30,4 +28,4 @@ indra-publishing = { id = "net.kyori.indra.publishing", version.ref = "indra" }
indra-licenser-spotless = { id = "net.kyori.indra.licenser.spotless", version.ref = "indra" }

[bundles]
protocol = ["protocol-codec", "protocol-connection", "protocol-common"]
fastutil = [ "fastutil-int-int-maps", "fastutil-int-object-maps", "fastutil-object-int-maps", "fastutil-object-object-maps" ]
46 changes: 28 additions & 18 deletions src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 GeyserMC
* Copyright (c) 2021-2025 GeyserMC
* Licensed under the MIT license
* @link https://github.com/GeyserMC/GlobalLinkServer
*/
Expand All @@ -8,39 +8,49 @@
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import org.geysermc.globallinkserver.bedrock.BedrockServer;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.globallinkserver.config.Config;
import org.geysermc.globallinkserver.config.ConfigReader;
import org.geysermc.globallinkserver.java.JavaServer;
import org.geysermc.globallinkserver.link.LinkManager;
import org.geysermc.globallinkserver.player.PlayerManager;
import org.geysermc.globallinkserver.util.CommandUtils;

public class GlobalLinkServer {
public class GlobalLinkServer extends JavaPlugin {
private static final Timer TIMER = new Timer();
public static final Logger LOGGER = Logger.getGlobal();
public static Logger LOGGER;

public static void main(String... args) {
// Make logging more simple, adopted from https://stackoverflow.com/a/5937929
System.setProperty(
"java.util.logging.SimpleFormatter.format", "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %5$s%6$s%n");
private LinkManager linkManager;

Config config = ConfigReader.readConfig();
@Override
public void onEnable() {
LOGGER = getLogger();

PlayerManager playerManager = new PlayerManager();
LinkManager linkManager = new LinkManager(config);
Config config = ConfigReader.readConfig();
linkManager = new LinkManager(config);

new JavaServer(playerManager, linkManager).startServer(config);
new BedrockServer(playerManager, linkManager).startServer(config);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, linkManager::cleanupTempLinks, 0, 0);

TimerTask task = new TimerTask() {
@Override
public void run() {
linkManager.cleanupTempLinks(playerManager);
linkManager.cleanupTempLinks();
}
};
TIMER.scheduleAtFixedRate(task, 0L, 60_000L);

LOGGER.info(
"Started Global Linking Server on java: " + config.javaPort() + ", bedrock: " + config.bedrockPort());
LOGGER.info("Started Global Linking Server plugin!");
}

@Override
public boolean onCommand(
@NonNull CommandSender sender, @NonNull Command command, @NonNull String label, @NonNull String[] args) {
if (sender instanceof Player player) {
CommandUtils.handleCommand(linkManager, player, command.getName() + " " + String.join(" ", args));
}
return true;
}
}
40 changes: 0 additions & 40 deletions src/main/java/org/geysermc/globallinkserver/Server.java

This file was deleted.

Loading

0 comments on commit a45ff2a

Please sign in to comment.