Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Cloud 2.0, publishing setup fixes #496

Merged
merged 14 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("")
}
val shadowJar = 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"
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object Versions {
const val guiceVersion = "5.1.0"
const val nettyVersion = "4.1.49.Final"
const val snakeyamlVersion = "1.28"
const val cloudVersion = "1.5.0"
const val cloudVersion = "2.0.0-beta.2"
const val bstatsVersion = "d2fbbd6823"

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() }
}
8 changes: 4 additions & 4 deletions bungee/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
var bungeeCommit = "master-SNAPSHOT"
//var bungeeCommit = "master-SNAPSHOT"
var gsonVersion = "2.8.0"
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
relocate("org.yaml")

// these dependencies are already present on the platform
provided("com.github.SpigotMC.BungeeCord", "bungeecord-proxy", bungeeCommit)
provided("net.md-5", "bungeecord-proxy", "1.20-R0.3-SNAPSHOT")
provided("com.google.code.gson", "gson", gsonVersion)
provided("com.google.guava", "guava", guavaVersion)
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
12 changes: 10 additions & 2 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,7 +15,7 @@ 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)
api("org.incendo", "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)
Expand All @@ -31,4 +33,10 @@ tasks {
replaceToken("branch", branchName())
replaceToken("buildNumber", buildNumber())
}
}
named<Jar>("jar") {
archiveClassifier.set("")
}
val shadowJar = 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 @@ -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
Loading