Skip to content

Commit 7b9bc20

Browse files
committed
fix: update parameter names and formatting in packet operation methods
1 parent 97135e6 commit 7b9bc20

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

surf-api-bukkit/surf-api-bukkit-server/src/main/kotlin/dev/slne/surf/surfapi/bukkit/server/impl/nms/bridges/packets/PacketOperationImpl.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class PacketOperationImpl : PacketOperation {
3939
connection.send(ClientboundBundlePacket(packets))
4040
}
4141

42-
override fun add(other: PacketOperation): PacketOperationImpl {
43-
require(other is PacketOperationImpl) { "operation must be an instance of PacketOperationImpl" }
42+
override fun add(operation: PacketOperation): PacketOperationImpl {
43+
require(operation is PacketOperationImpl) { "operation must be an instance of PacketOperationImpl" }
4444

45-
this.operation = this.operation.andThen(other.operation)
45+
this.operation = this.operation.andThen(operation.operation)
4646
return this
4747
}
4848

@@ -54,7 +54,7 @@ class PacketOperationImpl : PacketOperation {
5454
fun interface Operation {
5555
fun apply(
5656
player: Player,
57-
packets: LinkedList<Packet<in ClientGamePacketListener>>
57+
packets: LinkedList<Packet<in ClientGamePacketListener>>,
5858
): LinkedList<Packet<in ClientGamePacketListener>>
5959

6060
fun andThen(after: Operation): Operation {
@@ -68,13 +68,13 @@ class PacketOperationImpl : PacketOperation {
6868
}
6969
}
7070

71-
class EmptyOperation: Operation {
71+
class EmptyOperation : Operation {
7272
var empty: Boolean = true
7373
private set
7474

7575
override fun apply(
7676
player: Player,
77-
packets: LinkedList<Packet<in ClientGamePacketListener>>
77+
packets: LinkedList<Packet<in ClientGamePacketListener>>,
7878
): LinkedList<Packet<in ClientGamePacketListener>> {
7979
return packets
8080
}

surf-api-bukkit/surf-api-bukkit-server/src/main/kotlin/dev/slne/surf/surfapi/bukkit/server/impl/nms/bridges/packets/entity/SurfBukkitNmsSpawnPacketsImpl.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class SurfBukkitNmsSpawnPacketsImpl : SurfBukkitNmsSpawnPackets {
3737
override fun despawn(entityIds: IntList) =
3838
PacketOperationImpl.simple { ClientboundRemoveEntitiesPacket(entityIds) }
3939

40-
override fun despawn(vararg entityIds: Int) =
41-
PacketOperationImpl.simple { ClientboundRemoveEntitiesPacket(*entityIds) }
40+
override fun despawn(vararg entityId: Int) =
41+
PacketOperationImpl.simple { ClientboundRemoveEntitiesPacket(*entityId) }
4242

4343

4444
override fun spawnItemDisplay(
@@ -142,7 +142,7 @@ class SurfBukkitNmsSpawnPacketsImpl : SurfBukkitNmsSpawnPackets {
142142
yaw: Float,
143143
pitch: Float,
144144
deltaMovement: FinePosition?,
145-
onGround: Boolean
145+
onGround: Boolean,
146146
) = PacketOperationImpl.simple {
147147
ClientboundTeleportEntityPacket.teleport(
148148
entityId,

surf-api-bukkit/surf-api-bukkit-server/src/main/kotlin/dev/slne/surf/surfapi/bukkit/server/impl/nms/listener/packets/PacketRegistry.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ object PacketRegistry {
3737

3838
private fun <Nms : Packet<ServerGamePacketListener>, Api : NmsServerboundPacket> registerServerboundPacket(
3939
nms: KClass<Nms>,
40-
factory: ServerboundPacketFactory<Nms, Api>
40+
factory: ServerboundPacketFactory<Nms, Api>,
4141
) {
4242
SERVERBOUND_PACKETS.put(nms.java, factory)
4343
}
4444

45+
@Suppress("UNCHECKED_CAST")
4546
fun <Nms : Packet<*>> createServerboundPacketOrNull(packet: Nms): NmsServerboundPacket? {
4647
val factory = SERVERBOUND_PACKETS[packet.javaClass] as? ServerboundPacketFactory<Nms, *>
4748
return factory?.create(packet)
@@ -54,6 +55,7 @@ object PacketRegistry {
5455
CLIENTBOUND_PACKETS.put(nms.java, factory)
5556
}
5657

58+
@Suppress("UNCHECKED_CAST")
5759
fun <Nms : Packet<*>> createClientboundPacketOrNull(packet: Nms): NmsClientboundPacket? {
5860
val factory = CLIENTBOUND_PACKETS[packet.javaClass] as? ClientboundPacketFactory<Nms, *>
5961
return factory?.create(packet)

0 commit comments

Comments
 (0)