Skip to content

Commit 273df68

Browse files
authored
Merge pull request #38 from SLNE-Development/copilot/prevent-head-slot-overwrite
fix: /hat + version bump 2.0.19-SNAPSHOT
2 parents 49ab3ba + 9a71adb commit 273df68

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
kotlin.code.style=official
22
kotlin.stdlib.default.dependency=false
33
org.gradle.parallel=true
4-
version=1.21.11-2.0.18-SNAPSHOT
4+
version=1.21.11-2.0.19-SNAPSHOT

src/main/kotlin/dev/slne/surf/essentials/command/HatCommand.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ import org.bukkit.entity.Player
1111
fun hatCommand() = commandTree("hat") {
1212
withPermission(EssentialsPermissionRegistry.HAT_COMMAND)
1313
playerExecutor { player, _ ->
14+
val helmet = player.inventory.helmet
15+
if (helmet != null && !helmet.type.isAir) {
16+
player.sendText {
17+
appendErrorPrefix()
18+
error("Du trägst bereits einen Hut.")
19+
}
20+
return@playerExecutor
21+
}
22+
1423
val itemInHand = player.inventory.itemInMainHand
1524
player.inventory.helmet = itemInHand
1625

@@ -30,6 +39,16 @@ fun hatCommand() = commandTree("hat") {
3039
withPermission(EssentialsPermissionRegistry.HAT_COMMAND_OTHERS)
3140
playerExecutor { executor, args ->
3241
val player: Player by args
42+
val helmet = player.inventory.helmet
43+
if (helmet != null && !helmet.type.isAir) {
44+
executor.sendText {
45+
appendErrorPrefix()
46+
variableValue(player.name)
47+
error(" trägt bereits einen Hut.")
48+
}
49+
return@playerExecutor
50+
}
51+
3352
val itemInHand = executor.inventory.itemInMainHand
3453
player.inventory.helmet = itemInHand
3554

0 commit comments

Comments
 (0)