Update to gradle 8.14.2, add formatting

This commit is contained in:
NotAlexNoyle committed 2025-06-20 18:15:16 -04:00
1 parent 309dc0e588
commit 27110ee2f5
10 files changed
+106 -86

No files matched your search

+25 -19
View File
@@ -1,8 +1,9 @@
plugins {
id("java") // Tell gradle this is a java project.
id("java-library") // Import helper for source-based libraries.
id("com.diffplug.spotless") version "7.0.4" // Import auto-formatter.
id("com.gradleup.shadow") version "8.3.6" // Import shadow API.
java // Tell gradle this is a java project.
eclipse // Import eclipse plugin for IDE integration.
kotlin("jvm") version "2.1.21" // Import kotlin jvm plugin for kotlin/java integration.
}
java {
@@ -11,20 +12,17 @@ java {
}
group = "net.trueog.horsetpog" // Declare bundle identifier.
version = "1.1" // Declare plugin version (will be in .jar).
val apiVersion = "1.19" // Declare minecraft server target version.
tasks.named<ProcessResources>("processResources") {
val props = mapOf(
"version" to version,
"apiVersion" to apiVersion
)
val props = mapOf("version" to version, "apiVersion" to apiVersion)
inputs.properties(props) // Indicates to rerun if version changes.
filesMatching("plugin.yml") {
expand(props)
}
filesMatching("plugin.yml") { expand(props) }
from("LICENSE") { // Bundle license into .jars.
into("/")
}
@@ -46,10 +44,12 @@ dependencies {
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare purpur API version to be packaged.
compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.2.3") // Import MiniPlaceholders API.
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT") // Import WorldEdit.
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9") { // Import WorldGuard but without its bundled WorldEdit.
compileOnly(
"com.sk89q.worldguard:worldguard-bukkit:7.0.9"
) { // Import WorldGuard but without its bundled WorldEdit.
exclude(group = "com.sk89q.worldedit")
}
compileOnly(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG API.
compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG API.
}
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
@@ -58,18 +58,17 @@ tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .ja
}
tasks.shadowJar {
archiveClassifier.set("") // Use empty string instead of null.
exclude("io.github.miniplaceholders.*") // Exclude the MiniPlaceholders package from being shadowed.
archiveClassifier.set("") // Use empty string instead of null.
minimize()
}
tasks.build {
dependsOn(tasks.spotlessApply)
dependsOn(tasks.shadowJar)
}
tasks.jar {
archiveClassifier.set("part")
}
tasks.jar { archiveClassifier.set("part") }
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters")
@@ -78,13 +77,20 @@ tasks.withType<JavaCompile>().configureEach {
options.isFork = true
}
kotlin {
jvmToolchain(17)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.GRAAL_VM
}
}
spotless {
java {
removeUnusedImports()
palantirJavaFormat()
}
kotlinGradle {
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) }
target("build.gradle.kts", "settings.gradle.kts")
}
}
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+4 -5
View File
@@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -115,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
@@ -206,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
@@ -214,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+2 -2
View File
@@ -70,11 +70,11 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+2 -3
View File
@@ -1,11 +1,10 @@
rootProject.name = "HorseTp-OG"
// Run the bootstrap at configuration time.
val process = ProcessBuilder("sh", "bootstrap.sh")
.directory(rootDir)
.start()
val process = ProcessBuilder("sh", "bootstrap.sh").directory(rootDir).start()
val exitValue = process.waitFor()
if (exitValue != 0) {
throw GradleException("bootstrap.sh failed with exit code $exitValue")
}
@@ -1,19 +1,16 @@
package net.trueog.horsetpog;
import java.util.HashMap;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import java.util.HashMap;
import net.trueog.horsetpog.Listeners.OnEntityDismount;
import net.trueog.horsetpog.Listeners.OnPlayerTeleport;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public final class HorseTpOG extends JavaPlugin {
@@ -22,7 +19,7 @@ public final class HorseTpOG extends JavaPlugin {
private static HashMap<Player, Entity> vehicleCache = new HashMap<>();
@Override
public void onLoad(){
public void onLoad() {
// add the WorldGuard flag for an area where HorseTp will not work
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
try {
@@ -50,19 +47,17 @@ public final class HorseTpOG extends JavaPlugin {
getServer().getPluginManager().registerEvents(new OnEntityDismount(), this);
getServer().getPluginManager().registerEvents(new OnPlayerTeleport(), this);
}
public static HorseTpOG getPlugin(){
public static HorseTpOG getPlugin() {
return plugin;
}
public static StateFlag getHorseTpFlag(){
public static StateFlag getHorseTpFlag() {
return HorseTpFlag;
}
public static HashMap<Player, Entity> getVehicleCache(){
public static HashMap<Player, Entity> getVehicleCache() {
return vehicleCache;
}
}
@@ -1,5 +1,6 @@
package net.trueog.horsetpog.Listeners;
import net.trueog.horsetpog.HorseTpOG;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@@ -8,15 +9,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.spigotmc.event.entity.EntityDismountEvent;
import net.trueog.horsetpog.HorseTpOG;
public class OnEntityDismount implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
// when a player teleports, they are dismounted from their vehicle
// so when they get dismounted, teleport the vehicle to them
public void onEntityDismount(EntityDismountEvent event){
if(event.getEntity() instanceof Player){
public void onEntityDismount(EntityDismountEvent event) {
if (event.getEntity() instanceof Player) {
// When a player dismounts, add them and the vehicle
// to a cache, which is read on a teleport event to tp them
@@ -26,10 +25,13 @@ public class OnEntityDismount implements Listener {
HorseTpOG.getVehicleCache().put(player, vehicle);
// 5 ticks later, remove them from the cache
Bukkit.getScheduler().runTaskLater(HorseTpOG.getPlugin(), () -> {
Bukkit.getScheduler()
.runTaskLater(
HorseTpOG.getPlugin(),
() -> {
HorseTpOG.getVehicleCache().remove(player);
}, 5);
},
5);
}
}
}
@@ -1,8 +1,15 @@
package net.trueog.horsetpog.Listeners;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import java.util.Arrays;
import java.util.List;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.trueog.horsetpog.HorseTpOG;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
@@ -16,16 +23,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.trueog.horsetpog.HorseTpOG;
public class OnPlayerTeleport implements Listener {
@EventHandler
@@ -33,7 +30,10 @@ public class OnPlayerTeleport implements Listener {
// run all of this 1 tick after the teleport so that the players location gets updated
// and the dismount event is guaranteed to have been called
Bukkit.getScheduler().runTaskLater(HorseTpOG.getPlugin(), () -> {
Bukkit.getScheduler()
.runTaskLater(
HorseTpOG.getPlugin(),
() -> {
// if the player did not have a vehicle prior to the teleport
// ignore this handler
@@ -41,14 +41,18 @@ public class OnPlayerTeleport implements Listener {
return;
}
// this checks to see if the teleport was a result of a dismount, or a /tp
// TeleportCause.UNKNOWN is a dismount
if (! event.getCause().equals(TeleportCause.UNKNOWN)) {
if (!event.getCause().equals(TeleportCause.UNKNOWN)) {
// I have no idea why this works, but it does
// I reset the player's pitch/yaw and then teleport them back
event.getPlayer().teleport(new Location(event.getPlayer().getWorld(), event.getPlayer().getLocation().getX(), event.getPlayer().getLocation().getY(), event.getPlayer().getLocation().getZ()));
event.getPlayer()
.teleport(new Location(
event.getPlayer().getWorld(),
event.getPlayer().getLocation().getX(),
event.getPlayer().getLocation().getY(),
event.getPlayer().getLocation().getZ()));
event.getPlayer().teleport(event.getTo());
Player player = event.getPlayer();
@@ -60,8 +64,10 @@ public class OnPlayerTeleport implements Listener {
HorseTpOG.getVehicleCache().remove(player);
// check if the area that the player teleported to is a banned area
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
com.sk89q.worldedit.util.Location worldGuardPlayerLocation = BukkitAdapter.adapt(event.getTo());
RegionContainer container =
WorldGuard.getInstance().getPlatform().getRegionContainer();
com.sk89q.worldedit.util.Location worldGuardPlayerLocation =
BukkitAdapter.adapt(event.getTo());
RegionQuery query = container.createQuery();
ApplicableRegionSet set = query.getApplicableRegions(worldGuardPlayerLocation);
@@ -71,7 +77,7 @@ public class OnPlayerTeleport implements Listener {
// only stop the tp if the player is in a minecart or boat
// Otherwise, a protected area could be flooded with boats and minecarts
// that can't be destroyed by non-admins
if(vehicle instanceof Boat || vehicle instanceof Minecart) {
if (vehicle instanceof Boat || vehicle instanceof Minecart) {
player.sendMessage(Component.text("[HorseTp]")
.color(TextColor.color(0, 255, 0))
.append(Component.text(" You can't teleport boats here")
@@ -99,8 +105,12 @@ public class OnPlayerTeleport implements Listener {
vehicleWorld.loadChunk(vehicleChunk);
// wait 1 tick before teleporting the entity
List<Entity> finalPassengerList = passengerList; // apparently this is required for the compiler to be happy ?
Bukkit.getScheduler().runTaskLater(HorseTpOG.getPlugin(), () -> {
List<Entity> finalPassengerList =
passengerList; // apparently this is required for the compiler to be happy ?
Bukkit.getScheduler()
.runTaskLater(
HorseTpOG.getPlugin(),
() -> {
// teleport the vehicle and all of the passengers
// use try-catch to see if the vehicle still exists
try {
@@ -124,16 +134,20 @@ public class OnPlayerTeleport implements Listener {
// unload the chunk that the vehicle was in one tick later
// also add the player back to the vehicle
Bukkit.getScheduler().runTaskLater(HorseTpOG.getPlugin(), () -> {
Bukkit.getScheduler()
.runTaskLater(
HorseTpOG.getPlugin(),
() -> {
vehicleWorld.unloadChunk(vehicleChunk);
}, 1);
}, 1);
},
1);
},
1);
}
}, 1);
},
1);
}
// this method is used for teleporting players back when the region
// that they teleported to is restricted
// this is necessary because if someone is laggy, we need to load the
@@ -142,19 +156,24 @@ public class OnPlayerTeleport implements Listener {
// It just recursively calls itself, loading the chunk until
// the player is teleported back
public void loadChunksUntilTeleportComplete(World world, Location teleportFrom, Player player){
if(! Arrays.stream(world.getChunkAt(teleportFrom).getEntities()).toList().contains(player)){
public void loadChunksUntilTeleportComplete(World world, Location teleportFrom, Player player) {
if (!Arrays.stream(world.getChunkAt(teleportFrom).getEntities())
.toList()
.contains(player)) {
loadChunksUntilTeleportComplete(world, teleportFrom, player);
}
else{
for(int i = 0; i < (int) Math.ceil(((double) player.getPing()) / 50) + 10; i++){
Bukkit.getScheduler().runTaskLater(HorseTpOG.getPlugin(), () -> {
} else {
for (int i = 0; i < (int) Math.ceil(((double) player.getPing()) / 50) + 10; i++) {
Bukkit.getScheduler()
.runTaskLater(
HorseTpOG.getPlugin(),
() -> {
world.getChunkAt(teleportFrom).load();
player.sendBlockChange(player.getLocation(), world.getBlockData(player.getLocation()));
}, i);
player.sendBlockChange(
player.getLocation(), world.getBlockData(player.getLocation()));
},
i);
}
}
world.getChunkAt(teleportFrom).load();
}
}