mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2025-09-06 05:17:05 +02:00
Compare commits
1 Commits
feature/ad
...
feature/fo
Author | SHA1 | Date | |
---|---|---|---|
|
95786e32d2 |
13
.github/CONTRIBUTING.md
vendored
13
.github/CONTRIBUTING.md
vendored
@@ -1,7 +1,7 @@
|
||||
[issue]: https://github.com/PlaceholderAPI/PlaceholderAPI/issues/new
|
||||
[discord]: https://helpch.at/discord
|
||||
[code of conduct]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/CODE_OF_CONDUCT.md
|
||||
[wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/wiki
|
||||
[wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/docs/wiki/wiki
|
||||
[master]: https://github.com/PlaceholderAPI/PlaceholderAPI/tree/master
|
||||
[docs-wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/tree/docs/wiki
|
||||
[style]: https://github.com/PlaceholderAPI/PlaceholderAPI/tree/master/config/style
|
||||
@@ -40,8 +40,7 @@ In those cases should you report the issue to the issue tracker of the expansion
|
||||
## Pull requests
|
||||
As an open source project are we welcoming all contributions to improve PlaceholderAPI, being it changes to its code, or contributions to its documentation such as the [Wiki] or the Javadocs.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> When contributing, make sure to both base of and target the mentioned branch. Pull requests targeting the wrong branch may get closed without a warning.
|
||||
**When contributing, make sure to both base of and target the mentioned branch. Pull requests targeting the wrong branch may get closed without a warning.**
|
||||
|
||||
### Code contributions
|
||||
> **Source and Target Branch:** [`master`][master]
|
||||
@@ -57,10 +56,12 @@ Javadocs changes should usually be combined with [code contributions](#code-cont
|
||||
\*This branch may change in the future.
|
||||
|
||||
### Wiki contributions
|
||||
> **Source and Target Branch:** [`wiki`][docs-wiki]
|
||||
> **Source and Target Branch:** [`docs/wiki`][docs-wiki]
|
||||
|
||||
The Wiki of PlaceholderAPI is located on its own dedicated branch, hosting all the assets and files that get used to create it through the usage of GitHub Actions and GitHub Pages.
|
||||
We welcome contributions that update outdated information, add new expansions/plugins supporting PlaceholderAPI or even correct spelling mistakes and typos.
|
||||
The Wiki of PlaceholderAPI has a unique quirk by having a dedicated [`wiki` folder][wiki] hosting the pages found on the actual wiki itself.
|
||||
If you find outdated information, want to add missing expansions/plugins or just like to correct some wrong spelling should you both base of and target your contributions on the `docs/wiki` branch.
|
||||
|
||||
**Please only PR changes for the `wiki` folder on the `docs/wiki` branch! Pull requests not following this guidelines will be closed unnanounced.**
|
||||
|
||||
## Code of Conduct
|
||||
We have a [Code of Conduct] to maintain a welcoming atmosphere in this project.
|
||||
|
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -25,4 +25,4 @@ Closes N/A <!-- If your PR is based on an issue, change "N/A" the the issue ID (
|
||||
|
||||
|
||||
<!-- DO NOT ALTER ANYTHING BELOW THIS LINE! -->
|
||||
[Wiki]: https://wiki.placeholderapi.com
|
||||
[Wiki]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
|
||||
|
4
.github/label-commenter-config.yml
vendored
4
.github/label-commenter-config.yml
vendored
@@ -1,8 +1,8 @@
|
||||
comment:
|
||||
footer: "\
|
||||
----\n\n
|
||||
> [!NOTE]\n
|
||||
> *This is an automated response created by a **GitHub Action***<br>
|
||||
> **Note**\n
|
||||
> *This is an automated response created by a **GitHub Action***\n
|
||||
> *Mentioning the bot won't have any effect!*
|
||||
"
|
||||
|
||||
|
@@ -7,8 +7,6 @@
|
||||
|
||||
[discord]: https://helpch.at/discord
|
||||
[spigot]: https://www.spigotmc.org/resources/6245/
|
||||
[hangar]: https://hangar.papermc.io/HelpChat/PlaceholderAPI
|
||||
[bbb]: https://builtbybit.com/resources/placeholderapi.24306
|
||||
[Expansions cloud]: https://api.extendedclip.com/home
|
||||
[placeholder list]: https://helpch.at/placeholders
|
||||
[statistics]: https://bstats.org/plugin/bukkit/PlaceholderAPI
|
||||
@@ -17,10 +15,10 @@
|
||||
[ciImg]: http://ci.extendedclip.com/buildStatus/icon?job=PlaceholderAPI
|
||||
|
||||
[APIversionImg]: https://img.shields.io/nexus/placeholderapi/me.clip/placeholderapi?server=https%3A%2F%2Frepo.extendedclip.com&label=API%20Version
|
||||
[logo]: https://wiki.placeholderapi.com/assets/img/papi-logo.png
|
||||
[logo]: https://raw.githubusercontent.com/PlaceholderAPI/PlaceholderAPI/wiki/img/papi-logo.png
|
||||
|
||||
[contributing]: https://github.com/PlaceholderAPI/PlaceholderAPI/blob/master/.github/CONTRIBUTING.md
|
||||
[placeholderexpansion]: https://wiki.placeholderapi.com/developers/creating-a-placeholderexpansion/
|
||||
[placeholderexpansion]: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/PlaceholderExpansion
|
||||
<!-- The stuff above isn't visible in the readme -->
|
||||
|
||||
[![logo]][spigot]
|
||||
@@ -49,6 +47,4 @@ If you would like to create your own Placeholder Expansion for PlaceholderAPI, t
|
||||
- [Expansions Cloud]
|
||||
- [Placeholder List]
|
||||
- [Spigot Page][spigot]
|
||||
- [Hangar Page][hangar]
|
||||
- [BuiltByBit Page][bbb]
|
||||
- [Plugin Statistics][statistics]
|
||||
|
@@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "me.clip"
|
||||
version = "2.11.6-DEV-${System.getProperty("BUILD_NUMBER")}"
|
||||
version = "2.11.4-DEV-${System.getProperty("BUILD_NUMBER")}"
|
||||
|
||||
description = "An awesome placeholder provider!"
|
||||
|
||||
@@ -24,9 +24,9 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation("org.bstats:bstats-bukkit:3.0.1")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.3.1")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.3.0")
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT")
|
||||
compileOnlyApi("dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT") // this is temp
|
||||
compileOnlyApi("org.jetbrains:annotations:23.0.0")
|
||||
|
||||
testImplementation("org.openjdk.jmh:jmh-core:1.32")
|
||||
@@ -38,8 +38,8 @@ dependencies {
|
||||
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_17 // this is temp
|
||||
targetCompatibility = JavaVersion.VERSION_17 // this is temp
|
||||
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
|
@@ -162,7 +162,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
Bukkit.getAsyncScheduler().cancelTasks(this); // this is hopefully temp
|
||||
|
||||
adventure.close();
|
||||
adventure = null;
|
||||
|
@@ -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;
|
||||
@@ -38,16 +37,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,
|
||||
@@ -58,12 +47,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) {
|
||||
@@ -72,11 +55,6 @@ public final class CommandECloudDownload extends PlaceholderCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!expansion.isVerified()) {
|
||||
Msg.msg(sender, "&cThe expansion '&f" + params.get(0) + "&c' is not verified and can only be downloaded manually from &fhttps://placeholderapi.com/ecloud");
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion.Version version;
|
||||
if (params.size() < 2) {
|
||||
version = expansion.getVersion(expansion.getLatestVersion());
|
||||
@@ -108,7 +86,9 @@ public final class CommandECloudDownload extends PlaceholderCommand {
|
||||
.getVersion() + "] &ato file: &f" + file.getName(),
|
||||
"&aMake sure to type &f/papi reload &ato enable your new expansion!");
|
||||
|
||||
plugin.getCloudExpansionManager().load();
|
||||
plugin.getCloudExpansionManager().clean();
|
||||
plugin.getCloudExpansionManager()
|
||||
.fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,9 @@ public final class CommandECloudRefresh extends PlaceholderCommand {
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
plugin.getCloudExpansionManager().load();
|
||||
plugin.getCloudExpansionManager().clean();
|
||||
plugin.getCloudExpansionManager()
|
||||
.fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
||||
|
||||
Msg.msg(sender,
|
||||
"&aThe eCloud manager has been refreshed!");
|
||||
|
@@ -200,9 +200,7 @@ public final class CommandDump extends PlaceholderCommand {
|
||||
for (final Plugin other : plugins) {
|
||||
builder.append(" ")
|
||||
.append(String.format("%-" + size + "s", other.getName()))
|
||||
.append(" [Authors: [")
|
||||
.append(String.join(", ", other.getDescription().getAuthors()))
|
||||
.append("], Version: ")
|
||||
.append(" [Version: ")
|
||||
.append(other.getDescription().getVersion())
|
||||
.append("]")
|
||||
.append("\n");
|
||||
|
@@ -54,7 +54,7 @@ public final class CommandExpansionRegister extends PlaceholderCommand {
|
||||
final LocalExpansionManager manager = plugin.getLocalExpansionManager();
|
||||
|
||||
final File file = new File(manager.getExpansionsFolder(), params.get(0));
|
||||
if (!file.exists() || !file.getParentFile().equals(manager.getExpansionsFolder())) {
|
||||
if (!file.exists()) {
|
||||
Msg.msg(sender,
|
||||
"&cThe file &f" + file.getName() + "&c doesn't exist!");
|
||||
return;
|
||||
|
@@ -38,6 +38,10 @@ public final class PlaceholderAPIConfig {
|
||||
return plugin.getConfig().getBoolean("check_updates");
|
||||
}
|
||||
|
||||
public boolean cloudAllowUnverifiedExpansions() {
|
||||
return plugin.getConfig().getBoolean("cloud_allow_unverified_expansions");
|
||||
}
|
||||
|
||||
|
||||
public boolean isCloudEnabled() {
|
||||
return plugin.getConfig().getBoolean("cloud_enabled");
|
||||
|
@@ -46,8 +46,7 @@ public enum NMSVersion {
|
||||
SPIGOT_1_18_R1("v1_18_R1"),
|
||||
SPIGOT_1_19_R1("v1_19_R1"),
|
||||
SPIGOT_1_19_R2("v1_19_R2"),
|
||||
SPIGOT_1_19_R3("v1_19_R3"),
|
||||
SPIGOT_1_20_R1("v1_20_R1");
|
||||
SPIGOT_1_19_R3("v1_19_R3");
|
||||
|
||||
private final String version;
|
||||
|
||||
|
@@ -40,14 +40,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||
|
||||
/**
|
||||
* The type is {@link Type#INTERNAL} by default.
|
||||
* For external expansions, the type is updated on {@link me.clip.placeholderapi.expansion.manager.LocalExpansionManager#register(Class) register}.
|
||||
* @since 2.11.4
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
protected Type expansionType = Type.INTERNAL;
|
||||
|
||||
/**
|
||||
* The placeholder identifier of this expansion. May not contain {@literal %},
|
||||
* {@literal {}} or _
|
||||
@@ -167,27 +159,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||
return PlaceholderAPIPlugin.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the expansion
|
||||
*
|
||||
* @return the type of the expansion
|
||||
* @since 2.11.4
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public Type getExpansionType() {
|
||||
return expansionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the type of the expansion
|
||||
* @param expansionType the new type
|
||||
* @since 2.11.4
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public void setExpansionType(Type expansionType) {
|
||||
this.expansionType = expansionType;
|
||||
}
|
||||
|
||||
// === Configuration ===
|
||||
|
||||
/**
|
||||
@@ -195,7 +166,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||
* null when not specified.
|
||||
* <br>You may use the {@link Configurable} interface to define default values set
|
||||
*
|
||||
* @return ConfigurationSection that this expansion has.
|
||||
* @return ConfigurationSection that this epxpansion has.
|
||||
*/
|
||||
@Nullable
|
||||
public final ConfigurationSection getConfigSection() {
|
||||
@@ -423,8 +394,8 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return String.format("PlaceholderExpansion[name: '%s', author: '%s', version: '%s', type: '%s']", getName(),
|
||||
getAuthor(), getVersion(), getExpansionType());
|
||||
return String.format("PlaceholderExpansion[name: '%s', author: '%s', version: '%s']", getName(),
|
||||
getAuthor(), getVersion());
|
||||
}
|
||||
|
||||
// === Deprecated API ===
|
||||
@@ -461,19 +432,4 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||
public String getLink() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* An expansion provided by a plugin is considered internal
|
||||
*/
|
||||
INTERNAL,
|
||||
|
||||
/**
|
||||
* An expansion loaded from the expansions folder is considered external
|
||||
*/
|
||||
EXTERNAL
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -100,7 +100,7 @@ public final class CloudExpansionManager {
|
||||
|
||||
public void load() {
|
||||
clean();
|
||||
fetch();
|
||||
fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
@@ -170,7 +170,7 @@ public final class CloudExpansionManager {
|
||||
await.clear();
|
||||
}
|
||||
|
||||
public void fetch() {
|
||||
public void fetch(final boolean allowUnverified) {
|
||||
plugin.getLogger().info("Fetching available expansion information...");
|
||||
|
||||
ASYNC_EXECUTOR.submit(
|
||||
@@ -190,6 +190,9 @@ public final class CloudExpansionManager {
|
||||
|| expansion.getVersion(expansion.getLatestVersion()) == null) {
|
||||
toRemove.add(entry.getKey());
|
||||
}
|
||||
if (!allowUnverified && !expansion.isVerified()) {
|
||||
toRemove.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
for (String name : toRemove) {
|
||||
@@ -200,40 +203,33 @@ public final class CloudExpansionManager {
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to download expansion information", e);
|
||||
}
|
||||
|
||||
// loop through what's left on the main thread
|
||||
plugin
|
||||
.getServer()
|
||||
.getScheduler()
|
||||
.runTask(
|
||||
plugin,
|
||||
() -> {
|
||||
try {
|
||||
for (Map.Entry<String, CloudExpansion> entry : values.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
CloudExpansion expansion = entry.getValue();
|
||||
//todo: Figure out why this was being scheduled back on the main thread
|
||||
try {
|
||||
for (Map.Entry<String, CloudExpansion> entry : values.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
CloudExpansion expansion = entry.getValue();
|
||||
|
||||
expansion.setName(name);
|
||||
expansion.setName(name);
|
||||
|
||||
Optional<PlaceholderExpansion> localOpt =
|
||||
plugin.getLocalExpansionManager().findExpansionByName(name);
|
||||
if (localOpt.isPresent()) {
|
||||
PlaceholderExpansion local = localOpt.get();
|
||||
if (local.isRegistered()) {
|
||||
expansion.setHasExpansion(true);
|
||||
expansion.setShouldUpdate(
|
||||
!local.getVersion().equalsIgnoreCase(expansion.getLatestVersion()));
|
||||
}
|
||||
}
|
||||
Optional<PlaceholderExpansion> localOpt =
|
||||
plugin.getLocalExpansionManager().findExpansionByName(name);
|
||||
if (localOpt.isPresent()) {
|
||||
PlaceholderExpansion local = localOpt.get();
|
||||
if (local.isRegistered()) {
|
||||
expansion.setHasExpansion(true);
|
||||
expansion.setShouldUpdate(
|
||||
!local.getVersion().equalsIgnoreCase(expansion.getLatestVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
cache.put(toIndexName(expansion), expansion);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// ugly swallowing of every throwable, but we have to be defensive
|
||||
plugin
|
||||
.getLogger()
|
||||
.log(Level.WARNING, "Failed to download expansion information", e);
|
||||
}
|
||||
});
|
||||
cache.put(toIndexName(expansion), expansion);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// ugly swallowing of every throwable, but we have to be defensive
|
||||
plugin
|
||||
.getLogger()
|
||||
.log(Level.WARNING, "Failed to download expansion information", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -187,8 +187,6 @@ public final class LocalExpansionManager implements Listener {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
expansion.setExpansionType(PlaceholderExpansion.Type.EXTERNAL);
|
||||
|
||||
if (!expansion.register()) {
|
||||
Msg.warn("Cannot load expansion %s due to an unknown issue.", expansion.getIdentifier());
|
||||
@@ -211,11 +209,6 @@ public final class LocalExpansionManager implements Listener {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to register a {@link PlaceholderExpansion}
|
||||
* @param expansion the expansion to register
|
||||
* @return if the expansion was registered
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public boolean register(@NotNull final PlaceholderExpansion expansion) {
|
||||
final String identifier = expansion.getIdentifier().toLowerCase(Locale.ROOT);
|
||||
@@ -223,10 +216,10 @@ public final class LocalExpansionManager implements Listener {
|
||||
if (!expansion.canRegister()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Avoid loading two external expansions with the same identifier
|
||||
if (expansion.getExpansionType() == PlaceholderExpansion.Type.EXTERNAL && expansions.containsKey(identifier)) {
|
||||
Msg.warn("Failed to load external expansion %s. Identifier is already in use.", expansion.getIdentifier());
|
||||
|
||||
if (expansions.containsKey(identifier)) {
|
||||
Msg.warn("Failed to load expansion %s. Identifier is already in use.",
|
||||
expansion.getIdentifier());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -276,12 +269,13 @@ public final class LocalExpansionManager implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ExpansionRegisterEvent event = new ExpansionRegisterEvent(expansion);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
// this is temp
|
||||
// final ExpansionRegisterEvent event = new ExpansionRegisterEvent(expansion);
|
||||
// Bukkit.getPluginManager().callEvent(event);
|
||||
//
|
||||
// if (event.isCancelled()) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
expansionsLock.lock();
|
||||
try {
|
||||
@@ -294,24 +288,21 @@ public final class LocalExpansionManager implements Listener {
|
||||
Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);
|
||||
}
|
||||
|
||||
Msg.info(
|
||||
"Successfully registered %s expansion: %s [%s]",
|
||||
expansion.getExpansionType().name().toLowerCase(),
|
||||
expansion.getIdentifier(),
|
||||
expansion.getVersion()
|
||||
);
|
||||
Msg.info("Successfully registered expansion: %s [%s]", expansion.getIdentifier(),
|
||||
expansion.getVersion());
|
||||
|
||||
if (expansion instanceof Taskable) {
|
||||
((Taskable) expansion).start();
|
||||
}
|
||||
|
||||
// Check eCloud for updates only if the expansion is external
|
||||
if (plugin.getPlaceholderAPIConfig().isCloudEnabled() && expansion.getExpansionType() == PlaceholderExpansion.Type.EXTERNAL) {
|
||||
final Optional<CloudExpansion> cloudExpansionOptional = plugin.getCloudExpansionManager().findCloudExpansionByName(identifier);
|
||||
if (plugin.getPlaceholderAPIConfig().isCloudEnabled()) {
|
||||
final Optional<CloudExpansion> cloudExpansionOptional =
|
||||
plugin.getCloudExpansionManager().findCloudExpansionByName(identifier);
|
||||
if (cloudExpansionOptional.isPresent()) {
|
||||
CloudExpansion cloudExpansion = cloudExpansionOptional.get();
|
||||
cloudExpansion.setHasExpansion(true);
|
||||
cloudExpansion.setShouldUpdate(!cloudExpansion.getLatestVersion().equals(expansion.getVersion()));
|
||||
cloudExpansion.setShouldUpdate(
|
||||
!cloudExpansion.getLatestVersion().equals(expansion.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
@@ -54,35 +55,43 @@ public class UpdateChecker implements Listener {
|
||||
return spigotVersion;
|
||||
}
|
||||
|
||||
//todo: Figure out a better approach for this?
|
||||
public void fetch() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
CompletableFuture<Boolean> update = new CompletableFuture<>();
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
HttpsURLConnection con = (HttpsURLConnection) new URL(
|
||||
"https://api.spigotmc.org/legacy/update.php?resource=" + RESOURCE_ID).openConnection();
|
||||
"https://api.spigotmc.org/legacy/update.php?resource=" + RESOURCE_ID).openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
spigotVersion = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
||||
} catch (Exception ex) {
|
||||
plugin.getLogger().info("Failed to check for updates on spigot.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spigotVersion == null || spigotVersion.isEmpty()) {
|
||||
return;
|
||||
plugin.getLogger().info("Failed to check for updates on spigot.");
|
||||
return false;
|
||||
}
|
||||
|
||||
updateAvailable = spigotIsNewer();
|
||||
|
||||
if (!updateAvailable) {
|
||||
return;
|
||||
plugin.getLogger().info("PlaceholderAPI is up to date.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
return true;
|
||||
});
|
||||
|
||||
update.whenComplete((result, error) -> {
|
||||
if (result) {
|
||||
plugin.getLogger()
|
||||
.info("An update for PlaceholderAPI (v" + getSpigotVersion() + ") is available at:");
|
||||
.info("An update for PlaceholderAPI (v" + getSpigotVersion() + ") is available at:");
|
||||
plugin.getLogger()
|
||||
.info("https://www.spigotmc.org/resources/placeholderapi." + RESOURCE_ID + "/");
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
});
|
||||
.info("https://www.spigotmc.org/resources/placeholderapi." + RESOURCE_ID + "/");
|
||||
Bukkit.getPluginManager().registerEvents(UpdateChecker.this, plugin);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -40,11 +40,7 @@ public final class Futures {
|
||||
@NotNull final CompletableFuture<T> future,
|
||||
@NotNull final BiConsumer<T, Throwable> consumer) {
|
||||
future.whenComplete((value, exception) -> {
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
consumer.accept(value, exception);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(value, exception));
|
||||
}
|
||||
consumer.accept(value, exception);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -1,16 +1,17 @@
|
||||
# PlaceholderAPI
|
||||
# Version: ${version}
|
||||
# Version: @version@
|
||||
# Created by: extended_clip
|
||||
# Contributors: https://github.com/PlaceholderAPI/PlaceholderAPI/graphs/contributors
|
||||
# Issues: https://github.com/PlaceholderAPI/PlaceholderAPI/issues
|
||||
# Expansions: https://placeholderapi.com/ecloud
|
||||
# Wiki: https://wiki.placeholderapi.com/
|
||||
# Expansions: https://api.extendedclip.com/all/
|
||||
# Wiki: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
|
||||
# Discord: https://helpch.at/discord
|
||||
# No placeholders are provided with this plugin by default.
|
||||
# Download placeholders: /papi ecloud
|
||||
check_updates: true
|
||||
cloud_enabled: true
|
||||
cloud_sorting: "name"
|
||||
cloud_allow_unverified_expansions: false
|
||||
boolean:
|
||||
'true': 'yes'
|
||||
'false': 'no'
|
||||
|
@@ -4,6 +4,8 @@ main: "me.clip.placeholderapi.PlaceholderAPIPlugin"
|
||||
version: ${version}
|
||||
author: HelpChat
|
||||
|
||||
folia-supported: true
|
||||
|
||||
api-version: "1.13"
|
||||
description: "An awesome placeholder provider!"
|
||||
|
||||
@@ -37,6 +39,7 @@ permissions:
|
||||
placeholderapi.ecloud.info: true
|
||||
placeholderapi.ecloud.list: true
|
||||
placeholderapi.ecloud.clear: true
|
||||
placeholderapi.ecloud.toggle: true
|
||||
placeholderapi.ecloud.status: true
|
||||
placeholderapi.ecloud.update: true
|
||||
placeholderapi.ecloud.refresh: true
|
||||
@@ -81,6 +84,9 @@ permissions:
|
||||
placeholderapi.ecloud.clear:
|
||||
default: "op"
|
||||
description: "Allows you to clear the local eCloud expansion cache"
|
||||
placeholderapi.ecloud.toggle:
|
||||
default: "op"
|
||||
description: "Allows you to toggle/enable/disable the eCloud manager"
|
||||
placeholderapi.ecloud.status:
|
||||
default: "op"
|
||||
description: "Allows you to view the status of eCloud expansions"
|
||||
@@ -95,4 +101,4 @@ permissions:
|
||||
description: "Allows you to download an expansion from the eCloud"
|
||||
placeholderapi.ecloud.placeholders:
|
||||
default: "op"
|
||||
description: "Allows you to view the placeholders of a eCloud expansion"
|
||||
description: "Allows you to view the placeholders of a eCloud expansion"
|
Reference in New Issue
Block a user