diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index c9be95286..2c72a7783 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 - name: Set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a7aba4a34..07a5a2c07 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 - name: Set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java index 231bb04b3..c7e56fec1 100644 --- a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java +++ b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java @@ -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.Protocol1_9To1_8; import java.util.UUID; +import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; @@ -71,7 +72,7 @@ public class ArmorListener extends ViaBukkitListener { wrapper.scheduleSend(Protocol1_9To1_8.class); } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send armor update", e); } } diff --git a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/DeathListener.java b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/DeathListener.java index fad3c68e3..9939707b8 100644 --- a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/DeathListener.java +++ b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_9to1_8/DeathListener.java @@ -30,6 +30,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.plugin.Plugin; +import java.util.logging.Level; public class DeathListener extends ViaBukkitListener { @@ -66,7 +67,7 @@ public class DeathListener extends ViaBukkitListener { wrapper.scheduleSend(Protocol1_9To1_8.class); } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send death message", e); } } }); diff --git a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java index aec90eaf9..edf7d4f2a 100644 --- a/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java +++ b/bukkit-legacy/src/main/java/com/viaversion/viaversion/bukkit/util/ProtocolSupportUtil.java @@ -19,6 +19,8 @@ package com.viaversion.viaversion.bukkit.util; import java.lang.reflect.InvocationTargetException; 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.VersionType; import org.bukkit.entity.Player; @@ -52,7 +54,7 @@ public final class ProtocolSupportUtil { return ProtocolVersion.getProtocol(preNetty ? VersionType.RELEASE_INITIAL : VersionType.RELEASE, id); } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to get ProtocolSupport version", e); } return ProtocolVersion.unknown; } diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/multiversion/PlayerSneakListener.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/multiversion/PlayerSneakListener.java index e290adbaa..b8c46eaa6 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/multiversion/PlayerSneakListener.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/multiversion/PlayerSneakListener.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.WeakHashMap; +import java.util.logging.Level; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -148,7 +149,7 @@ public class PlayerSneakListener extends ViaBukkitListener { try { setSize.invoke(getHandle.invoke(player), DEFAULT_WIDTH, height); } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to set player height", e); } } } \ No newline at end of file diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java index bc5a6c64f..7807660fb 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java @@ -18,6 +18,7 @@ package com.viaversion.viaversion.bukkit.listeners.protocol1_15to1_14_4; import com.viaversion.viaversion.ViaVersionPlugin; +import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; 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.Protocol1_15To1_14_4; import java.util.Arrays; +import java.util.logging.Level; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; 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.scheduleSend(Protocol1_15To1_14_4.class); } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send entity glide fix metadata", e); } } } diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaInjector.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaInjector.java index 49b18284e..d0a6e20a9 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaInjector.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaInjector.java @@ -18,6 +18,7 @@ package com.viaversion.viaversion.bukkit.platform; import com.google.common.base.Preconditions; +import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.bukkit.handlers.BukkitChannelInitializer; 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.Method; import java.util.List; +import java.util.logging.Level; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginDescriptionFile; import org.checkerframework.checker.nullness.qual.Nullable; @@ -218,7 +220,7 @@ public class BukkitViaInjector extends LegacyViaInjector { } } } catch (ReflectiveOperationException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to check if ViaVersion is binded", e); } return false; } diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitInventoryQuickMoveProvider.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitInventoryQuickMoveProvider.java index 94aacf86e..af1263501 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitInventoryQuickMoveProvider.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitInventoryQuickMoveProvider.java @@ -153,7 +153,7 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider // send packetMethod.invoke(playerConnection, packet); } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to send packet to server", e); return false; } return true; diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitViaMovementTransmitter.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitViaMovementTransmitter.java index 87fc91fb1..5578473e9 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitViaMovementTransmitter.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/providers/BukkitViaMovementTransmitter.java @@ -25,6 +25,7 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.MovementTrac import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.logging.Level; import com.viaversion.viaversion.util.PipelineUtil; import io.netty.channel.ChannelHandlerContext; @@ -109,7 +110,7 @@ public class BukkitViaMovementTransmitter extends MovementTransmitterProvider { info.get(MovementTracker.class).incrementIdlePacket(); } } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to handle idle packet", e); } } } else { diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/tasks/protocol1_19to1_18_2/AckSequenceTask.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/tasks/protocol1_19to1_18_2/AckSequenceTask.java index c912ed5e9..a37d286f5 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/tasks/protocol1_19to1_18_2/AckSequenceTask.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/tasks/protocol1_19to1_18_2/AckSequenceTask.java @@ -17,12 +17,14 @@ */ 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.protocol.packet.PacketWrapper; 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.Protocol1_19To1_18_2; import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.SequenceStorage; +import java.util.logging.Level; public final class AckSequenceTask implements Runnable { @@ -42,7 +44,7 @@ public final class AckSequenceTask implements Runnable { ackPacket.write(Type.VAR_INT, sequence); ackPacket.scheduleSend(Protocol1_19To1_18_2.class); } catch (final Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send block changed ack packet", e); } } } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeChannelInitializer.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeChannelInitializer.java index b7fafdac2..bd4efb6d9 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeChannelInitializer.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeChannelInitializer.java @@ -17,12 +17,14 @@ */ package com.viaversion.viaversion.bungee.handlers; +import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.connection.UserConnectionImpl; import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; import io.netty.channel.Channel; import io.netty.channel.ChannelInitializer; import java.lang.reflect.Method; +import java.util.logging.Level; public class BungeeChannelInitializer extends ChannelInitializer { private final ChannelInitializer original; @@ -34,7 +36,7 @@ public class BungeeChannelInitializer extends ChannelInitializer { this.method = ChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class); this.method.setAccessible(true); } catch (NoSuchMethodException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to get initChannel method", e); } } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java index 4ebe2350d..a39dcf641 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java @@ -44,6 +44,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.UUID; +import java.util.logging.Level; import java.util.stream.Collectors; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.Server; @@ -109,7 +110,7 @@ public class BungeeServerHandler implements Listener { Object handshake = getHandshake.invoke(event.getPlayer().getPendingConnection()); setProtocol.invoke(handshake, protocols == null ? clientProtocolVersion.getVersion() : serverProtocolVersion.getVersion()); } 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 { checkServerChange(event, Via.getManager().getConnectionManager().getConnectedClient(event.getPlayer().getUniqueId())); } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to handle server switch", e); } } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java index aa898f543..a5f560ee0 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java @@ -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.storage.EntityTracker1_9; import java.util.Collections; +import java.util.logging.Level; import net.md_5.bungee.api.event.ServerConnectedEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; @@ -56,7 +57,7 @@ public class ElytraPatch implements Listener { wrapper.scheduleSend(Protocol1_9To1_8.class); } } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send elytra patch metadata packet!", e); } } } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMainHandProvider.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMainHandProvider.java index 73774c25d..dd8485493 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMainHandProvider.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMainHandProvider.java @@ -17,11 +17,13 @@ */ 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.UserConnection; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.MainHandProvider; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.logging.Level; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -52,7 +54,7 @@ public class BungeeMainHandProvider extends MainHandProvider { setMainHand.invoke(settings, hand); } } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to set main hand for " + player.getName(), e); } } } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeVersionProvider.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeVersionProvider.java index ccc773337..087b1d7dd 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeVersionProvider.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeVersionProvider.java @@ -72,10 +72,9 @@ public class BungeeVersionProvider extends BaseVersionProvider { try { list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class); return ProtocolVersion.getProtocol(list.get(0)); - } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); + } catch (NoSuchFieldException | IllegalAccessException ignored) { + // Fallback + return ProtocolVersion.getProtocol(ProxyServer.getInstance().getProtocolVersion()); } - // Fallback - return ProtocolVersion.getProtocol(ProxyServer.getInstance().getProtocolVersion()); } } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/storage/BungeeStorage.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/storage/BungeeStorage.java index c36db920a..54470223b 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/storage/BungeeStorage.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/storage/BungeeStorage.java @@ -17,11 +17,13 @@ */ package com.viaversion.viaversion.bungee.storage; +import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.StorableObject; import java.lang.reflect.Field; import java.util.Objects; import java.util.Set; import java.util.UUID; +import java.util.logging.Level; import net.md_5.bungee.api.connection.ProxiedPlayer; public class BungeeStorage implements StorableObject { @@ -52,7 +54,7 @@ public class BungeeStorage implements StorableObject { try { bossbar = (Set) bossField.get(player); } catch (IllegalAccessException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to get bossbar list", e); } } } diff --git a/common/src/main/java/com/viaversion/viaversion/legacy/bossbar/CommonBoss.java b/common/src/main/java/com/viaversion/viaversion/legacy/bossbar/CommonBoss.java index a3ac22416..9690af79e 100644 --- a/common/src/main/java/com/viaversion/viaversion/legacy/bossbar/CommonBoss.java +++ b/common/src/main/java/com/viaversion/viaversion/legacy/bossbar/CommonBoss.java @@ -36,6 +36,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.logging.Level; public class CommonBoss implements BossBar { private final UUID uuid; @@ -233,7 +234,7 @@ public class CommonBoss implements BossBar { try { wrapper.scheduleSend(Protocol1_9To1_8.class); } 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; } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to create bossbar packet", e); } return null; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol1_7.java b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol1_7.java index eaac0ebd4..f3dae8b1f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol1_7.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/base/BaseProtocol1_7.java @@ -120,7 +120,7 @@ public class BaseProtocol1_7 extends AbstractProtocol { @@ -105,7 +106,7 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol 1.12 chat item", e); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index 83650d3d1..26b312e52 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -70,6 +70,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.logging.Level; public class Protocol1_13To1_12_2 extends AbstractProtocol { @@ -183,7 +184,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol 1.13)", e); } InputStream blockS = MappingData.class.getClassLoader() @@ -65,7 +67,7 @@ public class BlockIdData { ); numberIdToString = new Int2ObjectOpenHashMap<>(map); } catch (IOException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to load block number to string mappings (1.12.2)", e); } // Ignored } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/TabCompleteTracker.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/TabCompleteTracker.java index ed9295b1f..18b024c62 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/TabCompleteTracker.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/TabCompleteTracker.java @@ -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_13to1_12_2.Protocol1_13To1_12_2; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.providers.PlayerLookTargetProvider; +import java.util.logging.Level; public class TabCompleteTracker implements StorableObject { private int transactionId; @@ -43,7 +44,7 @@ public class TabCompleteTracker implements StorableObject { try { wrapper.scheduleSendToServer(Protocol1_13To1_12_2.class); } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to send tab complete packet", e); } lastTabComplete = null; } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/PlayerPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/PlayerPackets.java index 17a1bd988..b40772c3d 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/PlayerPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/PlayerPackets.java @@ -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.storage.ClientChunks; import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; +import java.util.logging.Level; public class PlayerPackets { public static void register(Protocol1_9To1_8 protocol) { @@ -43,14 +44,14 @@ public class PlayerPackets { @Override public void register() { 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 -> { try { JsonObject obj = (JsonObject) wrapper.get(Type.COMPONENT, 0); ChatRewriter.toClient(obj, wrapper.user()); } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to transform chat component", e); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/SpawnPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/SpawnPackets.java index aa7b2defe..3169eccc6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/SpawnPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/packets/SpawnPackets.java @@ -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 java.util.ArrayList; import java.util.List; +import java.util.logging.Level; public class SpawnPackets { public static final ValueTransformer toNewDouble = new ValueTransformer(Type.DOUBLE) { @@ -275,7 +276,7 @@ public class SpawnPackets { try { packet.send(Protocol1_9To1_8.class); } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to send entity equipment packet", e); } } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/storage/EntityTracker1_9.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/storage/EntityTracker1_9.java index 924c11392..3ac5dba67 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/storage/EntityTracker1_9.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9to1_8/storage/EntityTracker1_9.java @@ -51,6 +51,7 @@ import java.util.List; import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; public class EntityTracker1_9 extends EntityTrackerBase { public static final String WITHER_TRANSLATABLE = "{\"translate\":\"entity.WitherBoss.name\"}"; @@ -101,7 +102,7 @@ public class EntityTracker1_9 extends EntityTrackerBase { try { wrapper.scheduleSend(Protocol1_9To1_8.class); } 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); } } 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 { wrapper.scheduleSend(Protocol1_9To1_8.class); } catch (Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to send metadata", e); } } metadataBuffer.remove(entityId); diff --git a/common/src/main/java/com/viaversion/viaversion/util/ComponentUtil.java b/common/src/main/java/com/viaversion/viaversion/util/ComponentUtil.java index cc5292e46..edab243a1 100644 --- a/common/src/main/java/com/viaversion/viaversion/util/ComponentUtil.java +++ b/common/src/main/java/com/viaversion/viaversion/util/ComponentUtil.java @@ -63,7 +63,7 @@ public final class ComponentUtil { } public static @Nullable Tag jsonToTag(@Nullable final JsonElement element) { - if (element == null) { + if (element == null || element.isJsonNull()) { return null; } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd4917..e6441136f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e0930..b82aa23a4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME 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 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/universal/build.gradle.kts b/universal/build.gradle.kts index 198aee5f1..d47f33ac0 100644 --- a/universal/build.gradle.kts +++ b/universal/build.gradle.kts @@ -1,7 +1,5 @@ -import io.papermc.hangarpublishplugin.model.Platforms - 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.+" } @@ -80,15 +78,15 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch changelog.set(changelogContent) apiKey.set(System.getenv("HANGAR_TOKEN")) platforms { - register(Platforms.PAPER) { + paper { jar.set(tasks.shadowJar.flatMap { it.archiveFile }) platformVersions.set(listOf(property("mcVersionRange") as String)) } - register(Platforms.VELOCITY) { + velocity { jar.set(tasks.shadowJar.flatMap { it.archiveFile }) platformVersions.set(listOf(property("velocityVersion") as String)) } - register(Platforms.WATERFALL) { + waterfall { jar.set(tasks.shadowJar.flatMap { it.archiveFile }) platformVersions.set(listOf(property("waterfallVersion") as String)) } diff --git a/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaInjector.java b/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaInjector.java index e182e901d..b07d77742 100644 --- a/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaInjector.java +++ b/velocity/src/main/java/com/viaversion/viaversion/velocity/platform/VelocityViaInjector.java @@ -29,6 +29,7 @@ import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.SortedSet; +import java.util.logging.Level; import org.jetbrains.annotations.Nullable; public class VelocityViaInjector implements ViaInjector { @@ -38,7 +39,7 @@ public class VelocityViaInjector implements ViaInjector { try { return Class.forName("com.velocitypowered.proxy.config.VelocityConfiguration").getMethod("getPlayerInfoForwardingMode"); } 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; } } diff --git a/velocity/src/main/java/com/viaversion/viaversion/velocity/providers/VelocityVersionProvider.java b/velocity/src/main/java/com/viaversion/viaversion/velocity/providers/VelocityVersionProvider.java index df272f163..1e7e850f4 100644 --- a/velocity/src/main/java/com/viaversion/viaversion/velocity/providers/VelocityVersionProvider.java +++ b/velocity/src/main/java/com/viaversion/viaversion/velocity/providers/VelocityVersionProvider.java @@ -27,6 +27,7 @@ import com.viaversion.viaversion.velocity.platform.VelocityViaInjector; import io.netty.channel.ChannelHandler; import java.lang.reflect.Method; import java.util.Arrays; +import java.util.logging.Level; import java.util.stream.IntStream; import org.jetbrains.annotations.Nullable; @@ -37,7 +38,7 @@ public class VelocityVersionProvider extends BaseVersionProvider { try { return Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection").getMethod("getAssociation"); } 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; } } diff --git a/velocity/src/main/java/com/viaversion/viaversion/velocity/service/ProtocolDetectorService.java b/velocity/src/main/java/com/viaversion/viaversion/velocity/service/ProtocolDetectorService.java index 612be037e..043508892 100644 --- a/velocity/src/main/java/com/viaversion/viaversion/velocity/service/ProtocolDetectorService.java +++ b/velocity/src/main/java/com/viaversion/viaversion/velocity/service/ProtocolDetectorService.java @@ -27,6 +27,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.logging.Level; public final class ProtocolDetectorService extends AbstractProtocolDetectorService { @@ -90,7 +91,7 @@ public final class ProtocolDetectorService extends AbstractProtocolDetectorServi try { return Via.getManager().getInjector().getServerProtocolVersion(); } catch (final Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to get lowest supported protocol version", e); return ProtocolVersion.v1_8; } } diff --git a/velocity/src/main/java/com/viaversion/viaversion/velocity/storage/VelocityStorage.java b/velocity/src/main/java/com/viaversion/viaversion/velocity/storage/VelocityStorage.java index 2a5fcaa36..b34e7cc00 100644 --- a/velocity/src/main/java/com/viaversion/viaversion/velocity/storage/VelocityStorage.java +++ b/velocity/src/main/java/com/viaversion/viaversion/velocity/storage/VelocityStorage.java @@ -18,6 +18,7 @@ package com.viaversion.viaversion.velocity.storage; import com.velocitypowered.api.proxy.Player; +import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.util.ReflectionUtil; import java.lang.reflect.InvocationTargetException; @@ -25,6 +26,7 @@ import java.lang.reflect.Method; import java.util.List; import java.util.Objects; import java.util.UUID; +import java.util.logging.Level; public class VelocityStorage implements StorableObject { private final Player player; @@ -42,7 +44,7 @@ public class VelocityStorage implements StorableObject { getMinecraftConnection = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer") .getDeclaredMethod("getMinecraftConnection"); } 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) getServerBossBars.invoke(sessionHandler); } } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to get bossbar list", e); } } return cachedBossbar;