From b99335e5b26162a7e9836ad1f4f8c2ce88567e1d Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Sun, 27 Dec 2020 18:47:48 +0100 Subject: [PATCH 01/14] First step at fixing #515 and for #516 --- .../manager/LocalExpansionManager.java | 55 +++++++++---------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java index 6ec3153..19cf234 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -22,27 +22,11 @@ package me.clip.placeholderapi.expansion.manager; import com.google.common.collect.ImmutableSet; 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.events.ExpansionRegisterEvent; import me.clip.placeholderapi.events.ExpansionUnregisterEvent; import me.clip.placeholderapi.events.ExpansionsLoadedEvent; -import me.clip.placeholderapi.expansion.Cacheable; -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.*; import me.clip.placeholderapi.expansion.cloud.CloudExpansion; import me.clip.placeholderapi.util.FileUtil; import me.clip.placeholderapi.util.Futures; @@ -61,6 +45,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; 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 { @NotNull @@ -167,9 +159,9 @@ public final class LocalExpansionManager implements Listener { 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()); + plugin.getLogger().severe("Failed to load Expansion class " + clazz.getSimpleName() + + " (Is a dependency missing?)"); + plugin.getLogger().severe("Cause: " + ex.getClass().getSimpleName() + " " + ex.getMessage()); } return Optional.empty(); @@ -218,9 +210,8 @@ public final class LocalExpansionManager implements Listener { if (expansion instanceof VersionSpecific) { VersionSpecific nms = (VersionSpecific) expansion; if (!nms.isCompatibleWith(PlaceholderAPIPlugin.getServerVersion())) { - plugin.getLogger().info( - "Your server version is not compatible with expansion: " + expansion.getIdentifier() - + " version: " + expansion.getVersion()); + plugin.getLogger().warning("Your server version is not compatible with expansion " + + expansion.getIdentifier() + " " + expansion.getVersion()); return false; } } @@ -334,6 +325,7 @@ public final class LocalExpansionManager implements Listener { @NotNull public CompletableFuture<@NotNull List<@NotNull Class>> findExpansionsOnDisk() { return Arrays.stream(folder.listFiles((dir, name) -> name.endsWith(".jar"))) + .filter(Objects::nonNull) .map(this::findExpansionInFile) .collect(Futures.collector()); } @@ -345,9 +337,9 @@ public final class LocalExpansionManager implements Listener { try { return FileUtil.findClass(file, PlaceholderExpansion.class); } catch (final VerifyError ex) { - plugin.getLogger().severe("expansion file " + file.getName() + " is outdated: \n" + - "Failed to load due to a [" + ex.getClass().getSimpleName() + "], attempted to use" + ex - .getMessage().substring(ex.getMessage().lastIndexOf(' '))); + plugin.getLogger().severe("Failed to load Expansion class " + file.getName() + + " (Is a dependency missing?)"); + plugin.getLogger().severe("Cause: " + ex.getClass().getSimpleName() + " " + ex.getMessage()); return null; } catch (final Exception ex) { throw new CompletionException(ex); @@ -365,10 +357,13 @@ public final class LocalExpansionManager implements Listener { if (ex.getCause() instanceof LinkageError) { throw ((LinkageError) ex.getCause()); } - - plugin.getLogger() - .log(Level.SEVERE, "Failed to load placeholder expansion from class: " + clazz.getName(), - ex); + + /* Currently causes an exception when clazz is null due to an expansion not having any. + * + *plugin.getLogger() + * .log(Level.SEVERE, "Failed to load placeholder expansion from class: " + clazz.getName(), + * ex); + */ return null; } } From e8b5660eda3046aee98396ac046537d8f92e78d9 Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 28 Dec 2020 22:17:01 +0100 Subject: [PATCH 02/14] Use invalid on PR too --- .github/label-commenter-config.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/label-commenter-config.yml b/.github/label-commenter-config.yml index 0af07f2..a8f9025 100644 --- a/.github/label-commenter-config.yml +++ b/.github/label-commenter-config.yml @@ -63,6 +63,18 @@ labels: It is recommended to [join our Discord Server](https://helpch.at/discord) as you often receive faster response compared to the issue tracker here. Questions about PlaceholderAPI should be asked in our [Discussions](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions). action: close + pull_request: + body: |- + Your Pull Request has been marked as invalid. + This means that it doesn't follow our [Contributing Guidelines](https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/.github/CONTRIBUTING.md). + + Here is a small summary of what you should know: + + - Pull requests for PlaceholderAPI should target the `develop` branch. + - Pull requests for the Wiki should target the `docs/wiki` branch. + + Don't hesitate to ask us any questions. + action: close - name: 'Target: Wiki' labeled: issue: From 8fa0f73a46a5e452dc12c57580704ea394659193 Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Thu, 31 Dec 2020 18:20:11 +0100 Subject: [PATCH 03/14] Fix resolvePlayer method --- .../placeholderapi/commands/impl/local/CommandParse.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java index 5231ebf..a4cd2b3 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java @@ -212,12 +212,15 @@ public final class CommandParse extends PlaceholderCommand { @Nullable private OfflinePlayer resolvePlayer(@NotNull final String name) { OfflinePlayer target = Bukkit.getPlayer(name); - + if (target == null) { - target = Bukkit.getOfflinePlayer(name); // this is probably not a great idea. + // Not the best option, but Spigot doesn't offer a good replacement (as usual) + target = Bukkit.getOfflinePlayer(name); + + return target.hasPlayedBefore() ? target : null; } - return target.hasPlayedBefore() ? target : null; + return target; } From 6a69ec833f19cb3493dcfd79f5b97511f778507b Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Fri, 1 Jan 2021 18:19:07 +0100 Subject: [PATCH 04/14] Use getPlayerExact --- .../clip/placeholderapi/commands/impl/local/CommandParse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java index a4cd2b3..3bd8bc2 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandParse.java @@ -211,7 +211,7 @@ public final class CommandParse extends PlaceholderCommand { @Nullable private OfflinePlayer resolvePlayer(@NotNull final String name) { - OfflinePlayer target = Bukkit.getPlayer(name); + OfflinePlayer target = Bukkit.getPlayerExact(name); if (target == null) { // Not the best option, but Spigot doesn't offer a good replacement (as usual) From 0a52ef7219b43e1d244b75bce4a613e72db5dbe8 Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Sun, 3 Jan 2021 15:38:10 +0100 Subject: [PATCH 05/14] Use a generic log message for this --- .../expansion/manager/LocalExpansionManager.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java index 19cf234..5e2e0b3 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -358,12 +358,8 @@ public final class LocalExpansionManager implements Listener { throw ((LinkageError) ex.getCause()); } - /* Currently causes an exception when clazz is null due to an expansion not having any. - * - *plugin.getLogger() - * .log(Level.SEVERE, "Failed to load placeholder expansion from class: " + clazz.getName(), - * ex); - */ + plugin.getLogger().warning("There was an issue with loading an expansion"); + return null; } } From f0dccbd594ecc9d2848016de1d38436c4992a075 Mon Sep 17 00:00:00 2001 From: PiggyPiglet Date: Sun, 3 Jan 2021 23:35:37 +0800 Subject: [PATCH 06/14] update gradle --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index fcd2d75..41ba3ca 100644 --- a/build.gradle +++ b/build.gradle @@ -128,4 +128,4 @@ publishing { } } -publish.dependsOn clean, test, jar \ No newline at end of file +publish.dependsOn clean, test, jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a0edc83..c78a2b9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Tue Jul 14 23:27:02 AWST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists From 07ac8e41c554e912deb9034e048a80fd28eea566 Mon Sep 17 00:00:00 2001 From: PiggyPiglet Date: Sun, 3 Jan 2021 23:42:23 +0800 Subject: [PATCH 07/14] Fix contract violations & add null checks which should close #515 --- .../manager/LocalExpansionManager.java | 18 +++++++++++++----- .../me/clip/placeholderapi/util/FileUtil.java | 7 ++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java index 5e2e0b3..18a4c2b 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -300,7 +300,10 @@ public final class LocalExpansionManager implements Listener { return; } - final long registered = classes.stream().map(this::register).filter(Optional::isPresent) + final long registered = classes.stream() + .filter(Objects::nonNull) + .map(this::register) + .filter(Optional::isPresent) .count(); Msg.msg(sender, @@ -321,11 +324,9 @@ public final class LocalExpansionManager implements Listener { } } - @NotNull - public CompletableFuture<@NotNull List<@NotNull Class>> findExpansionsOnDisk() { + public CompletableFuture<@NotNull List<@Nullable Class>> findExpansionsOnDisk() { return Arrays.stream(folder.listFiles((dir, name) -> name.endsWith(".jar"))) - .filter(Objects::nonNull) .map(this::findExpansionInFile) .collect(Futures.collector()); } @@ -335,7 +336,14 @@ public final class LocalExpansionManager implements Listener { @NotNull final File file) { return CompletableFuture.supplyAsync(() -> { try { - return FileUtil.findClass(file, PlaceholderExpansion.class); + final Class expansionClass = FileUtil.findClass(file, PlaceholderExpansion.class); + + if (expansionClass == null) { + plugin.getLogger().severe("Failed to load Expansion: " + file.getName() + ", as it does not have" + + "an a class which extends PlaceholderExpansion."); + } + + return expansionClass; } catch (final VerifyError ex) { plugin.getLogger().severe("Failed to load Expansion class " + file.getName() + " (Is a dependency missing?)"); diff --git a/src/main/java/me/clip/placeholderapi/util/FileUtil.java b/src/main/java/me/clip/placeholderapi/util/FileUtil.java index 9741a0d..7e20de1 100644 --- a/src/main/java/me/clip/placeholderapi/util/FileUtil.java +++ b/src/main/java/me/clip/placeholderapi/util/FileUtil.java @@ -20,6 +20,9 @@ package me.clip.placeholderapi.util; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import java.io.File; import java.io.IOException; import java.net.URL; @@ -28,8 +31,6 @@ import java.util.ArrayList; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class FileUtil { @@ -51,7 +52,7 @@ public class FileUtil { JarEntry entry; while ((entry = stream.getNextJarEntry()) != null) { final String name = entry.getName(); - if (name == null || name.isEmpty() || !name.endsWith(".class")) { + if (name.isEmpty() || !name.endsWith(".class")) { continue; } From 1478aabb5e8bc65c067772d91efdbf2f3ee2ad27 Mon Sep 17 00:00:00 2001 From: PiggyPiglet Date: Mon, 4 Jan 2021 10:25:38 +0800 Subject: [PATCH 08/14] remove an from log message Co-authored-by: Andre_601 <11576465+Andre601@users.noreply.github.com> --- .../placeholderapi/expansion/manager/LocalExpansionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java index 18a4c2b..2557ae2 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -340,7 +340,7 @@ public final class LocalExpansionManager implements Listener { if (expansionClass == null) { plugin.getLogger().severe("Failed to load Expansion: " + file.getName() + ", as it does not have" + - "an a class which extends PlaceholderExpansion."); + " a class which extends PlaceholderExpansion."); } return expansionClass; From 0c826a288e6cdd649ee3b42a278effc896a8d8ec Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Wed, 6 Jan 2021 14:40:33 +0100 Subject: [PATCH 09/14] Link to the wiki folder --- .github/label-commenter-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/label-commenter-config.yml b/.github/label-commenter-config.yml index a8f9025..048b4c7 100644 --- a/.github/label-commenter-config.yml +++ b/.github/label-commenter-config.yml @@ -86,7 +86,7 @@ labels: When doing so, make sure you follow these steps: - The Pull request targets the [`docs/wiki`](https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki) branch of the Repository. - - You only made changes to the files inside the `wiki` folder. + - You only made changes to the files inside the [`wiki`](https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki/wiki) folder. - You followed the general Styling Guidelines mentioned in the wiki's [README](https://github.com/PlaceholderAPI/PlaceholderAPI/blob/docs/wiki/wiki/README.md) file. If you have any questions about submitting a PR for the wiki or have any other questions don't hesitate to ask us about it. From c9492564e0d1251f022f720e6fa2d49653e29cb9 Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Wed, 6 Jan 2021 16:42:32 +0100 Subject: [PATCH 10/14] Mention Discussion entry --- .github/label-commenter-config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/label-commenter-config.yml b/.github/label-commenter-config.yml index 048b4c7..dfcfd6c 100644 --- a/.github/label-commenter-config.yml +++ b/.github/label-commenter-config.yml @@ -16,6 +16,7 @@ labels: This issue-tracker is reserved for Bug reports and feature requests towards PlaceholderAPI. Please report this issue to the Expansion's main issue-tracker. + A list of known Expansion repositories and their issue trackers can be found [here](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions/510#discussion-63812). action: close - name: 'Type: Duplicate' labeled: From f605db479ba9e89f544aae0902d666fc2599003e Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 11 Jan 2021 22:16:39 +0100 Subject: [PATCH 11/14] Improve message --- .github/label-commenter-config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/label-commenter-config.yml b/.github/label-commenter-config.yml index dfcfd6c..b87c77c 100644 --- a/.github/label-commenter-config.yml +++ b/.github/label-commenter-config.yml @@ -109,10 +109,11 @@ labels: labeled: issue: body: |- - The issue was marked as "inactive" which means it didn't recieve any responses from the Author ({{ issue.user.login }}) for a long period of time. - To keep the issue-tracker clean and up to date are we closing issues, that didn't receive any responses for a long time. + The issue has been marked as **inactive** which means it didn't recieve any responses from the Author ({{ issue.user.login }}) for a long period of time. + To keep the issue-tracker clean and up to date do we close issues that haven't received any responses for a long time. - If you're the Author and this issue is still present, make sure to respond with extra info and **do not create a new issue for the same problem!** + If you're the Author of this issue and the reported problem is still present, make sure to respond with additional info to this issue. + **Do not create a new issue for the same problem!** action: close unlabeled: issue: From fb70ba64039b3f5df7491cbf618a77016bb715ec Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 11 Jan 2021 22:22:34 +0100 Subject: [PATCH 12/14] Update invalid link --- .github/label-commenter-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/label-commenter-config.yml b/.github/label-commenter-config.yml index b87c77c..fe36911 100644 --- a/.github/label-commenter-config.yml +++ b/.github/label-commenter-config.yml @@ -131,5 +131,5 @@ labels: Remember to first read the [READ ME](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions/507) post to not face any issues. - For questions do we recommend to use the [Q&A Category](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions?discussions_q=category%3AQ%26A). + For questions do we recommend to use the [Q&A Category](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions/categories/-2-support). You can also use the Discussion to submit Feature requests (Feature requests through issues are still accepted tho). From c3ee5bbdc0b84a2be853ccb22a51dc1f7c9c8199 Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 11 Jan 2021 22:28:32 +0100 Subject: [PATCH 13/14] Actually was renamed too --- .github/label-commenter-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/label-commenter-config.yml b/.github/label-commenter-config.yml index fe36911..b047b6f 100644 --- a/.github/label-commenter-config.yml +++ b/.github/label-commenter-config.yml @@ -131,5 +131,5 @@ labels: Remember to first read the [READ ME](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions/507) post to not face any issues. - For questions do we recommend to use the [Q&A Category](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions/categories/-2-support). + For questions do we recommend to use the [(2) Support](https://github.com/PlaceholderAPI/PlaceholderAPI/discussions/categories/-2-support) category. You can also use the Discussion to submit Feature requests (Feature requests through issues are still accepted tho). From 9b9e0e4b9e0d9288775bcca41ec1451f90d56c3c Mon Sep 17 00:00:00 2001 From: Leon Mangler <8205464+LeonMangler@users.noreply.github.com> Date: Mon, 18 Jan 2021 22:00:02 +0100 Subject: [PATCH 14/14] Update PremiumVanish placeholders --- wiki/Placeholders.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wiki/Placeholders.md b/wiki/Placeholders.md index 4c2f9bf..891a152 100644 --- a/wiki/Placeholders.md +++ b/wiki/Placeholders.md @@ -3001,8 +3001,12 @@ Check [Plan Wiki](https://github.com/plan-player-analytics/Plan/wiki/Placeholder %premiumvanish_isvanished% %premiumvanish_vanishedplayers% %premiumvanish_playercount% +%premiumvanish_playercountwithoutshowintab% %premiumvanish_bungeeplayercount% %premiumvanish_bungeeplayercount@% +%premiumvanish_target% +%premiumvanish_uselevel% +%premiumvanish_seelevel% ``` `` is the name of the server it should show the playercount of.