mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI.git
synced 2024-12-29 12:28:21 +01:00
updated local expansion to not catch potential linkage errors, and report them. closes #377
This commit is contained in:
parent
30ead2ae4b
commit
07cd344123
@ -228,6 +228,8 @@ public final class LocalExpansionManager implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Optional<PlaceholderExpansion> register(@NotNull final Class<? extends PlaceholderExpansion> clazz)
|
public Optional<PlaceholderExpansion> register(@NotNull final Class<? extends PlaceholderExpansion> clazz)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
final PlaceholderExpansion expansion = createExpansionInstance(clazz);
|
final PlaceholderExpansion expansion = createExpansionInstance(clazz);
|
||||||
if (expansion == null || !expansion.register())
|
if (expansion == null || !expansion.register())
|
||||||
@ -237,6 +239,14 @@ public final class LocalExpansionManager implements Listener
|
|||||||
|
|
||||||
return Optional.of(expansion);
|
return Optional.of(expansion);
|
||||||
}
|
}
|
||||||
|
catch (final LinkageError ex)
|
||||||
|
{
|
||||||
|
plugin.getLogger().severe("expansion class " + clazz.getSimpleName() + " is outdated: \n" +
|
||||||
|
"Failed to load due to a [" + ex.getClass().getSimpleName() + "], attempted to use " + ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean unregister(@NotNull final PlaceholderExpansion expansion)
|
public boolean unregister(@NotNull final PlaceholderExpansion expansion)
|
||||||
{
|
{
|
||||||
@ -347,13 +357,13 @@ public final class LocalExpansionManager implements Listener
|
|||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public PlaceholderExpansion createExpansionInstance(@NotNull final Class<? extends PlaceholderExpansion> clazz)
|
public PlaceholderExpansion createExpansionInstance(@NotNull final Class<? extends PlaceholderExpansion> clazz) throws LinkageError
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return clazz.getDeclaredConstructor().newInstance();
|
return clazz.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
catch (final Throwable ex)
|
catch (final Exception ex)
|
||||||
{
|
{
|
||||||
plugin.getLogger().log(Level.SEVERE, "Failed to load placeholder expansion from class: " + clazz.getName(), ex);
|
plugin.getLogger().log(Level.SEVERE, "Failed to load placeholder expansion from class: " + clazz.getName(), ex);
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user