From cfd289939efa3a950ca05abb0eef8a202cd7ee91 Mon Sep 17 00:00:00 2001 From: PiggyPiglet Date: Mon, 13 Dec 2021 15:03:33 +0800 Subject: [PATCH] Merge pull request #667 from PlaceholderAPI/fix/666-lowercase-issues Fix issue with invalid placeholder pattern lowercasing text --- .../java/me/clip/placeholderapi/PlaceholderAPI.java | 4 ++-- .../me/clip/placeholderapi/PlaceholderAPIPlugin.java | 3 +-- .../java/me/clip/placeholderapi/PlaceholderHook.java | 1 - .../placeholderapi/expansion/cloud/CloudExpansion.java | 2 +- .../listeners/ServerLoadEventListener.java | 10 ---------- .../me/clip/placeholderapi/replacer/CharsReplacer.java | 2 +- src/main/java/me/clip/placeholderapi/util/Format.java | 2 +- 7 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java index beb93ce..4aff339 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java @@ -81,7 +81,7 @@ public final class PlaceholderAPI { */ @NotNull public static List setPlaceholders(final OfflinePlayer player, - @NotNull final List<@NotNull String> text) { + @NotNull final List text) { return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList()); } @@ -136,7 +136,7 @@ public final class PlaceholderAPI { */ @NotNull public static List setBracketPlaceholders(final OfflinePlayer player, - @NotNull final List<@NotNull String> text) { + @NotNull final List text) { return text.stream().map(line -> setBracketPlaceholders(player, line)) .collect(Collectors.toList()); } diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java b/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java index b121bd3..f0e590e 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java @@ -33,7 +33,6 @@ import me.clip.placeholderapi.expansion.manager.LocalExpansionManager; import me.clip.placeholderapi.listeners.ServerLoadEventListener; import me.clip.placeholderapi.updatechecker.UpdateChecker; import net.kyori.adventure.platform.bukkit.BukkitAudiences; -import net.kyori.adventure.text.serializer.craftbukkit.MinecraftComponentSerializer; import org.bstats.bukkit.Metrics; import org.bstats.charts.AdvancedPie; import org.bstats.charts.SimplePie; @@ -249,7 +248,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin { try { Class.forName("org.bukkit.event.server.ServerLoadEvent"); new ServerLoadEventListener(this); - } catch (final ExceptionInInitializerError | ClassNotFoundException ignored) { + } catch (final ClassNotFoundException ignored) { Bukkit.getScheduler() .runTaskLater(this, () -> getLocalExpansionManager().load(Bukkit.getConsoleSender()), 1); } diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderHook.java b/src/main/java/me/clip/placeholderapi/PlaceholderHook.java index 268ee86..55b2930 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderHook.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderHook.java @@ -26,7 +26,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public abstract class PlaceholderHook { - @Nullable public String onRequest(final OfflinePlayer player, @NotNull final String params) { if (player != null && player.isOnline()) { diff --git a/src/main/java/me/clip/placeholderapi/expansion/cloud/CloudExpansion.java b/src/main/java/me/clip/placeholderapi/expansion/cloud/CloudExpansion.java index b9e9566..b7db765 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/cloud/CloudExpansion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/cloud/CloudExpansion.java @@ -171,7 +171,7 @@ public class CloudExpansion { this.versions = versions; } - public class Version { + public static class Version { private String url, version, release_notes; diff --git a/src/main/java/me/clip/placeholderapi/listeners/ServerLoadEventListener.java b/src/main/java/me/clip/placeholderapi/listeners/ServerLoadEventListener.java index f7141d8..8967f3a 100644 --- a/src/main/java/me/clip/placeholderapi/listeners/ServerLoadEventListener.java +++ b/src/main/java/me/clip/placeholderapi/listeners/ServerLoadEventListener.java @@ -39,16 +39,6 @@ public final class ServerLoadEventListener implements Listener { Bukkit.getPluginManager().registerEvents(this, plugin); } - /** - * This method will be called when the server is first loaded - *

- * The goal of the method is to register all the expansions as soon as possible especially before - * players can join - *

- * This will ensure no issues with expansions and hooks. - * - * @param event the server load event - */ @EventHandler public void onServerLoad(@NotNull final ServerLoadEvent event) { HandlerList.unregisterAll(this); diff --git a/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java b/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java index 0b3bb0c..5160600 100644 --- a/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java +++ b/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java @@ -133,7 +133,7 @@ public final class CharsReplacer implements Replacer { parameters.setLength(0); if (oopsitsbad) { - builder.append(closure.head).append(identifierString); + builder.append(closure.head).append(identifier); if (identified) { builder.append('_').append(parametersString); diff --git a/src/main/java/me/clip/placeholderapi/util/Format.java b/src/main/java/me/clip/placeholderapi/util/Format.java index 1167375..558dd92 100644 --- a/src/main/java/me/clip/placeholderapi/util/Format.java +++ b/src/main/java/me/clip/placeholderapi/util/Format.java @@ -50,7 +50,7 @@ public final class Format { } @NotNull - private static String buildFormat(@NotNull final Align align, @NotNull final int[] spacing) { + private static String buildFormat(@NotNull final Align align, final int[] spacing) { return stream(spacing) .mapToObj(space -> "%" + (align == Align.LEFT ? "-" : "") + (space + 2) + "s") .collect(joining());