Skip to content

Commit

Permalink
Merge branch 'GeyserMC:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens-Co authored Jun 29, 2024
2 parents 4a0cfcd + 49bd564 commit 1ceeba6
Show file tree
Hide file tree
Showing 20 changed files with 312 additions and 138 deletions.
103 changes: 44 additions & 59 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,60 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
PROJECT: 'floodgate'
steps:
- name: Set Build Number
env:
BUILD_JSON: ${{ vars.RELEASEACTION_PREVRELEASE }}
run: |
BUILD_NUMBER=$(echo $BUILD_JSON | jq --arg branch "${GITHUB_REF_NAME}" 'if .[$branch] == null then 1 else .[$branch] | .t | tonumber + 1 end // 1')
echo "BUILD_NUMBER=${BUILD_NUMBER:=$GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: Get Release Info
id: release-info
uses: GeyserMC/actions/previous-release@master
with:
data: ${{ vars.RELEASEACTION_PREVRELEASE }}

- name: Checkout repository and submodules
# See https://github.com/actions/checkout/commits
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive

- name: Validate Gradle Wrapper
# See https://github.com/gradle/wrapper-validation-action/commits
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1
uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2

- name: Setup Java
# See https://github.com/actions/setup-java/commits
- uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
distribution: temurin

- name: Build
- name: Setup Gradle
# See https://github.com/gradle/actions/commits
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
with:
arguments: build
cache-read-only: ${{ github.ref_name != 'master' && github.ref_name != 'development' }}

- name: Build Floodgate
run: ./gradlew build
env:
BUILD_NUMBER: ${{ steps.release-info.outputs.curentRelease }}

- name: Archive artifacts (Floodgate Bungee)
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: success()
with:
name: Floodgate Bungee
path: bungee/build/libs/floodgate-bungee.jar
if-no-files-found: error

- name: Archive artifacts (Floodgate Spigot)
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
if: success()
with:
name: Floodgate Spigot
path: spigot/build/libs/floodgate-spigot.jar
if-no-files-found: error

- name: Archive artifacts (Floodgate Velocity)
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
if: success()
with:
name: Floodgate Velocity
Expand All @@ -67,18 +67,23 @@ jobs:

- name: Publish to Maven Repository
if: ${{ github.repository == 'GeyserMC/Floodgate' }}
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5
run: ./gradlew publish
env:
BUILD_NUMBER: ${{ steps.release-info.outputs.curentRelease }}
ORG_GRADLE_PROJECT_geysermcUsername: ${{ vars.DEPLOY_USER }}
ORG_GRADLE_PROJECT_geysermcPassword: ${{ secrets.DEPLOY_PASS }}
with:
arguments: publish
cache-read-only: ${{ github.ref_name != 'master' && github.ref_name != 'development' }}

- name: Get Version
if: ${{ success() && github.repository == 'GeyserMC/Floodgate' && github.ref_name == 'master' }}
id: get-version
run: |
version=$(cat gradle.properties | grep -o "version=[0-9\\.]*" | cut -d"=" -f2)
echo "VERSION=${version}" >> $GITHUB_OUTPUT
- name: Get Release Metadata
if: ${{ success() && github.repository == 'GeyserMC/Floodgate' && github.ref_name == 'master' }}
# See https://github.com/Kas-tle/base-release-action/releases/tag/main-11
uses: Kas-tle/base-release-action@b863fa0f89bd15267a96a72efb84aec25f168d4c # main-11
uses: GeyserMC/actions/release@master
id: metadata
with:
appID: ${{ secrets.RELEASE_APP_ID }}
appPrivateKey: ${{ secrets.RELEASE_APP_PK }}
Expand All @@ -88,45 +93,25 @@ jobs:
velocity:velocity/build/libs/floodgate-velocity.jar
releaseEnabled: false
saveMetadata: true

- name: Update Generated Metadata
if: ${{ success() && github.repository == 'GeyserMC/Floodgate' && github.ref_name == 'master' }}
run: |
cat metadata.json
echo
mv metadata.json metadata.json.tmp
version=$(cat gradle.properties | grep -o "version=[0-9\\.]*" | cut -d"=" -f2)
jq --arg project "${PROJECT}" --arg version "${version}" '
.
| .changes |= map({"commit", "summary", "message"})
| .downloads |= map_values({"name", "sha256"})
| {$project, "repo", $version, "number": .build, "changes", "downloads"}
' metadata.json.tmp > metadata.json
cat metadata.json
releaseProject: 'floodgate'
releaseVersion: ${{ steps.get-version.outputs.VERSION }}

- name: Publish to Downloads API
if: ${{ success() && github.ref_name == 'master' && github.repository == 'GeyserMC/Floodgate' }}
shell: bash
env:
DOWNLOADS_USERNAME: ${{ vars.DOWNLOADS_USERNAME }}
DOWNLOADS_PRIVATE_KEY: ${{ secrets.DOWNLOADS_PRIVATE_KEY }}
DOWNLOADS_SERVER_IP: ${{ secrets.DOWNLOADS_SERVER_IP }}
run: |
# Save the private key to a file
echo "$DOWNLOADS_PRIVATE_KEY" > id_ecdsa
chmod 600 id_ecdsa
# Create the build folder
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP mkdir -p "~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/"
# Copy over artifacts
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" bungee/build/libs/floodgate-bungee.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" spigot/build/libs/floodgate-spigot.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" velocity/build/libs/floodgate-velocity.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
# Run the build script
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
uses: GeyserMC/actions/upload-release@master
with:
username: ${{ vars.DOWNLOADS_USERNAME }}
privateKey: ${{ secrets.DOWNLOADS_PRIVATE_KEY }}
host: ${{ secrets.DOWNLOADS_SERVER_IP }}
files: |
bungee/build/libs/floodgate-bungee.jar
spigot/build/libs/floodgate-spigot.jar
velocity/build/libs/floodgate-velocity.jar
- name: Notify Discord
if: ${{ (success() || failure()) && github.repository == 'GeyserMC/Floodgate' }}
# See https://github.com/Tim203/actions-git-discord-webhook/commits
uses: Tim203/actions-git-discord-webhook@70f38ded3aca51635ec978ab4e1a58cd4cd0c2ff
uses: GeyserMC/actions/notify-discord@master
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
discordWebhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
body: ${{ steps.metadata.outputs.body }}
22 changes: 12 additions & 10 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,49 @@ jobs:
- name: Checkout repository and submodules
# See https://github.com/actions/checkout/commits
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: recursive

- name: Validate Gradle Wrapper
# See https://github.com/gradle/wrapper-validation-action/commits
uses: gradle/wrapper-validation-action@699bb18358f12c5b78b37bb0111d3a0e2276e0e2 # v2.1.1
uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2

- name: Set up JDK 17
- name: Setup Java
# See https://github.com/actions/setup-java/commits
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
distribution: temurin

- name: Build Floodgate
- name: Setup Gradle
# See https://github.com/gradle/actions/commits
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
with:
arguments: build
cache-read-only: true

- name: Build Floodgate
run: ./gradlew build

- name: Archive artifacts (Floodgate Bungee)
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: success()
with:
name: Floodgate Bungee
path: bungee/build/libs/floodgate-bungee.jar
if-no-files-found: error

- name: Archive artifacts (Floodgate Spigot)
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
if: success()
with:
name: Floodgate Spigot
path: spigot/build/libs/floodgate-spigot.jar
if-no-files-found: error

- name: Archive artifacts (Floodgate Velocity)
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
if: success()
with:
name: Floodgate Velocity
Expand Down
3 changes: 2 additions & 1 deletion build-logic/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ object Versions {
const val guiceVersion = "6.0.0"
const val nettyVersion = "4.1.49.Final"
const val snakeyamlVersion = "1.28"
const val cloudVersion = "2.0.0-beta.2"
const val cloudVersion = "2.0.0-SNAPSHOT" // for cloud-minecraft
const val cloudCore = "2.0.0-rc.1"
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 @@ -39,17 +39,18 @@
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.event.PreLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.connection.InitialHandler;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.event.EventPriority;
import net.md_5.bungee.netty.ChannelWrapper;
import org.geysermc.floodgate.api.ProxyFloodgateApi;
import org.geysermc.floodgate.api.logger.FloodgateLogger;
import org.geysermc.floodgate.api.player.FloodgatePlayer;
import org.geysermc.floodgate.config.ProxyFloodgateConfig;
import org.geysermc.floodgate.skin.SkinApplier;
import org.geysermc.floodgate.skin.SkinDataImpl;
import org.geysermc.floodgate.util.LanguageManager;
import org.geysermc.floodgate.util.MojangUtils;
import org.geysermc.floodgate.util.ReflectionUtils;

@SuppressWarnings("ConstantConditions")
Expand All @@ -66,7 +67,7 @@ public final class BungeeListener implements Listener {
checkNotNull(PLAYER_NAME, "Initial name field cannot be null");
}

@Inject private ProxyFloodgateConfig config;
@Inject private Plugin plugin;
@Inject private ProxyFloodgateApi api;
@Inject private LanguageManager languageManager;
@Inject private FloodgateLogger logger;
Expand All @@ -80,6 +81,8 @@ public final class BungeeListener implements Listener {
@Named("kickMessageAttribute")
private AttributeKey<String> kickMessageAttribute;

@Inject private MojangUtils mojangUtils;

@EventHandler(priority = EventPriority.LOWEST)
public void onPreLogin(PreLoginEvent event) {
// well, no reason to check if the player will be kicked anyway
Expand Down Expand Up @@ -127,13 +130,31 @@ public void onLogin(LoginEvent event) {

@EventHandler(priority = EventPriority.LOWEST)
public void onPostLogin(PostLoginEvent event) {
// To fix the February 2 2022 Mojang authentication changes
if (!config.isSendFloodgateData()) {
FloodgatePlayer player = api.getPlayer(event.getPlayer().getUniqueId());
if (player != null && !player.isLinked()) {
skinApplier.applySkin(player, new SkinDataImpl("", ""));
}
FloodgatePlayer player = api.getPlayer(event.getPlayer().getUniqueId());
if (player == null) {
return;
}

// Skin look up (on Spigot and friends) would result in it failing, so apply a default skin
if (!player.isLinked()) {
skinApplier.applySkin(player, SkinDataImpl.DEFAULT_SKIN);
return;
}

// Floodgate players are seen as offline mode players, meaning we have to look up
// the linked player's textures ourselves

event.registerIntent(plugin);

mojangUtils.skinFor(player.getJavaUniqueId())
.exceptionally(exception -> {
logger.debug("Unexpected skin fetch error for " + player.getJavaUniqueId(), exception);
return SkinDataImpl.DEFAULT_SKIN;
})
.thenAccept(skin -> {
skinApplier.applySkin(player, skin);
event.completeIntent(plugin);
});
}

@EventHandler(priority = EventPriority.HIGHEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ public void applySkin(@NonNull FloodgatePlayer floodgatePlayer, @NonNull SkinDat
SkinData currentSkin = currentSkin(properties);

SkinApplyEvent event = new SkinApplyEventImpl(floodgatePlayer, currentSkin, skinData);
event.setCancelled(floodgatePlayer.isLinked());

eventBus.fire(event);

if (event.isCancelled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package org.geysermc.floodgate.util;

import java.util.Collection;
import java.util.Locale;
import java.util.UUID;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
Expand Down Expand Up @@ -63,7 +64,8 @@ public BungeeCommandUtil(LanguageManager manager, ProxyServer server, FloodgateA
ProxiedPlayer player = (ProxiedPlayer) source;
UUID uuid = player.getUniqueId();
String username = player.getName();
String locale = Utils.getLocale(player.getLocale());
Locale playerLocale = player.getLocale(); // Is null during the PostLoginEvent, which can cause https://github.com/GeyserMC/Floodgate/issues/510
String locale = Utils.getLocale(playerLocale != null ? playerLocale : Locale.getDefault());

return new PlayerAudience(uuid, username, locale, source, this, true);
}
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,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("org.incendo", "cloud-core", Versions.cloudVersion)
api("org.incendo", "cloud-core", Versions.cloudCore)
api("org.bstats", "bstats-base", Versions.bstatsVersion)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import lombok.RequiredArgsConstructor;
import org.geysermc.configutils.ConfigUtilities;
import org.geysermc.configutils.file.codec.PathFileCodec;
import org.geysermc.configutils.file.template.ResourceTemplateReader;
import org.geysermc.configutils.file.template.TemplateReader;
import org.geysermc.configutils.updater.change.Changes;
import org.geysermc.floodgate.crypto.FloodgateCipher;
import org.geysermc.floodgate.crypto.KeyProducer;
Expand All @@ -46,6 +46,7 @@ public final class ConfigLoader {

private final KeyProducer keyProducer;
private final FloodgateCipher cipher;
private final TemplateReader reader;

@SuppressWarnings("unchecked")
public <T extends FloodgateConfig> T load() {
Expand All @@ -64,7 +65,7 @@ public <T extends FloodgateConfig> T load() {
ConfigUtilities.builder()
.fileCodec(PathFileCodec.of(dataDirectory))
.configFile("config.yml")
.templateReader(ResourceTemplateReader.of(getClass()))
.templateReader(reader)
.template(templateFile)
.changes(Changes.builder()
.version(1, Changes.versionBuilder()
Expand Down
Loading

0 comments on commit 1ceeba6

Please sign in to comment.