From 2b1cad5a729119042e77659d4e5e7e9884aabeee Mon Sep 17 00:00:00 2001 From: cerq <66092565+cerqiest@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:49:33 -0400 Subject: [PATCH 1/4] fix: property issues in offlineplayer --- .../dev/znci/rocket/scripting/globals/tables/Players.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt b/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt index 3654565..05d0f33 100644 --- a/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt +++ b/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt @@ -275,7 +275,7 @@ open class LuaOfflinePlayer(val offlinePlayer: OfflinePlayer) : TwineNative("") @TwineNativeProperty val lastDeathLocation - get() = offlinePlayer.lastDeathLocation + get() = offlinePlayer.lastDeathLocation?.let { LuaLocation.fromBukkit(it) } @TwineNativeProperty val lastLogin @@ -308,7 +308,7 @@ open class LuaOfflinePlayer(val offlinePlayer: OfflinePlayer) : TwineNative("") @TwineNativeProperty val respawnLocation - get() = offlinePlayer.respawnLocation + get() = offlinePlayer.respawnLocation?.let { LuaLocation.fromBukkit(it) } @TwineNativeProperty val uuid @@ -324,7 +324,7 @@ open class LuaOfflinePlayer(val offlinePlayer: OfflinePlayer) : TwineNative("") @TwineNativeProperty val isConnected - get() = offlinePlayer.isOnline + get() = offlinePlayer.isConnected @TwineNativeProperty val isOnline From babd167b39bff44aa211d9ed106eaf27c803bc08 Mon Sep 17 00:00:00 2001 From: cerq <66092565+cerqiest@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:52:38 -0400 Subject: [PATCH 2/4] fix: additional property issues in offlineplayer --- .../rocket/scripting/globals/tables/Players.kt | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt b/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt index 05d0f33..a103c6b 100644 --- a/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt +++ b/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt @@ -97,7 +97,7 @@ data class TitleTimeTable( @Suppress("unused") class LuaPlayer( - override val player: Player + val player: Player ) : LuaOfflinePlayer(player) { @TwineNativeFunction fun send(message: Any): Boolean { @@ -289,22 +289,15 @@ open class LuaOfflinePlayer(val offlinePlayer: OfflinePlayer) : TwineNative("") // in the case of location and name and the actual player instance in the case of player @TwineNativeProperty open val location: LuaLocation? - get() { - val location = offlinePlayer.location - return if (location != null) { - LuaLocation.fromBukkit(location) - } else { - null - } - } + get() = offlinePlayer.location?.let { LuaLocation.fromBukkit(it) } @TwineNativeProperty open val name get() = offlinePlayer.name - @TwineNativeProperty - open val player - get() = offlinePlayer.player + @TwineNativeProperty("player") + open val playerLuaProperty + get() = offlinePlayer.player?.let { LuaPlayer(it) } @TwineNativeProperty val respawnLocation From 9d678cf3b4a4f404c9a450e0aca0356c4fbda7d1 Mon Sep 17 00:00:00 2001 From: cerq <66092565+cerqiest@users.noreply.github.com> Date: Mon, 21 Apr 2025 00:05:40 -0400 Subject: [PATCH 3/4] refactor: remove useless type annotation --- .../kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt b/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt index a103c6b..c43aff4 100644 --- a/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt +++ b/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt @@ -17,7 +17,6 @@ package dev.znci.rocket.scripting.globals.tables import dev.znci.rocket.scripting.PermissionsManager import dev.znci.rocket.scripting.annotations.Global -import dev.znci.rocket.scripting.api.RocketError import dev.znci.rocket.util.MessageFormatter import dev.znci.twine.TwineNative import dev.znci.twine.TwineTable @@ -288,7 +287,7 @@ open class LuaOfflinePlayer(val offlinePlayer: OfflinePlayer) : TwineNative("") // location, name, and player are open because they are overridden in LuaPlayer with non-nullable values // in the case of location and name and the actual player instance in the case of player @TwineNativeProperty - open val location: LuaLocation? + open val location get() = offlinePlayer.location?.let { LuaLocation.fromBukkit(it) } @TwineNativeProperty From 452b27021673c6000fb1501819edb08af2606749 Mon Sep 17 00:00:00 2001 From: cerq <66092565+cerqiest@users.noreply.github.com> Date: Mon, 21 Apr 2025 00:08:22 -0400 Subject: [PATCH 4/4] refactor: change property names to remove `is` prefix to be consistent with other properties --- .../dev/znci/rocket/scripting/globals/tables/Players.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt b/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt index c43aff4..8234fa9 100644 --- a/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt +++ b/src/main/kotlin/dev/znci/rocket/scripting/globals/tables/Players.kt @@ -311,15 +311,15 @@ open class LuaOfflinePlayer(val offlinePlayer: OfflinePlayer) : TwineNative("") get() = offlinePlayer.hasPlayedBefore() @TwineNativeProperty - val isBanned + val banned get() = offlinePlayer.isBanned @TwineNativeProperty - val isConnected + val connected get() = offlinePlayer.isConnected @TwineNativeProperty - val isOnline + val online get() = offlinePlayer.isOnline @TwineNativeProperty