From 7b0c2fb51a9ffa4584f0e7f656b31840b9da9ee9 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Sat, 9 Mar 2024 13:57:41 +0100 Subject: [PATCH] Replace printStackTrace usages with proper logging (#3741) --- .../bukkit/listeners/protocol1_9to1_8/ArmorListener.java | 3 ++- .../bukkit/listeners/protocol1_9to1_8/DeathListener.java | 3 ++- .../viaversion/bukkit/util/ProtocolSupportUtil.java | 4 +++- .../bukkit/listeners/multiversion/PlayerSneakListener.java | 3 ++- .../protocol1_15to1_14_4/EntityToggleGlideListener.java | 4 +++- .../viaversion/bukkit/platform/BukkitViaInjector.java | 4 +++- .../bukkit/providers/BukkitInventoryQuickMoveProvider.java | 2 +- .../bukkit/providers/BukkitViaMovementTransmitter.java | 3 ++- .../bukkit/tasks/protocol1_19to1_18_2/AckSequenceTask.java | 4 +++- .../bungee/handlers/BungeeChannelInitializer.java | 4 +++- .../viaversion/bungee/handlers/BungeeServerHandler.java | 5 +++-- .../viaversion/bungee/listeners/ElytraPatch.java | 3 ++- .../bungee/providers/BungeeMainHandProvider.java | 4 +++- .../viaversion/bungee/providers/BungeeVersionProvider.java | 7 +++---- .../viaversion/bungee/storage/BungeeStorage.java | 4 +++- .../viaversion/viaversion/legacy/bossbar/CommonBoss.java | 5 +++-- .../viaversion/protocols/base/BaseProtocol1_7.java | 2 +- .../metadata/MetadataRewriter1_11To1_10.java | 2 +- .../protocol1_12to1_11_1/Protocol1_12To1_11_1.java | 3 ++- .../protocol1_13to1_12_2/Protocol1_13To1_12_2.java | 3 ++- .../protocols/protocol1_13to1_12_2/data/BlockIdData.java | 6 ++++-- .../protocol1_13to1_12_2/storage/TabCompleteTracker.java | 3 ++- .../protocols/protocol1_9to1_8/packets/PlayerPackets.java | 5 +++-- .../protocols/protocol1_9to1_8/packets/SpawnPackets.java | 3 ++- .../protocol1_9to1_8/storage/EntityTracker1_9.java | 7 ++++--- .../java/com/viaversion/viaversion/update/UpdateUtil.java | 3 ++- .../viaversion/velocity/platform/VelocityViaInjector.java | 3 ++- .../velocity/providers/VelocityVersionProvider.java | 3 ++- .../velocity/service/ProtocolDetectorService.java | 3 ++- .../viaversion/velocity/storage/VelocityStorage.java | 6 ++++-- 30 files changed, 74 insertions(+), 40 deletions(-) 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 b49b91e3e..357832ff1 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 org.bukkit.entity.Player; public final class ProtocolSupportUtil { @@ -46,7 +48,7 @@ public final class ProtocolSupportUtil { Object version = PROTOCOL_VERSION_METHOD.invoke(null, player); return (int) GET_ID_METHOD.invoke(version); } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to get ProtocolSupport version", e); } return -1; } 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 1ce42ab6f..d416c0d71 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 9188d9425..b940081e4 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.bukkit.handlers.BukkitChannelInitializer; import com.viaversion.viaversion.bukkit.util.NMSUtil; import com.viaversion.viaversion.platform.LegacyViaInjector; @@ -30,6 +31,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; @@ -217,7 +219,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 11d432118..48bc021c1 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 4a038647f..8b3f93d19 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 net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.api.event.ServerConnectEvent; @@ -108,7 +109,7 @@ public class BungeeServerHandler implements Listener { Object handshake = getHandshake.invoke(event.getPlayer().getPendingConnection()); setProtocol.invoke(handshake, protocols == null ? clientProtocolVersion : serverProtocolVersion); } catch (InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Error setting handshake version", e); } } @@ -117,7 +118,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 012582fe1..bc69b908b 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 @@ -68,10 +68,9 @@ public class BungeeVersionProvider extends BaseVersionProvider { try { list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class); return list.get(0); - } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); + } catch (NoSuchFieldException | IllegalAccessException ignored) { + // Fallback + return ProxyServer.getInstance().getProtocolVersion(); } - // Fallback - return 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 957b357ca..2690b9159 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 @@ -110,7 +110,7 @@ public class BaseProtocol1_7 extends AbstractProtocol { wrapper.set(Type.STRING, 0, GsonUtil.getGson().toJson(json)); // Update value } catch (JsonParseException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.SEVERE, "Error handling StatusResponse", e); } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/metadata/MetadataRewriter1_11To1_10.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/metadata/MetadataRewriter1_11To1_10.java index c06d28f54..66ae23ab4 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/metadata/MetadataRewriter1_11To1_10.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_11to1_10/metadata/MetadataRewriter1_11To1_10.java @@ -125,7 +125,7 @@ public class MetadataRewriter1_11To1_10 extends EntityRewriter { @@ -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 1d2664a2c..1fbc9121d 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 @@ -69,6 +69,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 { @@ -182,7 +183,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 3270f5092..31d755dab 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 29f7b34d6..d58cd3632 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 @@ -48,6 +48,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; +import java.util.logging.Level; import space.vectrix.flare.fastutil.Int2ObjectSyncMap; public class EntityTracker1_9 extends EntityTrackerBase { @@ -99,7 +100,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); } } @@ -327,7 +328,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); } } @@ -353,7 +354,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/update/UpdateUtil.java b/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java index db7eed9b5..eb92d2a51 100644 --- a/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java +++ b/common/src/main/java/com/viaversion/viaversion/update/UpdateUtil.java @@ -28,6 +28,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.util.Locale; import java.util.UUID; +import java.util.logging.Level; import org.checkerframework.checker.nullness.qual.Nullable; public final class UpdateUtil { @@ -105,7 +106,7 @@ public final class UpdateUtil { try { statistics = GsonUtil.getGson().fromJson(builder.toString(), JsonObject.class); } catch (JsonParseException e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to parse update response", e); return null; } return statistics.get("name").getAsString(); 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 f83842c8e..6068c2bd3 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.ints.IntLinkedOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSortedSet; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.logging.Level; import org.jetbrains.annotations.Nullable; @@ -39,7 +40,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 885b87e59..2bd255e5a 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 7cc9d4101..02b7ef08a 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 ProtocolVersion.getProtocol(Via.getManager().getInjector().getServerProtocolVersion()).getVersion(); } catch (final Exception e) { - e.printStackTrace(); + Via.getPlatform().getLogger().log(Level.WARNING, "Failed to get lowest supported protocol version", e); return ProtocolVersion.v1_8.getVersion(); } } 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;