mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI.git
synced 2026-11-04 17:00:11 -05:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27ec162393 | ||
|
|
12561adfad | ||
|
|
7d21d2f1d7 | ||
|
|
31a050af54 | ||
|
|
6dc238c45d | ||
|
|
23a00370ac | ||
|
|
c5c75a5e8c | ||
|
|
ecc4ca002c | ||
|
|
4845e35067 | ||
|
|
a41bf76656 | ||
|
|
8fcabecf63 | ||
|
|
e8306ed434 | ||
|
|
7da63d2d58 |
No files matched your search
@@ -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
@@ -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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user