mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-15 11:05:32 +01:00
Rework logging inside protocols and rewriters
This commit is contained in:
parent
91a86174a3
commit
c066b91bba
@ -17,13 +17,13 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriterBase;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.ProtocolLogger;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class EntityPositionHandler {
|
||||
@ -51,12 +51,13 @@ public class EntityPositionHandler {
|
||||
StoredEntityData storedEntity = entityRewriter.tracker(wrapper.user()).entityData(entityId);
|
||||
if (storedEntity == null) {
|
||||
if (Via.getManager().isDebug()) { // There is too many plugins violating this out there, and reading seems to be hard! :>
|
||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName());
|
||||
ProtocolLogger logger = entityRewriter.protocol().getLogger();
|
||||
logger.warning("Stored entity with id " + entityId + " missing at position: " + x + " - " + y + " - " + z + " in " + storageClass.getSimpleName());
|
||||
if (entityId == -1 && x == 0 && y == 0 && z == 0) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("DO NOT REPORT THIS TO VIA, THIS IS A PLUGIN ISSUE");
|
||||
logger.warning("DO NOT REPORT THIS TO VIA, THIS IS A PLUGIN ISSUE");
|
||||
} else if (!warnedForMissingEntity) {
|
||||
warnedForMissingEntity = true;
|
||||
ViaBackwards.getPlatform().getLogger().warning("This is very likely caused by a plugin sending a teleport packet for an entity outside of the player's range.");
|
||||
logger.warning("This is very likely caused by a plugin sending a teleport packet for an entity outside of the player's range.");
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -69,7 +70,7 @@ public class EntityPositionHandler {
|
||||
} else {
|
||||
positionStorage = storedEntity.get(storageClass);
|
||||
if (positionStorage == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
|
||||
entityRewriter.protocol().getLogger().warning("Stored entity with id " + entityId + " missing " + storageClass.getSimpleName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -81,7 +82,7 @@ public class EntityPositionHandler {
|
||||
StoredEntityData storedEntity = entityRewriter.tracker(user).entityData(entityId);
|
||||
EntityPositionStorage entityStorage;
|
||||
if (storedEntity == null || (entityStorage = storedEntity.get(EntityPositionStorage.class)) == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId + " in " + storageClass.getSimpleName());
|
||||
entityRewriter.protocol().getLogger().warning("Untracked entity with id " + entityId + " in " + storageClass.getSimpleName());
|
||||
return null;
|
||||
}
|
||||
return entityStorage;
|
||||
|
@ -156,7 +156,7 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
|
||||
return wrapper -> {
|
||||
ObjectType type = objectGetter.apply(wrapper.get(Types.BYTE, 0));
|
||||
if (type == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Could not find Entity Type" + wrapper.get(Types.BYTE, 0));
|
||||
protocol.getLogger().warning("Could not find Entity Type" + wrapper.get(Types.BYTE, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
|
||||
super(protocol, type);
|
||||
final Map<String, String> translatableMappings = TRANSLATABLES.get(sectionIdentifier);
|
||||
if (translatableMappings == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing " + sectionIdentifier + " translatables!");
|
||||
protocol.getLogger().warning("Missing " + sectionIdentifier + " translatables!");
|
||||
this.translatables = new HashMap<>();
|
||||
} else {
|
||||
this.translatables = translatableMappings;
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
@ -26,7 +25,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -59,7 +57,7 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
|
||||
byte type = wrapper.get(Types.BYTE, 0);
|
||||
EntityTypes1_13.EntityType entType = EntityTypes1_13.getTypeFromId(type, true);
|
||||
if (entType == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
|
||||
protocol.getLogger().warning("Could not find entity type " + type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,11 +47,13 @@ import com.viaversion.viaversion.protocols.v1_12to1_12_1.packet.ServerboundPacke
|
||||
import com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.ProtocolLogger;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class Protocol1_13To1_12_2 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> {
|
||||
|
||||
public static final BackwardsMappingData1_13 MAPPINGS = new BackwardsMappingData1_13();
|
||||
public static final ProtocolLogger LOGGER = new ProtocolLogger(Protocol1_13To1_12_2.class);
|
||||
private final EntityPacketRewriter1_13 entityRewriter = new EntityPacketRewriter1_13(this);
|
||||
private final BlockItemPacketRewriter1_13 blockItemPackets = new BlockItemPacketRewriter1_13(this);
|
||||
private final TranslatableRewriter<ClientboundPackets1_13> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON) {
|
||||
@ -133,6 +135,11 @@ public class Protocol1_13To1_12_2 extends BackwardsProtocol<ClientboundPackets1_
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolLogger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPacketRewriter1_13 getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package com.viaversion.viabackwards.protocol.v1_13to1_12_2.block_entity_handlers;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_13to1_12_2.provider.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
@ -43,7 +43,7 @@ public class BannerHandler implements BackwardsBlockEntityHandler {
|
||||
int color = (blockId - WALL_BANNER_START) >> 2;
|
||||
tag.putInt("Base", 15 - color);
|
||||
} else {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
||||
Protocol1_13To1_12_2.LOGGER.warning("Why does this block have the banner block entity? :(" + tag);
|
||||
}
|
||||
|
||||
// Invert colors
|
||||
|
@ -512,8 +512,8 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
|
||||
if (originalId == 362) { // base/colorless shulker box
|
||||
rawId = 0xe50000; // purple shulker box
|
||||
} else {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.12 item for " + originalId);
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
protocol.getLogger().warning("Failed to get new item for " + originalId);
|
||||
}
|
||||
|
||||
rawId = 0x10000;
|
||||
@ -658,7 +658,7 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
|
||||
}
|
||||
|
||||
if (Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Found unknown enchant: " + newId);
|
||||
protocol.getLogger().warning("Found unknown enchant: " + newId);
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
@ -822,8 +822,8 @@ public class BlockItemPacketRewriter1_13 extends BackwardsItemRewriter<Clientbou
|
||||
} else if (protocol.getMappingData().getItemMappings().inverse().getNewId(rawId & ~0xF) != -1) {
|
||||
rawId &= ~0xF; // Remove data
|
||||
} else {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.identifier());
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
protocol.getLogger().warning("Failed to get old item for " + item.identifier());
|
||||
}
|
||||
rawId = 16; // Stone
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
int oldId = EntityTypeMapping.getOldId(type);
|
||||
if (oldId == -1) {
|
||||
if (!hasData(entityType)) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.12 entity type for 1.13 entity type " + type + "/" + entityType);
|
||||
protocol.getLogger().warning("Could not find entity type mapping " + type + "/" + entityType);
|
||||
}
|
||||
} else {
|
||||
wrapper.set(Types.VAR_INT, 1, oldId);
|
||||
|
@ -103,8 +103,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
|
||||
} else {
|
||||
String oldChannel = ItemPacketRewriter1_13.getOldPluginChannelId(channel);
|
||||
if (oldChannel == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring clientbound plugin message with channel: " + channel);
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
protocol.getLogger().warning("Ignoring clientbound plugin message with channel: " + channel);
|
||||
}
|
||||
wrapper.cancel();
|
||||
return;
|
||||
@ -118,8 +118,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
|
||||
String rewritten = ItemPacketRewriter1_13.getOldPluginChannelId(s);
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in clientbound " + oldChannel + ": " + s);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
protocol.getLogger().warning("Ignoring plugin channel in clientbound " + oldChannel + ": " + s);
|
||||
}
|
||||
}
|
||||
wrapper.write(Types.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||
@ -394,7 +394,7 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
|
||||
//Maybe older versions used this and we need to implement this? The issue is that we would have to save the command block types
|
||||
wrapper.setPacketType(ServerboundPackets1_13.SET_COMMAND_BLOCK);
|
||||
wrapper.cancel();
|
||||
ViaBackwards.getPlatform().getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!");
|
||||
protocol.getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!");
|
||||
} else if (type == 1) {
|
||||
wrapper.setPacketType(ServerboundPackets1_13.SET_COMMAND_MINECART);
|
||||
wrapper.write(Types.VAR_INT, wrapper.read(Types.INT)); //Entity Id
|
||||
@ -482,8 +482,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
|
||||
default -> {
|
||||
String newChannel = ItemPacketRewriter1_13.getNewPluginChannelId(channel);
|
||||
if (newChannel == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring serverbound plugin message with channel: " + channel);
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
protocol.getLogger().warning("Ignoring serverbound plugin message with channel: " + channel);
|
||||
}
|
||||
wrapper.cancel();
|
||||
return;
|
||||
@ -497,8 +497,8 @@ public class PlayerPacketRewriter1_13 extends RewriterBase<Protocol1_13To1_12_2>
|
||||
String rewritten = ItemPacketRewriter1_13.getNewPluginChannelId(s);
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Ignoring plugin channel in serverbound " + Key.stripMinecraftNamespace(newChannel).toUpperCase(Locale.ROOT) + ": " + s);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
protocol.getLogger().warning("Ignoring plugin channel in serverbound " + Key.stripMinecraftNamespace(newChannel).toUpperCase(Locale.ROOT) + ": " + s);
|
||||
}
|
||||
}
|
||||
if (!rewrittenChannels.isEmpty()) {
|
||||
|
@ -125,7 +125,7 @@ public class BlockItemPacketRewriter1_14 extends BackwardsItemRewriter<Clientbou
|
||||
}
|
||||
|
||||
if (stringType == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Can't open inventory for 1.13 player! Type: " + type);
|
||||
protocol.getLogger().warning("Can't open inventory for player! Type: " + type);
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
if (oldId == -1) {
|
||||
EntityData entityData = entityDataForType(entityType);
|
||||
if (entityData == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13.2 entity type for 1.14 entity type " + type + "/" + entityType);
|
||||
protocol.getLogger().warning("Could not find entity type mapping " + type + "/" + entityType);
|
||||
wrapper.cancel();
|
||||
} else {
|
||||
wrapper.set(Types.VAR_INT, 1, entityData.replacementId());
|
||||
|
@ -55,7 +55,7 @@ public class SoundPacketRewriter1_14 extends RewriterBase<Protocol1_14To1_13_2>
|
||||
StoredEntityData storedEntity = wrapper.user().getEntityTracker(protocol.getClass()).entityData(entityId);
|
||||
EntityPositionStorage1_14 entityStorage;
|
||||
if (storedEntity == null || (entityStorage = storedEntity.get(EntityPositionStorage1_14.class)) == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId);
|
||||
protocol.getLogger().warning("Untracked entity with id " + entityId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data.CommandRewriter1_16_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.CommandRewriter1_16_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.BlockItemPacketRewriter1_16_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter.EntityPacketRewriter1_16_2;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.storage.BiomeStorage;
|
||||
@ -40,10 +40,12 @@ import com.viaversion.viaversion.protocols.v1_16_1to1_16_2.packet.ServerboundPac
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import com.viaversion.viaversion.util.ProtocolLogger;
|
||||
|
||||
public class Protocol1_16_2To1_16_1 extends BackwardsProtocol<ClientboundPackets1_16_2, ClientboundPackets1_16, ServerboundPackets1_16_2, ServerboundPackets1_16> {
|
||||
|
||||
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.16.2", "1.16", Protocol1_16_1To1_16_2.class);
|
||||
public static final ProtocolLogger LOGGER = new ProtocolLogger(Protocol1_16_2To1_16_1.class);
|
||||
private final EntityPacketRewriter1_16_2 entityRewriter = new EntityPacketRewriter1_16_2(this);
|
||||
private final BlockItemPacketRewriter1_16_2 blockItemPackets = new BlockItemPacketRewriter1_16_2(this);
|
||||
private final TranslatableRewriter<ClientboundPackets1_16_2> translatableRewriter = new TranslatableRewriter<>(this, ComponentRewriter.ReadType.JSON);
|
||||
@ -134,6 +136,11 @@ public class Protocol1_16_2To1_16_1 extends BackwardsProtocol<ClientboundPackets
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolLogger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPacketRewriter1_16_2 getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
|
@ -19,6 +19,7 @@ package com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||
@ -27,7 +28,7 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import java.util.Map;
|
||||
|
||||
public final class BiomeMappings {
|
||||
public final class BiomeMappings1_16_1 {
|
||||
|
||||
private static final Object2IntMap<String> MODERN_TO_LEGACY_ID = new Object2IntOpenHashMap<>();
|
||||
private static final Object2IntMap<String> LEGACY_BIOMES = new Object2IntOpenHashMap<>();
|
||||
@ -121,7 +122,7 @@ public final class BiomeMappings {
|
||||
for (final Map.Entry<String, JsonElement> entry : mappings.entrySet()) {
|
||||
final int legacyBiome = LEGACY_BIOMES.getInt(entry.getValue().getAsString());
|
||||
if (legacyBiome == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unknown legacy biome: " + entry.getValue().getAsString());
|
||||
Protocol1_16_2To1_16_1.LOGGER.warning("Unknown legacy biome: " + entry.getValue().getAsString());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -137,7 +138,7 @@ public final class BiomeMappings {
|
||||
final int legacyBiome = MODERN_TO_LEGACY_ID.getInt(Key.stripMinecraftNamespace(biome));
|
||||
if (legacyBiome == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Biome with id " + biome + " has no legacy biome mapping (custom datapack?)");
|
||||
Protocol1_16_2To1_16_1.LOGGER.warning("Biome with id " + biome + " has no legacy biome mapping (custom datapack?)");
|
||||
}
|
||||
return 1; // Plains
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data;
|
||||
package com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
@ -85,7 +85,7 @@ public class EntityPacketRewriter1_16_2 extends EntityRewriter<ClientboundPacket
|
||||
}
|
||||
} else if (!warned) {
|
||||
warned = true;
|
||||
ViaBackwards.getPlatform().getLogger().warning("1.16 and 1.16.1 clients are only partially supported and may have wrong biomes displayed.");
|
||||
protocol.getLogger().warning("1.16 and 1.16.1 clients are only partially supported and may have wrong biomes displayed.");
|
||||
}
|
||||
|
||||
// Just screw the registry and write the defaults for 1.16 and 1.16.1 clients
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.storage;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data.BiomeMappings;
|
||||
import com.viaversion.viabackwards.protocol.v1_16_2to1_16_1.data.BiomeMappings1_16_1;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
@ -31,7 +31,7 @@ public final class BiomeStorage implements StorableObject {
|
||||
}
|
||||
|
||||
public void addBiome(final String biome, final int id) {
|
||||
modernToLegacyBiomes.put(id, BiomeMappings.toLegacyBiome(biome));
|
||||
modernToLegacyBiomes.put(id, BiomeMappings1_16_1.toLegacyBiome(biome));
|
||||
}
|
||||
|
||||
public int legacyBiome(final int biome) {
|
||||
|
@ -178,7 +178,7 @@ public class BlockItemPacketRewriter1_16 extends BackwardsItemRewriter<Clientbou
|
||||
int biome = chunk.getBiomeData()[i];
|
||||
int legacyBiome = biomeStorage.legacyBiome(biome);
|
||||
if (legacyBiome == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Biome sent that does not exist in the biome registry: " + biome);
|
||||
protocol.getLogger().warning("Biome sent that does not exist in the biome registry: " + biome);
|
||||
legacyBiome = 1;
|
||||
}
|
||||
chunk.getBiomeData()[i] = legacyBiome;
|
||||
|
@ -207,7 +207,7 @@ public final class EntityPacketRewriter1_17 extends EntityRewriter<ClientboundPa
|
||||
NumberTag logicalHeight = tag.getNumberTag("logical_height");
|
||||
if (minY.asInt() != 0 || height.asInt() > 256 || logicalHeight.asInt() > 256) {
|
||||
if (warn && !warned) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Increased world height is NOT SUPPORTED for 1.16 players and below. They will see a void below y 0 and above 256");
|
||||
protocol.getLogger().warning("Increased world height is NOT SUPPORTED for 1.16 players and below. They will see a void below y 0 and above 256");
|
||||
warned = true;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public final class Protocol1_18_2To1_18 extends BackwardsProtocol<ClientboundPac
|
||||
final int id = wrapper.read(Types.VAR_INT);
|
||||
if ((byte) id != id) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Cannot send entity effect id " + id + " to old client");
|
||||
getLogger().warning("Cannot send entity effect id " + id + " to old client");
|
||||
}
|
||||
wrapper.cancel();
|
||||
return;
|
||||
|
@ -34,6 +34,7 @@ import com.viaversion.viaversion.api.minecraft.signature.SignableCommandArgument
|
||||
import com.viaversion.viaversion.api.minecraft.signature.model.DecoratableMessage;
|
||||
import com.viaversion.viaversion.api.minecraft.signature.model.MessageMetadata;
|
||||
import com.viaversion.viaversion.api.minecraft.signature.storage.ChatSession1_19_1;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
@ -168,7 +169,7 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
final int chatTypeId = wrapper.read(Types.VAR_INT);
|
||||
final JsonElement senderName = wrapper.read(Types.COMPONENT);
|
||||
final JsonElement targetName = wrapper.read(Types.OPTIONAL_COMPONENT);
|
||||
decoratedMessage = decorateChatMessage(wrapper.user().get(ChatRegistryStorage1_19_1.class), chatTypeId, senderName, targetName, message);
|
||||
decoratedMessage = decorateChatMessage(this, wrapper.user().get(ChatRegistryStorage1_19_1.class), chatTypeId, senderName, targetName, message);
|
||||
if (decoratedMessage == null) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
@ -374,7 +375,7 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
data = new byte[]{1};
|
||||
wrapper.set(Types.REMAINING_BYTES, 0, data);
|
||||
} else {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Received unexpected data in velocity:player_info (length=" + data.length + ")");
|
||||
getLogger().warning("Received unexpected data in velocity:player_info (length=" + data.length + ")");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -403,10 +404,12 @@ public final class Protocol1_19_1To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
public static @Nullable JsonElement decorateChatMessage(final ChatRegistryStorage chatRegistryStorage, final int chatTypeId, final JsonElement senderName, @Nullable final JsonElement targetName, final JsonElement message) {
|
||||
public static @Nullable JsonElement decorateChatMessage(final Protocol protocol, final ChatRegistryStorage chatRegistryStorage,
|
||||
final int chatTypeId, final JsonElement senderName,
|
||||
@Nullable final JsonElement targetName, final JsonElement message) {
|
||||
CompoundTag chatType = chatRegistryStorage.chatType(chatTypeId);
|
||||
if (chatType == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Chat message has unknown chat type id " + chatTypeId + ". Message: " + message);
|
||||
protocol.getLogger().warning("Chat message has unknown chat type id " + chatTypeId + ". Message: " + message);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol<ClientboundP
|
||||
final int chatTypeId = wrapper.read(Types.VAR_INT);
|
||||
final JsonElement senderName = wrapper.read(Types.COMPONENT);
|
||||
final JsonElement targetName = wrapper.read(Types.OPTIONAL_COMPONENT);
|
||||
final JsonElement result = Protocol1_19_1To1_19.decorateChatMessage(wrapper.user().get(ChatTypeStorage1_19_3.class), chatTypeId, senderName, targetName, content);
|
||||
final JsonElement result = Protocol1_19_1To1_19.decorateChatMessage(Protocol1_19_3To1_19_1.this, wrapper.user().get(ChatTypeStorage1_19_3.class), chatTypeId, senderName, targetName, content);
|
||||
if (result == null) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
@ -347,7 +347,7 @@ public final class Protocol1_19_3To1_19_1 extends BackwardsProtocol<ClientboundP
|
||||
final int chatTypeId = wrapper.read(Types.VAR_INT);
|
||||
final JsonElement senderName = wrapper.read(Types.COMPONENT);
|
||||
final JsonElement targetName = wrapper.read(Types.OPTIONAL_COMPONENT);
|
||||
final JsonElement result = Protocol1_19_1To1_19.decorateChatMessage(wrapper.user().get(ChatTypeStorage1_19_3.class), chatTypeId, senderName, targetName, content);
|
||||
final JsonElement result = Protocol1_19_1To1_19.decorateChatMessage(this, wrapper.user().get(ChatTypeStorage1_19_3.class), chatTypeId, senderName, targetName, content);
|
||||
if (result == null) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
|
@ -164,7 +164,7 @@ public final class Protocol1_19To1_18_2 extends BackwardsProtocol<ClientboundPac
|
||||
final int argumentTypeId = wrapper.read(Types.VAR_INT);
|
||||
String argumentType = MAPPINGS.getArgumentTypeMappings().identifier(argumentTypeId);
|
||||
if (argumentType == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unknown command argument type id: " + argumentTypeId);
|
||||
getLogger().warning("Unknown command argument type id: " + argumentTypeId);
|
||||
argumentType = "minecraft:no";
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public final class BlockItemPacketRewriter1_20_3 extends BackwardsItemRewriter<C
|
||||
} else if (positionSourceType == 1) {
|
||||
wrapper.write(Types.STRING, "minecraft:entity");
|
||||
} else {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unknown position source type: " + positionSourceType);
|
||||
protocol.getLogger().warning("Unknown position source type: " + positionSourceType);
|
||||
wrapper.cancel();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user