3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-24 15:20:19 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2023-02-20 12:03:33 +01:00
Ursprung 3c749bd939
Commit 1b54d10d91
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
17 geänderte Dateien mit 53 neuen und 78 gelöschten Zeilen

Datei anzeigen

@ -24,12 +24,18 @@ import com.viaversion.viabackwards.listener.FireExtinguishListener;
import com.viaversion.viabackwards.listener.LecternInteractListener; import com.viaversion.viabackwards.listener.LecternInteractListener;
import com.viaversion.viaversion.ViaVersionPlugin; import com.viaversion.viaversion.ViaVersionPlugin;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.MappingDataLoader;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.bukkit.platform.BukkitViaLoader; import com.viaversion.viaversion.bukkit.platform.BukkitViaLoader;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform { public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
public BukkitPlugin() {
// MappingDataLoader caching is enabled in ViaVersion on versions that construct the plugin on load
MappingDataLoader.enableMappingsCache();
}
@Override @Override
public void onLoad() { public void onLoad() {
if (!ViaVersionPlugin.getInstance().isLateBind()) { if (!ViaVersionPlugin.getInstance().isLateBind()) {
@ -50,11 +56,6 @@ public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
} }
private void onServerLoaded() { private void onServerLoaded() {
if (isOutdatedPostLoad()) {
disable();
return;
}
BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader(); BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader();
int protocolVersion = Via.getAPI().getServerVersion().highestSupportedVersion(); int protocolVersion = Via.getAPI().getServerVersion().highestSupportedVersion();
if (protocolVersion >= ProtocolVersion.v1_16.getVersion()) { if (protocolVersion >= ProtocolVersion.v1_16.getVersion()) {

Datei anzeigen

@ -20,15 +20,18 @@ package com.viaversion.viabackwards;
import com.viaversion.viabackwards.api.ViaBackwardsPlatform; import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.MappingDataLoader;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
public class BungeePlugin extends Plugin implements ViaBackwardsPlatform { public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
@Override @Override
public void onLoad() { public void onLoad() {
MappingDataLoader.enableMappingsCache();
Via.getManager().addEnableListener(() -> this.init(getDataFolder())); Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
} }
@Override @Override
public void disable() { public void disable() {
} }

Datei anzeigen

@ -44,6 +44,16 @@ public abstract class BackwardsProtocol<CU extends ClientboundPacketType, CM ext
Via.getManager().getProtocolManager().addMappingLoaderFuture(getClass(), protocolClass, runnable); Via.getManager().getProtocolManager().addMappingLoaderFuture(getClass(), protocolClass, runnable);
} }
@Override
protected void registerPackets() {
super.registerPackets();
final BackwardsMappings mappingData = getMappingData();
if (mappingData != null && mappingData.getViaVersionProtocolClass() != null) {
executeAsyncAfterLoaded(mappingData.getViaVersionProtocolClass(), this::loadMappingData);
}
}
@Override @Override
public boolean hasMappingDataToLoad() { public boolean hasMappingDataToLoad() {
// Manually load them later, since they depend on VV's mappings // Manually load them later, since they depend on VV's mappings

Datei anzeigen

@ -145,10 +145,6 @@ public interface ViaBackwardsPlatform {
return false; return false;
} }
default boolean isOutdatedPostLoad() {
return false;
}
/** /**
* Disable the plugin. * Disable the plugin.
*/ */

Datei anzeigen

@ -32,16 +32,16 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class BackwardsMappings extends MappingDataBase { public class BackwardsMappings extends MappingDataBase {
private final Class<? extends Protocol> vvProtocolClass; private final Class<? extends Protocol<?, ?, ?, ?>> vvProtocolClass;
private Int2ObjectMap<MappedItem> backwardsItemMappings; private Int2ObjectMap<MappedItem> backwardsItemMappings;
private Map<String, String> backwardsSoundMappings; private Map<String, String> backwardsSoundMappings;
private Map<String, String> entityNames; private Map<String, String> entityNames;
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass) { public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol<?, ?, ?, ?>> vvProtocolClass) {
this(oldVersion, newVersion, vvProtocolClass, false); this(oldVersion, newVersion, vvProtocolClass, false);
} }
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass, boolean hasDiffFile) { public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol<?, ?, ?, ?>> vvProtocolClass, boolean hasDiffFile) {
super(oldVersion, newVersion, hasDiffFile); super(oldVersion, newVersion, hasDiffFile);
Preconditions.checkArgument(vvProtocolClass == null || !vvProtocolClass.isAssignableFrom(BackwardsProtocol.class)); Preconditions.checkArgument(vvProtocolClass == null || !vvProtocolClass.isAssignableFrom(BackwardsProtocol.class));
this.vvProtocolClass = vvProtocolClass; this.vvProtocolClass = vvProtocolClass;
@ -168,4 +168,8 @@ public class BackwardsMappings extends MappingDataBase {
public @Nullable Map<String, String> getBackwardsSoundMappings() { public @Nullable Map<String, String> getBackwardsSoundMappings() {
return backwardsSoundMappings; return backwardsSoundMappings;
} }
public @Nullable Class<? extends Protocol<?, ?, ?, ?>> getViaVersionProtocolClass() {
return vvProtocolClass;
}
} }

Datei anzeigen

@ -43,8 +43,8 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.14", "1.13.2", Protocol1_14To1_13_2.class, true); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.14", "1.13.2", Protocol1_14To1_13_2.class, true);
private final EntityPackets1_14 entityRewriter = new EntityPackets1_14(this); private final EntityPackets1_14 entityRewriter = new EntityPackets1_14(this);
private final BlockItemPackets1_14 blockItemPackets = new BlockItemPackets1_14(this);
private final TranslatableRewriter<ClientboundPackets1_14> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_14> translatableRewriter = new TranslatableRewriter<>(this);
private BlockItemPackets1_14 blockItemPackets;
public Protocol1_13_2To1_14() { public Protocol1_13_2To1_14() {
super(ClientboundPackets1_14.class, ClientboundPackets1_13.class, ServerboundPackets1_14.class, ServerboundPackets1_13.class); super(ClientboundPackets1_14.class, ClientboundPackets1_13.class, ServerboundPackets1_14.class, ServerboundPackets1_13.class);
@ -52,7 +52,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
@Override @Override
protected void registerPackets() { protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_14To1_13_2.class, MAPPINGS::load); super.registerPackets();
translatableRewriter.registerBossBar(ClientboundPackets1_14.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_14.BOSSBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_14.CHAT_MESSAGE); translatableRewriter.registerComponentPacket(ClientboundPackets1_14.CHAT_MESSAGE);
@ -63,10 +63,6 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
translatableRewriter.registerPing(); translatableRewriter.registerPing();
new CommandRewriter1_14(this).registerDeclareCommands(ClientboundPackets1_14.DECLARE_COMMANDS); new CommandRewriter1_14(this).registerDeclareCommands(ClientboundPackets1_14.DECLARE_COMMANDS);
blockItemPackets = new BlockItemPackets1_14(this);
blockItemPackets.register();
entityRewriter.register();
new PlayerPackets1_14(this).register(); new PlayerPackets1_14(this).register();
new SoundPackets1_14(this).register(); new SoundPackets1_14(this).register();

Datei anzeigen

@ -56,10 +56,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
@Override @Override
protected void registerPackets() { protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_13_1To1_13.class, MAPPINGS::load); super.registerPackets();
entityRewriter.register();
itemRewriter.register();
WorldPackets1_13_1.register(this); WorldPackets1_13_1.register(this);
TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this); TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this);

Datei anzeigen

@ -42,8 +42,8 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.15", "1.14", Protocol1_15To1_14_4.class, true); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.15", "1.14", Protocol1_15To1_14_4.class, true);
private final EntityPackets1_15 entityRewriter = new EntityPackets1_15(this); private final EntityPackets1_15 entityRewriter = new EntityPackets1_15(this);
private final BlockItemPackets1_15 blockItemPackets = new BlockItemPackets1_15(this);
private final TranslatableRewriter<ClientboundPackets1_15> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_15> translatableRewriter = new TranslatableRewriter<>(this);
private BlockItemPackets1_15 blockItemPackets;
public Protocol1_14_4To1_15() { public Protocol1_14_4To1_15() {
super(ClientboundPackets1_15.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class); super(ClientboundPackets1_15.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
@ -51,7 +51,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
@Override @Override
protected void registerPackets() { protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_15To1_14_4.class, MAPPINGS::load); super.registerPackets();
translatableRewriter.registerBossBar(ClientboundPackets1_15.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_15.BOSSBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_15.CHAT_MESSAGE); translatableRewriter.registerComponentPacket(ClientboundPackets1_15.CHAT_MESSAGE);
@ -62,9 +62,6 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
translatableRewriter.registerTitle(ClientboundPackets1_15.TITLE); translatableRewriter.registerTitle(ClientboundPackets1_15.TITLE);
translatableRewriter.registerPing(); translatableRewriter.registerPing();
(blockItemPackets = new BlockItemPackets1_15(this)).register();
entityRewriter.register();
SoundRewriter<ClientboundPackets1_15> soundRewriter = new SoundRewriter<>(this); SoundRewriter<ClientboundPackets1_15> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerSound(ClientboundPackets1_15.SOUND); soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND); soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);

Datei anzeigen

@ -38,7 +38,6 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16; import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
@ -50,8 +49,8 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
public static final BackwardsMappings MAPPINGS = new BackwardsMappings(); public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
private final EntityPackets1_16 entityRewriter = new EntityPackets1_16(this); private final EntityPackets1_16 entityRewriter = new EntityPackets1_16(this);
private final BlockItemPackets1_16 blockItemPackets = new BlockItemPackets1_16(this);
private final TranslatableRewriter1_16 translatableRewriter = new TranslatableRewriter1_16(this); private final TranslatableRewriter1_16 translatableRewriter = new TranslatableRewriter1_16(this);
private BlockItemPackets1_16 blockItemPackets;
public Protocol1_15_2To1_16() { public Protocol1_15_2To1_16() {
super(ClientboundPackets1_16.class, ClientboundPackets1_15.class, ServerboundPackets1_16.class, ServerboundPackets1_14.class); super(ClientboundPackets1_16.class, ClientboundPackets1_15.class, ServerboundPackets1_16.class, ServerboundPackets1_14.class);
@ -59,7 +58,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
@Override @Override
protected void registerPackets() { protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_16To1_15_2.class, MAPPINGS::load); super.registerPackets();
translatableRewriter.registerBossBar(ClientboundPackets1_16.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_16.BOSSBAR);
translatableRewriter.registerCombatEvent(ClientboundPackets1_16.COMBAT_EVENT); translatableRewriter.registerCombatEvent(ClientboundPackets1_16.COMBAT_EVENT);
@ -70,9 +69,6 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
new CommandRewriter1_16(this).registerDeclareCommands(ClientboundPackets1_16.DECLARE_COMMANDS); new CommandRewriter1_16(this).registerDeclareCommands(ClientboundPackets1_16.DECLARE_COMMANDS);
(blockItemPackets = new BlockItemPackets1_16(this)).register();
entityRewriter.register();
registerClientbound(State.STATUS, 0x00, 0x00, wrapper -> { registerClientbound(State.STATUS, 0x00, 0x00, wrapper -> {
String original = wrapper.passthrough(Type.STRING); String original = wrapper.passthrough(Type.STRING);
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class); JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);

Datei anzeigen

@ -44,8 +44,8 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.16.2", "1.16", Protocol1_16_2To1_16_1.class, true); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.16.2", "1.16", Protocol1_16_2To1_16_1.class, true);
private final EntityPackets1_16_2 entityRewriter = new EntityPackets1_16_2(this); private final EntityPackets1_16_2 entityRewriter = new EntityPackets1_16_2(this);
private final BlockItemPackets1_16_2 blockItemPackets = new BlockItemPackets1_16_2(this);
private final TranslatableRewriter<ClientboundPackets1_16_2> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_16_2> translatableRewriter = new TranslatableRewriter<>(this);
private BlockItemPackets1_16_2 blockItemPackets;
public Protocol1_16_1To1_16_2() { public Protocol1_16_1To1_16_2() {
super(ClientboundPackets1_16_2.class, ClientboundPackets1_16.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16.class); super(ClientboundPackets1_16_2.class, ClientboundPackets1_16.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16.class);
@ -53,7 +53,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
@Override @Override
protected void registerPackets() { protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_16_2To1_16_1.class, MAPPINGS::load); super.registerPackets();
translatableRewriter.registerBossBar(ClientboundPackets1_16_2.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_16_2.BOSSBAR);
translatableRewriter.registerCombatEvent(ClientboundPackets1_16_2.COMBAT_EVENT); translatableRewriter.registerCombatEvent(ClientboundPackets1_16_2.COMBAT_EVENT);
@ -65,9 +65,6 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
new CommandRewriter1_16_2(this).registerDeclareCommands(ClientboundPackets1_16_2.DECLARE_COMMANDS); new CommandRewriter1_16_2(this).registerDeclareCommands(ClientboundPackets1_16_2.DECLARE_COMMANDS);
(blockItemPackets = new BlockItemPackets1_16_2(this)).register();
entityRewriter.register();
SoundRewriter<ClientboundPackets1_16_2> soundRewriter = new SoundRewriter<>(this); SoundRewriter<ClientboundPackets1_16_2> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND); soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND);
soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND); soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND);

Datei anzeigen

@ -54,8 +54,8 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.17", "1.16.2", Protocol1_17To1_16_4.class, true); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.17", "1.16.2", Protocol1_17To1_16_4.class, true);
private static final int[] EMPTY_ARRAY = {}; private static final int[] EMPTY_ARRAY = {};
private final EntityPackets1_17 entityRewriter = new EntityPackets1_17(this); private final EntityPackets1_17 entityRewriter = new EntityPackets1_17(this);
private final BlockItemPackets1_17 blockItemPackets = new BlockItemPackets1_17(this);
private final TranslatableRewriter<ClientboundPackets1_17> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_17> translatableRewriter = new TranslatableRewriter<>(this);
private BlockItemPackets1_17 blockItemPackets;
public Protocol1_16_4To1_17() { public Protocol1_16_4To1_17() {
super(ClientboundPackets1_17.class, ClientboundPackets1_16_2.class, ServerboundPackets1_17.class, ServerboundPackets1_16_2.class); super(ClientboundPackets1_17.class, ClientboundPackets1_16_2.class, ServerboundPackets1_17.class, ServerboundPackets1_16_2.class);
@ -63,7 +63,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
@Override @Override
protected void registerPackets() { protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_17To1_16_4.class, MAPPINGS::load); super.registerPackets();
translatableRewriter.registerComponentPacket(ClientboundPackets1_17.CHAT_MESSAGE); translatableRewriter.registerComponentPacket(ClientboundPackets1_17.CHAT_MESSAGE);
translatableRewriter.registerBossBar(ClientboundPackets1_17.BOSSBAR); translatableRewriter.registerBossBar(ClientboundPackets1_17.BOSSBAR);
@ -72,11 +72,6 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerOpenWindow(ClientboundPackets1_17.OPEN_WINDOW); translatableRewriter.registerOpenWindow(ClientboundPackets1_17.OPEN_WINDOW);
translatableRewriter.registerPing(); translatableRewriter.registerPing();
blockItemPackets = new BlockItemPackets1_17(this);
blockItemPackets.register();
entityRewriter.register();
SoundRewriter<ClientboundPackets1_17> soundRewriter = new SoundRewriter<>(this); SoundRewriter<ClientboundPackets1_17> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerSound(ClientboundPackets1_17.SOUND); soundRewriter.registerSound(ClientboundPackets1_17.SOUND);
soundRewriter.registerSound(ClientboundPackets1_17.ENTITY_SOUND); soundRewriter.registerSound(ClientboundPackets1_17.ENTITY_SOUND);

Datei anzeigen

@ -33,15 +33,14 @@ import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1; import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_17_1;
import com.viaversion.viaversion.rewriter.TagRewriter; import com.viaversion.viaversion.rewriter.TagRewriter;
public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPackets1_18, ClientboundPackets1_17_1, ServerboundPackets1_17, ServerboundPackets1_17> { public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPackets1_18, ClientboundPackets1_17_1, ServerboundPackets1_17, ServerboundPackets1_17> {
private static final BackwardsMappings MAPPINGS = new BackwardsMappings(); private static final BackwardsMappings MAPPINGS = new BackwardsMappings();
private final EntityPackets1_18 entityRewriter = new EntityPackets1_18(this); private final EntityPackets1_18 entityRewriter = new EntityPackets1_18(this);
private final BlockItemPackets1_18 itemRewriter = new BlockItemPackets1_18(this);
private final TranslatableRewriter<ClientboundPackets1_18> translatableRewriter = new TranslatableRewriter<>(this); private final TranslatableRewriter<ClientboundPackets1_18> translatableRewriter = new TranslatableRewriter<>(this);
private BlockItemPackets1_18 itemRewriter;
public Protocol1_17_1To1_18() { public Protocol1_17_1To1_18() {
super(ClientboundPackets1_18.class, ClientboundPackets1_17_1.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class); super(ClientboundPackets1_18.class, ClientboundPackets1_17_1.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
@ -49,7 +48,7 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
@Override @Override
protected void registerPackets() { protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_18To1_17_1.class, MAPPINGS::load); super.registerPackets();
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.CHAT_MESSAGE); translatableRewriter.registerComponentPacket(ClientboundPackets1_18.CHAT_MESSAGE);
translatableRewriter.registerComponentPacket(ClientboundPackets1_18.ACTIONBAR); translatableRewriter.registerComponentPacket(ClientboundPackets1_18.ACTIONBAR);
@ -62,10 +61,6 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerCombatKill(ClientboundPackets1_18.COMBAT_KILL); translatableRewriter.registerCombatKill(ClientboundPackets1_18.COMBAT_KILL);
translatableRewriter.registerPing(); translatableRewriter.registerPing();
itemRewriter = new BlockItemPackets1_18(this);
entityRewriter.register();
itemRewriter.register();
final SoundRewriter<ClientboundPackets1_18> soundRewriter = new SoundRewriter<>(this); final SoundRewriter<ClientboundPackets1_18> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerSound(ClientboundPackets1_18.SOUND); soundRewriter.registerSound(ClientboundPackets1_18.SOUND);
soundRewriter.registerSound(ClientboundPackets1_18.ENTITY_SOUND); soundRewriter.registerSound(ClientboundPackets1_18.ENTITY_SOUND);

Datei anzeigen

@ -43,7 +43,6 @@ import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ChatDecorationResult; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ChatDecorationResult;
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.Protocol1_19_1To1_19; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.Protocol1_19_1To1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPackets1_19;
import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.CommandRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
@ -66,10 +65,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
@Override @Override
protected void registerPackets() { protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_19To1_18_2.class, () -> { super.registerPackets();
MAPPINGS.load();
entityRewriter.onMappingDataLoaded();
});
translatableRewriter.registerComponentPacket(ClientboundPackets1_19.ACTIONBAR); translatableRewriter.registerComponentPacket(ClientboundPackets1_19.ACTIONBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19.TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19.TITLE_TEXT);
@ -81,9 +77,6 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
translatableRewriter.registerCombatKill(ClientboundPackets1_19.COMBAT_KILL); translatableRewriter.registerCombatKill(ClientboundPackets1_19.COMBAT_KILL);
translatableRewriter.registerPing(); translatableRewriter.registerPing();
blockItemPackets.register();
entityRewriter.register();
final SoundRewriter<ClientboundPackets1_19> soundRewriter = new SoundRewriter<>(this); final SoundRewriter<ClientboundPackets1_19> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerStopSound(ClientboundPackets1_19.STOP_SOUND); soundRewriter.registerStopSound(ClientboundPackets1_19.STOP_SOUND);
registerClientbound(ClientboundPackets1_19.SOUND, new PacketHandlers() { registerClientbound(ClientboundPackets1_19.SOUND, new PacketHandlers() {

Datei anzeigen

@ -46,7 +46,6 @@ import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPackets1_19_1; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPackets1_19_1;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3; import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.Protocol1_19_3To1_19_1;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3; import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
import com.viaversion.viaversion.rewriter.CommandRewriter; import com.viaversion.viaversion.rewriter.CommandRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter; import com.viaversion.viaversion.rewriter.StatisticsRewriter;
@ -69,10 +68,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
@Override @Override
protected void registerPackets() { protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_19_3To1_19_1.class, () -> { super.registerPackets();
MAPPINGS.load();
entityRewriter.onMappingDataLoaded();
});
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.SYSTEM_CHAT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.SYSTEM_CHAT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.ACTIONBAR); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_3.ACTIONBAR);
@ -85,9 +81,6 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
translatableRewriter.registerCombatKill(ClientboundPackets1_19_3.COMBAT_KILL); translatableRewriter.registerCombatKill(ClientboundPackets1_19_3.COMBAT_KILL);
translatableRewriter.registerPing(); translatableRewriter.registerPing();
itemRewriter.register();
entityRewriter.register();
final SoundRewriter<ClientboundPackets1_19_3> soundRewriter = new SoundRewriter<>(this); final SoundRewriter<ClientboundPackets1_19_3> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerStopSound(ClientboundPackets1_19_3.STOP_SOUND); soundRewriter.registerStopSound(ClientboundPackets1_19_3.STOP_SOUND);
registerClientbound(ClientboundPackets1_19_3.SOUND, wrapper -> { registerClientbound(ClientboundPackets1_19_3.SOUND, wrapper -> {

Datei anzeigen

@ -52,20 +52,14 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// TODO fallback field in components super.registerPackets();
executeAsyncAfterLoaded(Protocol1_19_4To1_19_3.class, () -> {
MAPPINGS.load();
entityRewriter.onMappingDataLoaded();
});
entityRewriter.register();
itemRewriter.register();
final SoundRewriter<ClientboundPackets1_19_4> soundRewriter = new SoundRewriter<>(this); final SoundRewriter<ClientboundPackets1_19_4> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerStopSound(ClientboundPackets1_19_4.STOP_SOUND); soundRewriter.registerStopSound(ClientboundPackets1_19_4.STOP_SOUND);
soundRewriter.register1_19_3Sound(ClientboundPackets1_19_4.SOUND); soundRewriter.register1_19_3Sound(ClientboundPackets1_19_4.SOUND);
soundRewriter.registerSound(ClientboundPackets1_19_4.ENTITY_SOUND); soundRewriter.registerSound(ClientboundPackets1_19_4.ENTITY_SOUND);
// TODO fallback field in components
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.ACTIONBAR); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.ACTIONBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_TEXT); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_SUBTITLE); translatableRewriter.registerComponentPacket(ClientboundPackets1_19_4.TITLE_SUBTITLE);
@ -128,4 +122,9 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
public EntityPackets1_19_4 getEntityRewriter() { public EntityPackets1_19_4 getEntityRewriter() {
return entityRewriter; return entityRewriter;
} }
@Override
public TranslatableRewriter<ClientboundPackets1_19_4> getTranslatableRewriter() {
return translatableRewriter;
}
} }

Datei anzeigen

@ -21,6 +21,7 @@ package com.viaversion.viabackwards;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.viaversion.viabackwards.api.ViaBackwardsPlatform; import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.MappingDataLoader;
import com.viaversion.viaversion.sponge.util.LoggerWrapper; import com.viaversion.viaversion.sponge.util.LoggerWrapper;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
@ -46,7 +47,7 @@ public class SpongePlugin implements ViaBackwardsPlatform {
@Listener @Listener
public void constructPlugin(ConstructPluginEvent event) { public void constructPlugin(ConstructPluginEvent event) {
// Init! MappingDataLoader.enableMappingsCache();
Via.getManager().addEnableListener(() -> this.init(getDataFolder())); Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
} }

Datei anzeigen

@ -28,6 +28,7 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.viaversion.viabackwards.api.ViaBackwardsPlatform; import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
import com.viaversion.viabackwards.utils.VersionInfo; import com.viaversion.viabackwards.utils.VersionInfo;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.MappingDataLoader;
import com.viaversion.viaversion.velocity.util.LoggerWrapper; import com.viaversion.viaversion.velocity.util.LoggerWrapper;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
@ -49,9 +50,9 @@ public class VelocityPlugin implements ViaBackwardsPlatform {
private Path configPath; private Path configPath;
@Subscribe(order = PostOrder.LATE) @Subscribe(order = PostOrder.LATE)
public void onProxyStart(ProxyInitializeEvent e) { public void onProxyStart(ProxyInitializeEvent event) {
// Setup Logger
this.logger = new LoggerWrapper(loggerSlf4j); this.logger = new LoggerWrapper(loggerSlf4j);
MappingDataLoader.enableMappingsCache();
Via.getManager().addEnableListener(() -> this.init(getDataFolder())); Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
} }