Merge branch 'master' into dev

# Conflicts:
#	bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java
#	bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaInjector.java
#	bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java
#	bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeVersionProvider.java
#	common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/storage/EntityTracker1_9.java
#	common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java
#	velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaInjector.java
#	velocity/src/main/java/com/viaversion/viaversion/velocity/service/ProtocolDetectorService.java
This commit is contained in:
Nassim Jahnke 2024-03-22 20:54:44 +01:00
commit feefe6f278
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
35 changed files with 80 additions and 49 deletions

View File

@ -13,7 +13,7 @@ jobs:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Validate Gradle Wrapper - name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1 uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with: with:

View File

@ -13,7 +13,7 @@ jobs:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Validate Gradle Wrapper - name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1 uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with: with:

View File

@ -25,6 +25,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.ArmorType;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -71,7 +72,7 @@ public class ArmorListener extends ViaBukkitListener {
wrapper.scheduleSend(Protocol1_9To1_8.class); wrapper.scheduleSend(Protocol1_9To1_8.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send armor update", e);
} }
} }

View File

@ -30,6 +30,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.util.logging.Level;
public class DeathListener extends ViaBukkitListener { public class DeathListener extends ViaBukkitListener {
@ -66,7 +67,7 @@ public class DeathListener extends ViaBukkitListener {
wrapper.scheduleSend(Protocol1_9To1_8.class); wrapper.scheduleSend(Protocol1_9To1_8.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send death message", e);
} }
} }
}); });

View File

@ -19,6 +19,8 @@ package com.viaversion.viaversion.bukkit.util;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.logging.Level;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.protocol.version.VersionType; import com.viaversion.viaversion.api.protocol.version.VersionType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -52,7 +54,7 @@ public final class ProtocolSupportUtil {
return ProtocolVersion.getProtocol(preNetty ? VersionType.RELEASE_INITIAL : VersionType.RELEASE, id); return ProtocolVersion.getProtocol(preNetty ? VersionType.RELEASE_INITIAL : VersionType.RELEASE, id);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to get ProtocolSupport version", e);
} }
return ProtocolVersion.unknown; return ProtocolVersion.unknown;
} }

View File

@ -30,6 +30,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.logging.Level;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -148,7 +149,7 @@ public class PlayerSneakListener extends ViaBukkitListener {
try { try {
setSize.invoke(getHandle.invoke(player), DEFAULT_WIDTH, height); setSize.invoke(getHandle.invoke(player), DEFAULT_WIDTH, height);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to set player height", e);
} }
} }
} }

View File

@ -18,6 +18,7 @@
package com.viaversion.viaversion.bukkit.listeners.protocol1_15to1_14_4; package com.viaversion.viaversion.bukkit.listeners.protocol1_15to1_14_4;
import com.viaversion.viaversion.ViaVersionPlugin; import com.viaversion.viaversion.ViaVersionPlugin;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -26,6 +27,7 @@ import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4; import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
import java.util.Arrays; import java.util.Arrays;
import java.util.logging.Level;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -84,7 +86,7 @@ public class EntityToggleGlideListener extends ViaBukkitListener {
packet.write(Types1_14.METADATA_LIST, Arrays.asList(new Metadata(0, Types1_14.META_TYPES.byteType, bitmask))); packet.write(Types1_14.METADATA_LIST, Arrays.asList(new Metadata(0, Types1_14.META_TYPES.byteType, bitmask)));
packet.scheduleSend(Protocol1_15To1_14_4.class); packet.scheduleSend(Protocol1_15To1_14_4.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send entity glide fix metadata", e);
} }
} }
} }

View File

@ -18,6 +18,7 @@
package com.viaversion.viaversion.bukkit.platform; package com.viaversion.viaversion.bukkit.platform;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.bukkit.handlers.BukkitChannelInitializer; import com.viaversion.viaversion.bukkit.handlers.BukkitChannelInitializer;
import com.viaversion.viaversion.bukkit.util.NMSUtil; import com.viaversion.viaversion.bukkit.util.NMSUtil;
@ -31,6 +32,7 @@ import io.netty.channel.ChannelInitializer;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
@ -218,7 +220,7 @@ public class BukkitViaInjector extends LegacyViaInjector {
} }
} }
} catch (ReflectiveOperationException e) { } catch (ReflectiveOperationException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to check if ViaVersion is binded", e);
} }
return false; return false;
} }

View File

@ -153,7 +153,7 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider
// send // send
packetMethod.invoke(playerConnection, packet); packetMethod.invoke(playerConnection, packet);
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to send packet to server", e);
return false; return false;
} }
return true; return true;

View File

@ -25,6 +25,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTrac
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.logging.Level;
import com.viaversion.viaversion.util.PipelineUtil; import com.viaversion.viaversion.util.PipelineUtil;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
@ -109,7 +110,7 @@ public class BukkitViaMovementTransmitter extends MovementTransmitterProvider {
info.get(MovementTracker.class).incrementIdlePacket(); info.get(MovementTracker.class).incrementIdlePacket();
} }
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to handle idle packet", e);
} }
} }
} else { } else {

View File

@ -17,12 +17,14 @@
*/ */
package com.viaversion.viaversion.bukkit.tasks.protocol1_19to1_18_2; package com.viaversion.viaversion.bukkit.tasks.protocol1_19to1_18_2;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.SequenceStorage; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.SequenceStorage;
import java.util.logging.Level;
public final class AckSequenceTask implements Runnable { public final class AckSequenceTask implements Runnable {
@ -42,7 +44,7 @@ public final class AckSequenceTask implements Runnable {
ackPacket.write(Type.VAR_INT, sequence); ackPacket.write(Type.VAR_INT, sequence);
ackPacket.scheduleSend(Protocol1_19To1_18_2.class); ackPacket.scheduleSend(Protocol1_19To1_18_2.class);
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send block changed ack packet", e);
} }
} }
} }

View File

@ -17,12 +17,14 @@
*/ */
package com.viaversion.viaversion.bungee.handlers; package com.viaversion.viaversion.bungee.handlers;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.connection.UserConnectionImpl; import com.viaversion.viaversion.connection.UserConnectionImpl;
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelInitializer;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.logging.Level;
public class BungeeChannelInitializer extends ChannelInitializer<Channel> { public class BungeeChannelInitializer extends ChannelInitializer<Channel> {
private final ChannelInitializer<Channel> original; private final ChannelInitializer<Channel> original;
@ -34,7 +36,7 @@ public class BungeeChannelInitializer extends ChannelInitializer<Channel> {
this.method = ChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class); this.method = ChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class);
this.method.setAccessible(true); this.method.setAccessible(true);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to get initChannel method", e);
} }
} }

View File

@ -44,6 +44,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.api.connection.Server;
@ -109,7 +110,7 @@ public class BungeeServerHandler implements Listener {
Object handshake = getHandshake.invoke(event.getPlayer().getPendingConnection()); Object handshake = getHandshake.invoke(event.getPlayer().getPendingConnection());
setProtocol.invoke(handshake, protocols == null ? clientProtocolVersion.getVersion() : serverProtocolVersion.getVersion()); setProtocol.invoke(handshake, protocols == null ? clientProtocolVersion.getVersion() : serverProtocolVersion.getVersion());
} catch (InvocationTargetException | IllegalAccessException e) { } catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Error setting handshake version", e);
} }
} }
@ -118,7 +119,7 @@ public class BungeeServerHandler implements Listener {
try { try {
checkServerChange(event, Via.getManager().getConnectionManager().getConnectedClient(event.getPlayer().getUniqueId())); checkServerChange(event, Via.getManager().getConnectionManager().getConnectedClient(event.getPlayer().getUniqueId()));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to handle server switch", e);
} }
} }

View File

@ -28,6 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
import java.util.Collections; import java.util.Collections;
import java.util.logging.Level;
import net.md_5.bungee.api.event.ServerConnectedEvent; import net.md_5.bungee.api.event.ServerConnectedEvent;
import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
@ -56,7 +57,7 @@ public class ElytraPatch implements Listener {
wrapper.scheduleSend(Protocol1_9To1_8.class); wrapper.scheduleSend(Protocol1_9To1_8.class);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send elytra patch metadata packet!", e);
} }
} }
} }

View File

@ -17,11 +17,13 @@
*/ */
package com.viaversion.viaversion.bungee.providers; package com.viaversion.viaversion.bungee.providers;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.ProtocolInfo;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.logging.Level;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -52,7 +54,7 @@ public class BungeeMainHandProvider extends MainHandProvider {
setMainHand.invoke(settings, hand); setMainHand.invoke(settings, hand);
} }
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to set main hand for " + player.getName(), e);
} }
} }
} }

View File

@ -72,10 +72,9 @@ public class BungeeVersionProvider extends BaseVersionProvider {
try { try {
list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class); list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class);
return ProtocolVersion.getProtocol(list.get(0)); return ProtocolVersion.getProtocol(list.get(0));
} catch (NoSuchFieldException | IllegalAccessException e) { } catch (NoSuchFieldException | IllegalAccessException ignored) {
e.printStackTrace(); // Fallback
return ProtocolVersion.getProtocol(ProxyServer.getInstance().getProtocolVersion());
} }
// Fallback
return ProtocolVersion.getProtocol(ProxyServer.getInstance().getProtocolVersion());
} }
} }

View File

@ -17,11 +17,13 @@
*/ */
package com.viaversion.viaversion.bungee.storage; package com.viaversion.viaversion.bungee.storage;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.connection.StorableObject;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class BungeeStorage implements StorableObject { public class BungeeStorage implements StorableObject {
@ -52,7 +54,7 @@ public class BungeeStorage implements StorableObject {
try { try {
bossbar = (Set<UUID>) bossField.get(player); bossbar = (Set<UUID>) bossField.get(player);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to get bossbar list", e);
} }
} }
} }

View File

@ -36,6 +36,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
public class CommonBoss implements BossBar { public class CommonBoss implements BossBar {
private final UUID uuid; private final UUID uuid;
@ -233,7 +234,7 @@ public class CommonBoss implements BossBar {
try { try {
wrapper.scheduleSend(Protocol1_9To1_8.class); wrapper.scheduleSend(Protocol1_9To1_8.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send bossbar packet", e);
} }
} }
@ -269,7 +270,7 @@ public class CommonBoss implements BossBar {
return wrapper; return wrapper;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to create bossbar packet", e);
} }
return null; return null;
} }

View File

@ -120,7 +120,7 @@ public class BaseProtocol1_7 extends AbstractProtocol<BaseClientboundPacket, Bas
wrapper.set(Type.STRING, 0, GsonUtil.getGson().toJson(json)); // Update value wrapper.set(Type.STRING, 0, GsonUtil.getGson().toJson(json)); // Update value
} catch (JsonParseException e) { } catch (JsonParseException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Error handling StatusResponse", e);
} }
}); });
} }

View File

@ -125,7 +125,7 @@ public class MetadataRewriter1_11To1_10 extends EntityRewriter<ClientboundPacket
wrapper.send(Protocol1_11To1_10.class); wrapper.send(Protocol1_11To1_10.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to update hologram position", e);
} }
} }
} }

View File

@ -48,6 +48,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import com.viaversion.viaversion.rewriter.SoundRewriter; import com.viaversion.viaversion.rewriter.SoundRewriter;
import java.util.logging.Level;
public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_12, ServerboundPackets1_9_3, ServerboundPackets1_12> { public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_12, ServerboundPackets1_9_3, ServerboundPackets1_12> {
@ -105,7 +106,7 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
wrapper.set(Type.COMPONENT, 0, obj); wrapper.set(Type.COMPONENT, 0, obj);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Error converting 1.11.2 -> 1.12 chat item", e);
} }
}); });

View File

@ -70,6 +70,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> { public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> {
@ -183,7 +184,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
} }
wrapper.set(Type.STRING, 0, GsonUtil.getGson().toJson(json)); wrapper.set(Type.STRING, 0, GsonUtil.getGson().toJson(json));
} catch (JsonParseException e) { } catch (JsonParseException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Error transforming status response", e);
} }
}); });
} }

View File

@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data;
import com.google.common.collect.ObjectArrays; import com.google.common.collect.ObjectArrays;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.util.GsonUtil; import com.viaversion.viaversion.util.GsonUtil;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@ -27,6 +28,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
public class BlockIdData { public class BlockIdData {
public static final String[] PREVIOUS = new String[0]; public static final String[] PREVIOUS = new String[0];
@ -52,7 +54,7 @@ public class BlockIdData {
} }
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to load block id mappings (1.12.2 -> 1.13)", e);
} }
InputStream blockS = MappingData.class.getClassLoader() InputStream blockS = MappingData.class.getClassLoader()
@ -65,7 +67,7 @@ public class BlockIdData {
); );
numberIdToString = new Int2ObjectOpenHashMap<>(map); numberIdToString = new Int2ObjectOpenHashMap<>(map);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to load block number to string mappings (1.12.2)", e);
} }
// Ignored // Ignored
} }

View File

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1; import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.PlayerLookTargetProvider; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.PlayerLookTargetProvider;
import java.util.logging.Level;
public class TabCompleteTracker implements StorableObject { public class TabCompleteTracker implements StorableObject {
private int transactionId; private int transactionId;
@ -43,7 +44,7 @@ public class TabCompleteTracker implements StorableObject {
try { try {
wrapper.scheduleSendToServer(Protocol1_13To1_12_2.class); wrapper.scheduleSendToServer(Protocol1_13To1_12_2.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send tab complete packet", e);
} }
lastTabComplete = null; lastTabComplete = null;
} }

View File

@ -36,6 +36,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.Compressio
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks; import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
import java.util.logging.Level;
public class PlayerPackets { public class PlayerPackets {
public static void register(Protocol1_9To1_8 protocol) { public static void register(Protocol1_9To1_8 protocol) {
@ -43,14 +44,14 @@ public class PlayerPackets {
@Override @Override
public void register() { public void register() {
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Chat Message (json) map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Chat Message (json)
map(Type.BYTE); // 1 - Chat Positon map(Type.BYTE); // 1 - Chat Position
handler(wrapper -> { handler(wrapper -> {
try { try {
JsonObject obj = (JsonObject) wrapper.get(Type.COMPONENT, 0); JsonObject obj = (JsonObject) wrapper.get(Type.COMPONENT, 0);
ChatRewriter.toClient(obj, wrapper.user()); ChatRewriter.toClient(obj, wrapper.user());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to transform chat component", e);
} }
}); });
} }

View File

@ -38,6 +38,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRew
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
public class SpawnPackets { public class SpawnPackets {
public static final ValueTransformer<Integer, Double> toNewDouble = new ValueTransformer<Integer, Double>(Type.DOUBLE) { public static final ValueTransformer<Integer, Double> toNewDouble = new ValueTransformer<Integer, Double>(Type.DOUBLE) {
@ -275,7 +276,7 @@ public class SpawnPackets {
try { try {
packet.send(Protocol1_9To1_8.class); packet.send(Protocol1_9To1_8.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to send entity equipment packet", e);
} }
} }
}); });

View File

@ -51,6 +51,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public class EntityTracker1_9 extends EntityTrackerBase { public class EntityTracker1_9 extends EntityTrackerBase {
public static final String WITHER_TRANSLATABLE = "{\"translate\":\"entity.WitherBoss.name\"}"; public static final String WITHER_TRANSLATABLE = "{\"translate\":\"entity.WitherBoss.name\"}";
@ -101,7 +102,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
try { try {
wrapper.scheduleSend(Protocol1_9To1_8.class); wrapper.scheduleSend(Protocol1_9To1_8.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send second hand item", e);
} }
} }
@ -329,7 +330,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
wrapper.scheduleSend(Protocol1_9To1_8.class); wrapper.scheduleSend(Protocol1_9To1_8.class);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send team packet", e);
} }
} }
@ -355,7 +356,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
try { try {
wrapper.scheduleSend(Protocol1_9To1_8.class); wrapper.scheduleSend(Protocol1_9To1_8.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to send metadata", e);
} }
} }
metadataBuffer.remove(entityId); metadataBuffer.remove(entityId);

View File

@ -63,7 +63,7 @@ public final class ComponentUtil {
} }
public static @Nullable Tag jsonToTag(@Nullable final JsonElement element) { public static @Nullable Tag jsonToTag(@Nullable final JsonElement element) {
if (element == null) { if (element == null || element.isJsonNull()) {
return null; return null;
} }

Binary file not shown.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@ -1,7 +1,5 @@
import io.papermc.hangarpublishplugin.model.Platforms
plugins { plugins {
id("io.papermc.hangar-publish-plugin") version "0.1.0" id("io.papermc.hangar-publish-plugin") version "0.1.2"
id("com.modrinth.minotaur") version "2.+" id("com.modrinth.minotaur") version "2.+"
} }
@ -80,15 +78,15 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch
changelog.set(changelogContent) changelog.set(changelogContent)
apiKey.set(System.getenv("HANGAR_TOKEN")) apiKey.set(System.getenv("HANGAR_TOKEN"))
platforms { platforms {
register(Platforms.PAPER) { paper {
jar.set(tasks.shadowJar.flatMap { it.archiveFile }) jar.set(tasks.shadowJar.flatMap { it.archiveFile })
platformVersions.set(listOf(property("mcVersionRange") as String)) platformVersions.set(listOf(property("mcVersionRange") as String))
} }
register(Platforms.VELOCITY) { velocity {
jar.set(tasks.shadowJar.flatMap { it.archiveFile }) jar.set(tasks.shadowJar.flatMap { it.archiveFile })
platformVersions.set(listOf(property("velocityVersion") as String)) platformVersions.set(listOf(property("velocityVersion") as String))
} }
register(Platforms.WATERFALL) { waterfall {
jar.set(tasks.shadowJar.flatMap { it.archiveFile }) jar.set(tasks.shadowJar.flatMap { it.archiveFile })
platformVersions.set(listOf(property("waterfallVersion") as String)) platformVersions.set(listOf(property("waterfallVersion") as String))
} }

View File

@ -29,6 +29,7 @@ import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.logging.Level;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class VelocityViaInjector implements ViaInjector { public class VelocityViaInjector implements ViaInjector {
@ -38,7 +39,7 @@ public class VelocityViaInjector implements ViaInjector {
try { try {
return Class.forName("com.velocitypowered.proxy.config.VelocityConfiguration").getMethod("getPlayerInfoForwardingMode"); return Class.forName("com.velocitypowered.proxy.config.VelocityConfiguration").getMethod("getPlayerInfoForwardingMode");
} catch (NoSuchMethodException | ClassNotFoundException e) { } catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to get getPlayerInfoForwardingMode method from Velocity, please report this issue on our GitHub.", e);
return null; return null;
} }
} }

View File

@ -27,6 +27,7 @@ import com.viaversion.viaversion.velocity.platform.VelocityViaInjector;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Arrays; import java.util.Arrays;
import java.util.logging.Level;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -37,7 +38,7 @@ public class VelocityVersionProvider extends BaseVersionProvider {
try { try {
return Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection").getMethod("getAssociation"); return Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection").getMethod("getAssociation");
} catch (NoSuchMethodException | ClassNotFoundException e) { } catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to get association method from Velocity, please report this issue on our GitHub.", e);
return null; return null;
} }
} }

View File

@ -27,6 +27,7 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
public final class ProtocolDetectorService extends AbstractProtocolDetectorService { public final class ProtocolDetectorService extends AbstractProtocolDetectorService {
@ -90,7 +91,7 @@ public final class ProtocolDetectorService extends AbstractProtocolDetectorServi
try { try {
return Via.getManager().getInjector().getServerProtocolVersion(); return Via.getManager().getInjector().getServerProtocolVersion();
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Failed to get lowest supported protocol version", e);
return ProtocolVersion.v1_8; return ProtocolVersion.v1_8;
} }
} }

View File

@ -18,6 +18,7 @@
package com.viaversion.viaversion.velocity.storage; package com.viaversion.viaversion.velocity.storage;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.util.ReflectionUtil; import com.viaversion.viaversion.util.ReflectionUtil;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -25,6 +26,7 @@ import java.lang.reflect.Method;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
public class VelocityStorage implements StorableObject { public class VelocityStorage implements StorableObject {
private final Player player; private final Player player;
@ -42,7 +44,7 @@ public class VelocityStorage implements StorableObject {
getMinecraftConnection = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer") getMinecraftConnection = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer")
.getDeclaredMethod("getMinecraftConnection"); .getDeclaredMethod("getMinecraftConnection");
} catch (NoSuchMethodException | ClassNotFoundException e) { } catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to initialize Velocity bossbar support, bossbars will not work.", e);
} }
} }
@ -64,7 +66,7 @@ public class VelocityStorage implements StorableObject {
cachedBossbar = (List<UUID>) getServerBossBars.invoke(sessionHandler); cachedBossbar = (List<UUID>) getServerBossBars.invoke(sessionHandler);
} }
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to get bossbar list", e);
} }
} }
return cachedBossbar; return cachedBossbar;