Skip to content

Commit

Permalink
Feature: Cloud 2.0, publishing setup fixes (#496)
Browse files Browse the repository at this point in the history
* - Update to cloud 2.0
- bump floodgate version to 2.2.3
- fix publishing setup - don't publish shadow jars, ensure api/core artifacts aren't shaded jars

* - update bstats
- fix alias -> description

* tiny cleanup, fix whitelisting bedrock players when the linked java account is online (and shares the same name)

* Update build process

* Ensure BUILD_JSON env is init

* Fallback to GH run number

* update guice to 6.0.0 to be compatible with java 21

* update languages module

* Support 1.20.5 spigot, update languages module, update Bungee dependency so the project builds

* remove codemc repo, update cloud-paper to snapshot build for 1.20.5 support

---------

Co-authored-by: Kas-tle <[email protected]>
  • Loading branch information
onebeastchris and Kas-tle authored Apr 28, 2024
1 parent 0fa00a8 commit 7a55305
Show file tree
Hide file tree
Showing 30 changed files with 394 additions and 326 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "core/src/main/resources/languages"]
path = core/src/main/resources/languages
url = https://github.com/GeyserMC/languages
branch = l10n_floodgate
branch = floodgate
11 changes: 11 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

dependencies {
api("org.geysermc.geyser", "common", Versions.geyserVersion)
api("org.geysermc.cumulus", "cumulus", Versions.cumulusVersion)
api("org.geysermc.event", "events", Versions.eventsVersion)

compileOnly("io.netty", "netty-transport", Versions.nettyVersion)
}

tasks {
named<Jar>("jar") {
archiveClassifier.set("")
}
named<ShadowJar>("shadowJar") {
archiveClassifier.set("shaded")
}
}
1 change: 1 addition & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "build-logic"
6 changes: 3 additions & 3 deletions build-logic/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ object Versions {
const val configUtilsVersion = "1.0-SNAPSHOT"
const val spigotVersion = "1.19.4-R0.1-SNAPSHOT"
const val fastutilVersion = "8.5.3"
const val guiceVersion = "5.1.0"
const val guiceVersion = "6.0.0"
const val nettyVersion = "4.1.49.Final"
const val snakeyamlVersion = "1.28"
const val cloudVersion = "1.5.0"
const val bstatsVersion = "d2fbbd6823"
const val cloudVersion = "2.0.0-beta.2"
const val bstatsVersion = "3.0.2"

const val javaWebsocketVersion = "1.5.2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ indra {

publishSnapshotsTo("geysermc", "https://repo.opencollab.dev/maven-snapshots")
publishReleasesTo("geysermc", "https://repo.opencollab.dev/maven-releases")
}

publishing {
// skip shadow jar from publishing. Workaround for https://github.com/johnrengelman/shadow/issues/651
val javaComponent = project.components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { skip() }
}
4 changes: 2 additions & 2 deletions bungee/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ var guavaVersion = "21.0"

dependencies {
api(projects.core)
implementation("cloud.commandframework", "cloud-bungee", Versions.cloudVersion)
implementation("org.incendo", "cloud-bungee", Versions.cloudVersion)
}

relocate("com.google.inject")
relocate("net.kyori")
relocate("cloud.commandframework")
relocate("org.incendo.cloud")
// used in cloud
relocate("io.leangen.geantyref")
// since 1.20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@

package org.geysermc.floodgate.module;

import cloud.commandframework.CommandManager;
import cloud.commandframework.bungee.BungeeCommandManager;
import cloud.commandframework.execution.CommandExecutionCoordinator;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import java.util.logging.Logger;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import org.geysermc.floodgate.BungeePlugin;
Expand All @@ -51,6 +47,7 @@
import org.geysermc.floodgate.platform.util.PlatformUtils;
import org.geysermc.floodgate.player.FloodgateCommandPreprocessor;
import org.geysermc.floodgate.player.UserAudience;
import org.geysermc.floodgate.player.audience.FloodgateSenderMapper;
import org.geysermc.floodgate.pluginmessage.BungeePluginMessageRegistration;
import org.geysermc.floodgate.pluginmessage.BungeePluginMessageUtils;
import org.geysermc.floodgate.pluginmessage.BungeeSkinApplier;
Expand All @@ -60,6 +57,9 @@
import org.geysermc.floodgate.util.BungeeCommandUtil;
import org.geysermc.floodgate.util.BungeePlatformUtils;
import org.geysermc.floodgate.util.LanguageManager;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.bungee.BungeeCommandManager;
import org.incendo.cloud.execution.ExecutionCoordinator;

@RequiredArgsConstructor
public final class BungeePlatformModule extends AbstractModule {
Expand Down Expand Up @@ -88,9 +88,8 @@ public Plugin bungeePlugin() {
public CommandManager<UserAudience> commandManager(CommandUtil commandUtil) {
CommandManager<UserAudience> commandManager = new BungeeCommandManager<>(
plugin,
CommandExecutionCoordinator.simpleCoordinator(),
commandUtil::getUserAudience,
audience -> (CommandSender) audience.source()
ExecutionCoordinator.simpleCoordinator(),
new FloodgateSenderMapper<>(commandUtil)
);
commandManager.registerCommandPreProcessor(new FloodgateCommandPreprocessor<>(commandUtil));
return commandManager;
Expand Down
16 changes: 11 additions & 5 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id("floodgate.generate-templates")
}
Expand All @@ -13,10 +15,8 @@ dependencies {
api("com.nukkitx.fastutil", "fastutil-short-object-maps", Versions.fastutilVersion)
api("com.nukkitx.fastutil", "fastutil-int-object-maps", Versions.fastutilVersion)
api("org.java-websocket", "Java-WebSocket", Versions.javaWebsocketVersion)
api("cloud.commandframework", "cloud-core", Versions.cloudVersion)

//todo use official dependency once https://github.com/Bastian/bstats-metrics/pull/118 is merged
api("com.github.Konicai.bstats-metrics", "bstats-base", Versions.bstatsVersion)
api("org.incendo", "cloud-core", Versions.cloudVersion)
api("org.bstats", "bstats-base", Versions.bstatsVersion)
}

// present on all platforms
Expand All @@ -31,4 +31,10 @@ tasks {
replaceToken("branch", branchName())
replaceToken("buildNumber", buildNumber())
}
}
named<Jar>("jar") {
archiveClassifier.set("")
}
named<ShadowJar>("shadowJar") {
archiveClassifier.set("shaded")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
package org.geysermc.floodgate.command;

import static org.geysermc.floodgate.command.CommonCommandMessage.CHECK_CONSOLE;
import static org.incendo.cloud.parser.standard.StringParser.stringParser;

import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.Command;
import cloud.commandframework.CommandManager;
import cloud.commandframework.arguments.standard.StringArgument;
import cloud.commandframework.context.CommandContext;
import com.google.inject.Inject;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -46,30 +42,33 @@
import org.geysermc.floodgate.platform.command.TranslatableMessage;
import org.geysermc.floodgate.player.UserAudience;
import org.geysermc.floodgate.player.UserAudience.PlayerAudience;
import org.geysermc.floodgate.player.audience.PlayerAudienceArgument;
import org.geysermc.floodgate.player.audience.ProfileAudience;
import org.geysermc.floodgate.player.audience.ProfileAudienceArgument;
import org.geysermc.floodgate.util.Constants;
import org.incendo.cloud.Command;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.context.CommandContext;
import org.incendo.cloud.description.Description;

@NoArgsConstructor
public final class LinkAccountCommand implements FloodgateCommand {
@Inject private FloodgateApi api;
@Inject private FloodgateLogger logger;

@Override
public Command<UserAudience> buildCommand(CommandManager<UserAudience> commandManager) {
public Command<PlayerAudience> buildCommand(CommandManager<UserAudience> commandManager) {
return commandManager.commandBuilder("linkaccount",
ArgumentDescription.of("Link your Java account with your Bedrock account"))
Description.of("Link your Java account with your Bedrock account"))
.senderType(PlayerAudience.class)
.permission(Permission.COMMAND_LINK.get())
.argument(ProfileAudienceArgument.of("player", true))
.argument(StringArgument.optional("code"))
.argument(PlayerAudienceArgument.ofAnyUsernameBoth("player"))
.optional("code", stringParser())
.handler(this::execute)
.build();
}

@Override
public void execute(CommandContext<UserAudience> context) {
UserAudience sender = context.getSender();
public void execute(CommandContext<PlayerAudience> context) {
UserAudience sender = context.sender();

PlayerLink link = api.getPlayerLink();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

package org.geysermc.floodgate.command;

import cloud.commandframework.Command;
import cloud.commandframework.CommandManager;
import cloud.commandframework.context.CommandContext;
import org.geysermc.floodgate.api.FloodgateApi;
import org.geysermc.floodgate.config.FloodgateConfig;
import org.geysermc.floodgate.platform.command.FloodgateCommand;
import org.geysermc.floodgate.player.UserAudience;
import org.geysermc.floodgate.util.Constants;
import org.incendo.cloud.Command;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.context.CommandContext;

public class TestCommand implements FloodgateCommand {
@Override
Expand All @@ -43,10 +43,9 @@ public Command<UserAudience> buildCommand(CommandManager<UserAudience> commandMa
.build();
}

@Override
public void execute(CommandContext<UserAudience> context) {
int players = FloodgateApi.getInstance().getPlayers().size();
context.getSender().sendMessage(String.valueOf(players));
context.sender().sendMessage(String.valueOf(players));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

import static org.geysermc.floodgate.command.CommonCommandMessage.CHECK_CONSOLE;

import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.Command;
import cloud.commandframework.CommandManager;
import cloud.commandframework.context.CommandContext;
import com.google.inject.Inject;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -44,24 +40,27 @@
import org.geysermc.floodgate.player.UserAudience.PlayerAudience;
import org.geysermc.floodgate.util.Constants;
import org.geysermc.floodgate.command.util.Permission;
import org.incendo.cloud.Command;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.context.CommandContext;
import org.incendo.cloud.description.Description;

@NoArgsConstructor
public final class UnlinkAccountCommand implements FloodgateCommand {
@Inject private FloodgateApi api;

@Override
public Command<UserAudience> buildCommand(CommandManager<UserAudience> commandManager) {
public Command<PlayerAudience> buildCommand(CommandManager<UserAudience> commandManager) {
return commandManager.commandBuilder("unlinkaccount",
ArgumentDescription.of("Unlink your Java account from your Bedrock account"))
Description.of("Unlink your Java account from your Bedrock account"))
.senderType(PlayerAudience.class)
.permission(Permission.COMMAND_UNLINK.get())
.handler(this::execute)
.build();
}

@Override
public void execute(CommandContext<UserAudience> context) {
UserAudience sender = context.getSender();
public void execute(CommandContext<PlayerAudience> context) {
UserAudience sender = context.sender();

PlayerLink link = api.getPlayerLink();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

import static org.geysermc.floodgate.command.CommonCommandMessage.CHECK_CONSOLE;

import cloud.commandframework.ArgumentDescription;
import cloud.commandframework.Command;
import cloud.commandframework.CommandManager;
import cloud.commandframework.context.CommandContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.inject.Inject;
Expand All @@ -46,10 +42,14 @@
import org.geysermc.floodgate.platform.command.TranslatableMessage;
import org.geysermc.floodgate.platform.util.PlayerType;
import org.geysermc.floodgate.player.UserAudience;
import org.geysermc.floodgate.player.audience.PlayerAudienceArgument;
import org.geysermc.floodgate.player.audience.ProfileAudience;
import org.geysermc.floodgate.player.audience.ProfileAudienceArgument;
import org.geysermc.floodgate.util.Constants;
import org.geysermc.floodgate.util.HttpClient;
import org.incendo.cloud.Command;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.context.CommandContext;
import org.incendo.cloud.description.Description;

public class WhitelistCommand implements FloodgateCommand {
@Inject private FloodgateConfig config;
Expand All @@ -59,23 +59,23 @@ public class WhitelistCommand implements FloodgateCommand {
@Override
public Command<UserAudience> buildCommand(CommandManager<UserAudience> commandManager) {
Command.Builder<UserAudience> builder = commandManager.commandBuilder("fwhitelist",
ArgumentDescription.of("Easy way to whitelist Bedrock players"))
Description.of("Easy way to whitelist Bedrock players"))
.permission(Permission.COMMAND_WHITELIST.get());

commandManager.command(builder
.literal("add", "a")
.argument(ProfileAudienceArgument.of("player", true, true, PlayerType.ONLY_BEDROCK))
.argument(PlayerAudienceArgument.ofAnyIdentifierBedrock("player"))
.handler(context -> performCommand(context, true)));

return builder
.literal("remove", "r")
.argument(ProfileAudienceArgument.of("player", true, true, PlayerType.ONLY_BEDROCK))
.argument(PlayerAudienceArgument.ofAnyIdentifierBedrock("player"))
.handler(context -> performCommand(context, false))
.build();
}

public void performCommand(CommandContext<UserAudience> context, boolean add) {
UserAudience sender = context.getSender();
UserAudience sender = context.sender();
ProfileAudience profile = context.get("player");
UUID uuid = profile.uuid();
String name = profile.username();
Expand Down Expand Up @@ -114,7 +114,7 @@ public void performCommand(CommandContext<UserAudience> context, boolean add) {
name = name.substring(config.getUsernamePrefix().length());
}

if (name.length() < 1 || name.length() > 16) {
if (name.isEmpty() || name.length() > 16) {
sender.sendMessage(Message.INVALID_USERNAME);
return;
}
Expand Down Expand Up @@ -181,11 +181,6 @@ public void performCommand(CommandContext<UserAudience> context, boolean add) {
});
}

@Override
public void execute(CommandContext<UserAudience> context) {
// ignored, all the logic is in the other method
}

@Override
public boolean shouldRegister(FloodgateConfig config) {
// currently only Spigot (our only non-Proxy platform) has a whitelist build-in.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import static org.geysermc.floodgate.util.Constants.COLOR_CHAR;

import cloud.commandframework.context.CommandContext;
import com.google.gson.JsonElement;
import com.google.inject.Inject;
import it.unimi.dsi.fastutil.Pair;
Expand All @@ -41,6 +40,7 @@
import org.geysermc.floodgate.util.HttpClient;
import org.geysermc.floodgate.util.HttpClient.HttpResponse;
import org.geysermc.floodgate.util.Utils;
import org.incendo.cloud.context.CommandContext;

final class FirewallCheckSubcommand extends FloodgateSubCommand {
@Inject
Expand All @@ -63,7 +63,7 @@ public Permission permission() {

@Override
public void execute(CommandContext<UserAudience> context) {
UserAudience sender = context.getSender();
UserAudience sender = context.sender();
executeChecks(
globalApiCheck(sender)
).whenComplete((response, $) ->
Expand Down
Loading

0 comments on commit 7a55305

Please sign in to comment.