Guard logging code because of paper changes

This commit is contained in:
GeorgH93 2023-02-26 22:36:35 +01:00
parent 36c6964109
commit 4e2502da1d
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
2 changed files with 26 additions and 6 deletions

View File

@ -28,7 +28,6 @@
import io.papermc.paper.plugin.bootstrap.PluginProviderContext; import io.papermc.paper.plugin.bootstrap.PluginProviderContext;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.logging.Level;
@SuppressWarnings({ "UnstableApiUsage", "unused" }) @SuppressWarnings({ "UnstableApiUsage", "unused" })
public class MinepacksBootstrap implements PluginBootstrap public class MinepacksBootstrap implements PluginBootstrap
@ -75,7 +74,15 @@ private boolean patchPluginMeta(final @NotNull PluginProviderContext context)
} }
catch(Exception e) catch(Exception e)
{ {
context.getLogger().log(Level.SEVERE, "Failed to patch main class in PluginMeta! Falling back to Standalone mode!", e); try
{
context.getLogger().error("Failed to patch main class in PluginMeta! Falling back to Standalone mode!", e);
}
catch(Throwable ignored)
{
System.out.println("[Minepacks] Failed to patch main class in PluginMeta! Falling back to Standalone mode!");
e.printStackTrace();
}
} }
return false; return false;
} }
@ -87,18 +94,31 @@ private boolean checkPcgfPluginLib(final @NotNull PluginProviderContext context)
{ {
if (new Version(version).olderThan(new Version(MagicValues.MIN_PCGF_PLUGIN_LIB_VERSION))) if (new Version(version).olderThan(new Version(MagicValues.MIN_PCGF_PLUGIN_LIB_VERSION)))
{ {
context.getLogger().info("PCGF-PluginLib to old! Switching to standalone mode!"); logInfo("PCGF-PluginLib to old! Switching to standalone mode!", context);
} }
else else
{ {
context.getLogger().info("PCGF-PluginLib installed. Switching to normal mode!"); logInfo("PCGF-PluginLib installed. Switching to normal mode!", context);
return true; return true;
} }
} }
else else
{ {
context.getLogger().info("PCGF-PluginLib not installed. Switching to standalone mode!"); logInfo("PCGF-PluginLib not installed. Switching to standalone mode!", context);
} }
return false; return false;
} }
//TODO remove this stupid code once the paper API stabilizes to a point where once can expect at least the logger class ot not randomly change
private void logInfo(final @NotNull String message, final @NotNull PluginProviderContext context)
{
try
{
context.getLogger().info(message);
}
catch(Throwable t)
{
System.out.println("[Minepacks] Failed to log message: " + message);
}
}
} }

View File

@ -7,7 +7,7 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<properties> <properties>
<revision>2.4.13.1</revision> <revision>2.4.14</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>