Use Ktfmt (Kotlin-style) using Spotless
This commit is contained in:
6 files changed
+76
-64
No files matched your search
@@ -4,6 +4,7 @@ plugins {
|
|||||||
kotlin("jvm") version "2.1.21"
|
kotlin("jvm") version "2.1.21"
|
||||||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17"
|
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17"
|
||||||
id("com.gradleup.shadow") version "8.3.6"
|
id("com.gradleup.shadow") version "8.3.6"
|
||||||
|
id("com.diffplug.spotless") version "7.0.4"
|
||||||
eclipse
|
eclipse
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ tasks.assemble {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.build {
|
tasks.build {
|
||||||
|
dependsOn(tasks.spotlessApply)
|
||||||
dependsOn(tasks.shadowJar)
|
dependsOn(tasks.shadowJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,3 +96,10 @@ java {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spotless {
|
||||||
|
kotlin {
|
||||||
|
ktfmt().kotlinlangStyle().configure {
|
||||||
|
it.setMaxWidth(120)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,4 +25,4 @@ class Events : Listener {
|
|||||||
player.velocity = player.location.direction.multiply(0.26)
|
player.velocity = player.location.direction.multiply(0.26)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import java.util.*
|
|||||||
|
|
||||||
object Helper {
|
object Helper {
|
||||||
private var boatTimeout: MutableMap<UUID, Long> = HashMap()
|
private var boatTimeout: MutableMap<UUID, Long> = HashMap()
|
||||||
|
|
||||||
fun getBoatTimeout(uuid: UUID): Long {
|
fun getBoatTimeout(uuid: UUID): Long {
|
||||||
val cooldown: Long
|
val cooldown: Long
|
||||||
if (!boatTimeout.containsKey(uuid)) {
|
if (!boatTimeout.containsKey(uuid)) {
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ class MoveBoatRunnable(private val boat: Boat, private val vec: Vector) : Runnab
|
|||||||
override fun run() {
|
override fun run() {
|
||||||
boat.move(MoverType.PLAYER, Vec3(vec.x, vec.y, vec.z))
|
boat.move(MoverType.PLAYER, Vec3(vec.x, vec.y, vec.z))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,4 +9,4 @@ class MoveHorseRunnable(private val horse: AbstractHorse, private val vec: Vecto
|
|||||||
override fun run() {
|
override fun run() {
|
||||||
horse.move(MoverType.PLAYER, Vec3(vec.x, vec.y, vec.z))
|
horse.move(MoverType.PLAYER, Vec3(vec.x, vec.y, vec.z))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,80 +29,82 @@ class RewindFixOG : JavaPlugin() {
|
|||||||
plugin = this
|
plugin = this
|
||||||
viaApi = Via.getAPI()
|
viaApi = Via.getAPI()
|
||||||
object : BukkitRunnable() {
|
object : BukkitRunnable() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
for (player in Bukkit.getOnlinePlayers()) {
|
for (player in Bukkit.getOnlinePlayers()) {
|
||||||
if (player.vehicle == null) {
|
if (player.vehicle == null) {
|
||||||
return
|
|
||||||
}
|
|
||||||
if (viaApi.getPlayerVersion(player.uniqueId) > 107) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (player.vehicle is CraftAbstractHorse && player.vehicle !is CraftLlama) {
|
|
||||||
val abstractHorse = player.vehicle as CraftAbstractHorse
|
|
||||||
if (abstractHorse.inventory.saddle == null) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val downVec = Vector(0, -1, 0)
|
if (viaApi.getPlayerVersion(player.uniqueId) > 107) {
|
||||||
val nmsHorse = abstractHorse.handle
|
|
||||||
Bukkit.getScheduler().runTask(plugin, MoveHorseRunnable(nmsHorse, downVec))
|
|
||||||
}
|
|
||||||
if (player.vehicle is CraftBoat) {
|
|
||||||
if ((player.vehicle as CraftBoat).isInWater) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val craftBoat = player.vehicle as CraftBoat
|
if (player.vehicle is CraftAbstractHorse && player.vehicle !is CraftLlama) {
|
||||||
val downVec = Vector(0.0, -0.5, 0.0)
|
val abstractHorse = player.vehicle as CraftAbstractHorse
|
||||||
val nmsBoat = craftBoat.handle
|
if (abstractHorse.inventory.saddle == null) {
|
||||||
Bukkit.getScheduler().runTask(plugin, MoveBoatRunnable(nmsBoat, downVec))
|
return
|
||||||
|
}
|
||||||
|
val downVec = Vector(0, -1, 0)
|
||||||
|
val nmsHorse = abstractHorse.handle
|
||||||
|
Bukkit.getScheduler().runTask(plugin, MoveHorseRunnable(nmsHorse, downVec))
|
||||||
|
}
|
||||||
|
if (player.vehicle is CraftBoat) {
|
||||||
|
if ((player.vehicle as CraftBoat).isInWater) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val craftBoat = player.vehicle as CraftBoat
|
||||||
|
val downVec = Vector(0.0, -0.5, 0.0)
|
||||||
|
val nmsBoat = craftBoat.handle
|
||||||
|
Bukkit.getScheduler().runTask(plugin, MoveBoatRunnable(nmsBoat, downVec))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(this, 0L, 1L)
|
.runTaskTimer(this, 0L, 1L)
|
||||||
protocolManager.addPacketListener(object :
|
protocolManager.addPacketListener(
|
||||||
PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.STEER_VEHICLE) {
|
object : PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.STEER_VEHICLE) {
|
||||||
override fun onPacketReceiving(event: PacketEvent) {
|
override fun onPacketReceiving(event: PacketEvent) {
|
||||||
val player = event.player
|
val player = event.player
|
||||||
val api = Via.getAPI()
|
val api = Via.getAPI()
|
||||||
if (api.getPlayerVersion(player.uniqueId) > 107) {
|
if (api.getPlayerVersion(player.uniqueId) > 107) {
|
||||||
return
|
|
||||||
}
|
|
||||||
val packet = event.packet
|
|
||||||
val sideways = packet.float.read(0)
|
|
||||||
val forward = packet.float.read(1)
|
|
||||||
if (forward == 0f && sideways == 0f) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (event.player.vehicle == null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (player.vehicle is CraftLlama) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (event.player.vehicle is CraftBoat) {
|
|
||||||
val craftBoat = event.player.vehicle as CraftBoat
|
|
||||||
val nmsBoat: Boat = craftBoat.handle
|
|
||||||
if (Helper.getBoatTimeout(player.uniqueId) != 0L) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val loc = player.location
|
val packet = event.packet
|
||||||
val vec = loc.direction
|
val sideways = packet.float.read(0)
|
||||||
vec.setY(0)
|
val forward = packet.float.read(1)
|
||||||
Bukkit.getScheduler().runTask(plugin, MoveBoatRunnable(nmsBoat, vec))
|
if (forward == 0f && sideways == 0f) {
|
||||||
} else if (event.player.vehicle is CraftAbstractHorse) {
|
|
||||||
val craftHorse = event.player.vehicle as CraftAbstractHorse
|
|
||||||
if (craftHorse.inventory.saddle == null) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val speed = craftHorse.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)?.value ?: return
|
if (event.player.vehicle == null) {
|
||||||
val nmsHorse: AbstractHorse = craftHorse.handle
|
return
|
||||||
val loc = player.location
|
}
|
||||||
val vec = loc.direction
|
if (player.vehicle is CraftLlama) {
|
||||||
vec.setY(0)
|
return
|
||||||
vec.multiply(3 * speed)
|
}
|
||||||
Bukkit.getScheduler().runTask(plugin, MoveHorseRunnable(nmsHorse, vec))
|
if (event.player.vehicle is CraftBoat) {
|
||||||
|
val craftBoat = event.player.vehicle as CraftBoat
|
||||||
|
val nmsBoat: Boat = craftBoat.handle
|
||||||
|
if (Helper.getBoatTimeout(player.uniqueId) != 0L) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val loc = player.location
|
||||||
|
val vec = loc.direction
|
||||||
|
vec.setY(0)
|
||||||
|
Bukkit.getScheduler().runTask(plugin, MoveBoatRunnable(nmsBoat, vec))
|
||||||
|
} else if (event.player.vehicle is CraftAbstractHorse) {
|
||||||
|
val craftHorse = event.player.vehicle as CraftAbstractHorse
|
||||||
|
if (craftHorse.inventory.saddle == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val speed = craftHorse.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)?.value ?: return
|
||||||
|
val nmsHorse: AbstractHorse = craftHorse.handle
|
||||||
|
val loc = player.location
|
||||||
|
val vec = loc.direction
|
||||||
|
vec.setY(0)
|
||||||
|
vec.multiply(3 * speed)
|
||||||
|
Bukkit.getScheduler().runTask(plugin, MoveHorseRunnable(nmsHorse, vec))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
this.server.pluginManager.registerEvents(Events(), this)
|
this.server.pluginManager.registerEvents(Events(), this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user