mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI.git
synced 2024-12-30 21:07:42 +01:00
Merge pull request #517 from PlaceholderAPI/fix/515-improve-logging
Fixing issues for logging when Expansion doesn't contain any classes.
This commit is contained in:
commit
d342c73f24
@ -22,27 +22,11 @@ package me.clip.placeholderapi.expansion.manager;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import java.io.File;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.CompletionException;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.events.ExpansionRegisterEvent;
|
import me.clip.placeholderapi.events.ExpansionRegisterEvent;
|
||||||
import me.clip.placeholderapi.events.ExpansionUnregisterEvent;
|
import me.clip.placeholderapi.events.ExpansionUnregisterEvent;
|
||||||
import me.clip.placeholderapi.events.ExpansionsLoadedEvent;
|
import me.clip.placeholderapi.events.ExpansionsLoadedEvent;
|
||||||
import me.clip.placeholderapi.expansion.Cacheable;
|
import me.clip.placeholderapi.expansion.*;
|
||||||
import me.clip.placeholderapi.expansion.Cleanable;
|
|
||||||
import me.clip.placeholderapi.expansion.Configurable;
|
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
|
||||||
import me.clip.placeholderapi.expansion.Taskable;
|
|
||||||
import me.clip.placeholderapi.expansion.VersionSpecific;
|
|
||||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||||
import me.clip.placeholderapi.util.FileUtil;
|
import me.clip.placeholderapi.util.FileUtil;
|
||||||
import me.clip.placeholderapi.util.Futures;
|
import me.clip.placeholderapi.util.Futures;
|
||||||
@ -61,6 +45,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public final class LocalExpansionManager implements Listener {
|
public final class LocalExpansionManager implements Listener {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ -167,9 +159,9 @@ public final class LocalExpansionManager implements Listener {
|
|||||||
|
|
||||||
return Optional.of(expansion);
|
return Optional.of(expansion);
|
||||||
} catch (final LinkageError ex) {
|
} catch (final LinkageError ex) {
|
||||||
plugin.getLogger().severe("expansion class " + clazz.getSimpleName() + " is outdated: \n" +
|
plugin.getLogger().severe("Failed to load Expansion class " + clazz.getSimpleName() +
|
||||||
"Failed to load due to a [" + ex.getClass().getSimpleName() + "], attempted to use " + ex
|
" (Is a dependency missing?)");
|
||||||
.getMessage());
|
plugin.getLogger().severe("Cause: " + ex.getClass().getSimpleName() + " " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@ -218,9 +210,8 @@ public final class LocalExpansionManager implements Listener {
|
|||||||
if (expansion instanceof VersionSpecific) {
|
if (expansion instanceof VersionSpecific) {
|
||||||
VersionSpecific nms = (VersionSpecific) expansion;
|
VersionSpecific nms = (VersionSpecific) expansion;
|
||||||
if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion())) {
|
if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion())) {
|
||||||
plugin.getLogger().info(
|
plugin.getLogger().warning("Your server version is not compatible with expansion " +
|
||||||
"Your server version is not compatible with expansion: " + expansion.getIdentifier()
|
expansion.getIdentifier() + " " + expansion.getVersion());
|
||||||
+ " version: " + expansion.getVersion());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,6 +325,7 @@ public final class LocalExpansionManager implements Listener {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public CompletableFuture<@NotNull List<@NotNull Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk() {
|
public CompletableFuture<@NotNull List<@NotNull Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk() {
|
||||||
return Arrays.stream(folder.listFiles((dir, name) -> name.endsWith(".jar")))
|
return Arrays.stream(folder.listFiles((dir, name) -> name.endsWith(".jar")))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.map(this::findExpansionInFile)
|
.map(this::findExpansionInFile)
|
||||||
.collect(Futures.collector());
|
.collect(Futures.collector());
|
||||||
}
|
}
|
||||||
@ -345,9 +337,9 @@ public final class LocalExpansionManager implements Listener {
|
|||||||
try {
|
try {
|
||||||
return FileUtil.findClass(file, PlaceholderExpansion.class);
|
return FileUtil.findClass(file, PlaceholderExpansion.class);
|
||||||
} catch (final VerifyError ex) {
|
} catch (final VerifyError ex) {
|
||||||
plugin.getLogger().severe("expansion file " + file.getName() + " is outdated: \n" +
|
plugin.getLogger().severe("Failed to load Expansion class " + file.getName() +
|
||||||
"Failed to load due to a [" + ex.getClass().getSimpleName() + "], attempted to use" + ex
|
" (Is a dependency missing?)");
|
||||||
.getMessage().substring(ex.getMessage().lastIndexOf(' ')));
|
plugin.getLogger().severe("Cause: " + ex.getClass().getSimpleName() + " " + ex.getMessage());
|
||||||
return null;
|
return null;
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
throw new CompletionException(ex);
|
throw new CompletionException(ex);
|
||||||
@ -366,9 +358,8 @@ public final class LocalExpansionManager implements Listener {
|
|||||||
throw ((LinkageError) ex.getCause());
|
throw ((LinkageError) ex.getCause());
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getLogger()
|
plugin.getLogger().warning("There was an issue with loading an expansion");
|
||||||
.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