Merge 94a9d84ba0
into 68f467ab29
This commit is contained in:
commit
854b60e375
|
@ -20,11 +20,13 @@ repositories {
|
|||
|
||||
maven("https://repo.codemc.org/repository/maven-public/")
|
||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
maven("https://nexuslite.gcnt.net/repos/other/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.bstats:bstats-bukkit:3.0.1")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.3.1")
|
||||
implementation("com.tcoded:FoliaLib:0.3.1")
|
||||
|
||||
compileOnly("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT")
|
||||
compileOnlyApi("org.jetbrains:annotations:23.0.0")
|
||||
|
@ -88,6 +90,7 @@ tasks {
|
|||
|
||||
relocate("org.bstats", "me.clip.placeholderapi.metrics")
|
||||
relocate("net.kyori", "me.clip.placeholderapi.libs.kyori")
|
||||
relocate("com.tcoded", "me.clip.placeholderapi.libs.tcoded")
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package me.clip.placeholderapi;
|
||||
|
||||
import com.tcoded.folialib.FoliaLib;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -54,6 +55,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||
@NotNull
|
||||
private static final Version VERSION;
|
||||
private static PlaceholderAPIPlugin instance;
|
||||
private static FoliaLib foliaLib;
|
||||
|
||||
static {
|
||||
String version = Bukkit.getServer().getBukkitVersion().split("-")[0];
|
||||
|
@ -102,6 +104,15 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the static instance of the FoliaLib class
|
||||
*
|
||||
* @return FoliaLib instance
|
||||
*/
|
||||
public static FoliaLib getFoliaLib() {
|
||||
return foliaLib;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configurable {@linkplain String} value that should be returned when a boolean is true
|
||||
*
|
||||
|
@ -147,6 +158,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||
@Override
|
||||
public void onLoad() {
|
||||
instance = this;
|
||||
foliaLib = new FoliaLib(this);
|
||||
|
||||
saveDefaultConfig();
|
||||
}
|
||||
|
@ -175,7 +187,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
foliaLib.getImpl().cancelAllTasks();
|
||||
|
||||
adventure.close();
|
||||
adventure = null;
|
||||
|
|
|
@ -200,40 +200,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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class UpdateChecker implements Listener {
|
|||
}
|
||||
|
||||
public void fetch() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
PlaceholderAPIPlugin.getFoliaLib().getImpl().runAsync(t -> {
|
||||
try {
|
||||
HttpsURLConnection con = (HttpsURLConnection) new URL(
|
||||
"https://api.spigotmc.org/legacy/update.php?resource=" + RESOURCE_ID).openConnection();
|
||||
|
@ -76,7 +76,7 @@ public class UpdateChecker implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
PlaceholderAPIPlugin.getFoliaLib().getImpl().runNextTick(t1 -> {
|
||||
plugin.getLogger()
|
||||
.info("An update for PlaceholderAPI (v" + getSpigotVersion() + ") is available at:");
|
||||
plugin.getLogger()
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.function.BiConsumer;
|
|||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.bukkit.Bukkit;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
PlaceholderAPIPlugin.getFoliaLib().getImpl().runNextTick(t -> consumer.accept(value, exception));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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!"
|
||||
|
||||
|
|
Loading…
Reference in New Issue