mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-10-31 23:59:33 +01:00
Some cleanup
This commit is contained in:
parent
1af2103f6c
commit
a0f8ab7bbb
@ -32,7 +32,7 @@ public interface ViaVersionCommand {
|
||||
* @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
|
||||
*/
|
||||
void registerSubCommand(ViaSubCommand command) throws Exception;
|
||||
void registerSubCommand(ViaSubCommand command);
|
||||
|
||||
/**
|
||||
* Check if a subcommand is registered.
|
||||
|
@ -48,6 +48,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -111,8 +112,7 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
||||
try {
|
||||
new PlayerSneakListener(plugin, use1_9Fix, plugin.getConf().is1_14HitboxFix()).register();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
Via.getPlatform().getLogger().warning("Could not load hitbox fix - please report this on our GitHub");
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Could not load hitbox fix - please report this on our GitHub", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,9 +165,7 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
||||
return null;
|
||||
}).get(10, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
Via.getPlatform().getLogger().severe("Error fetching hand item: " + e.getClass().getName());
|
||||
if (Via.getManager().isDebug())
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, "Error fetching hand item", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -17,17 +17,11 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.bungee.commands;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.bungee.commands.subs.ProbeSubCmd;
|
||||
import com.viaversion.viaversion.commands.ViaCommandHandler;
|
||||
|
||||
public class BungeeCommandHandler extends ViaCommandHandler {
|
||||
public BungeeCommandHandler() {
|
||||
try {
|
||||
registerSubCommand(new ProbeSubCmd());
|
||||
} catch (Exception e) {
|
||||
Via.getPlatform().getLogger().severe("Failed to register Bungee subcommands");
|
||||
e.printStackTrace();
|
||||
}
|
||||
registerSubCommand(new ProbeSubCmd());
|
||||
}
|
||||
}
|
||||
|
@ -28,27 +28,14 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
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
|
||||
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)
|
||||
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);
|
||||
Collections.sort(sorted);
|
||||
|
||||
@ -79,7 +66,7 @@ public class BungeeVersionProvider extends BaseVersionProvider {
|
||||
public static int getLowestSupportedVersion() {
|
||||
List<Integer> list;
|
||||
try {
|
||||
list = ReflectionUtil.getStatic(ref, "SUPPORTED_VERSION_IDS", List.class);
|
||||
list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class);
|
||||
return list.get(0);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -49,6 +49,7 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -99,8 +100,7 @@ public class ViaManagerImpl implements ViaManager {
|
||||
try {
|
||||
injector.inject();
|
||||
} catch (Exception e) {
|
||||
platform.getLogger().severe("ViaVersion failed to inject:");
|
||||
e.printStackTrace();
|
||||
platform.getLogger().log(Level.SEVERE, "ViaVersion failed to inject:", e);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -196,8 +196,7 @@ public class ViaManagerImpl implements ViaManager {
|
||||
|
||||
protocolManager.setServerProtocol(versionInfo);
|
||||
} catch (Exception e) {
|
||||
platform.getLogger().severe("ViaVersion failed to get the server protocol!");
|
||||
e.printStackTrace();
|
||||
platform.getLogger().log(Level.SEVERE, "ViaVersion failed to get the server protocol!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,8 +206,7 @@ public class ViaManagerImpl implements ViaManager {
|
||||
try {
|
||||
injector.uninject();
|
||||
} catch (Exception e) {
|
||||
platform.getLogger().severe("ViaVersion failed to uninject:");
|
||||
e.printStackTrace();
|
||||
platform.getLogger().log(Level.SEVERE, "ViaVersion failed to uninject:", e);
|
||||
}
|
||||
|
||||
loader.unload();
|
||||
@ -228,8 +226,7 @@ public class ViaManagerImpl implements ViaManager {
|
||||
try {
|
||||
version = Integer.parseInt(versionString);
|
||||
} catch (NumberFormatException e) {
|
||||
platform.getLogger().warning("Failed to determine Java version; could not parse: " + versionString);
|
||||
e.printStackTrace();
|
||||
platform.getLogger().log(Level.WARNING, "Failed to determine Java version; could not parse: " + versionString, e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import io.netty.channel.ChannelPipeline;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class LegacyViaInjector implements ViaInjector {
|
||||
@ -141,8 +142,7 @@ public abstract class LegacyViaInjector implements ViaInjector {
|
||||
ReflectionUtil.set(bootstrapAcceptor, "childHandler", ((WrappedChannelInitializer) initializer).original());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Via.getPlatform().getLogger().severe("Failed to remove injection handler, reload won't work with connections, please reboot!");
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to remove injection handler, reload won't work with connections, please reboot!", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectSortedMap;
|
||||
import java.util.logging.Level;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
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) {
|
||||
return throwable -> {
|
||||
Via.getPlatform().getLogger().severe("Error during mapping loading of " + protocolClass.getSimpleName());
|
||||
throwable.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, "Error during mapping loading of " + protocolClass.getSimpleName(), throwable);
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
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()) {
|
||||
Via.getPlatform().getLogger().warning("An error occurred with entity type rewriter");
|
||||
Via.getPlatform().getLogger().warning("Metadata: " + metadata);
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Error: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class TranslateRewriter {
|
||||
|
||||
@ -91,8 +92,7 @@ public class TranslateRewriter {
|
||||
hoverEvent.addProperty("action", "show_text");
|
||||
hoverEvent.add("value", baseArray);
|
||||
} catch (Exception e) {
|
||||
Via.getPlatform().getLogger().warning("Error rewriting show_achievement: " + hoverEvent);
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Error rewriting show_achievement: " + hoverEvent, e);
|
||||
JsonObject invalidText = new JsonObject();
|
||||
invalidText.addProperty("text", "Invalid statistic/achievement!");
|
||||
invalidText.addProperty("color", "red");
|
||||
|
@ -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.legacyimpl.NBTLegacyHoverEventSerializer;
|
||||
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class ChatRewriter {
|
||||
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);
|
||||
return LegacyComponentSerializer.legacySection().serialize(component);
|
||||
} catch (Exception e) {
|
||||
Via.getPlatform().getLogger().warning("Error converting json text to legacy: " + value);
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Error converting json text to legacy: " + value, e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
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.rewriter.ComponentRewriter;
|
||||
import java.util.logging.Level;
|
||||
|
||||
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);
|
||||
} catch (Exception e) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Error reading NBT in show_item:" + text);
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Error reading NBT in show_item:" + text, e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -89,8 +89,7 @@ public class ComponentRewriter1_13<C extends ClientboundPacketType> extends Comp
|
||||
object.addProperty("text", serializedNBT);
|
||||
hoverEvent.add("value", array);
|
||||
} catch (Exception e) {
|
||||
Via.getPlatform().getLogger().warning("Error writing NBT in show_item:" + text);
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.WARNING, "Error writing NBT in show_item:" + text, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class MappingData extends MappingDataBase {
|
||||
private final Map<String, CompoundTag> dimensionDataMap = new HashMap<>();
|
||||
@ -42,8 +43,7 @@ public class MappingData extends MappingDataBase {
|
||||
try {
|
||||
dimensionRegistry = NBTIO.readTag(MappingDataLoader.getResource("dimension-registry-1.16.2.nbt"));
|
||||
} catch (final IOException e) {
|
||||
Via.getPlatform().getLogger().severe("Error loading dimension registry:");
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, "Error loading dimension registry:", e);
|
||||
}
|
||||
|
||||
// Data of each dimension
|
||||
|
@ -71,6 +71,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
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> {
|
||||
@ -348,8 +349,7 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
|
||||
try {
|
||||
return convertToJson(null, tag);
|
||||
} catch (final Exception e) {
|
||||
Via.getPlatform().getLogger().severe("Error converting component: " + tag);
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting component: " + tag, e);
|
||||
return new JsonPrimitive("<error>");
|
||||
}
|
||||
}
|
||||
@ -358,8 +358,7 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
|
||||
try {
|
||||
return convertToTag(component);
|
||||
} catch (final Exception e) {
|
||||
Via.getPlatform().getLogger().severe("Error converting component: " + component);
|
||||
e.printStackTrace();
|
||||
Via.getPlatform().getLogger().log(Level.SEVERE, "Error converting component: " + component, e);
|
||||
return new StringTag("<error>");
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
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);
|
||||
logger.severe(metadataList.stream().sorted(Comparator.comparingInt(Metadata::id))
|
||||
.map(Metadata::toString).collect(Collectors.joining("\n", "Full metadata: ", "")));
|
||||
e.printStackTrace();
|
||||
logger.log(Level.SEVERE, "Error: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,11 +24,7 @@ import java.util.List;
|
||||
|
||||
public class VelocityCommandHandler extends ViaCommandHandler implements SimpleCommand {
|
||||
public VelocityCommandHandler() {
|
||||
try {
|
||||
registerSubCommand(new ProbeSubCmd());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
registerSubCommand(new ProbeSubCmd());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user