Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.code.style=official
kotlin.stdlib.default.dependency=false
org.gradle.parallel=true
version=3.3.0-SNAPSHOT
version=3.3.1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fun hatCommand() = commandTree("hat") {
playerExecutor { player, _ ->
val itemInHand = player.inventory.itemInMainHand
val helmet = player.inventory.helmet
player.inventory.helmet = itemInHand
player.inventory.setHelmet(itemInHand)
player.inventory.setItemInMainHand(helmet)

if (itemInHand.type.isAir) {
Expand All @@ -34,7 +34,7 @@ fun hatCommand() = commandTree("hat") {
val player: Player by args
val itemInHand = executor.inventory.itemInMainHand
val helmet = player.inventory.helmet
player.inventory.helmet = itemInHand
player.inventory.setHelmet(itemInHand)
player.inventory.setItemInMainHand(helmet)

if (itemInHand.type.isAir) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fun knightCommand() = commandTree("knight") {
withPermission(EssentialsPermissionRegistry.KNIGHT_COMMAND)
playerExecutor { player, _ ->
plugin.launch(plugin.entityDispatcher(player)) {
player.inventory.helmet = buildItem(Material.GOLDEN_HELMET) {
player.inventory.setHelmet(buildItem(Material.GOLDEN_HELMET) {
meta {
addEnchant(Enchantment.AQUA_AFFINITY, 10, true)
addEnchant(Enchantment.RESPIRATION, 10, true)
Expand All @@ -28,9 +28,9 @@ fun knightCommand() = commandTree("knight") {
displayName {
variableValue("Ritterhelm")
}
}
})

player.inventory.chestplate = buildItem(Material.GOLDEN_CHESTPLATE) {
player.inventory.setChestplate(buildItem(Material.GOLDEN_CHESTPLATE) {
meta {
addEnchant(Enchantment.PROTECTION, 10, true)
isUnbreakable = true
Expand All @@ -39,9 +39,9 @@ fun knightCommand() = commandTree("knight") {
displayName {
variableValue("Ritterbrustplatte")
}
}
})

player.inventory.leggings = buildItem(Material.GOLDEN_LEGGINGS) {
player.inventory.setLeggings(buildItem(Material.GOLDEN_LEGGINGS) {
meta {
addEnchant(Enchantment.SWIFT_SNEAK, 10, true)
addEnchant(Enchantment.PROTECTION, 10, true)
Expand All @@ -51,9 +51,9 @@ fun knightCommand() = commandTree("knight") {
displayName {
variableValue("Ritterhose")
}
}
})

player.inventory.boots = buildItem(Material.GOLDEN_BOOTS) {
player.inventory.setBoots(buildItem(Material.GOLDEN_BOOTS) {
meta {
addEnchant(Enchantment.DEPTH_STRIDER, 10, true)
addEnchant(Enchantment.PROTECTION, 10, true)
Expand All @@ -63,7 +63,7 @@ fun knightCommand() = commandTree("knight") {
displayName {
variableValue("Ritterschuhe")
}
}
})

player.inventory.setItem(0, buildItem(Material.GOLDEN_SWORD) {
meta {
Expand Down
23 changes: 7 additions & 16 deletions src/main/kotlin/dev/slne/surf/essentials/util/util/player-util.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package dev.slne.surf.essentials.util.util

import dev.slne.surf.api.paper.nms.NmsUseWithCaution
import dev.slne.surf.api.paper.nms.bridges.SurfPaperNmsPlayerBridge
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import net.kyori.adventure.nbt.*
Expand All @@ -12,25 +14,14 @@ import java.io.File
import java.io.IOException
import java.util.*

private const val PLAYER_DATA_FOLDER = "playerdata"
private const val PLAYER_DATA_FOLDER = "players/data"
private const val PLAYER_GAME_MODE_FILE = "playerGameType"

@OptIn(NmsUseWithCaution::class)
private fun getPlayerFile(uuid: UUID): File? {
for (world in Bukkit.getWorlds()) {
val worldFolder = world.worldFolder
if (!worldFolder.isDirectory()) {
continue
}

val playerDataFolder = File(worldFolder, PLAYER_DATA_FOLDER)
if (!playerDataFolder.isDirectory()) {
continue
}

val playerFile = File(playerDataFolder, "$uuid.dat")
if (playerFile.exists()) {
return playerFile
}
val playerFile = File(SurfPaperNmsPlayerBridge.getPlayerDataDir(), "$uuid.dat")
if (playerFile.exists()) {
return playerFile
}
return null
}
Expand Down