3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-19 14:30:16 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2023-11-20 19:56:48 +01:00
Ursprung 1af2103f6c
Commit a0f8ab7bbb
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
15 geänderte Dateien mit 34 neuen und 62 gelöschten Zeilen

Datei anzeigen

@ -32,7 +32,7 @@ public interface ViaVersionCommand {
* @param command Your own SubCommand instance to handle it. * @param command Your own SubCommand instance to handle it.
* @throws Exception throws an exception when the subcommand already exists or if it's not valid, example: spacee * @throws Exception throws an exception when the subcommand already exists or if it's not valid, example: spacee
*/ */
void registerSubCommand(ViaSubCommand command) throws Exception; void registerSubCommand(ViaSubCommand command);
/** /**
* Check if a subcommand is registered. * Check if a subcommand is registered.

Datei anzeigen

@ -48,6 +48,7 @@ import java.util.HashSet;
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;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -111,8 +112,7 @@ public class BukkitViaLoader implements ViaPlatformLoader {
try { try {
new PlayerSneakListener(plugin, use1_9Fix, plugin.getConf().is1_14HitboxFix()).register(); new PlayerSneakListener(plugin, use1_9Fix, plugin.getConf().is1_14HitboxFix()).register();
} catch (ReflectiveOperationException e) { } catch (ReflectiveOperationException e) {
Via.getPlatform().getLogger().warning("Could not load hitbox fix - please report this on our GitHub"); Via.getPlatform().getLogger().log(Level.WARNING, "Could not load hitbox fix - please report this on our GitHub", e);
e.printStackTrace();
} }
} }
} }
@ -165,9 +165,7 @@ public class BukkitViaLoader implements ViaPlatformLoader {
return null; return null;
}).get(10, TimeUnit.SECONDS); }).get(10, TimeUnit.SECONDS);
} catch (Exception e) { } catch (Exception e) {
Via.getPlatform().getLogger().severe("Error fetching hand item: " + e.getClass().getName()); Via.getPlatform().getLogger().log(Level.SEVERE, "Error fetching hand item", e);
if (Via.getManager().isDebug())
e.printStackTrace();
return null; return null;
} }
} }

Datei anzeigen

@ -17,17 +17,11 @@
*/ */
package com.viaversion.viaversion.bungee.commands; package com.viaversion.viaversion.bungee.commands;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.bungee.commands.subs.ProbeSubCmd; import com.viaversion.viaversion.bungee.commands.subs.ProbeSubCmd;
import com.viaversion.viaversion.commands.ViaCommandHandler; import com.viaversion.viaversion.commands.ViaCommandHandler;
public class BungeeCommandHandler extends ViaCommandHandler { public class BungeeCommandHandler extends ViaCommandHandler {
public BungeeCommandHandler() { public BungeeCommandHandler() {
try {
registerSubCommand(new ProbeSubCmd()); registerSubCommand(new ProbeSubCmd());
} catch (Exception e) {
Via.getPlatform().getLogger().severe("Failed to register Bungee subcommands");
e.printStackTrace();
}
} }
} }

Datei anzeigen

@ -28,27 +28,14 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.protocol.ProtocolConstants;
public class BungeeVersionProvider extends BaseVersionProvider { public class BungeeVersionProvider extends BaseVersionProvider {
private static Class<?> ref;
static {
try {
ref = Class.forName("net.md_5.bungee.protocol.ProtocolConstants");
} catch (Exception e) {
Via.getPlatform().getLogger().severe("Could not detect the ProtocolConstants class");
e.printStackTrace();
}
}
@Override @Override
public int getClosestServerProtocol(UserConnection user) throws Exception { public int getClosestServerProtocol(UserConnection user) throws Exception {
if (ref == null) {
return super.getClosestServerProtocol(user);
}
// TODO Have one constant list forever until restart? (Might limit plugins if they change this) // TODO Have one constant list forever until restart? (Might limit plugins if they change this)
List<Integer> list = ReflectionUtil.getStatic(ref, "SUPPORTED_VERSION_IDS", List.class); List<Integer> list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class);
List<Integer> sorted = new ArrayList<>(list); List<Integer> sorted = new ArrayList<>(list);
Collections.sort(sorted); Collections.sort(sorted);
@ -79,7 +66,7 @@ public class BungeeVersionProvider extends BaseVersionProvider {
public static int getLowestSupportedVersion() { public static int getLowestSupportedVersion() {
List<Integer> list; List<Integer> list;
try { try {
list = ReflectionUtil.getStatic(ref, "SUPPORTED_VERSION_IDS", List.class); list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class);
return list.get(0); return list.get(0);
} catch (NoSuchFieldException | IllegalAccessException e) { } catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();

Datei anzeigen

@ -49,6 +49,7 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -99,8 +100,7 @@ public class ViaManagerImpl implements ViaManager {
try { try {
injector.inject(); injector.inject();
} catch (Exception e) { } catch (Exception e) {
platform.getLogger().severe("ViaVersion failed to inject:"); platform.getLogger().log(Level.SEVERE, "ViaVersion failed to inject:", e);
e.printStackTrace();
return; return;
} }
@ -196,8 +196,7 @@ public class ViaManagerImpl implements ViaManager {
protocolManager.setServerProtocol(versionInfo); protocolManager.setServerProtocol(versionInfo);
} catch (Exception e) { } catch (Exception e) {
platform.getLogger().severe("ViaVersion failed to get the server protocol!"); platform.getLogger().log(Level.SEVERE, "ViaVersion failed to get the server protocol!", e);
e.printStackTrace();
} }
} }
@ -207,8 +206,7 @@ public class ViaManagerImpl implements ViaManager {
try { try {
injector.uninject(); injector.uninject();
} catch (Exception e) { } catch (Exception e) {
platform.getLogger().severe("ViaVersion failed to uninject:"); platform.getLogger().log(Level.SEVERE, "ViaVersion failed to uninject:", e);
e.printStackTrace();
} }
loader.unload(); loader.unload();
@ -228,8 +226,7 @@ public class ViaManagerImpl implements ViaManager {
try { try {
version = Integer.parseInt(versionString); version = Integer.parseInt(versionString);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
platform.getLogger().warning("Failed to determine Java version; could not parse: " + versionString); platform.getLogger().log(Level.WARNING, "Failed to determine Java version; could not parse: " + versionString, e);
e.printStackTrace();
return; return;
} }

Datei anzeigen

@ -32,6 +32,7 @@ import io.netty.channel.ChannelPipeline;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public abstract class LegacyViaInjector implements ViaInjector { public abstract class LegacyViaInjector implements ViaInjector {
@ -141,8 +142,7 @@ public abstract class LegacyViaInjector implements ViaInjector {
ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((WrappedChannelInitializer) initializer).original()); ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((WrappedChannelInitializer) initializer).original());
} }
} catch (Exception e) { } catch (Exception e) {
Via.getPlatform().getLogger().severe("Failed to remove injection handler, reload won't work with connections, please reboot!"); Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to remove injection handler, reload won't work with connections, please reboot!", e);
e.printStackTrace();
} }
} }

Datei anzeigen

@ -82,6 +82,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
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;
import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap; import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap;
import java.util.logging.Level;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
@ -514,8 +515,7 @@ public class ProtocolManagerImpl implements ProtocolManager {
private Function<Throwable, Void> mappingLoaderThrowable(Class<? extends Protocol> protocolClass) { private Function<Throwable, Void> mappingLoaderThrowable(Class<? extends Protocol> protocolClass) {
return throwable -> { return throwable -> {
Via.getPlatform().getLogger().severe("Error during mapping loading of " + protocolClass.getSimpleName()); Via.getPlatform().getLogger().log(Level.SEVERE, "Error during mapping loading of " + protocolClass.getSimpleName(), throwable);
throwable.printStackTrace();
return null; return null;
}; };
} }

Datei anzeigen

@ -34,6 +34,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac
import com.viaversion.viaversion.rewriter.EntityRewriter; import com.viaversion.viaversion.rewriter.EntityRewriter;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.logging.Level;
public class MetadataRewriter1_11To1_10 extends EntityRewriter<ClientboundPackets1_9_3, Protocol1_11To1_10> { public class MetadataRewriter1_11To1_10 extends EntityRewriter<ClientboundPackets1_9_3, Protocol1_11To1_10> {
@ -230,7 +231,7 @@ public class MetadataRewriter1_11To1_10 extends EntityRewriter<ClientboundPacket
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) { if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("An error occurred with entity type rewriter"); Via.getPlatform().getLogger().warning("An error occurred with entity type rewriter");
Via.getPlatform().getLogger().warning("Metadata: " + metadata); Via.getPlatform().getLogger().warning("Metadata: " + metadata);
e.printStackTrace(); Via.getPlatform().getLogger().log(Level.WARNING, "Error: ", e);
} }
} }

Datei anzeigen

@ -25,6 +25,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.data.AchievementTranslationMapping; import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.data.AchievementTranslationMapping;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.rewriter.ComponentRewriter; import com.viaversion.viaversion.rewriter.ComponentRewriter;
import java.util.logging.Level;
public class TranslateRewriter { public class TranslateRewriter {
@ -91,8 +92,7 @@ public class TranslateRewriter {
hoverEvent.addProperty("action", "show_text"); hoverEvent.addProperty("action", "show_text");
hoverEvent.add("value", baseArray); hoverEvent.add("value", baseArray);
} catch (Exception e) { } catch (Exception e) {
Via.getPlatform().getLogger().warning("Error rewriting show_achievement: " + hoverEvent); Via.getPlatform().getLogger().log(Level.WARNING, "Error rewriting show_achievement: " + hoverEvent, e);
e.printStackTrace();
JsonObject invalidText = new JsonObject(); JsonObject invalidText = new JsonObject();
invalidText.addProperty("text", "Invalid statistic/achievement!"); invalidText.addProperty("text", "Invalid statistic/achievement!");
invalidText.addProperty("color", "red"); invalidText.addProperty("color", "red");

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.libs.kyori.adventure.text.format.TextDecoration
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.legacyimpl.NBTLegacyHoverEventSerializer; import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.legacyimpl.NBTLegacyHoverEventSerializer;
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import java.util.logging.Level;
public final class ChatRewriter { public final class ChatRewriter {
public static final GsonComponentSerializer HOVER_GSON_SERIALIZER = GsonComponentSerializer.builder().emitLegacyHoverEvent().legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get()).build(); public static final GsonComponentSerializer HOVER_GSON_SERIALIZER = GsonComponentSerializer.builder().emitLegacyHoverEvent().legacyHoverEventSerializer(NBTLegacyHoverEventSerializer.get()).build();
@ -62,8 +63,7 @@ public final class ChatRewriter {
Component component = HOVER_GSON_SERIALIZER.deserialize(value); Component component = HOVER_GSON_SERIALIZER.deserialize(value);
return LegacyComponentSerializer.legacySection().serialize(component); return LegacyComponentSerializer.legacySection().serialize(component);
} catch (Exception e) { } catch (Exception e) {
Via.getPlatform().getLogger().warning("Error converting json text to legacy: " + value); Via.getPlatform().getLogger().log(Level.WARNING, "Error converting json text to legacy: " + value, e);
e.printStackTrace();
return ""; return "";
} }
} }

Datei anzeigen

@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
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.rewriter.ComponentRewriter; import com.viaversion.viaversion.rewriter.ComponentRewriter;
import java.util.logging.Level;
public class ComponentRewriter1_13<C extends ClientboundPacketType> extends ComponentRewriter<C> { public class ComponentRewriter1_13<C extends ClientboundPacketType> extends ComponentRewriter<C> {
@ -56,8 +57,7 @@ public class ComponentRewriter1_13<C extends ClientboundPacketType> extends Comp
tag = SNBT.deserializeCompoundTag(text); tag = SNBT.deserializeCompoundTag(text);
} catch (Exception e) { } catch (Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Error reading NBT in show_item:" + text); Via.getPlatform().getLogger().log(Level.WARNING, "Error reading NBT in show_item:" + text, e);
e.printStackTrace();
} }
return; return;
} }
@ -89,8 +89,7 @@ public class ComponentRewriter1_13<C extends ClientboundPacketType> extends Comp
object.addProperty("text", serializedNBT); object.addProperty("text", serializedNBT);
hoverEvent.add("value", array); hoverEvent.add("value", array);
} catch (Exception e) { } catch (Exception e) {
Via.getPlatform().getLogger().warning("Error writing NBT in show_item:" + text); Via.getPlatform().getLogger().log(Level.WARNING, "Error writing NBT in show_item:" + text, e);
e.printStackTrace();
} }
} }

Datei anzeigen

@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.data.MappingDataLoader;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
public class MappingData extends MappingDataBase { public class MappingData extends MappingDataBase {
private final Map<String, CompoundTag> dimensionDataMap = new HashMap<>(); private final Map<String, CompoundTag> dimensionDataMap = new HashMap<>();
@ -42,8 +43,7 @@ public class MappingData extends MappingDataBase {
try { try {
dimensionRegistry = NBTIO.readTag(MappingDataLoader.getResource("dimension-registry-1.16.2.nbt")); dimensionRegistry = NBTIO.readTag(MappingDataLoader.getResource("dimension-registry-1.16.2.nbt"));
} catch (final IOException e) { } catch (final IOException e) {
Via.getPlatform().getLogger().severe("Error loading dimension registry:"); Via.getPlatform().getLogger().log(Level.SEVERE, "Error loading dimension registry:", e);
e.printStackTrace();
} }
// Data of each dimension // Data of each dimension

Datei anzeigen

@ -71,6 +71,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;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPackets1_20_2, ClientboundPackets1_20_3, ServerboundPackets1_20_2, ServerboundPackets1_20_3> { public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPackets1_20_2, ClientboundPackets1_20_3, ServerboundPackets1_20_2, ServerboundPackets1_20_3> {
@ -348,8 +349,7 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
try { try {
return convertToJson(null, tag); return convertToJson(null, tag);
} catch (final Exception e) { } catch (final Exception e) {
Via.getPlatform().getLogger().severe("Error converting component: " + tag); Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting component: " + tag, e);
e.printStackTrace();
return new JsonPrimitive("<error>"); return new JsonPrimitive("<error>");
} }
} }
@ -358,8 +358,7 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
try { try {
return convertToTag(component); return convertToTag(component);
} catch (final Exception e) { } catch (final Exception e) {
Via.getPlatform().getLogger().severe("Error converting component: " + component); Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting component: " + component, e);
e.printStackTrace();
return new StringTag("<error>"); return new StringTag("<error>");
} }
} }

Datei anzeigen

@ -50,6 +50,7 @@ import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
@ -598,7 +599,7 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
+ " for " + (type != null ? type.name() : "untracked") + " entity type: " + metadata); + " for " + (type != null ? type.name() : "untracked") + " entity type: " + metadata);
logger.severe(metadataList.stream().sorted(Comparator.comparingInt(Metadata::id)) logger.severe(metadataList.stream().sorted(Comparator.comparingInt(Metadata::id))
.map(Metadata::toString).collect(Collectors.joining("\n", "Full metadata: ", ""))); .map(Metadata::toString).collect(Collectors.joining("\n", "Full metadata: ", "")));
e.printStackTrace(); logger.log(Level.SEVERE, "Error: ", e);
} }
} }
} }

Datei anzeigen

@ -24,11 +24,7 @@ import java.util.List;
public class VelocityCommandHandler extends ViaCommandHandler implements SimpleCommand { public class VelocityCommandHandler extends ViaCommandHandler implements SimpleCommand {
public VelocityCommandHandler() { public VelocityCommandHandler() {
try {
registerSubCommand(new ProbeSubCmd()); registerSubCommand(new ProbeSubCmd());
} catch (Exception e) {
e.printStackTrace();
}
} }
@Override @Override