Skip to content

Commit 61989ec

Browse files
committed
feat: bump velocity and make resource pack load earlier
1 parent c2476b5 commit 61989ec

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM --platform=$TARGETPLATFORM azul/zulu-openjdk:21-jre
1+
FROM eclipse-temurin:21-jre-alpin
22

33
# Download packages
4-
RUN apt-get update && apt-get install -y wget
4+
RUN apk add --no-cache wget
55

66
# We manually set the Velocity version to avoid bugs
7-
ENV VELOCITY_JAR_URL "https://fill-data.papermc.io/v1/objects/f82780ce33035ebe3d6ea7981f0e6e8a3e41a64f2080ef5c0f1266fada03cbee/velocity-3.4.0-SNAPSHOT-522.jar"
7+
ENV VELOCITY_JAR_URL "https://fill-data.papermc.io/v1/objects/61249fa5b9b33bc7e3223581eab6aedad790a295caf0e39da2ff3c8ec9d9117f/velocity-3.4.0-SNAPSHOT-523.jar"
88

99
RUN mkdir /app
1010
WORKDIR /app
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/dev/emortal/velocity/misc/listener/ResourcePackSender.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package dev.emortal.velocity.misc.listener;
22

33
import com.velocitypowered.api.event.Subscribe;
4+
import com.velocitypowered.api.event.connection.DisconnectEvent;
45
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
5-
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
6+
import com.velocitypowered.api.event.player.configuration.PlayerConfigurationEvent;
67
import com.velocitypowered.api.proxy.Player;
78
import com.velocitypowered.api.proxy.player.ResourcePackInfo;
89
import dev.emortal.velocity.adapter.resourcepack.ResourcePackProvider;
@@ -17,6 +18,9 @@
1718
import java.net.URI;
1819
import java.security.MessageDigest;
1920
import java.security.NoSuchAlgorithmException;
21+
import java.util.HashSet;
22+
import java.util.Set;
23+
import java.util.UUID;
2024
import java.util.concurrent.TimeUnit;
2125

2226
final class ResourcePackSender {
@@ -26,6 +30,8 @@ final class ResourcePackSender {
2630

2731
private ResourcePackInfo resourcePackInfo;
2832

33+
private final Set<UUID> rpAcceptedPlayers = new HashSet<>();
34+
2935
ResourcePackSender(@NotNull ResourcePackProvider resourcePackProvider, @NotNull EmortalScheduler scheduler) {
3036
this.updateResourcePackInfo(resourcePackProvider);
3137
scheduler.repeat(() -> this.updateResourcePackInfo(resourcePackProvider), 30, TimeUnit.SECONDS);
@@ -70,19 +76,26 @@ private byte[] fetchSha1() throws NoSuchAlgorithmException, IOException {
7076
}
7177

7278
@Subscribe
73-
void onPlayerJoin(@NotNull ServerPostConnectEvent event) {
74-
if (event.getPreviousServer() != null) return; // Don't send the resource pack if the player is switching servers
79+
void onPlayerConfiguration(PlayerConfigurationEvent event) {
80+
if (this.rpAcceptedPlayers.contains(event.player().getUniqueId())) return; // Don't send the resource pack if the player has already got it
7581

76-
event.getPlayer().sendResourcePackOffer(this.resourcePackInfo);
82+
event.player().sendResourcePackOffer(this.resourcePackInfo);
7783
}
7884

7985
@Subscribe
8086
void onPlayerResourceStatus(@NotNull PlayerResourcePackStatusEvent event) {
8187
LOGGER.info("Player {} resource pack status {}", event.getPlayer().getUsername(), event.getStatus());
8288
Player player = event.getPlayer();
8389
switch (event.getStatus()) {
90+
case SUCCESSFUL -> this.rpAcceptedPlayers.add(player.getUniqueId());
8491
case DECLINED -> ChatMessages.RESOURCE_PACK_DECLINED.send(player);
8592
case FAILED_DOWNLOAD -> ChatMessages.RESOURCE_PACK_FAILED.send(player);
8693
}
8794
}
95+
96+
@Subscribe
97+
void onPlayerDisconnect(DisconnectEvent event) {
98+
this.rpAcceptedPlayers.remove(event.getPlayer().getUniqueId());
99+
}
100+
88101
}

0 commit comments

Comments
 (0)