Compare commits

..
Author SHA1 Message Date
PiggyPiglet 27ec162393 Merge pull request #1253 from PlaceholderAPI/t3/enforce-cloud-update-verification
Enforce eCloud restrictions on updates
2026-10-24 16:35:25 +08:00
darbyjack 12561adfad fix: enforce eCloud download restrictions 2026-10-24 03:06:38 +00:00
Funnycube 7d21d2f1d7 2.12.4 dev 2026-07-03 21:49:43 +10:00
Funnycube 31a050af54 2.12.3 release 2026-07-03 21:21:05 +10:00
Andre_601 6dc238c45d Merge pull request #1221 from Andre601/master
Add dedicated comment action for failed validation
2026-07-01 14:12:32 +02:00
PiggyPiglet 23a00370ac Merge pull request #1235 from PlaceholderAPI/feat/expansion-logging-improvements
fix(logging): improve local expansion failure diagnostics
2026-07-01 19:53:21 +08:00
darbyjack c5c75a5e8c fix(logging): avoid msg during local expansion manager initialization 2026-06-30 20:13:43 -05:00
darbyjack ecc4ca002c improve(logging): log expansion instantiation failures with stack trace 2026-06-30 20:04:08 -05:00
PiggyPiglet 4845e35067 Merge pull request #1227 from PlaceholderAPI/fix/version-parsing
fix(parsing): adjust parsing to support paper dev builds better
2026-06-20 19:13:20 +08:00
darbyjack a41bf76656 feat(version): implement version resolver that utilizes server build info from paper 2026-06-16 17:31:03 -05:00
darbyjack 8fcabecf63 fix(parsing): adjust parsing to support paper dev builds better 2026-06-16 16:15:04 -05:00
Andre_601 e8306ed434 Delete .github/workflows/pr_wiki_validation.yml 2026-05-28 00:19:18 +02:00
Andre_601 7da63d2d58 Merge pull request #2 from Andre601/feature/wiki-improve-validation
Feature/wiki improve validation
2026-05-28 00:05:41 +02:00
Andre_601 ff1d8bb74c Separate comment into its own workflow. 2026-05-27 23:52:08 +02:00
Andre_601 532c98a41d Improve Wiki validation run 2026-05-27 23:35:42 +02:00
Gabriel Dumitru 79fabecbf3 ci: change trigger for pr_wiki_validation workflow 2026-05-25 11:34:24 +03:00
Funnycube eacac0ca98 Disable PR wiki validation workflow 2026-05-24 14:50:43 +10:00
PiggyPiglet feb4eff237 Merge pull request #1205 from PlaceholderAPI/feat/new-chars-replacer
Feat/new chars replacer
2026-02-25 21:13:49 +08:00
10 changed files with 295 additions and 91 deletions

No files matched your search

@@ -0,0 +1,34 @@
#
# A separate Workflow to comment on Pull requests
# for failed Wiki validation runs.
#
# This is to avoid code execution injected by
# extensions, plugins or hooks in MkDocs, that could
# abuse write permissions.
#
name: "Comment on failed Validation"
on:
workflow_run:
workflows:
- "Validate Wiki Build"
types:
- completed
permissions:
pull-requests: write
jobs:
comment:
if: github.event.workflow_run.conclusion == 'failure'
runs-on: ubuntu-latest
steps:
- name: Comment on Pull request
uses: peter-evans/create-or-update-comment@v5
with:
issue-number: ${{ github.event.workflow_run.pull_requests[0].number }}
body: |
## Build validation failed
Something went wrong while running a test-build with this Pull request's changes.
Please check the [Workflow Run Logs](${{ github.event.workflow_run.html_url }}) for any details.
-55
View File
@@ -1,55 +0,0 @@
#
# Validates Pull requests targeting the wiki branch
# to ensure that the site can be build successfully
# without broken links, navigation, etc.
#
name: "Validate Wiki Build"
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
paths-ignore:
- "README.md"
branches:
- wiki
workflow_dispatch:
permissions:
contents: read
issues: write
env:
RUN_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_number }}"
jobs:
buildWiki:
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: "${{ github.event.pull_request.head.sha }}"
- name: "Setup Python 3.x"
uses: actions/setup-python@v6
with:
python-version: 3.x
- name: "Install dependencies"
run: "python -m pip install mkdocs-material"
- name: "Build Site"
run: "mkdocs build --strict"
- name: "Create Comment"
uses: peter-evans/create-or-update-comment@v5
if: ${{ failure() }}
with:
body: |-
## Wiki Build failure
Something went wrong while creating a test-build of the Wiki for this Pull request.
Please check the [Workflow Logs](${{ env.RUN_URL }}) for any errors.
issue-number: "${{ github.event.pull_request.number }}"
token: "${{ secrets.GITHUB_TOKEN }}"
edit-mode: replace
+1 -1
View File
@@ -9,7 +9,7 @@ plugins {
}
group = "me.clip"
version = "2.12.3-DEV-${System.getProperty("BUILD_NUMBER")}"
version = "2.12.4-DEV-${System.getProperty("BUILD_NUMBER")}"
description = "An awesome placeholder provider!"
@@ -60,17 +60,8 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
private static PlaceholderAPIPlugin instance;
static {
String version = Bukkit.getServer().getBukkitVersion().split("-")[0];
String suffix;
if (version.chars()
.filter(c -> c == '.')
.count() == 1) {
suffix = "R1";
version = 'v' + version.replace('.', '_') + '_' + suffix;
} else {
int minor = Integer.parseInt(version.split("\\.")[2].charAt(0) + "");
version = 'v' + version.replace('.', '_').replace("_" + minor, "") + '_' + "R" + (minor - 1);
}
final String version = ServerVersionResolver.resolve(
Bukkit.getServer().getBukkitVersion()).getLegacyVersion();
boolean isSpigot;
try {
@@ -0,0 +1,133 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
*
* PlaceholderAPI 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.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi;
import java.util.OptionalInt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
final class ServerVersionResolver {
private static final String PAPER_BUILD_INFO_PROVIDER =
"me.clip.placeholderapi.PaperServerBuildInfoProvider";
private ServerVersionResolver() {
}
@NotNull
static ServerBuild resolve(@NotNull final String bukkitVersion) {
return resolve(bukkitVersion, resolvePaperBuildInfo());
}
@NotNull
static ServerBuild resolve(@NotNull final String bukkitVersion,
@Nullable final ServerBuild paperBuildInfo) {
if (paperBuildInfo != null) {
return paperBuildInfo;
}
return new ServerBuild(normalizeBukkitVersion(bukkitVersion), OptionalInt.empty());
}
@Nullable
private static ServerBuild resolvePaperBuildInfo() {
try {
final Class<?> provider = Class.forName(
PAPER_BUILD_INFO_PROVIDER,
true,
ServerVersionResolver.class.getClassLoader()
);
final Object result = provider.getMethod("get").invoke(null);
if (result instanceof ServerBuild) {
return (ServerBuild) result;
}
} catch (final ReflectiveOperationException | LinkageError ignored) {
// Paper is unavailable or exposes an incompatible ServerBuildInfo API.
}
return null;
}
@NotNull
static String normalizeBukkitVersion(@NotNull final String bukkitVersion) {
String version = bukkitVersion.split("-", 2)[0];
// Some Paper development versions include build metadata in the Bukkit version.
// Keep this fallback for Paper forks that do not expose ServerBuildInfo.
final int paperBuildMetadataIndex = version.indexOf(".build.");
if (paperBuildMetadataIndex != -1) {
version = version.substring(0, paperBuildMetadataIndex);
}
return version;
}
static final class ServerBuild {
@NotNull
private final String minecraftVersionId;
@NotNull
private final OptionalInt buildNumber;
ServerBuild(@NotNull final String minecraftVersionId,
@NotNull final OptionalInt buildNumber) {
this.minecraftVersionId = minecraftVersionId;
this.buildNumber = buildNumber;
}
@NotNull
String getMinecraftVersionId() {
return minecraftVersionId;
}
@NotNull
OptionalInt getBuildNumber() {
return buildNumber;
}
@NotNull
String getLegacyVersion() {
String version = minecraftVersionId;
if (version.chars()
.filter(c -> c == '.')
.count() == 1) {
return 'v' + version.replace('.', '_') + "_R1";
}
final String[] versionParts = version.split("\\.");
int minor = 1;
if (versionParts.length > 2 && !versionParts[2].isEmpty()) {
try {
minor = Integer.parseInt(versionParts[2].charAt(0) + "");
} catch (final NumberFormatException ignored) {
minor = 1;
}
}
return 'v' + version.replace('.', '_').replace("_" + minor, "")
+ "_R" + (minor - 1);
}
}
}
@@ -20,7 +20,6 @@
package me.clip.placeholderapi.commands.impl.cloud;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
@@ -39,16 +38,6 @@ public final class CommandECloudDownload extends PlaceholderCommand {
super("download");
}
private boolean isBlockedExpansion(String name) {
String env = System.getenv("PAPI_BLOCKED_EXPANSIONS");
if (env == null) {
return false;
}
return Arrays.stream(env.split(","))
.anyMatch(s -> s.equalsIgnoreCase(name));
}
@Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
@NotNull final CommandSender sender, @NotNull final String alias,
@@ -59,12 +48,6 @@ public final class CommandECloudDownload extends PlaceholderCommand {
return;
}
if (isBlockedExpansion(params.get(0))) {
Msg.msg(sender,
"&cThis expansion can't be downloaded.");
return;
}
final CloudExpansion expansion = plugin.getCloudExpansionManager()
.findCloudExpansionByName(params.get(0)).orElse(null);
if (expansion == null) {
@@ -91,11 +74,6 @@ public final class CommandECloudDownload extends PlaceholderCommand {
}
}
if (!version.isVerified()) {
Msg.msg(sender, "&cThe expansion '&f" + params.get(0) + "&c' is not verified and can only be downloaded manually from &fhttps://ecloud.placeholderapi.com");
return;
}
plugin.getCloudExpansionManager().downloadExpansion(expansion, version)
.whenComplete((file, exception) -> {
if (exception != null) {
@@ -33,6 +33,7 @@ import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -274,6 +275,16 @@ public final class CloudExpansionManager {
@NotNull
public CompletableFuture<File> downloadExpansion(@NotNull final CloudExpansion expansion,
@NotNull final CloudExpansion.Version version) {
final String blockedExpansions = System.getenv("PAPI_BLOCKED_EXPANSIONS");
if (blockedExpansions != null && Arrays.stream(blockedExpansions.split(","))
.anyMatch(name -> name.equalsIgnoreCase(expansion.getName()))) {
return failedDownload("This expansion can't be downloaded.");
}
if (!version.isVerified()) {
return failedDownload("The expansion is not verified and can only be downloaded manually from https://ecloud.placeholderapi.com");
}
final CompletableFuture<File> previous = await.get(toIndexName(expansion));
if (previous != null) {
return previous;
@@ -309,4 +320,10 @@ public final class CloudExpansionManager {
return download;
}
private CompletableFuture<File> failedDownload(String message) {
final CompletableFuture<File> failed = new CompletableFuture<>();
failed.completeExceptionally(new IllegalArgumentException(message));
return failed;
}
}
@@ -94,7 +94,7 @@ public final class LocalExpansionManager implements Listener {
this.folder = new File(plugin.getDataFolder(), EXPANSIONS_FOLDER_NAME);
if (!this.folder.exists() && !folder.mkdirs()) {
Msg.warn("Failed to create expansions folder!");
plugin.getLogger().warning("Failed to create expansions folder!");
}
}
@@ -455,7 +455,7 @@ public final class LocalExpansionManager implements Listener {
throw ((LinkageError) ex.getCause());
}
Msg.warn("There was an issue with loading an expansion.");
Msg.severe("Failed to create expansion instance for class %s.", ex, clazz.getName());
return null;
}
}
@@ -0,0 +1,42 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
*
* PlaceholderAPI 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.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi;
import io.papermc.paper.ServerBuildInfo;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@ApiStatus.Internal
public final class PaperServerBuildInfoProvider {
private PaperServerBuildInfoProvider() {
}
@NotNull
public static ServerVersionResolver.ServerBuild get() {
final ServerBuildInfo buildInfo = ServerBuildInfo.buildInfo();
return new ServerVersionResolver.ServerBuild(
buildInfo.minecraftVersionId(),
buildInfo.buildNumber()
);
}
}
@@ -0,0 +1,64 @@
/*
* This file is part of PlaceholderAPI
*
* PlaceholderAPI
* Copyright (c) 2015 - 2026 PlaceholderAPI Team
*
* PlaceholderAPI 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.
*
* PlaceholderAPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package me.clip.placeholderapi;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.OptionalInt;
import org.junit.jupiter.api.Test;
public final class ServerVersionResolverTest {
@Test
void usesPaperBuildInfoWhenAvailable() {
final ServerVersionResolver.ServerBuild paperBuild =
new ServerVersionResolver.ServerBuild("26.2", OptionalInt.of(10));
final ServerVersionResolver.ServerBuild result =
ServerVersionResolver.resolve("26.2.build.10-alpha", paperBuild);
assertSame(paperBuild, result);
assertEquals("26.2", result.getMinecraftVersionId());
assertEquals(OptionalInt.of(10), result.getBuildNumber());
assertEquals("v26_2_R1", result.getLegacyVersion());
}
@Test
void stripsPaperBuildMetadataWhenServerBuildInfoIsUnavailable() {
final ServerVersionResolver.ServerBuild result =
ServerVersionResolver.resolve("26.2.build.10-alpha", null);
assertEquals("26.2", result.getMinecraftVersionId());
assertEquals(OptionalInt.empty(), result.getBuildNumber());
assertEquals("v26_2_R1", result.getLegacyVersion());
}
@Test
void preservesTraditionalBukkitVersions() {
final ServerVersionResolver.ServerBuild result =
ServerVersionResolver.resolve("1.21.11-R0.1-SNAPSHOT", null);
assertEquals("1.21.11", result.getMinecraftVersionId());
assertEquals(OptionalInt.empty(), result.getBuildNumber());
}
}