Supports both bukkit and folia
This commit is contained in:
parent
c4a046ff24
commit
d33bd63d42
|
@ -34,6 +34,8 @@ dependencies {
|
|||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.8.2")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
||||
|
||||
implementation("cn.handyplus.lib.adapter:FoliaLib:1.0.0")
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,6 +90,8 @@ tasks {
|
|||
|
||||
relocate("org.bstats", "me.clip.placeholderapi.metrics")
|
||||
relocate("net.kyori", "me.clip.placeholderapi.libs.kyori")
|
||||
|
||||
relocate("cn.handyplus.lib.FoliaLib", "me.clip.placeholderapi.libs.FoliaLib")
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
|
@ -23,6 +23,8 @@ package me.clip.placeholderapi;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.handyplus.lib.adapter.HandySchedulerUtil;
|
||||
import me.clip.placeholderapi.commands.PlaceholderCommandRouter;
|
||||
import me.clip.placeholderapi.configuration.PlaceholderAPIConfig;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
|
@ -140,6 +142,8 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
HandySchedulerUtil.init(this);
|
||||
|
||||
setupCommand();
|
||||
setupMetrics();
|
||||
setupExpansions();
|
||||
|
@ -153,6 +157,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||
if (config.checkUpdates()) {
|
||||
new UpdateChecker(this).fetch();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -162,7 +167,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
HandySchedulerUtil.cancelTask();
|
||||
|
||||
adventure.close();
|
||||
adventure = null;
|
||||
|
@ -250,8 +255,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||
Class.forName("org.bukkit.event.server.ServerLoadEvent");
|
||||
new ServerLoadEventListener(this);
|
||||
} catch (final ClassNotFoundException ignored) {
|
||||
Bukkit.getScheduler()
|
||||
.runTaskLater(this, () -> getLocalExpansionManager().load(Bukkit.getConsoleSender()), 1);
|
||||
HandySchedulerUtil.runTaskLater(() -> getLocalExpansionManager().load(Bukkit.getConsoleSender()), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package me.clip.placeholderapi.expansion.manager;
|
||||
|
||||
import cn.handyplus.lib.adapter.HandySchedulerUtil;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.Resources;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
@ -201,12 +202,7 @@ public final class CloudExpansionManager {
|
|||
}
|
||||
|
||||
// loop through what's left on the main thread
|
||||
plugin
|
||||
.getServer()
|
||||
.getScheduler()
|
||||
.runTask(
|
||||
plugin,
|
||||
() -> {
|
||||
HandySchedulerUtil.runTask(() -> {
|
||||
try {
|
||||
for (Map.Entry<String, CloudExpansion> entry : values.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.io.InputStreamReader;
|
|||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import cn.handyplus.lib.adapter.HandySchedulerUtil;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.util.Msg;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -55,7 +57,7 @@ public class UpdateChecker implements Listener {
|
|||
}
|
||||
|
||||
public void fetch() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
HandySchedulerUtil.runTaskAsynchronously(() -> {
|
||||
try {
|
||||
HttpsURLConnection con = (HttpsURLConnection) new URL(
|
||||
"https://api.spigotmc.org/legacy/update.php?resource=" + RESOURCE_ID).openConnection();
|
||||
|
@ -76,7 +78,7 @@ public class UpdateChecker implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
HandySchedulerUtil.runTask(() -> {
|
||||
plugin.getLogger()
|
||||
.info("An update for PlaceholderAPI (v" + getSpigotVersion() + ") is available at:");
|
||||
plugin.getLogger()
|
||||
|
|
|
@ -27,6 +27,8 @@ import java.util.function.BiConsumer;
|
|||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import cn.handyplus.lib.adapter.HandySchedulerUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -43,7 +45,7 @@ public final class Futures {
|
|||
if (Bukkit.isPrimaryThread()) {
|
||||
consumer.accept(value, exception);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(value, exception));
|
||||
HandySchedulerUtil.runTask(() -> consumer.accept(value, exception));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ author: HelpChat
|
|||
|
||||
api-version: "1.13"
|
||||
description: "An awesome placeholder provider!"
|
||||
folia-supported: true
|
||||
|
||||
commands:
|
||||
placeholderapi:
|
||||
|
|
Loading…
Reference in New Issue