diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927..afba109 100755 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fc..c7d437b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..65dcd68 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd3..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/spigot/build.gradle.kts b/spigot/build.gradle.kts index ab364e4..4f45941 100644 --- a/spigot/build.gradle.kts +++ b/spigot/build.gradle.kts @@ -1,10 +1,10 @@ plugins { `java-library` id("com.github.johnrengelman.shadow") version "7.1.2" - id("net.minecrell.plugin-yml.bukkit") version "0.5.2" + id("net.minecrell.plugin-yml.bukkit") version "0.6.0" // lowest version with folia-compatible in the plugin-yml is 0.6.0 } -val versionStr = (System.getenv("VERSION")?: "v1.0.0").removePrefix("v") +val versionStr = (System.getenv("VERSION")?: "v1.19.0").removePrefix("v") group = "com.funniray.minimap" version = versionStr @@ -76,7 +76,8 @@ tasks { bukkit { name = "MinimapControl" main = "com.funniray.minimap.spigot.SpigotMinimap" - authors = listOf("funniray") + authors = listOf("funniray", "Thowan") + foliaSupported = true description = "Control minimap settings from server-side software" apiVersion = "1.13" diff --git a/spigot/src/main/java/com/funniray/minimap/spigot/SpigotMain.java b/spigot/src/main/java/com/funniray/minimap/spigot/SpigotMain.java index 3f5f08c..5336b5d 100644 --- a/spigot/src/main/java/com/funniray/minimap/spigot/SpigotMain.java +++ b/spigot/src/main/java/com/funniray/minimap/spigot/SpigotMain.java @@ -58,7 +58,8 @@ public void onPluginMessageReceived(@NotNull String channel, @NotNull Player pla public void onJoin(PlayerJoinEvent event) { // The player join event is slightly too early. I unfortunately don't know an event that fires late enough for Xaeros to recognize the packet // If anyone knows, please let me know - plugin.getServer().getScheduler().runTaskLater(plugin, ()->this.handlePlayerJoined(new SpigotPlayer(event.getPlayer())), 40L); + Player player = event.getPlayer(); + plugin.getScheduler().runTaskLater(player, 40L, () -> this.handlePlayerJoined(new SpigotPlayer(player))); } @EventHandler diff --git a/spigot/src/main/java/com/funniray/minimap/spigot/SpigotMinimap.java b/spigot/src/main/java/com/funniray/minimap/spigot/SpigotMinimap.java index 2e70c7c..30afb29 100644 --- a/spigot/src/main/java/com/funniray/minimap/spigot/SpigotMinimap.java +++ b/spigot/src/main/java/com/funniray/minimap/spigot/SpigotMinimap.java @@ -1,11 +1,13 @@ package com.funniray.minimap.spigot; +import com.funniray.minimap.spigot.scheduler.SchedulerAdapter; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import org.bukkit.plugin.java.JavaPlugin; public final class SpigotMinimap extends JavaPlugin { private static SpigotMinimap instance; private final SpigotMain main = new SpigotMain(this); + private final SchedulerAdapter scheduler = SchedulerAdapter.create(this); public ViaHook viaHook; public boolean viaHooked; @@ -48,4 +50,5 @@ public void onDisable() { public static SpigotMinimap getInstance() { return instance; } + public SchedulerAdapter getScheduler() {return scheduler;} } diff --git a/spigot/src/main/java/com/funniray/minimap/spigot/impl/SpigotPlayer.java b/spigot/src/main/java/com/funniray/minimap/spigot/impl/SpigotPlayer.java index 82a47b6..ca73876 100644 --- a/spigot/src/main/java/com/funniray/minimap/spigot/impl/SpigotPlayer.java +++ b/spigot/src/main/java/com/funniray/minimap/spigot/impl/SpigotPlayer.java @@ -8,7 +8,6 @@ import net.kyori.adventure.platform.bukkit.MinecraftComponentSerializer; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; @@ -23,7 +22,8 @@ public SpigotPlayer(Player player) { @Override public void sendPluginMessage(byte[] message, String channel) { - Bukkit.getScheduler().runTask(SpigotMinimap.getInstance(), ()->nativePlayer.sendPluginMessage(SpigotMinimap.getInstance(), channel, message)); + SpigotMinimap plugin = SpigotMinimap.getInstance(); + plugin.getScheduler().runTask(nativePlayer, ()->nativePlayer.sendPluginMessage(plugin, channel, message)); } @Override diff --git a/spigot/src/main/java/com/funniray/minimap/spigot/scheduler/BukkitSchedulerAdapter.java b/spigot/src/main/java/com/funniray/minimap/spigot/scheduler/BukkitSchedulerAdapter.java new file mode 100644 index 0000000..f56d9ea --- /dev/null +++ b/spigot/src/main/java/com/funniray/minimap/spigot/scheduler/BukkitSchedulerAdapter.java @@ -0,0 +1,23 @@ +package com.funniray.minimap.spigot.scheduler; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +public final class BukkitSchedulerAdapter implements SchedulerAdapter { + private final Plugin plugin; + + public BukkitSchedulerAdapter(Plugin plugin) { + this.plugin = plugin; + } + + @Override + public void runTask(Player player, Runnable task) { + Bukkit.getScheduler().runTask(plugin, task); + } + + @Override + public void runTaskLater(Player player, long delayTicks, Runnable task) { + Bukkit.getScheduler().runTaskLater(plugin, task, delayTicks); + } +} \ No newline at end of file diff --git a/spigot/src/main/java/com/funniray/minimap/spigot/scheduler/FoliaSchedulerAdapter.java b/spigot/src/main/java/com/funniray/minimap/spigot/scheduler/FoliaSchedulerAdapter.java new file mode 100644 index 0000000..c365e48 --- /dev/null +++ b/spigot/src/main/java/com/funniray/minimap/spigot/scheduler/FoliaSchedulerAdapter.java @@ -0,0 +1,44 @@ +package com.funniray.minimap.spigot.scheduler; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public final class FoliaSchedulerAdapter implements SchedulerAdapter { + private final Plugin plugin; + + public FoliaSchedulerAdapter(Plugin plugin) { + this.plugin = plugin; + } + + @Override + public void runTask(Player player, Runnable task) { + schedule(player, task, 1L); + } + + @Override + public void runTaskLater(Player player, long delayTicks, Runnable task) { + schedule(player, task, delayTicks); + } + + private void schedule(Player player, Runnable task, long delayTicks) { + try { + Method getScheduler = player.getClass().getMethod("getScheduler"); + Object entityScheduler = getScheduler.invoke(player); + + Method execute = entityScheduler.getClass().getMethod( + "execute", + Plugin.class, + Runnable.class, + Runnable.class, + long.class + ); + + execute.invoke(entityScheduler, plugin, task, null, delayTicks); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException exception) { + throw new IllegalStateException("Unable to schedule a task on Folia", exception); + } + } +} \ No newline at end of file diff --git a/spigot/src/main/java/com/funniray/minimap/spigot/scheduler/SchedulerAdapter.java b/spigot/src/main/java/com/funniray/minimap/spigot/scheduler/SchedulerAdapter.java new file mode 100644 index 0000000..138c735 --- /dev/null +++ b/spigot/src/main/java/com/funniray/minimap/spigot/scheduler/SchedulerAdapter.java @@ -0,0 +1,19 @@ +package com.funniray.minimap.spigot.scheduler; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +public interface SchedulerAdapter { + void runTask(Player player, Runnable task); + + void runTaskLater(Player player, long delayTicks, Runnable task); + + static SchedulerAdapter create(Plugin plugin) { + try { + Class.forName("io.papermc.paper.threadedregions.RegionizedServer"); + return new FoliaSchedulerAdapter(plugin); + } catch (ClassNotFoundException exception) { + return new BukkitSchedulerAdapter(plugin); + } + } +} \ No newline at end of file diff --git a/sponge/build.gradle.kts b/sponge/build.gradle.kts index e80d475..c2f9a8a 100644 --- a/sponge/build.gradle.kts +++ b/sponge/build.gradle.kts @@ -11,7 +11,7 @@ repositories { mavenCentral() } -val versionStr = (System.getenv("VERSION")?: "v1.0.0").removePrefix("v") +val versionStr = (System.getenv("VERSION")?: "v1.19.0").removePrefix("v") group = "com.funniray.minimap" version = versionStr