3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2023-02-20 12:02:25 +01:00
Ursprung d74f91d606
Commit 7b5cb92982
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
10 geänderte Dateien mit 31 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -38,6 +38,7 @@ import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypeMap;
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.rewriter.Rewriter;
import com.viaversion.viaversion.exception.CancelException;
import com.viaversion.viaversion.exception.InformativeException;
import java.util.Collections;
@ -148,6 +149,8 @@ public abstract class AbstractProtocol<CU extends ClientboundPacketType, CM exte
* Register the packets for this protocol. To be overriden.
*/
protected void registerPackets() {
callRegister(getEntityRewriter());
callRegister(getItemRewriter());
}
/**
@ -156,6 +159,20 @@ public abstract class AbstractProtocol<CU extends ClientboundPacketType, CM exte
* To be overridden if needed.
*/
protected void onMappingDataLoaded() {
callOnMappingDataLoaded(getEntityRewriter());
callOnMappingDataLoaded(getItemRewriter());
}
private void callRegister(@Nullable Rewriter<?> rewriter) {
if (rewriter != null) {
rewriter.register();
}
}
private void callOnMappingDataLoaded(@Nullable Rewriter<?> rewriter) {
if (rewriter != null) {
rewriter.onMappingDataLoaded();
}
}
protected void addEntityTracker(UserConnection connection, EntityTracker tracker) {

Datei anzeigen

@ -37,4 +37,7 @@ public interface Rewriter<T extends Protocol> {
* @return protocol of the rewriter
*/
T protocol();
default void onMappingDataLoaded() {
}
}

Datei anzeigen

@ -49,9 +49,6 @@ public abstract class RewriterBase<T extends Protocol> implements Rewriter<T> {
protected void registerRewrites() {
}
public void onMappingDataLoaded() {
}
@Override
public T protocol() {
return protocol;

Datei anzeigen

@ -59,7 +59,7 @@ public class BungeePlugin extends Plugin implements ViaServerProxyPlatform<Proxi
@Override
public void onLoad() {
try {
ProtocolConstants.class.getField("MINECRAFT_1_19_1");
ProtocolConstants.class.getField("MINECRAFT_1_19_4");
} catch (NoSuchFieldException e) {
getLogger().warning(" / \\");
getLogger().warning(" / \\");

Datei anzeigen

@ -59,8 +59,7 @@ public class ViaManagerImpl implements ViaManager {
private final ViaPlatformLoader loader;
private final Set<String> subPlatforms = new HashSet<>();
private List<Runnable> enableListeners = new ArrayList<>();
private PlatformTask mappingLoadingTask;
private boolean debug;
private PlatformTask<?> mappingLoadingTask;
public ViaManagerImpl(ViaPlatform<?> platform, ViaInjector injector, ViaCommandHandler commandHandler, ViaPlatformLoader loader) {
this.platform = platform;
@ -124,7 +123,7 @@ public class ViaManagerImpl implements ViaManager {
if (platform.isProxy()) {
platform.getLogger().info("ViaVersion detected lowest supported version by the proxy: " + ProtocolVersion.getProtocol(protocolVersion.lowestSupportedVersion()));
platform.getLogger().info("Highest supported version by the proxy: " + ProtocolVersion.getProtocol(protocolVersion.highestSupportedVersion()));
if (debug) {
if (debugHandler.enabled()) {
platform.getLogger().info("Supported version range: " + Arrays.toString(protocolVersion.supportedVersions().toArray(new int[0])));
}
} else {

Datei anzeigen

@ -27,7 +27,6 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_9;
import com.viaversion.viaversion.protocols.protocol1_10to1_9_3.packets.InventoryPackets;
@ -58,7 +57,7 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
return metaList;
}
};
private final ItemRewriter itemRewriter = new InventoryPackets(this);
private final InventoryPackets itemRewriter = new InventoryPackets(this);
public Protocol1_10To1_9_3_4() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
@ -243,7 +242,7 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
}
@Override
public ItemRewriter getItemRewriter() {
public InventoryPackets getItemRewriter() {
return itemRewriter;
}
}

Datei anzeigen

@ -20,7 +20,6 @@ package com.viaversion.viaversion.protocols.protocol1_14_1to1_14;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14;
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.packets.EntityPackets;
@ -29,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPacke
public class Protocol1_14_1To1_14 extends AbstractProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
private final EntityRewriter metadataRewriter = new MetadataRewriter1_14_1To1_14(this);
private final MetadataRewriter1_14_1To1_14 metadataRewriter = new MetadataRewriter1_14_1To1_14(this);
public Protocol1_14_1To1_14() {
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
@ -48,7 +47,7 @@ public class Protocol1_14_1To1_14 extends AbstractProtocol<ClientboundPackets1_1
}
@Override
public EntityRewriter getEntityRewriter() {
public MetadataRewriter1_14_1To1_14 getEntityRewriter() {
return metadataRewriter;
}
}

Datei anzeigen

@ -281,7 +281,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
@Override
protected void onMappingDataLoaded() {
entityRewriter.onMappingDataLoaded();
super.onMappingDataLoaded();
Types1_19_3.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("block_marker", ParticleType.Readers.BLOCK)

Datei anzeigen

@ -49,8 +49,7 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
@Override
protected void registerPackets() {
entityRewriter.register();
itemRewriter.register();
super.registerPackets();
final SoundRewriter<ClientboundPackets1_19_3> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerSound(ClientboundPackets1_19_3.ENTITY_SOUND);
@ -84,6 +83,7 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
Entity1_19_4Types.initialize(this);
Types1_19_4.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
@ -95,7 +95,6 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
.reader("vibration", ParticleType.Readers.VIBRATION)
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
.reader("shriek", ParticleType.Readers.SHRIEK);
entityRewriter.onMappingDataLoaded();
}
@Override

Datei anzeigen

@ -268,6 +268,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
Types1_19.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("block_marker", ParticleType.Readers.BLOCK)
@ -279,7 +280,6 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
.reader("shriek", ParticleType.Readers.SHRIEK);
Entity1_19Types.initialize(this);
entityRewriter.onMappingDataLoaded();
}
@Override