feat: update to 26.1.2 and use modern API

This commit is contained in:
MoRanYue 2026-07-04 19:24:30 +08:00
commit 4f5818c272
7 changed files with 18 additions and 67 deletions

View file

@ -3,7 +3,7 @@ plugins {
}
group = 'xyz.hynse'
version = "2.4"
version = "3.0"
repositories {
mavenCentral()
@ -14,10 +14,10 @@ repositories {
}
dependencies {
compileOnly "dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT"
compileOnly "io.papermc.paper:paper-api:26.1.2.build.+"
}
def targetJavaVersion = 17
def targetJavaVersion = 25
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -4,7 +4,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import xyz.hynse.foliaflow.command.ReloadCommand;
import xyz.hynse.foliaflow.util.CheckSafeTeleportation;
import xyz.hynse.foliaflow.watcher.PortalWatcher;
import java.io.File;
@ -14,13 +13,11 @@ import java.io.InputStreamReader;
public class FoliaFlow extends JavaPlugin {
private boolean isFirstEnable = true;
//public boolean isUnSafeTeleport = false;
public static FoliaFlow instance;
public static double horizontalCoefficient;
public static double verticalCoefficient;
public static double spawnHeight;
public static double TeleportOffset;
//public static CheckSafeTeleportation checkSafeTeleportation;
@Override
public void onEnable() {
@ -66,8 +63,6 @@ public class FoliaFlow extends JavaPlugin {
private void register() {
getCommand("flowreload").setExecutor(new ReloadCommand());
// checkSafeTeleportation = new CheckSafeTeleportation();
// checkSafeTeleportation.updateSafeTeleportation();
getServer().getPluginManager().registerEvents(new PortalWatcher(), this);
}
}

View file

@ -1,6 +1,7 @@
package xyz.hynse.foliaflow.command;
import org.bukkit.ChatColor;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -13,9 +14,9 @@ public class ReloadCommand implements CommandExecutor {
if (!sender.hasPermission("foliaflow.reload")) return true;
try {
FoliaFlow.instance.reload();
sender.sendMessage(ChatColor.YELLOW + "FoliaFlow reloaded.");
sender.sendMessage(Component.text("FoliaFlow reloaded.").color(NamedTextColor.YELLOW));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + "Something went wrong reloading FoliaFlow, see the console for more.");
sender.sendMessage(Component.text("Something went wrong reloading FoliaFlow, see the console for more.").color(NamedTextColor.RED));
e.printStackTrace();
}
return true;

View file

@ -1,49 +0,0 @@
package xyz.hynse.foliaflow.util;
import org.yaml.snakeyaml.Yaml;
import xyz.hynse.foliaflow.FoliaFlow;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Map;
import static org.bukkit.Bukkit.getServer;
public class CheckSafeTeleportation {
public boolean checkUnsafeEndPortalTeleportation() {
File configFile = new File(getServer().getWorldContainer(), "config/paper-global.yml");
if (!configFile.exists()) {
FoliaFlow.instance.getLogger().warning("paper-global.yml not found!");
return false;
}
try (FileInputStream fis = new FileInputStream(configFile)) {
Yaml yaml = new Yaml();
Map<String, Object> config = yaml.load(fis);
Map<String, Object> unsupportedSettings = (Map<String, Object>) config.get("unsupported-settings");
if (unsupportedSettings != null) {
Boolean setting = (Boolean) unsupportedSettings.get("allow-unsafe-end-portal-teleportation");
return setting != null && setting;
}
} catch (IOException e) {
FoliaFlow.instance.getLogger().severe("Failed to read paper-global.yml: " + e.getMessage());
}
return false;
}
// public void updateSafeTeleportation() {
// boolean safeTeleportation = checkUnsafeEndPortalTeleportation();
// if (safeTeleportation) {
// FoliaFlow.instance.isUnSafeTeleport = true;
// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is true.");
// } else {
// FoliaFlow.instance.isUnSafeTeleport = false;
// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is false.");
// }
// }
}

View file

@ -10,10 +10,11 @@ public class SchedulerUtil {
private static boolean tryFolia() {
try {
Bukkit.getAsyncScheduler();
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
return true;
} catch (Throwable ignored) {}
return false;
} catch (ClassNotFoundException e) {
return false;
}
}
public static Boolean isFolia() {
@ -22,7 +23,10 @@ public class SchedulerUtil {
}
public static void runLaterEntity(Entity entity, Plugin plugin, Runnable runnable, int ticks) {
if (isFolia()) entity.getScheduler().runDelayed(plugin, (task) -> runnable.run(), null, ticks);
else Bukkit.getScheduler().runTaskLater(plugin, runnable, ticks);
if (isFolia()) {
entity.getScheduler().runDelayed(plugin, (task) -> runnable.run(), null, ticks);
} else {
Bukkit.getScheduler().runTaskLater(plugin, runnable, ticks);
}
}
}

View file

@ -1,7 +1,7 @@
name: FoliaFlow
version: '${version}'
main: xyz.hynse.foliaflow.FoliaFlow
api-version: 1.20
api-version: '26.1.2'
folia-supported: true
commands:
flowreload: