Skip to content

Commit

Permalink
Updated Via API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Feb 14, 2024
1 parent d8aff7f commit 289f565
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ repositories {
}

dependencies {
compileOnly "com.viaversion:viaversion-common:4.10.0-24w06a-SNAPSHOT"
compileOnly "com.viaversion:viabackwards-common:4.10.0-24w06a-SNAPSHOT"
compileOnly "com.viaversion:viaversion-common:4.10.0-24w07a-SNAPSHOT"
compileOnly "com.viaversion:viabackwards-common:4.10.0-24w07a-SNAPSHOT"
compileOnly "com.viaversion:viarewind-common:3.0.5"
compileOnly "net.raphimc:ViaLegacy:2.2.21"
compileOnly "net.raphimc:ViaAprilFools:2.0.10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.viaversion.viaversion.api.ViaAPI;
import com.viaversion.viaversion.api.command.ViaCommandSender;
import com.viaversion.viaversion.api.configuration.ViaVersionConfig;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.platform.ViaPlatform;
import com.viaversion.viaversion.configuration.AbstractViaConfig;
import com.viaversion.viaversion.libs.gson.JsonObject;
Expand All @@ -38,13 +39,13 @@
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

public class ViaVersionPlatformImpl implements ViaPlatform<UUID> {
public class ViaVersionPlatformImpl implements ViaPlatform<UserConnection> {

private static final Logger LOGGER = new JLoggerToSLF4J(LoggerFactory.getLogger("ViaVersion"));

private final File dataFolder;
private final AbstractViaConfig config;
private final ViaAPI<UUID> api;
private final ViaAPI<UserConnection> api;

public ViaVersionPlatformImpl(final File rootFolder) {
this.dataFolder = new File(rootFolder, "ViaLoader");
Expand Down Expand Up @@ -132,7 +133,7 @@ public boolean isProxy() {
}

@Override
public ViaAPI<UUID> getApi() {
public ViaAPI<UserConnection> getApi() {
return this.api;
}

Expand All @@ -159,7 +160,7 @@ protected AbstractViaConfig createConfig() {
return new VLViaConfig(new File(this.dataFolder, "viaversion.yml"));
}

protected ViaAPI<UUID> createApi() {
protected ViaAPI<UserConnection> createApi() {
return new VLApiBase();
}

Expand Down
15 changes: 13 additions & 2 deletions src/main/java/net/raphimc/vialoader/impl/viaversion/VLApiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@
package net.raphimc.vialoader.impl.viaversion;

import com.viaversion.viaversion.ViaAPIBase;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import io.netty.buffer.ByteBuf;

import java.util.UUID;
public class VLApiBase extends ViaAPIBase<UserConnection> {

public class VLApiBase extends ViaAPIBase<UUID> {
@Override
public ProtocolVersion getPlayerProtocolVersion(final UserConnection player) {
return player.getProtocolInfo().protocolVersion();
}

@Override
public void sendRawPacket(final UserConnection player, final ByteBuf packet) {
player.scheduleSendRawPacket(packet);
}

}

0 comments on commit 289f565

Please sign in to comment.