mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-12-22 16:28:12 +01:00
viaversion update
This commit is contained in:
parent
aa322427e1
commit
64258b7742
@ -52,8 +52,8 @@ tasks.named<ProcessResources>("processResources") {
|
||||
|
||||
dependencies {
|
||||
// transitive = false because Guava is conflicting on runClient
|
||||
implementation("us.myles:viaversion:3.2.1") { isTransitive = false }
|
||||
include("us.myles:viaversion:3.2.1")
|
||||
implementation("us.myles:viaversion:3.3.0-21w13a") { isTransitive = false }
|
||||
include("us.myles:viaversion:3.3.0-21w13a")
|
||||
implementation("org.yaml:snakeyaml:1.26")
|
||||
include("org.yaml:snakeyaml:1.26")
|
||||
|
||||
|
@ -45,10 +45,9 @@ import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.server.command.CommandSource;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import us.myles.ViaVersion.ViaManager;
|
||||
import us.myles.ViaVersion.ViaManagerImpl;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -89,7 +88,7 @@ public class ViaFabric implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Via.init(ViaManager.builder()
|
||||
Via.init(ViaManagerImpl.builder()
|
||||
.injector(new VRInjector())
|
||||
.loader(new VRLoader())
|
||||
.commandHandler(new VRCommandHandler())
|
||||
@ -97,9 +96,9 @@ public class ViaFabric implements ModInitializer {
|
||||
|
||||
FabricLoader.getInstance().getModContainer("viabackwards").ifPresent(mod -> MappingDataLoader.enableMappingsCache());
|
||||
|
||||
Via.getManager().init();
|
||||
((ViaManagerImpl) Via.getManager()).init();
|
||||
|
||||
ProtocolRegistry.registerBaseProtocol(ViaFabricHostnameProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
|
||||
Via.getManager().getProtocolManager().registerBaseProtocol(ViaFabricHostnameProtocol.INSTANCE, Range.lessThan(Integer.MIN_VALUE));
|
||||
ProtocolVersion.register(-2, "AUTO");
|
||||
|
||||
FabricLoader.getInstance().getEntrypoints("viafabric:via_api_initialized", Runnable.class).forEach(Runnable::run);
|
||||
@ -115,7 +114,7 @@ public class ViaFabric implements ModInitializer {
|
||||
}
|
||||
}
|
||||
|
||||
config = new VRConfig(FabricLoader.getInstance().getConfigDirectory().toPath().resolve("ViaFabric")
|
||||
config = new VRConfig(FabricLoader.getInstance().getConfigDir().resolve("ViaFabric")
|
||||
.resolve("viafabric.yml").toFile());
|
||||
|
||||
INIT_FUTURE.complete(null);
|
||||
|
@ -32,8 +32,8 @@ import net.minecraft.server.command.CommandSource;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||
import us.myles.viaversion.libs.bungeecordchat.api.chat.TextComponent;
|
||||
import us.myles.viaversion.libs.bungeecordchat.chat.ComponentSerializer;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -60,7 +60,7 @@ public class NMSCommandSender implements ViaCommandSender {
|
||||
}
|
||||
|
||||
private String legacyToJson(String legacy) {
|
||||
return ComponentSerializer.toString(TextComponent.fromLegacyText(legacy));
|
||||
return GsonComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(legacy));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,8 +44,8 @@ import java.util.List;
|
||||
public class MixinDebugHud {
|
||||
@Inject(at = @At("RETURN"), method = "getLeftText")
|
||||
protected void getLeftText(CallbackInfoReturnable<List<String>> info) {
|
||||
String line = "[ViaFabric] I: " + Via.getManager().getConnections().size() + " (F: "
|
||||
+ Via.getManager().getConnectedClients().size() + ")";
|
||||
String line = "[ViaFabric] I: " + Via.getManager().getConnectionManager().getConnections().size() + " (F: "
|
||||
+ Via.getManager().getConnectionManager().getConnectedClients().size() + ")";
|
||||
@SuppressWarnings("ConstantConditions") ChannelHandler viaDecoder = ((MixinClientConnectionAccessor) MinecraftClient.getInstance().getNetworkHandler()
|
||||
.getConnection()).getChannel().pipeline().get(CommonTransformer.HANDLER_DECODER_NAME);
|
||||
if (viaDecoder instanceof FabricDecodeHandler) {
|
||||
|
@ -50,14 +50,12 @@ import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||
import us.myles.ViaVersion.api.configuration.ConfigurationProvider;
|
||||
import us.myles.ViaVersion.api.platform.TaskId;
|
||||
import us.myles.ViaVersion.api.platform.ViaConnectionManager;
|
||||
import us.myles.ViaVersion.api.platform.ViaPlatform;
|
||||
import us.myles.ViaVersion.dump.PluginInfo;
|
||||
import us.myles.ViaVersion.sponge.VersionInfo;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.bungeecordchat.api.chat.TextComponent;
|
||||
import us.myles.viaversion.libs.bungeecordchat.chat.ComponentSerializer;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import us.myles.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
@ -76,14 +74,12 @@ public class VRPlatform implements ViaPlatform<UUID> {
|
||||
private final Logger logger = new JLoggerToLog4j(LogManager.getLogger("ViaVersion"));
|
||||
private final VRViaConfig config;
|
||||
private final File dataFolder;
|
||||
private final ViaConnectionManager connectionManager;
|
||||
private final ViaAPI<UUID> api;
|
||||
|
||||
public VRPlatform() {
|
||||
Path configDir = FabricLoader.getInstance().getConfigDirectory().toPath().resolve("ViaFabric");
|
||||
config = new VRViaConfig(configDir.resolve("viaversion.yml").toFile());
|
||||
dataFolder = configDir.toFile();
|
||||
connectionManager = new ViaConnectionManager();
|
||||
api = new VRViaAPI();
|
||||
}
|
||||
|
||||
@ -99,6 +95,10 @@ public class VRPlatform implements ViaPlatform<UUID> {
|
||||
return MinecraftClient.getInstance().getServer();
|
||||
}
|
||||
|
||||
public static String legacyToJson(String legacy) {
|
||||
return GsonComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(legacy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
@ -196,7 +196,7 @@ public class VRPlatform implements ViaPlatform<UUID> {
|
||||
if (server != null && server.isOnThread()) {
|
||||
return getServerPlayers();
|
||||
}
|
||||
return Via.getManager().getConnectedClients().values().stream()
|
||||
return Via.getManager().getConnectionManager().getConnectedClients().values().stream()
|
||||
.map(UserCommandSender::new)
|
||||
.toArray(ViaCommandSender[]::new);
|
||||
}
|
||||
@ -302,13 +302,4 @@ public class VRPlatform implements ViaPlatform<UUID> {
|
||||
public boolean isOldClientsAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViaConnectionManager getConnectionManager() {
|
||||
return connectionManager;
|
||||
}
|
||||
|
||||
private String legacyToJson(String legacy) {
|
||||
return ComponentSerializer.toString(TextComponent.fromLegacyText(legacy));
|
||||
}
|
||||
}
|
||||
|
@ -25,49 +25,14 @@
|
||||
|
||||
package com.github.creeper123123321.viafabric.platform;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.ViaAPI;
|
||||
import us.myles.ViaVersion.api.ViaAPIBase;
|
||||
import us.myles.ViaVersion.api.boss.BossBar;
|
||||
import us.myles.ViaVersion.api.boss.BossColor;
|
||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VRViaAPI implements ViaAPI<UUID> {
|
||||
@Override
|
||||
public int getPlayerVersion(UUID uuid) {
|
||||
UserConnection con = Via.getManager().getConnection(uuid);
|
||||
if (con != null) {
|
||||
return con.getProtocolInfo().getProtocolVersion();
|
||||
}
|
||||
try {
|
||||
return Via.getManager().getInjector().getServerProtocolVersion();
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInjected(UUID uuid) {
|
||||
return Via.getManager().isClientConnected(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return Via.getPlatform().getPluginVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawPacket(UUID uuid, ByteBuf byteBuf) throws IllegalArgumentException {
|
||||
UserConnection ci = Via.getManager().getConnection(uuid);
|
||||
ci.sendRawPacket(byteBuf);
|
||||
}
|
||||
|
||||
public class VRViaAPI extends ViaAPIBase<UUID> {
|
||||
@Override
|
||||
public BossBar<Void> createBossBar(String s, BossColor bossColor, BossStyle bossStyle) {
|
||||
return new VRBossBar(s, 1f, bossColor, bossStyle);
|
||||
@ -77,12 +42,4 @@ public class VRViaAPI implements ViaAPI<UUID> {
|
||||
public BossBar<Void> createBossBar(String s, float v, BossColor bossColor, BossStyle bossStyle) {
|
||||
return new VRBossBar(s, v, bossColor, bossStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<Integer> getSupportedVersions() {
|
||||
SortedSet<Integer> outputSet = new TreeSet<>(ProtocolRegistry.getSupportedVersions());
|
||||
outputSet.removeAll(Via.getPlatform().getConf().getBlockedProtocols());
|
||||
|
||||
return outputSet;
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,7 @@ import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.exception.CancelException;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.base.BaseProtocol1_16;
|
||||
import us.myles.ViaVersion.protocols.base.BaseProtocol1_7;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.base.VersionProvider;
|
||||
import us.myles.ViaVersion.protocols.base.*;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -50,7 +47,7 @@ import java.net.SocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class VRVersionProvider extends VersionProvider {
|
||||
public class VRVersionProvider extends BaseVersionProvider {
|
||||
private int[] multiconnectSupportedVersions = null;
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user