Skip to content

Commit

Permalink
Merge branch 'GeyserMC:master' into rp
Browse files Browse the repository at this point in the history
  • Loading branch information
onebeastchris authored Aug 11, 2024
2 parents b43e2db + d3ea651 commit 20e4919
Show file tree
Hide file tree
Showing 20 changed files with 177 additions and 132 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ locales/
/packs/
/dump.json
/saved-refresh-tokens.json
/saved-auth-chains.json
/custom_mappings/
/languages/
/custom-skulls.yml
/custom-skulls.yml
/permissions.yml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!

## Supported Versions
Geyser is currently supporting Minecraft Bedrock 1.20.80 - 1.21.3 and Minecraft Java Server 1.21. For more info please see [here](https://geysermc.org/wiki/geyser/supported-versions/).
Geyser is currently supporting Minecraft Bedrock 1.20.80 - 1.21.3 and Minecraft Java Server 1.21/1.21.1. For more info please see [here](https://geysermc.org/wiki/geyser/supported-versions/).

## Setting Up
Take a look [here](https://geysermc.org/wiki/geyser/setup/) for how to set up Geyser.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
private IGeyserPingPassthrough geyserBungeePingPassthrough;
private GeyserImpl geyser;

// We can't disable the plugin; hence we need to keep track of it manually
private boolean disabled;

@Override
public void onLoad() {
onGeyserInitialize();
Expand All @@ -98,7 +95,6 @@ public void onGeyserInitialize() {
}

if (!this.loadConfig()) {
disabled = true;
return;
}
this.geyserLogger.setDebug(geyserConfig.isDebugMode());
Expand All @@ -112,7 +108,7 @@ public void onGeyserInitialize() {

@Override
public void onEnable() {
if (disabled) {
if (geyser == null) {
return; // Config did not load properly!
}
// Big hack - Bungee does not provide us an event to listen to, so schedule a repeating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public void onGeyserInitialize() {
}

public void onGeyserEnable() {
// "Disabling" a mod isn't possible; so if we fail to initialize we need to manually stop here
if (geyser == null) {
return;
}

if (GeyserImpl.getInstance().isReloading()) {
if (!loadConfig()) {
return;
Expand Down
2 changes: 2 additions & 0 deletions bootstrap/spigot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {

modrinth {
uploadFile.set(tasks.getByPath("shadowJar"))
gameVersions.addAll("1.16.5", "1.17", "1.17.1", "1.18", "1.18.1", "1.18.2", "1.19",
"1.19.1", "1.19.2", "1.19.3", "1.19.4", "1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4", "1.20.5", "1.20.6")
loaders.addAll("spigot", "paper")
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public void onGeyserInitialize() {
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_server.message", "1.13.2"));
geyserLogger.error("");
geyserLogger.error("*********************************************");
Bukkit.getPluginManager().disablePlugin(this);
return;
}

Expand All @@ -131,7 +130,6 @@ public void onGeyserInitialize() {
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_server_type.message", "Paper"));
geyserLogger.error("");
geyserLogger.error("*********************************************");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
}
Expand All @@ -144,10 +142,25 @@ public void onGeyserInitialize() {
geyserLogger.error("This version of Spigot is using an outdated version of netty. Please use Paper instead!");
geyserLogger.error("");
geyserLogger.error("*********************************************");
Bukkit.getPluginManager().disablePlugin(this);
return;
}

try {
// Check spigot config for BungeeCord mode
if (Bukkit.getServer().spigot().getConfig().getBoolean("settings.bungeecord")) {
warnInvalidProxySetups("BungeeCord");
return;
}

// Now: Check for velocity mode - deliberately after checking bungeecord because this is a paper only option
if (Bukkit.getServer().spigot().getPaperConfig().getBoolean("proxies.velocity.enabled")) {
warnInvalidProxySetups("Velocity");
return;
}
} catch (NoSuchMethodError e) {
// no-op
}

if (!loadConfig()) {
return;
}
Expand All @@ -162,6 +175,11 @@ public void onGeyserInitialize() {

@Override
public void onEnable() {
// Disabling the plugin in onLoad() is not supported; we need to manually stop here
if (geyser == null) {
return;
}

// Create command manager early so we can add Geyser extension commands
var sourceConverter = new CommandSourceConverter<>(
CommandSender.class,
Expand Down Expand Up @@ -458,4 +476,13 @@ private boolean loadConfig() {

return true;
}

private void warnInvalidProxySetups(String platform) {
geyserLogger.error("*********************************************");
geyserLogger.error("");
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_proxy_backend", platform));
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.bootstrap.setup_guide", "https://geysermc.org/wiki/geyser/setup/"));
geyserLogger.error("");
geyserLogger.error("*********************************************");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public void onGeyserInitialize() {

@Override
public void onGeyserEnable() {
// If e.g. the config failed to load, GeyserImpl was not loaded and we cannot start
if (geyser == null) {
return;
}
if (GeyserImpl.getInstance().isReloading()) {
if (!loadConfig()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ public void onGeyserInitialize() {

@Override
public void onGeyserEnable() {
// If e.g. the config failed to load, GeyserImpl was not loaded and we cannot start
if (geyser == null) {
return;
}
boolean reloading = geyser.isReloading();
if (reloading) {
if (!this.loadConfig()) {
Expand All @@ -155,6 +159,9 @@ public void onGeyserEnable() {
// Only initialize the ping passthrough if the protocol version is above beta 1.7.3, as that's when the status protocol was added
this.pingPassthrough = GeyserLegacyPingPassthrough.init(this.geyser);
}
if (this.config.getRemote().authType() == AuthType.FLOODGATE) {
ViaProxy.getConfig().setPassthroughBungeecordPlayerInfo(true);
}
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/viaproxy/src/main/resources/viaproxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: "${name}-ViaProxy"
version: "${version}"
author: "${author}"
main: "org.geysermc.geyser.platform.viaproxy.GeyserViaProxyPlugin"
min-version: "3.2.1"
min-version: "3.3.2"
45 changes: 45 additions & 0 deletions build-logic/src/main/kotlin/geyser.build-logic.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
repositories {
// mavenLocal()

mavenCentral()

// Floodgate, Cumulus etc.
maven("https://repo.opencollab.dev/main")

// Paper, Velocity
maven("https://repo.papermc.io/repository/maven-public")

// Spigot
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") {
mavenContent { snapshotsOnly() }
}

// BungeeCord
maven("https://oss.sonatype.org/content/repositories/snapshots") {
mavenContent { snapshotsOnly() }
}

// NeoForge
maven("https://maven.neoforged.net/releases") {
mavenContent { releasesOnly() }
}

// Minecraft
maven("https://libraries.minecraft.net") {
name = "minecraft"
mavenContent { releasesOnly() }
}

// ViaVersion
maven("https://repo.viaversion.com") {
name = "viaversion"
}

// Jitpack for e.g. MCPL
maven("https://jitpack.io") {
content { includeGroupByRegex("com\\.github\\..*") }
}

// For Adventure snapshots
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.maven

plugins {
id("geyser.build-logic")
id("geyser.publish-conventions")
id("architectury-plugin")
id("dev.architectury.loom")
Expand Down Expand Up @@ -116,12 +117,3 @@ dependencies {
minecraft(libs.minecraft)
mappings(loom.officialMojangMappings())
}

repositories {
// mavenLocal()
maven("https://repo.opencollab.dev/main")
maven("https://jitpack.io")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://maven.neoforged.net/releases")
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ modrinth {
versionNumber.set(project.version as String + "-" + System.getenv("BUILD_NUMBER"))
versionType.set("beta")
changelog.set(System.getenv("CHANGELOG") ?: "")
gameVersions.add(libs.minecraft.get().version as String)
gameVersions.addAll("1.21", libs.minecraft.get().version as String)
failSilently.set(true)

syncBodyFrom.set(rootProject.file("README.md").readText())
}
}
41 changes: 19 additions & 22 deletions core/src/main/java/org/geysermc/geyser/GeyserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {

private final SessionManager sessionManager = new SessionManager();

/**
* This is used in GeyserConnect to stop the bedrock server binding to a port
*/
@Setter
private static boolean shouldStartListener = true;

private FloodgateCipher cipher;
private FloodgateSkinUploader skinUploader;
private NewsHandler newsHandler;
Expand Down Expand Up @@ -436,24 +430,27 @@ private void startInstance() {
bedrockThreadCount = Math.max(1, SystemPropertyUtil.getInt("io.netty.eventLoopThreads", NettyRuntime.availableProcessors() * 2));
}

if (shouldStartListener) {
this.geyserServer = new GeyserServer(this, bedrockThreadCount);
this.geyserServer.bind(new InetSocketAddress(config.getBedrock().address(), config.getBedrock().port()))
.whenComplete((avoid, throwable) -> {
if (throwable == null) {
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().address(),
String.valueOf(config.getBedrock().port())));
this.geyserServer = new GeyserServer(this, bedrockThreadCount);
this.geyserServer.bind(new InetSocketAddress(config.getBedrock().address(), config.getBedrock().port()))
.whenComplete((avoid, throwable) -> {
String address = config.getBedrock().address();
String port = String.valueOf(config.getBedrock().port()); // otherwise we get commas

if (throwable == null) {
if ("0.0.0.0".equals(address)) {
// basically just hide it in the log because some people get confused and try to change it
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start.ip_suppressed", port));
} else {
String address = config.getBedrock().address();
int port = config.getBedrock().port();
logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", address, String.valueOf(port)));
if (!"0.0.0.0".equals(address)) {
logger.info(Component.text("Suggestion: try setting `address` under `bedrock` in the Geyser config back to 0.0.0.0", NamedTextColor.GREEN));
logger.info(Component.text("Then, restart this server.", NamedTextColor.GREEN));
}
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", address, port));
}
}).join();
}
} else {
logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", address, port));
if (!"0.0.0.0".equals(address)) {
logger.info(Component.text("Suggestion: try setting `address` under `bedrock` in the Geyser config back to 0.0.0.0", NamedTextColor.GREEN));
logger.info(Component.text("Then, restart this server.", NamedTextColor.GREEN));
}
}
}).join();

if (config.getRemote().authType() == AuthType.FLOODGATE) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,31 @@ public DumpCommand(GeyserImpl geyser, String name, String description, String pe
this.geyser = geyser;
}

@Override
public void register(CommandManager<GeyserCommandSource> manager) {
manager.command(baseBuilder(manager)
.optional(ARGUMENTS, stringArrayParser(), SuggestionProvider.blockingStrings((ctx, input) -> {
// parse suggestions here
List<String> inputs = new ArrayList<>();
while (input.hasRemainingInput()) {
inputs.add(input.readStringSkipWhitespace());
}

if (inputs.size() <= 2) {
return SUGGESTIONS; // only `geyser dump` was typed (2 literals)
}

// the rest of the input after `geyser dump` is for this argument
inputs = inputs.subList(2, inputs.size());

// don't suggest any words they have already typed
List<String> suggestions = new ArrayList<>();
SUGGESTIONS.forEach(suggestions::add);
suggestions.removeAll(inputs);
return suggestions;
}))
.handler(this::execute));
}
@Override
public void register(CommandManager<GeyserCommandSource> manager) {
manager.command(baseBuilder(manager)
.optional(ARGUMENTS, stringArrayParser(), SuggestionProvider.blockingStrings((ctx, input) -> {
// parse suggestions here
List<String> inputs = new ArrayList<>();
while (input.hasRemainingInput()) {
inputs.add(input.readStringSkipWhitespace());
}

if (inputs.size() <= 2) {
return SUGGESTIONS; // only `geyser dump` was typed (2 literals)
}

// the rest of the input after `geyser dump` is for this argument
inputs = inputs.subList(2, inputs.size());

// don't suggest any words they have already typed
List<String> suggestions = new ArrayList<>();
SUGGESTIONS.forEach(suggestions::add);
suggestions.removeAll(inputs);
return suggestions;
}))
.handler(this::execute));
}

@Override
public void execute(CommandContext<GeyserCommandSource> context) {
Expand All @@ -113,13 +113,15 @@ public void execute(CommandContext<GeyserCommandSource> context) {
source.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.dump.collecting", source.locale()));
String dumpData;
try {
DumpInfo dump = new DumpInfo(geyser, addLog);

if (offlineDump) {
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
// Make arrays easier to read
prettyPrinter.indentArraysWith(new DefaultIndenter(" ", "\n"));
dumpData = MAPPER.writer(prettyPrinter).writeValueAsString(new DumpInfo(addLog));
dumpData = MAPPER.writer(prettyPrinter).writeValueAsString(dump);
} else {
dumpData = MAPPER.writeValueAsString(new DumpInfo(addLog));
dumpData = MAPPER.writeValueAsString(dump);
}
} catch (IOException e) {
source.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.dump.collect_error", source.locale()));
Expand Down
Loading

0 comments on commit 20e4919

Please sign in to comment.