Compare commits

..
Author SHA1 Message Date
PiggyPiglet 96701da560 move folder debug msg above listfiles 2026-07-06 06:59:17 +08:00
PiggyPiglet ccf520a1b0 debug msgs 2026-07-06 06:54:38 +08: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
8 changed files with 277 additions and 57 deletions

No files matched your search

-43
View File
@@ -1,43 +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:
types:
- opened
- reopened
- synchronize
paths-ignore:
- "README.md"
branches:
- wiki
workflow_dispatch:
permissions:
contents: read
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 }}"
persist-credentials: false
- 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"
+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);
}
}
}
@@ -91,6 +91,8 @@ public final class CommandDump extends PlaceholderCommand {
@NotNull
private CompletableFuture<String> postDump(@NotNull final String dump) {
System.out.println("DUMP CREATE SUCCESS");
return CompletableFuture.supplyAsync(() -> {
try {
final HttpURLConnection connection = ((HttpURLConnection) new URL(URL + "documents")
@@ -110,6 +112,7 @@ public final class CommandDump extends PlaceholderCommand {
return gson.fromJson(json, JsonObject.class).get("key").getAsString();
}
} catch (final IOException ex) {
ex.printStackTrace();
throw new CompletionException(ex);
}
});
@@ -123,6 +126,8 @@ public final class CommandDump extends PlaceholderCommand {
.append(DATE_FORMAT.format(Instant.now()))
.append("\n\n");
System.out.println("DUMP1");
builder.append("PlaceholderAPI: ")
.append(plugin.getDescription().getVersion())
.append("\n\n");
@@ -130,6 +135,8 @@ public final class CommandDump extends PlaceholderCommand {
builder.append("Expansions Registered:")
.append('\n');
System.out.println("DUMP2");
final List<PlaceholderExpansion> expansions = plugin.getLocalExpansionManager()
.getExpansions()
.stream()
@@ -139,6 +146,8 @@ public final class CommandDump extends PlaceholderCommand {
)
.collect(Collectors.toList());
System.out.println("DUMP3");
int size = expansions.stream().map(e -> e.getIdentifier().length())
.max(Integer::compareTo)
.orElse(0);
@@ -163,6 +172,7 @@ public final class CommandDump extends PlaceholderCommand {
.getExpansionsFolder()
.list((dir, name) -> name.toLowerCase(Locale.ROOT).endsWith(".jar"));
System.out.println("DUMP4");
if (jars == null) {
builder.append(" ¨[Warning]: Could not load jar files from expansions folder.");
@@ -182,10 +192,14 @@ public final class CommandDump extends PlaceholderCommand {
.append(plugin.getServer().getVersion())
.append("\n");
System.out.println("DUMP5");
builder.append("Java Version: ")
.append(System.getProperty("java.version"))
.append("\n\n");
System.out.println("DUMP6");
builder.append("Plugin Info:")
.append('\n');
@@ -193,6 +207,8 @@ public final class CommandDump extends PlaceholderCommand {
.sorted(Comparator.comparing(Plugin::getName))
.collect(Collectors.toList());
System.out.println("DUMP7");
size = plugins.stream().map(pl -> pl.getName().length())
.max(Integer::compareTo)
.orElse(0);
@@ -208,6 +224,8 @@ public final class CommandDump extends PlaceholderCommand {
.append("\n");
}
System.out.println("DUMP8");
return builder.toString();
}
}
@@ -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!");
}
}
@@ -351,13 +351,19 @@ public final class LocalExpansionManager implements Listener {
Msg.info("Placeholder expansion registration initializing...");
Futures.onMainThread(plugin, findExpansionsOnDisk(), (classes, exception) -> {
System.out.println("LOAD1");
if (exception != null) {
Msg.severe("Failed to load class files of expansion.", exception);
exception.printStackTrace();
return;
}
System.out.println("LOAD2 - size: " + classes.size());
final List<PlaceholderExpansion> registered = classes.stream()
.filter(Objects::nonNull)
.peek(clazz -> System.out.println("Attempting register of - " + clazz))
.map(this::register)
.filter(Optional::isPresent)
.map(Optional::get)
@@ -386,6 +392,8 @@ public final class LocalExpansionManager implements Listener {
Msg.msg(sender, message.toString());
Bukkit.getPluginManager().callEvent(new ExpansionsLoadedEvent(registered));
System.out.println("LOAD3");
});
}
@@ -401,7 +409,12 @@ public final class LocalExpansionManager implements Listener {
@NotNull
public CompletableFuture<@NotNull List<@Nullable Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk() {
System.out.println(folder);
File[] files = folder.listFiles((dir, name) -> name.endsWith(".jar"));
System.out.println("FIND FILES - " + Arrays.toString(files));
if (files == null) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
@@ -414,6 +427,8 @@ public final class LocalExpansionManager implements Listener {
@NotNull
public CompletableFuture<@Nullable Class<? extends PlaceholderExpansion>> findExpansionInFile(
@NotNull final File file) {
System.out.println("FOUND FILE - " + file);
return CompletableFuture.supplyAsync(() -> {
try {
final Class<? extends PlaceholderExpansion> expansionClass = FileUtil.findClass(file, PlaceholderExpansion.class);
@@ -455,7 +470,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());
}
}