Compare commits

..
25 Commits
Author SHA1 Message Date
Nassim Jahnke 1d566100fb 5.7.0 Release 2025-12-29 12:46:28 +01:00
Nassim Jahnke 212cca1d65 Add null check to uuid in Velocity kick method 2025-12-27 21:45:35 +01:00
Nassim Jahnke 1f40811877 Track merchant offer items for hashing 2025-12-27 12:48:32 +01:00
Nassim Jahnke f45d2f8567 Fix UUID hashing
Fixes #4727
2025-12-26 20:24:34 +01:00
Nassim Jahnke 9b19bfc6df Move logging config options to new section and update defaults 2025-12-25 21:37:43 +01:00
FlorianMichael c2a8400751 Update block connection mapping file (#4759) 2025-12-25 09:11:02 +01:00
David Lüdtke 3cbfbd3b9f Fix world border lerp size set in ticks instead of millis (#4755) (#4757) 2025-12-23 09:54:43 +01:00
Nassim Jahnke ea6808b697 Update sprite atlas in 1.21.9->1.21.11
Fixes #4734
2025-12-21 18:00:08 +01:00
Nassim Jahnke 85f868c37e Put set_objective and set_score packets through component rewriter 2025-12-21 15:39:35 +01:00
Rocco f6e036df76 Restore 1.8 hitbox margin for 1.21.11+ clients (#4733) 2025-12-21 10:52:34 +01:00
FlorianMichael 55ed56668e Fix alignment of pre/post packet debug (#4754) 2025-12-20 20:42:35 +01:00
FlorianMichael 705509489a Support packet types with different states in debug handling (#4751) 2025-12-20 16:33:57 +01:00
Nassim Jahnke 57a42e1156 Handle block_state_property enchantment terms
Fixes #4750
2025-12-20 11:54:41 +01:00
FlorianMichael 7181f485eb Fix pps sub command not working (#4749) 2025-12-19 09:43:26 +01:00
Kichura 5f3dc1be53 [ci skip] Error on absent artifacts, set CI timeout to 30 mins (#4745) 2025-12-19 09:42:26 +01:00
booky 4f06afc2bd Cancel serverbound stab packets (#4744) 2025-12-15 16:05:10 +01:00
RK_01 c267a754e7 Always send extra attributes in 1.20.5 (#4742) 2025-12-15 09:27:42 +01:00
RK_01 7657a59b07 Add step_height and version dependent interaction range 1.20.5 attributes (#4741) 2025-12-14 22:15:03 +01:00
Nassim Jahnke f95ec49d6f Properly pass on packet type in PacketWrapper.create 2025-12-14 20:20:12 +01:00
FlorianMichael 1be574bc21 Handle lit_furnace as furnace in 1.8->1.9 (#4739) 2025-12-14 13:48:22 +01:00
Nassim Jahnke 0640e2468c Don't auto-split long lines when dumping config
Fixes #4740
2025-12-14 10:43:18 +01:00
FlorianMichael 2adfee3b60 [ci skip] Include the newest ViaProxy version from 3.0.0 to 4.0.0 (#4738) 2025-12-13 19:59:00 +01:00
riku6460 b65d7af793 Fix default dripstone particle in 1.21.9->1.21.11 (#4735) 2025-12-13 11:18:06 +01:00
Nassim Jahnke 8f7fd34fa4 Add max-error-length config option 2025-12-13 11:17:41 +01:00
Nassim Jahnke 5bf0e9b22a Bump version to 5.6.1-SNAPSHOT 2025-12-13 10:49:22 +01:00
59 changed files with 474 additions and 157 deletions

No files matched your search

+2
View File
@@ -8,6 +8,7 @@ jobs:
# Only run on PRs if the source branch is on a different repo. We do not need to run everything twice.
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
@@ -30,3 +31,4 @@ jobs:
with:
name: Artifacts
path: build/libs/
if-no-files-found: error
+1
View File
@@ -13,6 +13,7 @@ jobs:
publish:
if: github.repository_owner == 'ViaVersion'
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
@@ -11,6 +11,7 @@ permissions:
jobs:
update-gradle-wrapper:
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
@@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
import com.viaversion.viaversion.api.protocol.version.BlockedProtocolVersions;
import java.util.concurrent.TimeUnit;
public interface ViaVersionConfig extends Config {
@@ -67,11 +68,16 @@ public interface ViaVersionConfig extends Config {
boolean isShowNewDeathMessages();
/**
* Get if entity data errors will be suppressed
* Get if entity data errors will be logged
*
* @return true if entity data errors suppression is enabled
* @return true if entity data error logging is enabled
*/
boolean isSuppressMetadataErrors();
boolean logEntityDataErrors();
@Deprecated(forRemoval = true)
default boolean isSuppressMetadataErrors() {
return !logEntityDataErrors();
}
/**
* Get if blocking in 1.9 & 1.10 appears as a player holding a shield
@@ -148,7 +154,9 @@ public interface ViaVersionConfig extends Config {
* @return The number of packets a client can send per second.
*/
@Deprecated(forRemoval = true)
int getMaxPPS();
default int getMaxPPS() {
return getPacketTrackerConfig().maxRate();
}
/**
* Get the kick message sent if the user hits the max packets per second.
@@ -156,7 +164,9 @@ public interface ViaVersionConfig extends Config {
* @return Kick message, with colour codes using '&'
*/
@Deprecated(forRemoval = true)
String getMaxPPSKickMessage();
default String getMaxPPSKickMessage() {
return getPacketTrackerConfig().maxRateKickMessage();
}
/**
* The time in seconds that should be tracked for warnings
@@ -164,7 +174,9 @@ public interface ViaVersionConfig extends Config {
* @return Time in seconds that should be tracked for warnings
*/
@Deprecated(forRemoval = true)
int getTrackingPeriod();
default int getTrackingPeriod() {
return (int) TimeUnit.NANOSECONDS.toSeconds(getPacketTrackerConfig().trackingPeriodNanos());
}
/**
* The number of packets per second to count as a warning
@@ -172,7 +184,9 @@ public interface ViaVersionConfig extends Config {
* @return The number of packets per second to count as a warning.
*/
@Deprecated(forRemoval = true)
int getWarningPPS();
default int getWarningPPS() {
return getPacketTrackerConfig().warningRate();
}
/**
* Get the maximum number of warnings the client can have in the interval
@@ -180,7 +194,9 @@ public interface ViaVersionConfig extends Config {
* @return The number of packets a client can send per second.
*/
@Deprecated(forRemoval = true)
int getMaxWarnings();
default int getMaxWarnings() {
return getPacketTrackerConfig().maxWarnings();
}
/**
* Get the kick message sent if the user goes over the warnings in the interval
@@ -188,7 +204,9 @@ public interface ViaVersionConfig extends Config {
* @return Kick message, with colour codes using '&'
*/
@Deprecated(forRemoval = true)
String getMaxWarningsKickMessage();
default String getMaxWarningsKickMessage() {
return getPacketTrackerConfig().warningKickMessage();
}
RateLimitConfig getPacketTrackerConfig();
@@ -284,18 +302,28 @@ public interface ViaVersionConfig extends Config {
String getReloadDisconnectMsg();
/**
* Should we hide errors that occur when trying to convert block and item data over versions?
* Should we log warnings on issues when trying to convert data over versions?
*
* @return true if enabled
*/
boolean isSuppressConversionWarnings();
boolean logOtherConversionWarnings();
/**
* Should we hide errors that occur when trying to convert text components?
* Should we log errors that occur when trying to convert text components?
*
* @return true if enabled
*/
boolean isSuppressTextComponentConversionWarnings();
boolean logTextComponentConversionErrors();
@Deprecated(forRemoval = true)
default boolean isSuppressConversionWarnings() {
return !logOtherConversionWarnings();
}
@Deprecated(forRemoval = true)
default boolean isSuppressTextComponentConversionWarnings() {
return !logTextComponentConversionErrors();
}
/**
* Should we disable the 1.13 auto-complete feature to stop spam kicks? (for any server lower than 1.13)
@@ -498,4 +526,19 @@ public interface ViaVersionConfig extends Config {
* @return true if enabled
*/
boolean cancelSwingInInventory();
/**
* Returns the max length of error messages. Longer messages will be truncated unless in debug mode.
*
* @return the max length of error messages
*/
int maxErrorLength();
/**
* If enabled, 1.21.11+ clients on 1.8 (or older) servers will get wider entity hitboxes,
* but only when attacking with an item.
*
* @return true if enabled
*/
boolean use1_8HitboxMargin();
}
@@ -354,7 +354,7 @@ public class MappingDataBase implements MappingData {
*/
protected int checkValidity(final int id, final int mappedId, final String type) {
if (mappedId == -1) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
getLogger().warning(String.format("Missing %s %s for %s %s %d", mappedVersion, type, unmappedVersion, type, id));
}
return 0;
@@ -52,7 +52,7 @@ public interface DebugHandler {
void addPacketTypeNameToLog(String packetTypeName);
/**
* Adds a packet id to the list of packet types to log.
* Adds a packet type to the list of packet types to log.
* Packets will be checked on each protocol transformer, so this is best used on single protocol pipes.
*
* @param packetType packet type
@@ -66,6 +66,13 @@ public interface DebugHandler {
*/
boolean removePacketTypeNameToLog(String packetTypeName);
/**
* Removes a packet type from the list of packet types to log.
*
* @param packetType Packet type to remove
*/
boolean removePacketTypeToLog(PacketType packetType);
/**
* Resets packet type filters.
*/
@@ -121,7 +128,12 @@ public interface DebugHandler {
*/
boolean shouldLog(PacketWrapper wrapper, Direction direction);
default void enableAndLogIds(final PacketType... packetTypes) {
/**
* Enables debug mode and adds the given packet types to the log list.
*
* @param packetTypes packet types to log
*/
default void enableAndLogTypes(final PacketType... packetTypes) {
setEnabled(true);
for (final PacketType packetType : packetTypes) {
addPacketTypeToLog(packetType);
@@ -135,7 +147,7 @@ public interface DebugHandler {
* @param t thrown exception
*/
default void error(final String error, final Throwable t) {
if (!Via.getConfig().isSuppressConversionWarnings() || enabled()) {
if (Via.getConfig().logOtherConversionWarnings() || enabled()) {
Via.getPlatform().getLogger().log(Level.SEVERE, error, t);
}
}
@@ -132,7 +132,7 @@ public class PacketTracker {
public boolean isPacketLimiterEnabled() {
ViaVersionConfig config = Via.getConfig();
return packetLimiterEnabled && config.getPacketTrackerConfig().enabled() && config.getPacketSizeTrackerConfig().enabled();
return packetLimiterEnabled && (config.getPacketTrackerConfig().enabled() || config.getPacketSizeTrackerConfig().enabled());
}
public void setPacketLimiterEnabled(boolean packetLimiterEnabled) {
@@ -258,9 +258,7 @@ public interface PacketWrapper {
* @param packetType packet type of the new packet
* @return The newly created packet wrapper
*/
default PacketWrapper create(PacketType packetType) {
return create(packetType.getId());
}
PacketWrapper create(PacketType packetType);
/**
* Creates a new packet with values.
@@ -269,9 +267,7 @@ public interface PacketWrapper {
* @param handler handler to write to the packet
* @return newly created packet wrapper
*/
default PacketWrapper create(PacketType packetType, PacketHandler handler) throws InformativeException {
return create(packetType.getId(), handler);
}
PacketWrapper create(PacketType packetType, PacketHandler handler) throws InformativeException;
/**
* Creates a new packet for the target of this packet.
@@ -141,7 +141,7 @@ public abstract class PacketHandlers implements PacketHandler {
try {
handler.handle(h);
} catch (Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
Via.getPlatform().getLogger().log(Level.WARNING, "Failed to handle packet", e);
}
h.cancel();
@@ -22,9 +22,11 @@
*/
package com.viaversion.viaversion.api.type.types;
import com.viaversion.viaversion.api.minecraft.codec.Ops;
import com.viaversion.viaversion.api.type.OptionalType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.util.UUIDUtil;
import io.netty.buffer.ByteBuf;
import java.util.UUID;
@@ -45,6 +47,11 @@ public class UUIDType extends Type<UUID> {
buffer.writeLong(object.getLeastSignificantBits());
}
@Override
public void write(final Ops ops, final UUID value) {
ops.write(Types.INT_ARRAY_PRIMITIVE, UUIDUtil.toIntArray(value));
}
public static final class OptionalUUIDType extends OptionalType<UUID> {
public OptionalUUIDType() {
@@ -31,6 +31,8 @@ import java.util.UUID;
public final class GameProfileType extends Type<GameProfile> {
private static final GameProfile.Property[] EMPTY_PROPERTIES = new GameProfile.Property[0];
public GameProfileType() {
super(GameProfile.class);
}
@@ -54,7 +56,7 @@ public final class GameProfileType extends Type<GameProfile> {
public void write(final Ops ops, final GameProfile value) {
ops.writeMap(map -> map
.writeOptional("name", Types.STRING, value.name())
.writeOptional("id", Types.STRING, value.id() != null ? value.id().toString() : null)
.write("properties", Types.PROFILE_PROPERTY_ARRAY, value.properties()));
.writeOptional("id", Types.UUID, value.id())
.writeOptional("properties", Types.PROFILE_PROPERTY_ARRAY, value.properties(), EMPTY_PROPERTIES));
}
}
@@ -29,7 +29,6 @@ import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public class InformativeException extends RuntimeException {
private static final int MAX_MESSAGE_LENGTH = 5_000;
private final List<DataEntry> dataEntries = new ArrayList<>();
private boolean shouldBePrinted = true;
private int sources;
@@ -72,8 +71,8 @@ public class InformativeException extends RuntimeException {
builder.append(entry.name()).append(": ");
String s = String.valueOf(entry.value());
if (!Via.getManager().isDebug() && s.length() > 10 && builder.length() + s.length() > MAX_MESSAGE_LENGTH) {
final int remaining = Math.max(0, MAX_MESSAGE_LENGTH - builder.length());
if (!Via.getManager().isDebug() && s.length() > 10 && builder.length() + s.length() > Via.getConfig().maxErrorLength()) {
final int remaining = Math.max(0, Via.getConfig().maxErrorLength() - builder.length());
s = s.substring(0, Math.min(remaining, s.length())) + "...";
}
builder.append(StringUtil.forLogging(s));
@@ -214,8 +214,8 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform<Player>
@Override
public boolean kickPlayer(UserConnection connection, String message) {
UUID uuid = connection.getProtocolInfo().getUuid();
Player player = Bukkit.getPlayer(uuid);
if (player != null) {
Player player;
if (uuid != null && (player = Bukkit.getPlayer(uuid)) != null) {
player.kickPlayer(message);
return true;
} else {
@@ -48,7 +48,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
private boolean checkForUpdates;
private boolean preventCollision;
private boolean useNewEffectIndicator;
private boolean suppressMetadataErrors;
private boolean logEntityDataErrors;
private boolean shieldBlocking;
private boolean noDelayShieldBlocking;
private boolean showShieldWhenSwordInHand;
@@ -69,8 +69,8 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
private String blockedDisconnectMessage;
private boolean logBlockedJoins;
private String reloadDisconnectMessage;
private boolean suppressConversionWarnings;
private boolean suppressTextComponentConversionWarnings;
private boolean logOtherConversionErrors;
private boolean logTextComponentConversionErrors;
private boolean disable1_13TabComplete;
private boolean teamColourFix;
private boolean serversideBlockConnections;
@@ -97,6 +97,8 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
private boolean hideScoreboardNumbers;
private boolean fix1_21PlacementRotation;
private boolean cancelSwingInInventory;
private int maxErrorLength;
private boolean use1_8HitboxMargin;
protected AbstractViaConfig(final File configFile, final Logger logger) {
super(configFile, logger);
@@ -105,7 +107,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
@Override
public void reload() {
super.reload();
updateConfig();
if (updateConfig()) {
save();
}
loadFields();
}
@@ -113,7 +117,6 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
checkForUpdates = getBoolean("check-for-updates", true);
preventCollision = getBoolean("prevent-collision", true);
useNewEffectIndicator = getBoolean("use-new-effect-indicator", true);
suppressMetadataErrors = getBoolean("suppress-metadata-errors", false);
shieldBlocking = getBoolean("shield-blocking", true);
noDelayShieldBlocking = getBoolean("no-delay-shield-blocking", false);
showShieldWhenSwordInHand = getBoolean("show-shield-when-sword-in-hand", false);
@@ -130,11 +133,8 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
autoTeam = getBoolean("auto-team", true);
blockedProtocolVersions = loadBlockedProtocolVersions();
blockedDisconnectMessage = getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
logBlockedJoins = getBoolean("log-blocked-joins", false);
reloadDisconnectMessage = getString("reload-disconnect-msg", "Server reload, please rejoin!");
teamColourFix = getBoolean("team-colour-fix", true);
suppressConversionWarnings = getBoolean("suppress-conversion-warnings", false);
suppressTextComponentConversionWarnings = getBoolean("suppress-text-component-conversion-warnings", true);
disable1_13TabComplete = getBoolean("disable-1_13-auto-complete", false);
serversideBlockConnections = getBoolean("serverside-blockconnections", true);
reduceBlockStorageMemory = getBoolean("reduce-blockstorage-memory", false);
@@ -163,23 +163,68 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
hideScoreboardNumbers = getBoolean("hide-scoreboard-numbers", false);
fix1_21PlacementRotation = getBoolean("fix-1_21-placement-rotation", true);
cancelSwingInInventory = getBoolean("cancel-swing-in-inventory", true);
use1_8HitboxMargin = getBoolean("use-1_8-hitbox-margin", true);
packetTrackerConfig = loadRateLimitConfig(getSection("packet-limiter"), "%pps", 1);
packetSizeTrackerConfig = loadRateLimitConfig(getSection("packet-size-limiter"), "%bps", 1024);
final ConfigSection loggingSection = getSection("logging");
logBlockedJoins = loggingSection.getBoolean("log-blocked-joins", false);
logEntityDataErrors = loggingSection.getBoolean("log-entity-data-errors", true);
logTextComponentConversionErrors = loggingSection.getBoolean("log-text-component-conversion-errors", false);
logOtherConversionErrors = loggingSection.getBoolean("log-other-conversion-warnings", false);
maxErrorLength = loggingSection.getInt("max-error-length", 1500);
}
protected void updateConfig() {
/**
* Updates the config if the existing merging of default and provided config is not enough.
* <p>
* This can for example include renaming config options or changing default values.
*
* @return true if the config should be saved after calling this method
* @see #originalRootSection()
*/
protected boolean updateConfig() {
ConfigSection original = originalRootSection();
if (original != null && original.contains("max-pps")) {
if (original == null) {
return false;
}
boolean modified = false;
if (original.contains("max-pps")) {
// 5.5.0 pps changes
ConfigSection section = getSection("packet-limiter");
section.set("max-per-second", original.getInt("max-pps", -1));
section.set("max-per-second-kick-message", original.getString("max-pps-kick-msg", "You are sending too many packets!"));
section.set("sustained-max-per-second", original.getInt("tracking-warning-pps", -1));
section.set("sustained-threshold", original.getInt("tracking-max-warnings", 3));
section.set("sustained-period-seconds", original.getInt("tracking-period", 6));
section.set("sustained-period-seconds", original.getInt("tracking-period", 7));
section.set("sustained-kick-message", original.getString("tracking-max-kick-msg", "You are sending too many packets, :("));
save();
modified = true;
}
final int initialConfigVersion = original.getInt("init-config-version", 0); // version the config was initially created with
final int configVersion = original.getInt("config-version", 0);
final boolean migrateDefaults = original.getBoolean("migrate-default-config-changes", true);
if (configVersion < 1 && migrateDefaults) {
// 5.5.0/5.7.0 change of defaults
final ConfigSection packetLimiterSection = getSection("packet-limiter");
final int sustainedMax = packetLimiterSection.getInt("sustained-max-per-second", 0);
if (sustainedMax == 120 || sustainedMax == 150) {
packetLimiterSection.set("sustained-max-per-second", 200);
modified = true;
}
if (packetLimiterSection.getInt("sustained-period-seconds", 0) == 6) {
packetLimiterSection.set("sustained-period-seconds", 7);
modified = true;
}
ConfigSection loggingSection = getSection("logging");
loggingSection.set("log-blocked-joins", original.getBoolean("log-blocked-joins", false));
loggingSection.set("log-entity-data-errors", !original.getBoolean("suppress-metadata-errors", false));
loggingSection.set("max-error-length", original.getInt("max-error-length", 1500));
// Don't migrate the others
}
return modified;
}
private BlockedProtocolVersions loadBlockedProtocolVersions() {
@@ -292,8 +337,8 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
}
@Override
public boolean isSuppressMetadataErrors() {
return suppressMetadataErrors;
public boolean logEntityDataErrors() {
return logEntityDataErrors || Via.getManager().isDebug();
}
@Override
@@ -336,36 +381,6 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
return hologramOffset;
}
@Override
public int getMaxPPS() {
return packetTrackerConfig.maxRate();
}
@Override
public String getMaxPPSKickMessage() {
return packetTrackerConfig.maxRateKickMessage();
}
@Override
public int getTrackingPeriod() {
return (int) TimeUnit.NANOSECONDS.toSeconds(packetTrackerConfig.trackingPeriodNanos());
}
@Override
public int getWarningPPS() {
return packetTrackerConfig.warningRate();
}
@Override
public int getMaxWarnings() {
return packetTrackerConfig.maxWarnings();
}
@Override
public String getMaxWarningsKickMessage() {
return packetTrackerConfig.warningKickMessage();
}
@Override
public RateLimitConfig getPacketTrackerConfig() {
return packetTrackerConfig;
@@ -453,13 +468,13 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
}
@Override
public boolean isSuppressConversionWarnings() {
return suppressConversionWarnings && !Via.getManager().isDebug(); // Debug mode overrules config
public boolean logOtherConversionWarnings() {
return logOtherConversionErrors || Via.getManager().isDebug();
}
@Override
public boolean isSuppressTextComponentConversionWarnings() {
return suppressTextComponentConversionWarnings && !Via.getManager().isDebug(); // Debug mode overrules config
public boolean logTextComponentConversionErrors() {
return logTextComponentConversionErrors || Via.getManager().isDebug();
}
@Override
@@ -606,4 +621,14 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
public boolean cancelSwingInInventory() {
return cancelSwingInInventory;
}
@Override
public int maxErrorLength() {
return maxErrorLength;
}
@Override
public boolean use1_8HitboxMargin() {
return use1_8HitboxMargin;
}
}
@@ -21,16 +21,15 @@ import com.viaversion.viaversion.api.debug.DebugHandler;
import com.viaversion.viaversion.api.protocol.packet.Direction;
import com.viaversion.viaversion.api.protocol.packet.PacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import com.viaversion.viaversion.api.protocol.packet.State;
import java.util.HashSet;
import java.util.Set;
public final class DebugHandlerImpl implements DebugHandler {
private final Set<String> packetTypesToLog = new HashSet<>();
private final IntSet clientboundPacketIdsToLog = new IntOpenHashSet();
private final IntSet serverboundPacketIdsToLog = new IntOpenHashSet();
private final Set<PacketType> clientboundPacketsToLog = new HashSet<>();
private final Set<PacketType> serverboundPacketsToLog = new HashSet<>();
private boolean logPrePacketTransform = true;
private boolean logPostPacketTransform;
private boolean enabled;
@@ -52,7 +51,7 @@ public final class DebugHandlerImpl implements DebugHandler {
@Override
public void addPacketTypeToLog(PacketType packetType) {
(packetType.direction() == Direction.SERVERBOUND ? serverboundPacketIdsToLog : clientboundPacketIdsToLog).add(packetType.getId());
(packetType.direction() == Direction.SERVERBOUND ? serverboundPacketsToLog : clientboundPacketsToLog).add(packetType);
}
@Override
@@ -60,9 +59,16 @@ public final class DebugHandlerImpl implements DebugHandler {
return packetTypesToLog.remove(packetTypeName);
}
@Override
public boolean removePacketTypeToLog(final PacketType packetType) {
return (packetType.direction() == Direction.SERVERBOUND ? serverboundPacketsToLog : clientboundPacketsToLog).remove(packetType);
}
@Override
public void clearPacketTypesToLog() {
packetTypesToLog.clear();
serverboundPacketsToLog.clear();
clientboundPacketsToLog.clear();
}
@Override
@@ -87,8 +93,21 @@ public final class DebugHandlerImpl implements DebugHandler {
@Override
public boolean shouldLog(final PacketWrapper wrapper, final Direction direction) {
return packetTypesToLog.isEmpty() && serverboundPacketIdsToLog.isEmpty() && clientboundPacketIdsToLog.isEmpty()
|| (wrapper.getPacketType() != null && packetTypesToLog.contains(wrapper.getPacketType().getName()))
|| (direction == Direction.SERVERBOUND ? serverboundPacketIdsToLog : clientboundPacketIdsToLog).contains(wrapper.getId());
if (packetTypesToLog.isEmpty() && serverboundPacketsToLog.isEmpty() && clientboundPacketsToLog.isEmpty()) {
return true;
}
final Set<PacketType> packetTypes = direction == Direction.SERVERBOUND ? serverboundPacketsToLog : clientboundPacketsToLog;
if (wrapper.getPacketType() != null) {
return packetTypesToLog.contains(wrapper.getPacketType().getName()) || packetTypes.contains(wrapper.getPacketType());
}
final State state = wrapper.user().getProtocolInfo().getState(direction);
for (final PacketType packetType : packetTypes) {
if (packetType.getId() == wrapper.getId() && packetType.state() == state) {
return true;
}
}
return false;
}
}
@@ -119,12 +119,13 @@ public class ProtocolPipelineImpl implements ProtocolPipeline {
}
private void logPacket(Direction direction, State state, PacketWrapper packetWrapper, int originalID, boolean post) {
final String stage = post ? "POST" : "PRE ";
ProtocolInfo protocolInfo = userConnection.getProtocolInfo();
String actualUsername = protocolInfo.getUsername();
String username = actualUsername != null ? actualUsername + " " : "";
Via.getPlatform().getLogger().log(Level.INFO, "{0}: {1}{2} {3}: {4} ({5}) -> {6} ({7}) [{8}] {9}",
new Object[]{
post ? "Post" : "Pre",
stage,
username,
direction,
state,
@@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.type.TypeConverter;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.exception.CancelException;
import com.viaversion.viaversion.exception.InformativeException;
import com.viaversion.viaversion.util.ArrayUtil;
import com.viaversion.viaversion.util.PipelineUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
@@ -428,6 +429,18 @@ public class PacketWrapperImpl implements PacketWrapper {
return wrapper;
}
@Override
public PacketWrapperImpl create(final PacketType packetType) {
return new PacketWrapperImpl(packetType, null, user());
}
@Override
public PacketWrapperImpl create(final PacketType packetType, final PacketHandler handler) throws InformativeException {
PacketWrapperImpl wrapper = create(packetType);
handler.handle(wrapper);
return wrapper;
}
@Override
public void apply(Direction direction, State state, List<Protocol> pipeline) throws InformativeException, CancelException {
// Indexed loop to allow additions to the tail
@@ -624,7 +637,7 @@ public class PacketWrapperImpl implements PacketWrapper {
@Override
public String toString() {
return "{" + type + ": " + value + "}";
return "{" + type + ": " + ArrayUtil.toString(value) + "}";
}
}
}
@@ -84,6 +84,7 @@ final class Protocol1_98To1_99 extends AbstractProtocol<ClientboundPacket1_21_6,
componentRewriter.registerComponentPacket(ClientboundPackets1_21_6.SET_SUBTITLE_TEXT);
componentRewriter.registerBossEvent(ClientboundPackets1_21_6.BOSS_EVENT);
componentRewriter.registerComponentPacket(ClientboundPackets1_21_6.DISCONNECT);
componentRewriter.registerComponentPacket(ClientboundConfigurationPackets1_21_6.DISCONNECT);
componentRewriter.registerTabList(ClientboundPackets1_21_6.TAB_LIST);
componentRewriter.registerSetPlayerTeam1_21_5(ClientboundPackets1_21_6.SET_PLAYER_TEAM);
componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_6.PLAYER_COMBAT_KILL);
@@ -91,6 +92,8 @@ final class Protocol1_98To1_99 extends AbstractProtocol<ClientboundPacket1_21_6,
componentRewriter.registerComponentPacket(ClientboundPackets1_21_6.SYSTEM_CHAT);
componentRewriter.registerDisguisedChat(ClientboundPackets1_21_6.DISGUISED_CHAT);
componentRewriter.registerPlayerChat1_21_5(ClientboundPackets1_21_6.PLAYER_CHAT);
componentRewriter.registerSetObjective(ClientboundPackets1_21_6.SET_OBJECTIVE);
componentRewriter.registerSetScore1_20_3(ClientboundPackets1_21_6.SET_SCORE);
componentRewriter.registerPing();
// If needed for any particle, item, or block changes. Extend ParticleRewriter for particle serializer changes
@@ -396,7 +396,7 @@ public class EntityPacketRewriter1_11 extends EntityRewriter<ClientboundPackets1
}
}
} catch (Exception e) {
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
if (Via.getConfig().logEntityDataErrors()) {
protocol.getLogger().warning("An error occurred with entity type rewriter");
protocol.getLogger().warning("Entity data: " + entityData);
protocol.getLogger().log(Level.WARNING, "Error: ", e);
@@ -87,7 +87,7 @@ public class TranslateRewriter {
hoverEvent.addProperty("action", "show_text");
hoverEvent.add("value", baseArray);
} catch (Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
protocol.getLogger().log(Level.WARNING, "Error rewriting show_achievement: " + StringUtil.forLogging(hoverEvent), e);
}
JsonObject invalidText = new JsonObject();
@@ -57,7 +57,7 @@ public class ComponentRewriter1_13<C extends ClientboundPacketType> extends Json
try {
tag = ComponentUtil.deserializeLegacyShowItem(value, SerializerVersion.V1_12);
} catch (Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
Protocol1_12_2To1_13.LOGGER.log(Level.WARNING, "Error reading NBT in show_item: " + StringUtil.forLogging(value), e);
}
return;
@@ -96,7 +96,7 @@ public class ComponentRewriter1_13<C extends ClientboundPacketType> extends Json
showItem.addProperty("text", SerializerVersion.V1_13.toSNBT(tag));
hoverEvent.add("value", newValue);
} catch (Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
Protocol1_12_2To1_13.LOGGER.log(Level.WARNING, "Error writing NBT in show_item: " + StringUtil.forLogging(value), e);
}
}
@@ -119,7 +119,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
flags |= 1;
Optional<SoundSource1_12_2> finalSource = SoundSource1_12_2.findBySource(originalSource);
if (finalSource.isEmpty()) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
Protocol1_12_2To1_13.LOGGER.warning("Could not handle unknown sound source " + originalSource + " falling back to default: master");
}
finalSource = Optional.of(SoundSource1_12_2.MASTER);
@@ -141,7 +141,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
String old = channel;
channel = getNewPluginChannelId(channel);
if (channel == null) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
protocol.getLogger().warning("Ignoring clientbound plugin message with channel: " + old);
}
wrapper.cancel();
@@ -153,7 +153,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
String rewritten = getNewPluginChannelId(s);
if (rewritten != null) {
rewrittenChannels.add(rewritten);
} else if (!Via.getConfig().isSuppressConversionWarnings()) {
} else if (Via.getConfig().logOtherConversionWarnings()) {
protocol.getLogger().warning("Ignoring plugin channel in clientbound " + Key.stripMinecraftNamespace(channel).toUpperCase(Locale.ROOT) + ": " + s);
}
}
@@ -431,7 +431,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
} else if (Protocol1_12_2To1_13.MAPPINGS.getItemMappings().getNewId(IdAndData.removeData(rawId)) != -1) {
rawId = IdAndData.removeData(rawId);
} else {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
protocol.getLogger().warning("Failed to get new item for " + item.identifier());
}
rawId = 16; // Stone
@@ -505,7 +505,7 @@ public class ItemPacketRewriter1_13 extends ItemRewriter<ClientboundPackets1_12_
}
if (rawId == null) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
protocol.getLogger().warning("Failed to get old item for " + item.identifier());
}
rawId = 0x10000; // Stone
@@ -88,7 +88,7 @@ public class WorldPacketRewriter1_13 {
String motive = wrapper.read(Types.STRING);
Optional<Integer> id = provider.getIntByIdentifier(motive);
if (id.isEmpty() && !Via.getConfig().isSuppressConversionWarnings()) {
if (id.isEmpty() && Via.getConfig().logOtherConversionWarnings()) {
Protocol1_12_2To1_13.LOGGER.warning("Could not find painting motive: " + motive + " falling back to default (0)");
}
wrapper.write(Types.VAR_INT, id.orElse(0));
@@ -408,7 +408,7 @@ public class WorldPacketRewriter1_13 {
if (!VALID_BIOMES.contains(biome)) {
if (biome != 255 // is it generated naturally? *shrug*
&& latestBiomeWarn != biome) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
Protocol1_12_2To1_13.LOGGER.warning("Received invalid biome id: " + biome);
}
latestBiomeWarn = biome;
@@ -571,12 +571,12 @@ public class WorldPacketRewriter1_13 {
}
newId = Protocol1_12_2To1_13.MAPPINGS.getBlockMappings().getNewId(IdAndData.removeData(oldId)); // Remove data
if (newId != -1) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
Protocol1_12_2To1_13.LOGGER.warning("Missing block " + oldId);
}
return newId;
}
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
Protocol1_12_2To1_13.LOGGER.warning("Missing block completely " + oldId);
}
// Default air
@@ -21,8 +21,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.NumberTag;
import com.viaversion.nbt.tag.ShortTag;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.item.DataItem;
@@ -59,7 +57,7 @@ public final class ComponentRewriter1_14<C extends ClientboundPacketType> extend
try {
tag = ComponentUtil.deserializeLegacyShowItem(value, SerializerVersion.V1_13);
} catch (Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
Protocol1_13_2To1_14.LOGGER.log(Level.WARNING, "Error reading NBT in show_item: " + StringUtil.forLogging(value), e);
}
return;
@@ -84,7 +82,7 @@ public final class ComponentRewriter1_14<C extends ClientboundPacketType> extend
showItem.addProperty("text", SerializerVersion.V1_14.toSNBT(tag));
hoverEvent.add("value", newValue);
} catch (Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
Protocol1_13_2To1_14.LOGGER.log(Level.WARNING, "Error writing NBT in show_item: " + StringUtil.forLogging(value), e);
}
}
@@ -170,7 +170,7 @@ public class EntityPacketRewriter1_16 extends EntityRewriter<ClientboundPackets1
if (attributeIdentifier == null) {
attributeIdentifier = Key.namespaced(key);
if (!Key.isValid(attributeIdentifier)) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
protocol.getLogger().warning("Invalid attribute: " + key);
}
actualSize--;
@@ -93,6 +93,7 @@ public final class Protocol1_16_4To1_17 extends AbstractProtocol<ClientboundPack
componentRewriter.registerTabList(ClientboundPackets1_16_2.TAB_LIST);
componentRewriter.registerOpenScreen1_14(ClientboundPackets1_16_2.OPEN_SCREEN);
componentRewriter.registerSetPlayerTeam1_13(ClientboundPackets1_16_2.SET_PLAYER_TEAM);
componentRewriter.registerSetObjective(ClientboundPackets1_16_2.SET_OBJECTIVE);
componentRewriter.registerPing();
SoundRewriter<ClientboundPackets1_16_2> soundRewriter = new SoundRewriter<>(this);
@@ -80,6 +80,7 @@ public final class Protocol1_17_1To1_18 extends AbstractProtocol<ClientboundPack
componentRewriter.registerOpenScreen1_14(ClientboundPackets1_17_1.OPEN_SCREEN);
componentRewriter.registerPlayerCombatKill(ClientboundPackets1_17_1.PLAYER_COMBAT_KILL);
componentRewriter.registerSetPlayerTeam1_13(ClientboundPackets1_17_1.SET_PLAYER_TEAM);
componentRewriter.registerSetObjective(ClientboundPackets1_17_1.SET_OBJECTIVE);
componentRewriter.registerPing();
registerServerbound(ServerboundPackets1_17.CLIENT_INFORMATION, new PacketHandlers() {
@@ -239,7 +239,7 @@ public final class EntityPacketRewriter1_19 extends EntityRewriter<ClientboundPa
addMonsterSpawnData(currentDimension);
String dimensionKey = registryStorage.dimensionKey(currentDimension);
if (dimensionKey == null) {
if (!Via.getConfig().isSuppressConversionWarnings()) {
if (Via.getConfig().logOtherConversionWarnings()) {
protocol.getLogger().warning("The server tried to send dimension data from a dimension the client wasn't told about on join. " +
"Plugins and mods have to make sure they are not creating new dimension types while players are online, and proxies need to make sure they don't scramble dimension data." +
" Received dimension: " + currentDimension + ". Known dimensions: " + registryStorage.dimensions());
@@ -117,6 +117,7 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol<ClientboundPa
componentRewriter.registerOpenScreen1_14(ClientboundPackets1_19_1.OPEN_SCREEN);
componentRewriter.registerPlayerCombatKill(ClientboundPackets1_19_1.PLAYER_COMBAT_KILL);
componentRewriter.registerSetPlayerTeam1_13(ClientboundPackets1_19_1.SET_PLAYER_TEAM);
componentRewriter.registerSetObjective(ClientboundPackets1_19_1.SET_OBJECTIVE);
componentRewriter.registerPing();
final CommandRewriter<ClientboundPackets1_19_1> commandRewriter = new CommandRewriter<>(this) {
@@ -169,7 +169,7 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter<Clientboun
final JsonElement updatedComponent = ComponentUtil.convertJson(pageTag.getValue(), SerializerVersion.V1_19_4, SerializerVersion.V1_20_3);
pageTag.setValue(updatedComponent.toString());
} catch (final Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
protocol.getLogger().log(Level.SEVERE, "Error during book conversion: " + StringUtil.forLogging(pageTag.getValue()), e);
}
}
@@ -110,8 +110,11 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol<ClientboundPa
componentRewriter.registerComponentPacket(ClientboundPackets1_20_3.SET_SUBTITLE_TEXT);
componentRewriter.registerBossEvent(ClientboundPackets1_20_3.BOSS_EVENT);
componentRewriter.registerComponentPacket(ClientboundPackets1_20_3.DISCONNECT);
componentRewriter.registerComponentPacket(ClientboundConfigurationPackets1_20_3.DISCONNECT);
componentRewriter.registerTabList(ClientboundPackets1_20_3.TAB_LIST);
componentRewriter.registerPlayerInfoUpdate1_20_3(ClientboundPackets1_20_3.PLAYER_INFO_UPDATE);
componentRewriter.registerSetObjective(ClientboundPackets1_20_3.SET_OBJECTIVE);
componentRewriter.registerSetScore1_20_3(ClientboundPackets1_20_3.SET_SCORE);
componentRewriter.registerPing();
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO, wrapper -> {
@@ -218,7 +218,7 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Js
try {
tagTag = tag != null ? (CompoundTag) inputSerializerVersion().toTag(tag.getValue()) : null;
} catch (final Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
protocol.getLogger().log(Level.WARNING, "Error reading NBT in show_item: " + StringUtil.forLogging(itemTag), e);
}
return;
@@ -252,7 +252,7 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Js
try {
components = toTag(connection, data);
} catch (final Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
protocol.getLogger().log(Level.WARNING, "Error writing components in show_item!", e);
}
return;
@@ -35,6 +35,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.StructuredItem;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_20_3;
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
@@ -278,11 +279,8 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
storage.clear();
// Handle creative interaction range
final byte gamemode = wrapper.get(Types.BYTE, 0);
if (gamemode == GameMode.CREATIVE.id()) {
sendRangeAttributes(wrapper.user(), true);
}
sendRangeAttributes(wrapper.user(), gamemode == GameMode.CREATIVE.id());
});
}
});
@@ -408,9 +406,18 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
private void sendRangeAttributes(final UserConnection connection, final boolean creativeMode) {
final PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES, connection);
wrapper.write(Types.VAR_INT, tracker(connection).clientEntityId());
wrapper.write(Types.VAR_INT, 2); // Number of attributes
writeAttribute(wrapper, "player.block_interaction_range", 4.5, creativeMode ? CREATIVE_BLOCK_INTERACTION_RANGE : null, 0.5);
writeAttribute(wrapper, "player.entity_interaction_range", 3.0, creativeMode ? CREATIVE_ENTITY_INTERACTION_RANGE : null, 2.0);
if (connection.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) {
wrapper.write(Types.VAR_INT, 3); // Number of attributes
this.writeAttribute(wrapper, "generic.step_height", 0.5D, null, 0D);
} else {
wrapper.write(Types.VAR_INT, 2); // Number of attributes
}
this.writeAttribute(wrapper, "player.block_interaction_range", 4.5D, creativeMode ? CREATIVE_BLOCK_INTERACTION_RANGE : null, 0.5D);
if (connection.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) {
this.writeAttribute(wrapper, "player.entity_interaction_range", 3D, creativeMode ? CREATIVE_ENTITY_INTERACTION_RANGE : null, 1D);
} else {
this.writeAttribute(wrapper, "player.entity_interaction_range", 3D, creativeMode ? CREATIVE_ENTITY_INTERACTION_RANGE : null, 2D);
}
wrapper.scheduleSend(Protocol1_20_3To1_20_5.class);
}
@@ -113,10 +113,10 @@ public class ConfigurationState implements StorableObject {
packetQueue.add(hasJoinGamePacket ? 1 : 0, toQueuedPacket(clientInformationPacket, false, true));
}
final ConfigurationState.QueuedPacket[] queuedPackets = packetQueue.toArray(EMPTY_PACKET_ARRAY);
final QueuedPacket[] queuedPackets = packetQueue.toArray(EMPTY_PACKET_ARRAY);
packetQueue.clear();
for (final ConfigurationState.QueuedPacket packet : queuedPackets) {
for (final QueuedPacket packet : queuedPackets) {
final PacketWrapper queuedWrapper;
try {
if (packet.packetType() != null) {
@@ -176,7 +176,7 @@ public class ConfigurationState implements StorableObject {
private final int packetId;
private final boolean skipCurrentPipeline;
private QueuedPacket(final ByteBuf buf, final boolean clientbound, final PacketType packetType,
private QueuedPacket(final ByteBuf buf, final boolean clientbound, @Nullable final PacketType packetType,
final int packetId, final boolean skipCurrentPipeline) {
this.buf = buf;
this.clientbound = clientbound;
@@ -82,12 +82,15 @@ public final class Protocol1_21_2To1_21_4 extends AbstractProtocol<ClientboundPa
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_SUBTITLE_TEXT);
componentRewriter.registerBossEvent(ClientboundPackets1_21_2.BOSS_EVENT);
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.DISCONNECT);
componentRewriter.registerComponentPacket(ClientboundConfigurationPackets1_21.DISCONNECT);
componentRewriter.registerTabList(ClientboundPackets1_21_2.TAB_LIST);
componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_2.PLAYER_COMBAT_KILL);
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.SYSTEM_CHAT);
componentRewriter.registerDisguisedChat(ClientboundPackets1_21_2.DISGUISED_CHAT);
componentRewriter.registerPlayerChat(ClientboundPackets1_21_2.PLAYER_CHAT, ChatType.TYPE);
componentRewriter.registerSetPlayerTeam1_13(ClientboundPackets1_21_2.SET_PLAYER_TEAM);
componentRewriter.registerSetObjective(ClientboundPackets1_21_2.SET_OBJECTIVE);
componentRewriter.registerSetScore1_20_3(ClientboundPackets1_21_2.SET_SCORE);
componentRewriter.registerPing();
particleRewriter.registerExplode1_21_2(ClientboundPackets1_21_2.EXPLODE);
@@ -96,11 +96,14 @@ public final class Protocol1_21_4To1_21_5 extends AbstractProtocol<ClientboundPa
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_SUBTITLE_TEXT);
componentRewriter.registerBossEvent(ClientboundPackets1_21_2.BOSS_EVENT);
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.DISCONNECT);
componentRewriter.registerComponentPacket(ClientboundConfigurationPackets1_21.DISCONNECT);
componentRewriter.registerTabList(ClientboundPackets1_21_2.TAB_LIST);
componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_2.PLAYER_COMBAT_KILL);
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.SYSTEM_CHAT);
componentRewriter.registerDisguisedChat(ClientboundPackets1_21_2.DISGUISED_CHAT);
componentRewriter.registerPlayerInfoUpdate1_21_4(ClientboundPackets1_21_2.PLAYER_INFO_UPDATE);
componentRewriter.registerSetObjective(ClientboundPackets1_21_2.SET_OBJECTIVE);
componentRewriter.registerSetScore1_20_3(ClientboundPackets1_21_2.SET_SCORE);
componentRewriter.registerPing();
particleRewriter.registerLevelParticles1_21_4(ClientboundPackets1_21_2.LEVEL_PARTICLES);
@@ -321,7 +321,7 @@ public final class ComponentRewriter1_21_5 extends JsonNBTComponentRewriter<Clie
try {
return uglyJsonToTagUncaught(connection, value);
} catch (final Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting json text component: " + StringUtil.forLogging(value), e);
}
return new StringTag("<error>");
@@ -103,6 +103,7 @@ public final class Protocol1_21_5To1_21_6 extends AbstractProtocol<ClientboundPa
componentRewriter.registerComponentPacket(ClientboundPackets1_21_5.SET_SUBTITLE_TEXT);
componentRewriter.registerBossEvent(ClientboundPackets1_21_5.BOSS_EVENT);
componentRewriter.registerComponentPacket(ClientboundPackets1_21_5.DISCONNECT);
componentRewriter.registerComponentPacket(ClientboundConfigurationPackets1_21.DISCONNECT);
componentRewriter.registerTabList(ClientboundPackets1_21_5.TAB_LIST);
componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_5.PLAYER_COMBAT_KILL);
componentRewriter.registerPlayerInfoUpdate1_21_4(ClientboundPackets1_21_5.PLAYER_INFO_UPDATE);
@@ -110,6 +111,8 @@ public final class Protocol1_21_5To1_21_6 extends AbstractProtocol<ClientboundPa
componentRewriter.registerDisguisedChat(ClientboundPackets1_21_5.DISGUISED_CHAT);
componentRewriter.registerPlayerChat1_21_5(ClientboundPackets1_21_5.PLAYER_CHAT);
componentRewriter.registerSetPlayerTeam1_21_5(ClientboundPackets1_21_5.SET_PLAYER_TEAM);
componentRewriter.registerSetObjective(ClientboundPackets1_21_5.SET_OBJECTIVE);
componentRewriter.registerSetScore1_20_3(ClientboundPackets1_21_5.SET_SCORE);
componentRewriter.registerPing();
particleRewriter.registerLevelParticles1_21_4(ClientboundPackets1_21_5.LEVEL_PARTICLES);
@@ -89,6 +89,7 @@ public final class Protocol1_21_7To1_21_9 extends AbstractProtocol<ClientboundPa
componentRewriter.registerComponentPacket(ClientboundPackets1_21_6.SET_SUBTITLE_TEXT);
componentRewriter.registerBossEvent(ClientboundPackets1_21_6.BOSS_EVENT);
componentRewriter.registerComponentPacket(ClientboundPackets1_21_6.DISCONNECT);
componentRewriter.registerComponentPacket(ClientboundConfigurationPackets1_21_6.DISCONNECT);
componentRewriter.registerTabList(ClientboundPackets1_21_6.TAB_LIST);
componentRewriter.registerSetPlayerTeam1_21_5(ClientboundPackets1_21_6.SET_PLAYER_TEAM);
componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_6.PLAYER_COMBAT_KILL);
@@ -96,6 +97,8 @@ public final class Protocol1_21_7To1_21_9 extends AbstractProtocol<ClientboundPa
componentRewriter.registerComponentPacket(ClientboundPackets1_21_6.SYSTEM_CHAT);
componentRewriter.registerDisguisedChat(ClientboundPackets1_21_6.DISGUISED_CHAT);
componentRewriter.registerPlayerChat1_21_5(ClientboundPackets1_21_6.PLAYER_CHAT);
componentRewriter.registerSetObjective(ClientboundPackets1_21_6.SET_OBJECTIVE);
componentRewriter.registerSetScore1_20_3(ClientboundPackets1_21_6.SET_SCORE);
componentRewriter.registerPing();
final SoundRewriter<ClientboundPacket1_21_6> soundRewriter = new SoundRewriter<>(this);
@@ -137,6 +137,11 @@ public final class Protocol1_21_9To1_21_11 extends AbstractProtocol<ClientboundP
if (!tag.getBoolean("natural")) {
attributes.putFloat("visual/sky_light_factor", 0F);
}
if (tag.getBoolean("ultrawarm")) {
final CompoundTag defaultDripstoneParticle = new CompoundTag();
defaultDripstoneParticle.putString("type", "dripping_dripstone_lava");
attributes.put("visual/default_dripstone_particle", defaultDripstoneParticle);
}
moveAttribute(tag, attributes, "cloud_height", "visual/cloud_height", cloudHeight -> {
if (cloudHeight instanceof NumberTag numberTag) {
@@ -172,12 +177,15 @@ public final class Protocol1_21_9To1_21_11 extends AbstractProtocol<ClientboundP
componentRewriter.registerComponentPacket(ClientboundPackets1_21_9.SET_SUBTITLE_TEXT);
componentRewriter.registerBossEvent(ClientboundPackets1_21_9.BOSS_EVENT);
componentRewriter.registerComponentPacket(ClientboundPackets1_21_9.DISCONNECT);
componentRewriter.registerComponentPacket(ClientboundConfigurationPackets1_21_9.DISCONNECT);
componentRewriter.registerTabList(ClientboundPackets1_21_9.TAB_LIST);
componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_9.PLAYER_COMBAT_KILL);
componentRewriter.registerPlayerInfoUpdate1_21_4(ClientboundPackets1_21_9.PLAYER_INFO_UPDATE);
componentRewriter.registerComponentPacket(ClientboundPackets1_21_9.SYSTEM_CHAT);
componentRewriter.registerDisguisedChat(ClientboundPackets1_21_9.DISGUISED_CHAT);
componentRewriter.registerPlayerChat1_21_5(ClientboundPackets1_21_9.PLAYER_CHAT);
componentRewriter.registerSetObjective(ClientboundPackets1_21_9.SET_OBJECTIVE);
componentRewriter.registerSetScore1_20_3(ClientboundPackets1_21_9.SET_SCORE);
componentRewriter.registerPing();
particleRewriter.registerLevelParticles1_21_4(ClientboundPackets1_21_9.LEVEL_PARTICLES);
@@ -17,10 +17,13 @@
*/
package com.viaversion.viaversion.protocols.v1_21_9to1_21_11.rewriter;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.data.AttackRange;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_21_5;
import com.viaversion.viaversion.protocols.v1_21_4to1_21_5.rewriter.RecipeDisplayRewriter1_21_5;
@@ -66,6 +69,18 @@ public final class BlockItemPacketRewriter1_21_11 extends StructuredItemRewriter
recipeRewriter.registerRecipeBookAdd(ClientboundPackets1_21_9.RECIPE_BOOK_ADD);
recipeRewriter.registerPlaceGhostRecipe(ClientboundPackets1_21_9.PLACE_GHOST_RECIPE);
protocol.registerClientbound(ClientboundPackets1_21_9.SET_BORDER_LERP_SIZE, wrapper -> {
wrapper.passthrough(Types.DOUBLE); // oldSize
wrapper.passthrough(Types.DOUBLE); // newSize
wrapper.write(Types.VAR_LONG, wrapper.read(Types.VAR_LONG) / 50); // lerpTime
});
protocol.registerClientbound(ClientboundPackets1_21_9.INITIALIZE_BORDER, wrapper -> {
wrapper.passthrough(Types.DOUBLE); // newCenterX
wrapper.passthrough(Types.DOUBLE); // newCenterZ
wrapper.passthrough(Types.DOUBLE); // oldSize
wrapper.passthrough(Types.DOUBLE); // newSize
wrapper.write(Types.VAR_LONG, wrapper.read(Types.VAR_LONG) / 50); // lerpTime
});
protocol.registerClientbound(ClientboundPackets1_21_9.SET_TIME, wrapper -> {
final long gameTime = wrapper.passthrough(Types.LONG);
wrapper.user().get(GameTimeStorage.class).setGameTime(gameTime);
@@ -78,6 +93,10 @@ public final class BlockItemPacketRewriter1_21_11 extends StructuredItemRewriter
@Override
protected void handleItemDataComponentsToClient(final UserConnection connection, final Item item, final StructuredDataContainer container) {
upgradeData(item, container);
// Add data components to fix issues in older protocols
appendItemDataFixComponents(connection, item);
super.handleItemDataComponentsToClient(connection, item, container);
}
@@ -87,6 +106,14 @@ public final class BlockItemPacketRewriter1_21_11 extends StructuredItemRewriter
super.handleItemDataComponentsToServer(connection, item, container);
}
private void appendItemDataFixComponents(final UserConnection connection, final Item item) {
final ProtocolVersion serverVersion = connection.getProtocolInfo().serverProtocolVersion();
if (Via.getConfig().use1_8HitboxMargin() && serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_8)) {
// Set 0.1 hitbox margin like in 1.8. Creative range is 4F instead of default 5F as measured empirically.
item.dataContainer().set(StructuredDataKey.ATTACK_RANGE, new AttackRange(0F, 3F, 0F, 4F, 0.1F, 1F));
}
}
public static void upgradeData(final Item item, final StructuredDataContainer container) {
}
@@ -18,10 +18,12 @@
package com.viaversion.viaversion.protocols.v1_21_9to1_21_11.rewriter;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ClientboundPacket1_21_9;
import com.viaversion.viaversion.protocols.v1_21_9to1_21_11.Protocol1_21_9To1_21_11;
import com.viaversion.viaversion.rewriter.text.NBTComponentRewriter;
import com.viaversion.viaversion.util.Key;
public final class ComponentRewriter1_21_11 extends NBTComponentRewriter<ClientboundPacket1_21_9> {
@@ -30,12 +32,17 @@ public final class ComponentRewriter1_21_11 extends NBTComponentRewriter<Clientb
}
@Override
protected void handleShowItem(final UserConnection connection, final CompoundTag itemTag, final CompoundTag componentsTag) {
super.handleShowItem(connection, itemTag, componentsTag);
if (componentsTag == null) {
return;
}
protected void processCompoundTag(final UserConnection connection, final CompoundTag tag) {
super.processCompoundTag(connection, tag);
// Remove or update data from componentsTag
final StringTag sprite = tag.getStringTag("sprite");
if (sprite != null) {
final String strippedSprite = Key.stripNamespace(sprite.getValue());
if (strippedSprite.startsWith("item/")) {
tag.putString("atlas", "items");
} else if (strippedSprite.startsWith("block/")) {
tag.putString("atlas", "blocks");
}
}
}
}
@@ -21,6 +21,8 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_11;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_21_11;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_21_5to1_21_6.packet.ServerboundPackets1_21_6;
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ClientboundPacket1_21_9;
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ClientboundPackets1_21_9;
import com.viaversion.viaversion.protocols.v1_21_9to1_21_11.Protocol1_21_9To1_21_11;
@@ -45,6 +47,14 @@ public final class EntityPacketRewriter1_21_11 extends EntityRewriter<Clientboun
registerLogin1_20_5(ClientboundPackets1_21_9.LOGIN);
registerRespawn1_20_5(ClientboundPackets1_21_9.RESPAWN);
protocol.registerServerbound(ServerboundPackets1_21_6.PLAYER_ACTION, wrapper -> {
final int action = wrapper.passthrough(Types.VAR_INT);
// cancel spear "stab" packets sent by the client
if (action == 7) {
wrapper.cancel();
}
});
protocol.registerClientbound(ClientboundPackets1_21_9.HORSE_SCREEN_OPEN, ClientboundPackets1_21_11.MOUNT_SCREEN_OPEN);
}
@@ -96,12 +96,15 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol<ClientboundPack
componentRewriter.registerComponentPacket(ClientboundPackets1_21.SET_SUBTITLE_TEXT);
componentRewriter.registerBossEvent(ClientboundPackets1_21.BOSS_EVENT);
componentRewriter.registerComponentPacket(ClientboundPackets1_21.DISCONNECT);
componentRewriter.registerComponentPacket(ClientboundConfigurationPackets1_21.DISCONNECT);
componentRewriter.registerTabList(ClientboundPackets1_21.TAB_LIST);
componentRewriter.registerSetPlayerTeam1_13(ClientboundPackets1_21.SET_PLAYER_TEAM);
componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21.PLAYER_COMBAT_KILL);
componentRewriter.registerComponentPacket(ClientboundPackets1_21.SYSTEM_CHAT);
componentRewriter.registerDisguisedChat(ClientboundPackets1_21.DISGUISED_CHAT);
componentRewriter.registerPlayerChat(ClientboundPackets1_21.PLAYER_CHAT, ChatType.TYPE);
componentRewriter.registerSetObjective(ClientboundPackets1_21.SET_OBJECTIVE);
componentRewriter.registerSetScore1_20_3(ClientboundPackets1_21.SET_SCORE);
componentRewriter.registerPing();
particleRewriter.registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES);
@@ -382,6 +382,28 @@ public class ItemPacketRewriter1_9 extends ItemRewriter<ClientboundPackets1_8, S
@Override
public @Nullable Item handleItemToClient(final UserConnection connection, @Nullable final Item item) {
if (item == null) return null;
if (item.identifier() == 62) {
item.setIdentifier(61);
CompoundTag tag = item.tag();
if (tag == null) {
tag = new CompoundTag();
}
tag.putBoolean(nbtTagName("lit_furnace"), true);
CompoundTag display = tag.getCompoundTag("display");
if (display == null) {
tag.put("display", display = new CompoundTag());
display.putBoolean(nbtTagName(), true);
}
StringTag nameTag = display.getStringTag("Name");
if (nameTag == null) {
nameTag = new StringTag("1.8 Lit Furnace");
display.put("Name", nameTag);
display.putBoolean(nbtTagName("custom_name"), true);
}
item.setTag(tag);
}
if (item.identifier() == 383 && item.data() != 0) { // Monster Egg
CompoundTag tag = item.tag();
if (tag == null) {
@@ -442,6 +464,24 @@ public class ItemPacketRewriter1_9 extends ItemRewriter<ClientboundPackets1_8, S
@Override
public @Nullable Item handleItemToServer(final UserConnection connection, @Nullable final Item item) {
if (item == null) return null;
if (item.identifier() == 61) {
CompoundTag tag = item.tag();
if (tag != null && tag.remove(nbtTagName("lit_furnace")) != null) {
item.setIdentifier(62);
CompoundTag display = tag.getCompoundTag("display");
if (display != null) {
if (display.remove(nbtTagName("custom_name")) != null) {
display.remove("Name");
}
if (display.remove(nbtTagName()) != null) {
tag.remove("display");
if (tag.isEmpty()) {
item.setTag(null);
}
}
}
}
}
if (item.identifier() == 383 && item.data() == 0) { // Monster Egg
CompoundTag tag = item.tag();
int data = 0;
@@ -32,7 +32,6 @@ import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
import com.viaversion.viaversion.api.minecraft.GameMode;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.Vector3d;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
@@ -648,7 +647,7 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
// ---------------------------------------------------------------------------
private void logException(Exception e, @Nullable EntityType type, List<EntityData> entityDataList, EntityData entityData) {
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
if (Via.getConfig().logEntityDataErrors()) {
protocol.getLogger().severe("An error occurred in entity data handler " + this.getClass().getSimpleName()
+ " for " + (type != null ? type.name() : "untracked") + " entity type: " + entityData);
protocol.getLogger().severe(entityDataList.stream().sorted(Comparator.comparingInt(EntityData::id))
@@ -402,13 +402,13 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
int size = wrapper.passthrough(Types.VAR_INT);
for (int i = 0; i < size; i++) {
final Item input = wrapper.read(itemCostType);
wrapper.write(mappedItemCostType, handleItemToClient(wrapper.user(), input));
wrapper.write(mappedItemCostType, handleItemToClientAndTrackHash(wrapper.user(), input));
passthroughClientboundItem(wrapper); // Result
Item secondInput = wrapper.read(optionalItemCostType);
if (secondInput != null) {
handleItemToClient(wrapper.user(), secondInput);
handleItemToClientAndTrackHash(wrapper.user(), secondInput);
}
wrapper.write(mappedOptionalItemCostType, secondInput);
@@ -257,14 +257,22 @@ public class RegistryDataRewriter implements com.viaversion.viaversion.api.rewri
final ListTag<CompoundTag> terms;
if (requirements != null && (terms = requirements.getListTag("terms", CompoundTag.class)) != null) {
for (final CompoundTag term : terms) {
final CompoundTag predicate = term.getCompoundTag("predicate");
if (predicate != null && Key.equals(term.getString("condition"), "entity_properties")) {
updateType(predicate, "type", protocol.getMappingData().getEntityMappings());
}
updateEnchantmentTerm(term);
}
}
}
private void updateEnchantmentTerm(final CompoundTag term) {
if (Key.equals(term.getString("condition"), "entity_properties")) {
final CompoundTag predicate = term.getCompoundTag("predicate");
if (predicate != null) {
updateType(predicate, "type", protocol.getMappingData().getEntityMappings());
}
} else if (Key.equals(term.getString("condition"), "block_state_property")) {
updateType(term, "block", protocol.getMappingData().getFullBlockMappings());
}
}
private void updateAttributesFields(final CompoundTag effects) {
final ListTag<CompoundTag> attributesList = TagUtil.getNamespacedCompoundTagList(effects, "attributes");
if (attributesList == null) {
@@ -299,20 +307,34 @@ public class RegistryDataRewriter implements com.viaversion.viaversion.api.rewri
final Consumer<CompoundTag> rewriter = enchantmentEffectHandlers.get(effect);
if (rewriter != null) {
rewriter.accept(effectTag);
} else if (effect.equals("play_sound")) {
updateType(effectTag, "sound", protocol.getMappingData().getFullSoundMappings());
}
}
protected void updateType(final CompoundTag tag, final String key, final FullMappings mappings) {
final StringTag typeTag = tag.getStringTag(key);
final Tag typeTag = tag.get(key);
if (typeTag == null || mappings == null) {
return;
}
String mappedType = mappings.mappedIdentifier(typeTag.getValue());
if (typeTag instanceof StringTag stringTag) {
setMappedOrDummyId(mappings, stringTag);
} else if (typeTag instanceof ListTag<?> listTag && listTag.getElementType() == StringTag.class) {
//noinspection unchecked
final ListTag<StringTag> typesTag = (ListTag<StringTag>) listTag;
for (final StringTag entry : typesTag) {
setMappedOrDummyId(mappings, entry);
}
}
}
private void setMappedOrDummyId(final FullMappings mappings, final StringTag tag) {
String mappedType = mappings.mappedIdentifier(tag.getValue());
if (mappedType == null) {
mappedType = mappings.mappedIdentifier(0); // Dummy
}
typeTag.setValue(mappedType);
tag.setValue(mappedType);
}
private void updateItemList(final ListTag<StringTag> listTag) {
@@ -100,6 +100,25 @@ public abstract class ComponentRewriterBase<C extends ClientboundPacketType> imp
});
}
public void registerSetObjective(final C packetType) {
protocol.registerClientbound(packetType, wrapper -> {
wrapper.passthrough(Types.STRING); // Objective Name
final byte action = wrapper.passthrough(Types.BYTE);
if (action == 0 || action == 2) {
passthroughAndProcess(wrapper); // Display Name
}
});
}
public void registerSetScore1_20_3(final C packetType) {
protocol.registerClientbound(packetType, wrapper -> {
wrapper.passthrough(Types.STRING); // Owner
wrapper.passthrough(Types.STRING); // Objective name
wrapper.passthrough(Types.VAR_INT); // Score
passthroughAndProcessOptional(wrapper);
});
}
public void registerSetPlayerTeam1_13(final C packetType) {
protocol.registerClientbound(packetType, wrapper -> {
wrapper.passthrough(Types.STRING); // Team Name
@@ -167,7 +167,7 @@ public class CommentStore {
int currentKeyIndents = 0;
String key = "";
for (final String line : rawYaml.split("\n")) {
for (final String line : rawYaml.lines().toList()) {
if (line.isEmpty()) {
continue;
}
@@ -65,7 +65,7 @@ public final class ComponentUtil {
final TextComponent component = SerializerVersion.V1_20_3.toComponent(tag);
return component != null ? SerializerVersion.V1_19_4.toJson(component) : null;
} catch (final Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting tag: " + StringUtil.forLogging(tag), e);
}
return plainToJson("<error>");
@@ -81,7 +81,7 @@ public final class ComponentUtil {
final TextComponent component = SerializerVersion.V1_19_4.toComponent(element);
return trimStrings(SerializerVersion.V1_20_3.toTag(component));
} catch (final Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting component: " + StringUtil.forLogging(element), e);
}
return new StringTag("<error>");
@@ -110,7 +110,7 @@ public final class ComponentUtil {
final TextComponent component = SerializerVersion.V1_20_5.toComponent(tag);
return component != null ? SerializerVersion.V1_20_3.toString(component) : null;
} catch (final Exception e) {
if (!Via.getConfig().isSuppressTextComponentConversionWarnings()) {
if (Via.getConfig().logTextComponentConversionErrors()) {
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting tag: " + StringUtil.forLogging(tag), e);
}
return plainToJson("<error>").toString();
@@ -41,6 +41,7 @@ public abstract class Config extends ConfigSection {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setPrettyFlow(false);
options.setSplitLines(false);
options.setIndent(2);
return new Yaml(new CustomSafeConstructor(), new Representer(options), options);
});
@@ -21,17 +21,29 @@ block-versions: []
block-protocols: []
# Change the blocked disconnect message
block-disconnect-msg: "You are using an unsupported Minecraft version!"
# Whether to log more info about kicks due to blocked protocol versions to the console.
log-blocked-joins: false
# If you use ProtocolLib, we can't reload without kicking the players.
# (We don't suggest using reload either, use a plugin manager)
# You can customize the message we kick people with if you use ProtocolLib here.
reload-disconnect-msg: "Server reload, please rejoin!"
# We warn when there's an error converting item/block or component/nbt data over versions, should we suppress these? (Only suggested if spamming)
suppress-conversion-warnings: false
# This can be disabled for debugging purposes if text in chat/entities/items shows an error tag.
suppress-text-component-conversion-warnings: true
# Settings for logging behavior. When debugging issues, we may ask you to change some of these.
# Most of these are disabled by default to prevent log spam from bad user input.
logging:
# Whether to log more info about kicks due to blocked protocol versions to the console.
log-blocked-joins: false
# Whether to log errors during entity data conversion.
log-entity-data-errors: true
# Whether to log errors during text component conversion.
log-text-component-conversion-errors: false
# Whether to warn for other issues when converting items, blocks, or other data between server and client.
log-other-conversion-warnings: false
# Maximum length of error messages in the console.
max-error-length: 1500
#
# Used for auto updating config files. Do not touch.
config-version: 1
init-config-version: 1
# Whether to update config values that were left on their default to newly changed defaults. Recommended to keep enabled.
migrate-default-config-changes: true
#----------------------------------------------------------#
# VELOCITY OPTIONS #
#----------------------------------------------------------#
@@ -70,9 +82,9 @@ packet-limiter:
max-per-second-kick-message: "You are sending too many packets!"
#
# We can also kick them if they repeatedly send too many packets over a longer period of time.
# E.g. if a player sends over 150 packets per second for 4 out of 7 seconds, we kick them.
# E.g. if a player sends over 200 packets per second for 4 out of 7 seconds, we kick them.
# The maximum packets per second a client can send over a longer period of time.
sustained-max-per-second: 150
sustained-max-per-second: 200
# Period to track in seconds.
sustained-period-seconds: 7
# The number of seconds within the interval that the client can exceed the limit before being kicked.
@@ -192,8 +204,6 @@ cancel-swing-in-inventory: true
prevent-collision: true
# If the above is true, should we automatically team players until you do?
auto-team: true
# When enabled if certain entity data can't be read, we won't tell you about it
suppress-metadata-errors: false
# When enabled, 1.9+ will be able to block by using shields
shield-blocking: true
# If this setting is active, the main hand is used instead of the off-hand to trigger the blocking of the player.
@@ -228,3 +238,5 @@ chunk-border-fix: false
left-handed-handling: true
# Tries to cancel block break/place sounds sent by 1.8 servers to 1.9+ clients to prevent them from playing twice
cancel-block-sounds: true
# If enabled, 1.21.11+ clients on 1.8 servers will get wider entity hitboxes when attacking with items
use-1_8-hitbox-margin: true
@@ -21,9 +21,11 @@ import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.FloatTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.GameProfile;
import com.viaversion.viaversion.api.minecraft.GlobalBlockPosition;
import com.viaversion.viaversion.api.minecraft.Holder;
import com.viaversion.viaversion.api.minecraft.HolderSet;
import com.viaversion.viaversion.api.minecraft.ResolvableProfile;
import com.viaversion.viaversion.api.minecraft.codec.CodecContext;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item;
@@ -45,6 +47,7 @@ import com.viaversion.viaversion.common.PlatformTestBase;
import com.viaversion.viaversion.protocols.v1_21_6to1_21_7.Protocol1_21_6To1_21_7;
import com.viaversion.viaversion.rewriter.RegistryDataRewriter;
import com.viaversion.viaversion.util.KeyMappings;
import com.viaversion.viaversion.util.UUIDUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@@ -134,6 +137,22 @@ public class ItemHashTest extends PlatformTestBase {
Assertions.assertEquals(606382024, hasher.hash(), "banner_pattern hash mismatch");
}
@Test
void testResolableProfile() {
final GameProfile profile = new GameProfile(
"",
UUIDUtil.fromIntArray(new int[]{431522009, 458574629, -1388245934, -172269387}),
new GameProfile.Property[]{
new GameProfile.Property(
"textures",
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjk1OWFjMjg0ZGZhY2NhNWE4ZTZjMTc5NjA5ODI1ODc1YTc2OGFmMzI5MWM3N2U4YTY4YmQ5MDM0ZGEzZWM2NCJ9fX0="
)
}
);
hasher.write(Types.RESOLVABLE_PROFILE, new ResolvableProfile(profile));
Assertions.assertEquals(-1192115620, hasher.hash(), "Resolvable profile hash mismatch");
}
private CompoundTag createCompoundTag() {
final CompoundTag tag = new CompoundTag();
tag.putInt("id", 1);
+1 -1
View File
@@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=5.6.0
projectVersion=5.7.0
# Smile emoji (note that modrinth may not have added the version on release yet)
mcVersions=1.21.11, 1.21.10, 1.21.9, 1.21.8, 1.21.7, 1.21.6, 1.21.5, 1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 1.20.6, 1.20.5, 1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9
+2 -2
View File
@@ -6,7 +6,7 @@ gson = "2.13.1"
snakeYaml = "2.5"
fastutil = "8.5.15"
vianbt = "5.1.2"
mcstructs = "5-3.2.0-SNAPSHOT"
mcstructs = "5-3.2.2-SNAPSHOT"
# Common provided
netty = "4.0.20.Final"
@@ -20,7 +20,7 @@ checkerQual = "3.51.0"
paper = "1.20.4-R0.1-SNAPSHOT"
legacyBukkit = "1.8.8-R0.1-SNAPSHOT"
velocity = "3.1.1"
viaProxy = "3.4.7-SNAPSHOT"
viaProxy = "[3.0.0,4.0.0)"
[libraries]
@@ -183,6 +183,9 @@ public class VelocityPlugin implements ViaServerProxyPlatform<Player> {
@Override
public boolean kickPlayer(UserConnection connection, String message) {
final UUID uuid = connection.getProtocolInfo().getUuid();
if (uuid == null) {
return false;
}
return PROXY.getPlayer(uuid).map(it -> {
it.disconnect(LegacyComponentSerializer.legacySection().deserialize(message));
return true;