Skip to content

Commit b9c71b0

Browse files
authored
Add getStatsDataPath method for statistical data retrieval (#357)
2 parents b2a4e0c + 3f296fe commit b9c71b0

5 files changed

Lines changed: 24 additions & 10 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
77
javaVersion=25
88
mcVersion=26.1.2
99
group=dev.slne.surf.api
10-
version=3.14.0
10+
version=3.15.0
1111
relocationPrefix=dev.slne.surf.api.libs
1212
snapshot=false

surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v1-21-11/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v1_21_11/bridges/V1_21_11SurfPaperNmsPlayerBridgeImpl.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@ import net.minecraft.world.entity.EntityEquipment
3636
import net.minecraft.world.entity.LivingEntity
3737
import net.minecraft.world.entity.npc.InventoryCarrier
3838
import net.minecraft.world.entity.player.Inventory
39-
import net.minecraft.world.level.storage.TagValueInput
40-
import net.minecraft.world.level.storage.TagValueOutput
41-
import net.minecraft.world.level.storage.ValueInput
42-
import net.minecraft.world.level.storage.ValueOutput
39+
import net.minecraft.world.level.storage.*
4340
import org.bukkit.craftbukkit.CraftEquipmentSlot
4441
import org.bukkit.craftbukkit.inventory.CraftItemStack
4542
import org.bukkit.entity.Player
4643
import org.bukkit.inventory.EquipmentSlot
4744
import org.bukkit.inventory.ItemStack
4845
import java.io.File
46+
import java.nio.file.Path
4947
import java.util.*
5048
import java.util.concurrent.CompletableFuture
5149
import kotlin.io.path.createTempFile
@@ -237,6 +235,10 @@ class V1_21_11SurfPaperNmsPlayerBridgeImpl : SurfPaperNmsPlayerBridge {
237235
return MinecraftServer.getServer().playerDataStorage.playerDir
238236
}
239237

238+
override fun getStatsDataPath(): Path {
239+
return MinecraftServer.getServer().getWorldPath(LevelResource.PLAYER_STATS_DIR)
240+
}
241+
240242
private suspend fun loadPlayerTag(server: MinecraftServer, nameAndId: NameAndId): CompoundTag {
241243
val dataStorage = server.playerDataStorage
242244
return withContext(Dispatchers.IO) {

surf-api-paper/surf-api-paper-nms/surf-api-paper-nms-v26-1/src/main/kotlin/dev/slne/surf/api/paper/server/nms/v26_1/bridges/V26_1SurfPaperNmsPlayerBridgeImpl.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@ import net.minecraft.world.entity.EntityEquipment
3636
import net.minecraft.world.entity.LivingEntity
3737
import net.minecraft.world.entity.npc.InventoryCarrier
3838
import net.minecraft.world.entity.player.Inventory
39-
import net.minecraft.world.level.storage.TagValueInput
40-
import net.minecraft.world.level.storage.TagValueOutput
41-
import net.minecraft.world.level.storage.ValueInput
42-
import net.minecraft.world.level.storage.ValueOutput
39+
import net.minecraft.world.level.storage.*
4340
import org.bukkit.craftbukkit.CraftEquipmentSlot
4441
import org.bukkit.craftbukkit.inventory.CraftItemStack
4542
import org.bukkit.entity.Player
4643
import org.bukkit.inventory.EquipmentSlot
4744
import org.bukkit.inventory.ItemStack
4845
import java.io.File
46+
import java.nio.file.Path
4947
import java.util.concurrent.CompletableFuture
5048
import kotlin.io.path.createTempFile
5149
import kotlin.jvm.optionals.getOrNull
@@ -233,7 +231,11 @@ class V26_1SurfPaperNmsPlayerBridgeImpl : SurfPaperNmsPlayerBridge {
233231
}
234232

235233
override fun getPlayerDataDir(): File {
236-
return MinecraftServer.getServer().playerDataStorage.playerDir
234+
return MinecraftServer.getServer().playerDataStorage.playerDir
235+
}
236+
237+
override fun getStatsDataPath(): Path {
238+
return MinecraftServer.getServer().getWorldPath(LevelResource.PLAYER_STATS_DIR)
237239
}
238240

239241
private suspend fun loadPlayerTag(server: MinecraftServer, nameAndId: NameAndId): CompoundTag {

surf-api-paper/surf-api-paper/api/surf-api-paper.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,7 @@ public abstract interface class dev/slne/surf/api/paper/nms/bridges/SurfPaperNms
17171717
public abstract fun getPaperRawChatType ()Lnet/kyori/adventure/chat/ChatType;
17181718
public abstract fun getPlayerDataDir ()Ljava/io/File;
17191719
public abstract fun getRemoteChatSessionData (Lorg/bukkit/entity/Player;)Ldev/slne/surf/api/paper/nms/bridges/data/chat/RemoteChatSessionData;
1720+
public abstract fun getStatsDataPath ()Ljava/nio/file/Path;
17201721
public abstract fun increaseNextChatIndex (Lorg/bukkit/entity/Player;)Ljava/lang/Integer;
17211722
public abstract fun runOnChatMessageChain (Lorg/bukkit/entity/Player;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function1;)V
17221723
public abstract fun sendPlayerChatMessage (Lorg/bukkit/entity/Player;Lnet/kyori/adventure/chat/SignedMessage;Lnet/kyori/adventure/chat/ChatType$Bound;)V
@@ -1731,6 +1732,7 @@ public final class dev/slne/surf/api/paper/nms/bridges/SurfPaperNmsPlayerBridge$
17311732
public fun getPaperRawChatType ()Lnet/kyori/adventure/chat/ChatType;
17321733
public fun getPlayerDataDir ()Ljava/io/File;
17331734
public fun getRemoteChatSessionData (Lorg/bukkit/entity/Player;)Ldev/slne/surf/api/paper/nms/bridges/data/chat/RemoteChatSessionData;
1735+
public fun getStatsDataPath ()Ljava/nio/file/Path;
17341736
public fun increaseNextChatIndex (Lorg/bukkit/entity/Player;)Ljava/lang/Integer;
17351737
public fun runOnChatMessageChain (Lorg/bukkit/entity/Player;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function1;)V
17361738
public fun sendPlayerChatMessage (Lorg/bukkit/entity/Player;Lnet/kyori/adventure/chat/SignedMessage;Lnet/kyori/adventure/chat/ChatType$Bound;)V

surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/nms/bridges/SurfPaperNmsPlayerBridge.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.bukkit.inventory.EntityEquipment
1515
import org.bukkit.inventory.ItemStack
1616
import org.jetbrains.annotations.ApiStatus
1717
import java.io.File
18+
import java.nio.file.Path
1819

1920
@NmsUseWithCaution
2021
@ApiStatus.NonExtendable
@@ -84,6 +85,13 @@ interface SurfPaperNmsPlayerBridge {
8485
*/
8586
fun getPlayerDataDir(): File
8687

88+
/**
89+
* Retrieves the file system path used for storing statistical data.
90+
*
91+
* @return a [Path] object representing the location where statistical data is stored
92+
*/
93+
fun getStatsDataPath(): Path
94+
8795
companion object : SurfPaperNmsPlayerBridge by playerBridge {
8896
val INSTANCE get() = playerBridge
8997
}

0 commit comments

Comments
 (0)