Skip to content

Commit

Permalink
(feat): 1.20.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakShearman committed Mar 2, 2024
1 parent d58b885 commit 0c8f17f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ FROM --platform=$TARGETPLATFORM azul/zulu-openjdk:21-jre
RUN apt-get update && apt-get install -y wget

# We manually set the Velocity version to avoid bugs
ENV VELOCITY_JAR_URL "https://api.papermc.io/v2/projects/velocity/versions/3.2.0-SNAPSHOT/builds/265/downloads/velocity-3.2.0-SNAPSHOT-265.jar"
ENV VIA_VERSION_JAR_URL "https://github.com/ViaVersion/ViaVersion/releases/download/4.8.0/ViaVersion-4.8.0.jar"
ENV VELOCITY_JAR_URL "https://api.papermc.io/v2/projects/velocity/versions/3.3.0-SNAPSHOT/builds/365/downloads/velocity-3.3.0-SNAPSHOT-365.jar"
ENV VIA_VERSION_JAR_URL "https://github.com/ViaVersion/ViaVersion/releases/download/4.9.2/ViaVersion-4.9.2.jar"

RUN mkdir /app
WORKDIR /app
Expand All @@ -22,10 +22,10 @@ WORKDIR /app/plugins
RUN wget -O viaversion.jar $VIA_VERSION_JAR_URL
COPY run/plugins/viaversion/config.yml viaversion/config.yml

#RUN wget -O viabackwards.jar https://github.com/ViaVersion/ViaBackwards/releases/download/4.5.1/ViaBackwards-4.5.1.jar
RUN wget -O viabackwards.jar https://github.com/ViaVersion/ViaBackwards/releases/download/4.9.1/ViaBackwards-4.9.1.jar
COPY build/libs/*-all.jar velocity-core.jar
# Go back to the base directory for our server
WORKDIR /app

ENTRYPOINT ["java"]
CMD ["-Dlog4j2.debug", "--enable-preview", "-jar", "/app/velocity.jar"]
CMD ["-Dlog4j2.debug", "-jar", "/app/velocity.jar"]
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ repositories {

maven("https://repo.papermc.io/repository/maven-snapshots/")
maven("https://packages.confluent.io/maven/")
maven("https://repo.viaversion.com")
}

dependencies {
// Metrics
implementation("io.pyroscope:agent:0.12.0")

compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
compileOnly("com.velocitypowered:velocity-proxy:3.2.0-SNAPSHOT")
compileOnly("com.viaversion:viaversion-api:4.9.2")
annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
implementation("net.kyori:adventure-text-minimessage:4.14.0")

Expand Down
2 changes: 1 addition & 1 deletion run/plugins/viaversion/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ use-new-effect-indicator: true
velocity-ping-interval: -1
velocity-ping-save: false
velocity-servers:
default: 763
default: 765
vine-climb-fix: false
2 changes: 1 addition & 1 deletion src/main/java/dev/emortal/velocity/lang/ChatMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public interface ChatMessages {
Args1<String> ERROR_PLAYER_INVITED_TO_PARTY = username -> red(username + " has already been invited to your party");
Args1<String> ERROR_PLAYER_IN_THIS_PARTY = username -> red(username + " is already in the party");
Args0 ERROR_YOU_NOT_INVITED_TO_PARTY = () -> red("You are not invited to this party");
Args0 ERROR_YOU_IN_THIS_PARTY = () -> red("You are already in that party");
Args0 ERROR_ALREADY_IN_PARTY = () -> red("You are already in a party. Use <click:run_command:/party leave>/party leave</click> to leave");
Args0 ERROR_CANNOT_KICK_LEADER = () -> red("You cannot kick the party leader");
Args1<String> ERROR_PLAYER_NOT_IN_PARTY = username -> red(username + " is not in your party");
Args0 ERROR_CANNOT_LEAVE_AS_LEADER = () -> Component.text()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.platform.ViaServerProxyPlatform;
import dev.emortal.api.message.gamesdk.GameReadyMessage;
import dev.emortal.api.message.matchmaker.MatchCreatedMessage;
import dev.emortal.api.model.matchmaker.Assignment;
Expand All @@ -13,6 +15,7 @@
import dev.emortal.velocity.lang.ChatMessages;
import dev.emortal.velocity.messaging.MessagingModule;
import dev.emortal.velocity.adapter.player.PlayerProvider;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;

import java.util.UUID;
Expand Down Expand Up @@ -62,6 +65,16 @@ private void movePlayersToMatch(@NotNull Match match) {

RegisteredServer server = this.serverProvider.createServerFromAssignment(assignment);

// Weirdness required here. Register the server version with ViaVersion to allow for more seamless updates
// Some servers can be on old/new versions, and we need to handle that
ViaServerProxyPlatform platform = (ViaServerProxyPlatform) Via.getPlatform();

if (assignment.hasProtocolVersion()) {
platform.protocolDetectorService().setProtocolVersion(assignment.getServerId(), (int) assignment.getProtocolVersion());
}

playerProvider.allPlayers().forEach(p -> p.sendMessage(Component.text("protocolVer: " + assignment.getProtocolVersion())));

ChatMessages.SENDING_TO_SERVER.send(player, serverId);
player.createConnectionRequest(server).fireAndForget();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void execute(@NotNull CommandSource source, @NotNull ArgumentProvider arg
case JoinPartyResult.Success ignored -> ChatMessages.YOU_JOINED_PARTY.send(player, target.username());
case JoinPartyResult.Error error -> {
switch (error) {
case ALREADY_IN_PARTY -> ChatMessages.ERROR_YOU_IN_THIS_PARTY.send(player);
case ALREADY_IN_PARTY -> ChatMessages.ERROR_ALREADY_IN_PARTY.send(player);
case NOT_INVITED -> ChatMessages.ERROR_YOU_NOT_INVITED_TO_PARTY.send(player);
}
}
Expand Down

0 comments on commit 0c8f17f

Please sign in to comment.