From 5bca9dc41f6d3c50c55aa8a14cc3de8bb98a9463 Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Thu, 24 Sep 2020 22:31:26 +0200 Subject: [PATCH 01/20] Remove Gson --- build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index bc86bfc..2590b4f 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,6 @@ repositories { } dependencies { - implementation "com.google.code.gson:gson:2.8.6" implementation "org.bstats:bstats-bukkit:1.5" compileOnly "org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT" @@ -48,7 +47,6 @@ shadowJar { archiveClassifier.set("") relocate "org.bstats", "me.clip.placeholderapi.metrics" - relocate "com.google.gson", "me.clip.placeholderapi.libs.gson" } license { @@ -116,4 +114,4 @@ publishing { } } -publish.dependsOn clean, test, jar \ No newline at end of file +publish.dependsOn clean, test, jar From c64946173b09c04bc10d007c32d90e1879f3b6d3 Mon Sep 17 00:00:00 2001 From: darbyjack Date: Fri, 25 Sep 2020 19:08:56 -0500 Subject: [PATCH 02/20] Implemented working version for 1.8.8 - 1.16.3 --- .../commands/impl/local/CommandDump.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java index d3c3637..48ab55e 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java @@ -21,7 +21,17 @@ package me.clip.placeholderapi.commands.impl.local; import com.google.common.io.CharStreams; -import com.google.gson.JsonParser; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import me.clip.placeholderapi.PlaceholderAPIPlugin; +import me.clip.placeholderapi.commands.PlaceholderCommand; +import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import me.clip.placeholderapi.util.Msg; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -41,20 +51,15 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.logging.Level; import java.util.stream.Collectors; -import me.clip.placeholderapi.PlaceholderAPIPlugin; -import me.clip.placeholderapi.commands.PlaceholderCommand; -import me.clip.placeholderapi.expansion.PlaceholderExpansion; -import me.clip.placeholderapi.util.Msg; -import org.bukkit.command.CommandSender; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Unmodifiable; public final class CommandDump extends PlaceholderCommand { @NotNull private static final String URL = "https://paste.helpch.at/"; + @NotNull + private static final Gson gson = new Gson(); + @NotNull private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.LONG) @@ -102,9 +107,8 @@ public final class CommandDump extends PlaceholderCommand { try (final InputStream stream = connection.getInputStream()) { //noinspection UnstableApiUsage - final String json = CharStreams - .toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); - return JsonParser.parseString(json).getAsJsonObject().get("key").getAsString(); + final String json = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); + return gson.fromJson(json, JsonObject.class).get("key").getAsString(); } } catch (final IOException ex) { throw new CompletionException(ex); From 0e56ea95039190eaad98a85edb8a1f257f221491 Mon Sep 17 00:00:00 2001 From: Huynh Tien Date: Sat, 6 Mar 2021 20:37:43 +0700 Subject: [PATCH 03/20] should it use setBracketPlaceholders?? --- src/main/java/me/clip/placeholderapi/PlaceholderAPI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java index e162d09..df1ffea 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java @@ -146,7 +146,7 @@ public final class PlaceholderAPI { } public static List setBracketPlaceholders(Player player, List text) { - return setPlaceholders((OfflinePlayer) player, text); + return setBracketPlaceholders((OfflinePlayer) player, text); } /** From d0e62e643434523e92b4ebe61ecbf9731079f3bb Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Tue, 13 Apr 2021 17:54:57 +0200 Subject: [PATCH 04/20] Update Copyright ~ Fixed a typo and updated missed files from #543 --- .../clip/placeholderapi/PlaceholderAPI.java | 2 +- .../placeholderapi/PlaceholderAPIPlugin.java | 2 +- .../clip/placeholderapi/PlaceholderHook.java | 2 +- .../commands/PlaceholderCommand.java | 2 +- .../commands/PlaceholderCommandRouter.java | 2 +- .../commands/impl/cloud/CommandECloud.java | 2 +- .../impl/cloud/CommandECloudClear.java | 2 +- .../impl/cloud/CommandECloudDownload.java | 2 +- .../cloud/CommandECloudExpansionInfo.java | 2 +- .../cloud/CommandECloudExpansionList.java | 2 +- .../CommandECloudExpansionPlaceholders.java | 2 +- .../impl/cloud/CommandECloudRefresh.java | 2 +- .../impl/cloud/CommandECloudStatus.java | 2 +- .../impl/cloud/CommandECloudToggle.java | 2 +- .../impl/cloud/CommandECloudUpdate.java | 2 +- .../commands/impl/local/CommandDump.java | 2 +- .../impl/local/CommandExpansionRegister.java | 2 +- .../local/CommandExpansionUnregister.java | 2 +- .../commands/impl/local/CommandHelp.java | 2 +- .../commands/impl/local/CommandInfo.java | 2 +- .../commands/impl/local/CommandList.java | 2 +- .../commands/impl/local/CommandParse.java | 2 +- .../commands/impl/local/CommandReload.java | 2 +- .../commands/impl/local/CommandVersion.java | 2 +- .../configuration/ExpansionSort.java | 2 +- .../configuration/PlaceholderAPIConfig.java | 2 +- .../events/ExpansionRegisterEvent.java | 2 +- .../events/ExpansionUnregisterEvent.java | 2 +- .../events/ExpansionsLoadedEvent.java | 4 +- .../events/PlaceholderHookUnloadEvent.java | 2 +- .../exceptions/NoDefaultCommandException.java | 2 +- .../placeholderapi/expansion/Cacheable.java | 2 +- .../placeholderapi/expansion/Cleanable.java | 2 +- .../expansion/Configurable.java | 2 +- .../placeholderapi/expansion/NMSVersion.java | 2 +- .../expansion/PlaceholderExpansion.java | 2 +- .../placeholderapi/expansion/Relational.java | 2 +- .../placeholderapi/expansion/Taskable.java | 2 +- .../placeholderapi/expansion/Version.java | 2 +- .../expansion/VersionSpecific.java | 2 +- .../expansion/cloud/CloudExpansion.java | 2 +- .../manager/CloudExpansionManager.java | 2 +- .../manager/LocalExpansionManager.java | 2 +- .../listeners/ServerLoadEventListener.java | 2 +- .../replacer/CharsReplacer.java | 52 ++----------------- .../replacer/RegexReplacer.java | 2 +- .../placeholderapi/replacer/Replacer.java | 2 +- .../updatechecker/UpdateChecker.java | 2 +- .../me/clip/placeholderapi/util/FileUtil.java | 4 +- .../me/clip/placeholderapi/util/Format.java | 4 +- .../me/clip/placeholderapi/util/Futures.java | 4 +- .../java/me/clip/placeholderapi/util/Msg.java | 4 +- .../clip/placeholderapi/util/TimeFormat.java | 4 +- .../me/clip/placeholderapi/util/TimeUtil.java | 4 +- 54 files changed, 65 insertions(+), 107 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java index 1bfec4b..beb93ce 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderAPI.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java b/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java index b0828bb..7472076 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderHook.java b/src/main/java/me/clip/placeholderapi/PlaceholderHook.java index 24d9e7c..91c3263 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderHook.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderHook.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/PlaceholderCommand.java b/src/main/java/me/clip/placeholderapi/commands/PlaceholderCommand.java index db5f496..2d6b78a 100644 --- a/src/main/java/me/clip/placeholderapi/commands/PlaceholderCommand.java +++ b/src/main/java/me/clip/placeholderapi/commands/PlaceholderCommand.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/PlaceholderCommandRouter.java b/src/main/java/me/clip/placeholderapi/commands/PlaceholderCommandRouter.java index de0c459..2a81e85 100644 --- a/src/main/java/me/clip/placeholderapi/commands/PlaceholderCommandRouter.java +++ b/src/main/java/me/clip/placeholderapi/commands/PlaceholderCommandRouter.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloud.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloud.java index 22bc053..0cfbc16 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloud.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloud.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudClear.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudClear.java index 6d6121c..3296657 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudClear.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudClear.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudDownload.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudDownload.java index 5717447..ee9e6ca 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudDownload.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudDownload.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionInfo.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionInfo.java index 7e0c5b2..267505e 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionInfo.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionInfo.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionList.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionList.java index 299da7b..e35d846 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionList.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionList.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionPlaceholders.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionPlaceholders.java index e1def67..46eda28 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionPlaceholders.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionPlaceholders.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudRefresh.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudRefresh.java index fb11086..77f023e 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudRefresh.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudRefresh.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudStatus.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudStatus.java index a264703..f1e6333 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudStatus.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudStatus.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudToggle.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudToggle.java index 85f1fff..57539d5 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudToggle.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudToggle.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudUpdate.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudUpdate.java index b2d6405..0cb4a10 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudUpdate.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudUpdate.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java index 55c06ea..d30699d 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionRegister.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionRegister.java index c6085b6..9f0bcbd 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionRegister.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionRegister.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionUnregister.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionUnregister.java index bf0861b..3d03283 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionUnregister.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionUnregister.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandHelp.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandHelp.java index f1a24bd..aeb53e7 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandHelp.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandHelp.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandInfo.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandInfo.java index 3d98b61..d4dc03a 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandInfo.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandInfo.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandList.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandList.java index 6d8506b..5a5b28a 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandList.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandList.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. 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 b077d57..60c4ff8 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 @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandReload.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandReload.java index ca48275..77ac57a 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandReload.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandReload.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandVersion.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandVersion.java index 0c7a285..4ad73dd 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandVersion.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandVersion.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/configuration/ExpansionSort.java b/src/main/java/me/clip/placeholderapi/configuration/ExpansionSort.java index ed4211d..79b1f2a 100644 --- a/src/main/java/me/clip/placeholderapi/configuration/ExpansionSort.java +++ b/src/main/java/me/clip/placeholderapi/configuration/ExpansionSort.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/configuration/PlaceholderAPIConfig.java b/src/main/java/me/clip/placeholderapi/configuration/PlaceholderAPIConfig.java index e10733e..9d9a057 100644 --- a/src/main/java/me/clip/placeholderapi/configuration/PlaceholderAPIConfig.java +++ b/src/main/java/me/clip/placeholderapi/configuration/PlaceholderAPIConfig.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/events/ExpansionRegisterEvent.java b/src/main/java/me/clip/placeholderapi/events/ExpansionRegisterEvent.java index a57c705..6f812dc 100644 --- a/src/main/java/me/clip/placeholderapi/events/ExpansionRegisterEvent.java +++ b/src/main/java/me/clip/placeholderapi/events/ExpansionRegisterEvent.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/events/ExpansionUnregisterEvent.java b/src/main/java/me/clip/placeholderapi/events/ExpansionUnregisterEvent.java index f4bef93..4c0beb1 100644 --- a/src/main/java/me/clip/placeholderapi/events/ExpansionUnregisterEvent.java +++ b/src/main/java/me/clip/placeholderapi/events/ExpansionUnregisterEvent.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java b/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java index e54b26a..b173007 100644 --- a/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java +++ b/src/main/java/me/clip/placeholderapi/events/ExpansionsLoadedEvent.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -26,7 +26,7 @@ import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; /** - * Indicates that all {@link PlaceholderExpansion PlayceholderExpansions} + * Indicates that all {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlayceholderExpansions} * have been loaded. *
This event is fired on Server load and when reloading the * confiuration. diff --git a/src/main/java/me/clip/placeholderapi/events/PlaceholderHookUnloadEvent.java b/src/main/java/me/clip/placeholderapi/events/PlaceholderHookUnloadEvent.java index 48d2edf..24a8a0b 100644 --- a/src/main/java/me/clip/placeholderapi/events/PlaceholderHookUnloadEvent.java +++ b/src/main/java/me/clip/placeholderapi/events/PlaceholderHookUnloadEvent.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/exceptions/NoDefaultCommandException.java b/src/main/java/me/clip/placeholderapi/exceptions/NoDefaultCommandException.java index 203c48e..d4ceebd 100644 --- a/src/main/java/me/clip/placeholderapi/exceptions/NoDefaultCommandException.java +++ b/src/main/java/me/clip/placeholderapi/exceptions/NoDefaultCommandException.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/Cacheable.java b/src/main/java/me/clip/placeholderapi/expansion/Cacheable.java index 7c22ca2..aa105f8 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/Cacheable.java +++ b/src/main/java/me/clip/placeholderapi/expansion/Cacheable.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/Cleanable.java b/src/main/java/me/clip/placeholderapi/expansion/Cleanable.java index e582230..b408acf 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/Cleanable.java +++ b/src/main/java/me/clip/placeholderapi/expansion/Cleanable.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/Configurable.java b/src/main/java/me/clip/placeholderapi/expansion/Configurable.java index af8bc25..a20b73b 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/Configurable.java +++ b/src/main/java/me/clip/placeholderapi/expansion/Configurable.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/NMSVersion.java b/src/main/java/me/clip/placeholderapi/expansion/NMSVersion.java index f64011b..a4b2ac3 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/NMSVersion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/NMSVersion.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java index f19da06..16c216e 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/Relational.java b/src/main/java/me/clip/placeholderapi/expansion/Relational.java index 5b315c6..6d05e94 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/Relational.java +++ b/src/main/java/me/clip/placeholderapi/expansion/Relational.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/Taskable.java b/src/main/java/me/clip/placeholderapi/expansion/Taskable.java index cedbb47..fa0ac21 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/Taskable.java +++ b/src/main/java/me/clip/placeholderapi/expansion/Taskable.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/Version.java b/src/main/java/me/clip/placeholderapi/expansion/Version.java index 4cbb1ab..0ba9029 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/Version.java +++ b/src/main/java/me/clip/placeholderapi/expansion/Version.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/VersionSpecific.java b/src/main/java/me/clip/placeholderapi/expansion/VersionSpecific.java index 97ddf42..7c91500 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/VersionSpecific.java +++ b/src/main/java/me/clip/placeholderapi/expansion/VersionSpecific.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. 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 492b980..b9e9566 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/cloud/CloudExpansion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/cloud/CloudExpansion.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/CloudExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/manager/CloudExpansionManager.java index 4ad0406..c79ee11 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/CloudExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/CloudExpansionManager.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. 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 8a86fc8..bbf01e9 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/listeners/ServerLoadEventListener.java b/src/main/java/me/clip/placeholderapi/listeners/ServerLoadEventListener.java index b3e8c46..f7141d8 100644 --- a/src/main/java/me/clip/placeholderapi/listeners/ServerLoadEventListener.java +++ b/src/main/java/me/clip/placeholderapi/listeners/ServerLoadEventListener.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java b/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java index eaa2bf8..0442442 100644 --- a/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java +++ b/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -50,58 +50,16 @@ public final class CharsReplacer implements Replacer { for (int i = 0; i < chars.length; i++) { final char l = chars[i]; - if (l == '&' && ++i < chars.length) { - final char c = Character.toLowerCase(chars[i]); - - if (c != '0' && c != '1' && c != '2' && c != '3' && c != '4' && c != '5' && c != '6' - && c != '7' && c != '8' && c != '9' && c != 'a' && c != 'b' && c != 'c' && c != 'd' - && c != 'e' && c != 'f' && c != 'k' && c != 'l' && c != 'm' && c != 'n' && c != 'o' && c != 'r' - && c != 'x') { - builder.append(l).append(chars[i]); - } else { - builder.append(ChatColor.COLOR_CHAR); - - if (c != 'x') { - builder.append(chars[i]); - continue; - } - - if ((i > 1 && chars[i - 2] == '\\') /*allow escaping &x*/) { - builder.setLength(builder.length() - 2); - builder.append('&').append(chars[i]); - continue; - } - - builder.append(c); - - int j = 0; - while (++j <= 6) { - if (i + j >= chars.length) { - break; - } - - final char x = chars[i + j]; - builder.append(ChatColor.COLOR_CHAR).append(x); - } - - if (j == 7) { - i += 6; - } else { - builder.setLength(builder.length() - (j * 2)); // undo &x parsing - } - } - continue; - } - if (l != closure.head || i + 1 >= chars.length) { builder.append(l); continue; } boolean identified = false; - boolean oopsitsbad = true; + boolean invalid = true; boolean hadSpace = false; + // Little setup to check if the placeholder is %identified_values% while (++i < chars.length) { final char p = chars[i]; @@ -110,7 +68,7 @@ public final class CharsReplacer implements Replacer { break; } if (p == closure.tail) { - oopsitsbad = false; + invalid = false; break; } @@ -132,7 +90,7 @@ public final class CharsReplacer implements Replacer { identifier.setLength(0); parameters.setLength(0); - if (oopsitsbad) { + if (invalid) { builder.append(closure.head).append(identifierString); if (identified) { diff --git a/src/main/java/me/clip/placeholderapi/replacer/RegexReplacer.java b/src/main/java/me/clip/placeholderapi/replacer/RegexReplacer.java index b9e1261..8eccfbe 100644 --- a/src/main/java/me/clip/placeholderapi/replacer/RegexReplacer.java +++ b/src/main/java/me/clip/placeholderapi/replacer/RegexReplacer.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/replacer/Replacer.java b/src/main/java/me/clip/placeholderapi/replacer/Replacer.java index b96140a..339088f 100644 --- a/src/main/java/me/clip/placeholderapi/replacer/Replacer.java +++ b/src/main/java/me/clip/placeholderapi/replacer/Replacer.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java b/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java index f914e69..bce51b8 100644 --- a/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java +++ b/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java @@ -4,7 +4,7 @@ * PlaceholderAPI * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/util/FileUtil.java b/src/main/java/me/clip/placeholderapi/util/FileUtil.java index 7e20de1..6bed142 100644 --- a/src/main/java/me/clip/placeholderapi/util/FileUtil.java +++ b/src/main/java/me/clip/placeholderapi/util/FileUtil.java @@ -2,9 +2,9 @@ * This file is part of PlaceholderAPI * * PlaceholderAPI - * Copyright (c) 2015 - 2020 PlaceholderAPI Team + * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/util/Format.java b/src/main/java/me/clip/placeholderapi/util/Format.java index 1d959c2..1167375 100644 --- a/src/main/java/me/clip/placeholderapi/util/Format.java +++ b/src/main/java/me/clip/placeholderapi/util/Format.java @@ -2,9 +2,9 @@ * This file is part of PlaceholderAPI * * PlaceholderAPI - * Copyright (c) 2015 - 2020 PlaceholderAPI Team + * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/util/Futures.java b/src/main/java/me/clip/placeholderapi/util/Futures.java index 01a3586..8f07e32 100644 --- a/src/main/java/me/clip/placeholderapi/util/Futures.java +++ b/src/main/java/me/clip/placeholderapi/util/Futures.java @@ -2,9 +2,9 @@ * This file is part of PlaceholderAPI * * PlaceholderAPI - * Copyright (c) 2015 - 2020 PlaceholderAPI Team + * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/util/Msg.java b/src/main/java/me/clip/placeholderapi/util/Msg.java index 702b251..31aa49f 100644 --- a/src/main/java/me/clip/placeholderapi/util/Msg.java +++ b/src/main/java/me/clip/placeholderapi/util/Msg.java @@ -2,9 +2,9 @@ * This file is part of PlaceholderAPI * * PlaceholderAPI - * Copyright (c) 2015 - 2020 PlaceholderAPI Team + * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/util/TimeFormat.java b/src/main/java/me/clip/placeholderapi/util/TimeFormat.java index e0b9717..9558daa 100644 --- a/src/main/java/me/clip/placeholderapi/util/TimeFormat.java +++ b/src/main/java/me/clip/placeholderapi/util/TimeFormat.java @@ -2,9 +2,9 @@ * This file is part of PlaceholderAPI * * PlaceholderAPI - * Copyright (c) 2015 - 2020 PlaceholderAPI Team + * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. diff --git a/src/main/java/me/clip/placeholderapi/util/TimeUtil.java b/src/main/java/me/clip/placeholderapi/util/TimeUtil.java index 33b14fc..85e07df 100644 --- a/src/main/java/me/clip/placeholderapi/util/TimeUtil.java +++ b/src/main/java/me/clip/placeholderapi/util/TimeUtil.java @@ -2,9 +2,9 @@ * This file is part of PlaceholderAPI * * PlaceholderAPI - * Copyright (c) 2015 - 2020 PlaceholderAPI Team + * Copyright (c) 2015 - 2021 PlaceholderAPI Team * - * PlaceholderAPI free software: you can redistribute it and/or modify + * PlaceholderAPI is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. From 4e8b1b47d13b4eb2ec3e8e4c259776a8106e3b45 Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Tue, 13 Apr 2021 17:57:59 +0200 Subject: [PATCH 05/20] Re-add removed code That should actually NOT be here... --- .../replacer/CharsReplacer.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java b/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java index 0442442..702e173 100644 --- a/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java +++ b/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java @@ -49,6 +49,49 @@ public final class CharsReplacer implements Replacer { for (int i = 0; i < chars.length; i++) { final char l = chars[i]; + + if (l == '&' && ++i < chars.length) { + final char c = Character.toLowerCase(chars[i]); + + if (c != '0' && c != '1' && c != '2' && c != '3' && c != '4' && c != '5' && c != '6' + && c != '7' && c != '8' && c != '9' && c != 'a' && c != 'b' && c != 'c' && c != 'd' + && c != 'e' && c != 'f' && c != 'k' && c != 'l' && c != 'm' && c != 'n' && c != 'o' && c != 'r' + && c != 'x') { + builder.append(l).append(chars[i]); + } else { + builder.append(ChatColor.COLOR_CHAR); + + if (c != 'x') { + builder.append(chars[i]); + continue; + } + + if ((i > 1 && chars[i - 2] == '\\') /*allow escaping &x*/) { + builder.setLength(builder.length() - 2); + builder.append('&').append(chars[i]); + continue; + } + + builder.append(c); + + int j = 0; + while (++j <= 6) { + if (i + j >= chars.length) { + break; + } + + final char x = chars[i + j]; + builder.append(ChatColor.COLOR_CHAR).append(x); + } + + if (j == 7) { + i += 6; + } else { + builder.setLength(builder.length() - (j * 2)); // undo &x parsing + } + } + continue; + } if (l != closure.head || i + 1 >= chars.length) { builder.append(l); @@ -59,7 +102,6 @@ public final class CharsReplacer implements Replacer { boolean invalid = true; boolean hadSpace = false; - // Little setup to check if the placeholder is %identified_values% while (++i < chars.length) { final char p = chars[i]; From 41275509b27053e5662754d424a0a127cace39b0 Mon Sep 17 00:00:00 2001 From: Andre601 <11576465+Andre601@users.noreply.github.com> Date: Tue, 13 Apr 2021 17:58:42 +0200 Subject: [PATCH 06/20] Undo renaming of boolean --- .../java/me/clip/placeholderapi/replacer/CharsReplacer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java b/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java index 702e173..0b3bb0c 100644 --- a/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java +++ b/src/main/java/me/clip/placeholderapi/replacer/CharsReplacer.java @@ -99,7 +99,7 @@ public final class CharsReplacer implements Replacer { } boolean identified = false; - boolean invalid = true; + boolean oopsitsbad = true; boolean hadSpace = false; while (++i < chars.length) { @@ -110,7 +110,7 @@ public final class CharsReplacer implements Replacer { break; } if (p == closure.tail) { - invalid = false; + oopsitsbad = false; break; } @@ -132,7 +132,7 @@ public final class CharsReplacer implements Replacer { identifier.setLength(0); parameters.setLength(0); - if (invalid) { + if (oopsitsbad) { builder.append(closure.head).append(identifierString); if (identified) { From 748b9f33f779025d4b7c260786d7006ff0d3a983 Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Mon, 26 Apr 2021 18:05:42 +0200 Subject: [PATCH 07/20] Build jars on PR (Compile and build validation) --- .github/workflows/pr_build_jars.yml | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/pr_build_jars.yml diff --git a/.github/workflows/pr_build_jars.yml b/.github/workflows/pr_build_jars.yml new file mode 100644 index 0000000..a559eea --- /dev/null +++ b/.github/workflows/pr_build_jars.yml @@ -0,0 +1,31 @@ +name: "Build Jars on Java 8, 9, 10 and 11" + +on: + pull_request: + branches: + - development + paths: + - "src/**" + - "build.gradle" + +jobs: + testBuilds: + name: "Build Jars against Java 8, 9, 10 and 11" + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 4 + matrix: + java-version: [8, 9, 10, 11] + steps: + - name: "Checkout Code" + uses: actions/checkout@v2 + - name: "Prepare Java ${{ matrix.java-version }}" + uses: actions/setup-java@v2 + with: + distribution: "zulu" + java-version: "${{ matrix.java-version }}" + - name: "Make build.gradle executable" + run: "chmod +x gradlew" + - name: "Build jar" + run: "./gradlew shadowJar" From 09e68e7510e01d623b77b884385308e808c4b90e Mon Sep 17 00:00:00 2001 From: Vaishnav Anil Date: Fri, 25 Jun 2021 05:07:14 +0530 Subject: [PATCH 08/20] Extracted URLClassLoader out of try-with-resources block --- src/main/java/me/clip/placeholderapi/util/FileUtil.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/util/FileUtil.java b/src/main/java/me/clip/placeholderapi/util/FileUtil.java index 6bed142..b98770f 100644 --- a/src/main/java/me/clip/placeholderapi/util/FileUtil.java +++ b/src/main/java/me/clip/placeholderapi/util/FileUtil.java @@ -42,13 +42,11 @@ public class FileUtil { } final URL jar = file.toURI().toURL(); - + final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader()); final List matches = new ArrayList<>(); final List> classes = new ArrayList<>(); - try (final JarInputStream stream = new JarInputStream( - jar.openStream()); final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, - clazz.getClassLoader())) { + try (final JarInputStream stream = new JarInputStream(jar.openStream())) { JarEntry entry; while ((entry = stream.getNextJarEntry()) != null) { final String name = entry.getName(); From df8583df57489ec5cf8308abf11a0024b34431d5 Mon Sep 17 00:00:00 2001 From: Vaishnav Anil Date: Fri, 25 Jun 2021 05:08:14 +0530 Subject: [PATCH 09/20] Close URLClassLoader if Expansion class was not found --- src/main/java/me/clip/placeholderapi/util/FileUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/util/FileUtil.java b/src/main/java/me/clip/placeholderapi/util/FileUtil.java index b98770f..825ff54 100644 --- a/src/main/java/me/clip/placeholderapi/util/FileUtil.java +++ b/src/main/java/me/clip/placeholderapi/util/FileUtil.java @@ -67,8 +67,11 @@ public class FileUtil { } } } - - return classes.isEmpty() ? null : classes.get(0); + if (classes.isEmpty()) { + loader.close(); + return null; + } + return classes.get(0); } } From 4c4b1602d9158746dbd7525802aa7ada4056142a Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Fri, 25 Jun 2021 16:32:45 +0200 Subject: [PATCH 10/20] Build against Java 8, 11 and 16 --- .github/workflows/pr_build_jars.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr_build_jars.yml b/.github/workflows/pr_build_jars.yml index a559eea..920c24b 100644 --- a/.github/workflows/pr_build_jars.yml +++ b/.github/workflows/pr_build_jars.yml @@ -1,4 +1,4 @@ -name: "Build Jars on Java 8, 9, 10 and 11" +name: "Test compiling against Java 8, 11 and 16" on: pull_request: @@ -10,22 +10,22 @@ on: jobs: testBuilds: - name: "Build Jars against Java 8, 9, 10 and 11" + name: "Test-compile against Java 8, 11 and 16" runs-on: ubuntu-latest strategy: fail-fast: false max-parallel: 4 matrix: - java-version: [8, 9, 10, 11] + java-version: [8, 11, 16] steps: - name: "Checkout Code" uses: actions/checkout@v2 - name: "Prepare Java ${{ matrix.java-version }}" uses: actions/setup-java@v2 with: - distribution: "zulu" + distribution: "adobt" java-version: "${{ matrix.java-version }}" - name: "Make build.gradle executable" run: "chmod +x gradlew" - - name: "Build jar" + - name: "Build jar with Java ${{ matrix.java-version }}" run: "./gradlew shadowJar" From af268c4941d01a37ccd8b491d513ee06621e9ba8 Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Fri, 25 Jun 2021 16:33:27 +0200 Subject: [PATCH 11/20] adoPt I always make that mistake... --- .github/workflows/pr_build_jars.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_build_jars.yml b/.github/workflows/pr_build_jars.yml index 920c24b..ba543f6 100644 --- a/.github/workflows/pr_build_jars.yml +++ b/.github/workflows/pr_build_jars.yml @@ -23,7 +23,7 @@ jobs: - name: "Prepare Java ${{ matrix.java-version }}" uses: actions/setup-java@v2 with: - distribution: "adobt" + distribution: "adopt" java-version: "${{ matrix.java-version }}" - name: "Make build.gradle executable" run: "chmod +x gradlew" From 4c968f012dea657440e5240e29034066ac2fcbce Mon Sep 17 00:00:00 2001 From: Starmism Date: Wed, 30 Jun 2021 05:03:47 -0600 Subject: [PATCH 12/20] Cleanup build.gradle (cherry picked from commit 7750ba7033dc9fdf40d55fcd9ecc20a94819a7c1) --- build.gradle | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index e8ad4fc..ffe47d3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.apache.tools.ant.filters.ReplaceTokens + plugins { id "java" id "maven-publish" @@ -6,7 +8,7 @@ plugins { } group "me.clip" -version "2.10.10-DEV-${System.getProperty("BUILD_NUMBER")}" +version "2.10.10-DEV" description "An awesome placeholder provider!" @@ -32,7 +34,7 @@ dependencies { processResources { from(sourceSets.main.resources.srcDirs) { - filter org.apache.tools.ant.filters.ReplaceTokens, tokens: [name: rootProject.name, version: project.version.toString(), description: project.description] + filter ReplaceTokens, tokens: [name: rootProject.name, version: project.version.toString(), description: project.description] } } @@ -73,7 +75,7 @@ license { } ext { - year = 2020 + year = 2021 } } @@ -89,7 +91,7 @@ sourceSets { publishing { repositories { maven { - if (version.contains("-DEV-")) { + if (version.contains("-DEV")) { url = uri("https://repo.extendedclip.com/content/repositories/dev/") } else { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") From 0c102a18238452ca7a560e4ae38bff4a6160302b Mon Sep 17 00:00:00 2001 From: Starmism Date: Wed, 30 Jun 2021 05:04:36 -0600 Subject: [PATCH 13/20] Remove the @NotNull's because they are overridden by expansion devs anyways, and it turns out people can make them null anyways. This adds a hashcode check and pretty error for it. (cherry picked from commit f5386d4ca55c23b54f3c5f952f08040b0967f4a3) --- .../expansion/PlaceholderExpansion.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java index 16c216e..4133017 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java @@ -22,7 +22,6 @@ package me.clip.placeholderapi.expansion; import java.util.Collections; import java.util.List; -import java.util.Objects; import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderHook; import org.bukkit.Bukkit; @@ -46,7 +45,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return placeholder identifier that is associated with this expansion */ - @NotNull public abstract String getIdentifier(); /** @@ -54,7 +52,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return name of the author for this expansion */ - @NotNull public abstract String getAuthor(); /** @@ -62,7 +59,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return current version of this expansion */ - @NotNull public abstract String getVersion(); /** @@ -70,7 +66,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return {@link #getIdentifier()} by default, name of this expansion if specified */ - @NotNull public String getName() { return getIdentifier(); } @@ -90,7 +85,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return placeholder list that this expansion provides */ - @NotNull public List getPlaceholders() { return Collections.emptyList(); } @@ -369,4 +363,18 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { return null; } + @Override + public int hashCode() { + if (this.getIdentifier() == null) { + throw new NullPointerException("Identifier must not be null! Error occurred in: " + this.getClass().getName()); + } + if (this.getAuthor() == null) { + throw new NullPointerException("Author must not be null! Error occurred in: " + this.getClass().getName()); + } + if (this.getVersion() == null) { + throw new NullPointerException("Version must not be null! Error occurred in: " + this.getClass().getName()); + } + + return super.hashCode(); + } } From 14d885392c1d913c5b44b78ecbae20651f253a82 Mon Sep 17 00:00:00 2001 From: Starmism Date: Wed, 30 Jun 2021 05:05:18 -0600 Subject: [PATCH 14/20] Fix version checker to compare the individual semver numbers instead of combining it together. (cherry picked from commit ef5cd9d37680cc6cc1321ef2e04af09b44a2c681) --- .../updatechecker/UpdateChecker.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java b/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java index bce51b8..44be055 100644 --- a/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java +++ b/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java @@ -23,6 +23,7 @@ package me.clip.placeholderapi.updatechecker; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; +import java.util.Arrays; import javax.net.ssl.HttpsURLConnection; import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.util.Msg; @@ -90,17 +91,22 @@ public class UpdateChecker implements Listener { return false; } - String plV = toReadable(pluginVersion); - String spV = toReadable(spigotVersion); - return plV.compareTo(spV) < 0; + int[] plV = toReadable(pluginVersion); + int[] spV = toReadable(spigotVersion); + + if (plV[0] < spV[0]) { + return true; + } else if ((plV[1] < spV[1])) { + return true; + } else return plV[2] < spV[2]; } - private String toReadable(String version) { - if (version.contains("-DEV-")) { - version = version.split("-DEV-")[0]; + private int[] toReadable(String version) { + if (version.contains("-DEV")) { + version = version.split("-DEV")[0]; } - return version.replaceAll("\\.", ""); + return Arrays.stream(version.split("\\.")).mapToInt(Integer::parseInt).toArray(); } @EventHandler(priority = EventPriority.MONITOR) From ac9b0c42b7593001eb177bb2ee60b433c36948ff Mon Sep 17 00:00:00 2001 From: Star Date: Wed, 30 Jun 2021 05:33:06 -0600 Subject: [PATCH 15/20] Update src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java Co-authored-by: Andre_601 <11576465+Andre601@users.noreply.github.com> (cherry picked from commit ccf4f5934386b005831757d298e2da9d8f46cb1a) --- .../me/clip/placeholderapi/updatechecker/UpdateChecker.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java b/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java index 44be055..2163be2 100644 --- a/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java +++ b/src/main/java/me/clip/placeholderapi/updatechecker/UpdateChecker.java @@ -98,7 +98,9 @@ public class UpdateChecker implements Listener { return true; } else if ((plV[1] < spV[1])) { return true; - } else return plV[2] < spV[2]; + } else { + return plV[2] < spV[2]; + } } private int[] toReadable(String version) { From 679ef900913d4c2f542b0b6b22fcb1324b1f1668 Mon Sep 17 00:00:00 2001 From: Starmism Date: Wed, 30 Jun 2021 05:43:14 -0600 Subject: [PATCH 16/20] Re-add NotNull's (cherry picked from commit 2bfd8e7e5efb25f648b8a6de934b1eff675481b1) --- .../clip/placeholderapi/expansion/PlaceholderExpansion.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java index 4133017..4fac2a1 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java @@ -45,6 +45,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return placeholder identifier that is associated with this expansion */ + @NotNull public abstract String getIdentifier(); /** @@ -52,6 +53,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return name of the author for this expansion */ + @NotNull public abstract String getAuthor(); /** @@ -59,6 +61,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return current version of this expansion */ + @NotNull public abstract String getVersion(); /** @@ -66,6 +69,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return {@link #getIdentifier()} by default, name of this expansion if specified */ + @NotNull public String getName() { return getIdentifier(); } @@ -85,6 +89,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return placeholder list that this expansion provides */ + @NotNull public List getPlaceholders() { return Collections.emptyList(); } From 252802dcbe68e610c08de18cc587f31bf5d8fc53 Mon Sep 17 00:00:00 2001 From: Starmism Date: Wed, 30 Jun 2021 10:13:12 -0600 Subject: [PATCH 17/20] Removed nullcheck from hashcode, and moved it up the chain. --- .../expansion/PlaceholderExpansion.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java index 4fac2a1..1e71a45 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java @@ -367,19 +367,4 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { public String getLink() { return null; } - - @Override - public int hashCode() { - if (this.getIdentifier() == null) { - throw new NullPointerException("Identifier must not be null! Error occurred in: " + this.getClass().getName()); - } - if (this.getAuthor() == null) { - throw new NullPointerException("Author must not be null! Error occurred in: " + this.getClass().getName()); - } - if (this.getVersion() == null) { - throw new NullPointerException("Version must not be null! Error occurred in: " + this.getClass().getName()); - } - - return super.hashCode(); - } } From 94bf5fea57ed67cae96f9e3adcca30d637479e93 Mon Sep 17 00:00:00 2001 From: Starmism Date: Wed, 30 Jun 2021 10:13:29 -0600 Subject: [PATCH 18/20] POJO to help with checking that expansions have all required methods implemented. --- .../expansion/manager/MethodSignature.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/me/clip/placeholderapi/expansion/manager/MethodSignature.java diff --git a/src/main/java/me/clip/placeholderapi/expansion/manager/MethodSignature.java b/src/main/java/me/clip/placeholderapi/expansion/manager/MethodSignature.java new file mode 100644 index 0000000..8a7d735 --- /dev/null +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/MethodSignature.java @@ -0,0 +1,37 @@ +package me.clip.placeholderapi.expansion.manager; + +import java.util.Arrays; +import java.util.Objects; + +public final class MethodSignature { + private final String name; + private final Class[] params; + + protected MethodSignature(String name, Class[] params) { + this.name = name; + this.params = params; + } + + public String getName() { + return name; + } + + public Class[] getParams() { + return params; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MethodSignature that = (MethodSignature) o; + return Objects.equals(name, that.name) && Arrays.equals(params, that.params); + } + + @Override + public int hashCode() { + int result = Objects.hash(name); + result = 31 * result + Arrays.hashCode(params); + return result; + } +} From 9b6b558002cc9b23fc69c60884d52df55e6c0142 Mon Sep 17 00:00:00 2001 From: Starmism Date: Wed, 30 Jun 2021 10:13:47 -0600 Subject: [PATCH 19/20] Add method implementation checking and nullchecking for fields. --- .../manager/LocalExpansionManager.java | 46 +++++++++++++++---- 1 file changed, 38 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 bbf01e9..872215c 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/manager/LocalExpansionManager.java @@ -46,18 +46,25 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Unmodifiable; import java.io.File; +import java.lang.reflect.Modifier; 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; +import java.util.stream.Collectors; public final class LocalExpansionManager implements Listener { @NotNull private static final String EXPANSIONS_FOLDER_NAME = "expansions"; + @NotNull + private static final Set ABSTRACT_EXPANSION_METHODS = Arrays.stream(PlaceholderExpansion.class.getDeclaredMethods()) + .filter(method -> Modifier.isAbstract(method.getModifiers())) + .map(method -> new MethodSignature(method.getName(), method.getParameterTypes())) + .collect(Collectors.toSet()); @NotNull private final File folder; @@ -153,20 +160,33 @@ public final class LocalExpansionManager implements Listener { @NotNull final Class clazz) { try { final PlaceholderExpansion expansion = createExpansionInstance(clazz); - if (expansion == null || !expansion.register()) { + + Objects.requireNonNull(expansion.getAuthor(), "The expansion author is null!"); + Objects.requireNonNull(expansion.getIdentifier(), "The expansion identifier is null!"); + Objects.requireNonNull(expansion.getVersion(), "The expansion version is null!"); + + if (!expansion.register()) { return Optional.empty(); } return Optional.of(expansion); - } catch (final LinkageError ex) { - plugin.getLogger().severe("Failed to load Expansion class " + clazz.getSimpleName() + - " (Is a dependency missing?)"); - plugin.getLogger().severe("Cause: " + ex.getClass().getSimpleName() + " " + ex.getMessage()); + } catch (LinkageError | NullPointerException ex) { + final String reason; + + if (ex instanceof LinkageError) { + reason = " (Is a dependency missing?)"; + } else { + reason = " - One of its properties is null which is not allowed!"; + } + + plugin.getLogger().severe("Failed to load expansion class " + clazz.getSimpleName() + + reason); + plugin.getLogger().log(Level.SEVERE, "", ex); } return Optional.empty(); } - + @ApiStatus.Internal public boolean register(@NotNull final PlaceholderExpansion expansion) { final String identifier = expansion.getIdentifier().toLowerCase(); @@ -341,6 +361,16 @@ public final class LocalExpansionManager implements Listener { if (expansionClass == null) { plugin.getLogger().severe("Failed to load Expansion: " + file.getName() + ", as it does not have" + " a class which extends PlaceholderExpansion."); + return null; + } + + Set expansionMethods = Arrays.stream(expansionClass.getDeclaredMethods()) + .map(method -> new MethodSignature(method.getName(), method.getParameterTypes())) + .collect(Collectors.toSet()); + if (!expansionMethods.containsAll(ABSTRACT_EXPANSION_METHODS)) { + plugin.getLogger().severe("Failed to load Expansion: " + file.getName() + ", as it does not have the" + + " required methods declared for a PlaceholderExpansion."); + return null; } return expansionClass; @@ -365,8 +395,8 @@ public final class LocalExpansionManager implements Listener { if (ex.getCause() instanceof LinkageError) { throw ((LinkageError) ex.getCause()); } - - plugin.getLogger().warning("There was an issue with loading an expansion"); + + plugin.getLogger().warning("There was an issue with loading an expansion."); return null; } From c4a2256fff7ec2fb15ad34fc4f8231e6b02f3408 Mon Sep 17 00:00:00 2001 From: Starmism Date: Thu, 1 Jul 2021 07:54:42 -0600 Subject: [PATCH 20/20] Appease the Pigman --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ffe47d3..b1c6b8a 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group "me.clip" -version "2.10.10-DEV" +version "2.10.10-DEV-${System.getProperty("BUILD_NUMBER")}" description "An awesome placeholder provider!"