Skip to content

Commit b0e2a94

Browse files
committed
refactor: reorganize package structure for NPC properties and related classes
1 parent fa3a799 commit b0e2a94

27 files changed

+242
-189
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
SLNE_SNAPSHOTS_REPO_PASSWORD: ${{ secrets.SLNE_SNAPSHOTS_REPO_PASSWORD }}
1212
SLNE_RELEASES_REPO_USERNAME: ${{ secrets.SLNE_RELEASES_REPO_USERNAME }}
1313
SLNE_RELEASES_REPO_PASSWORD: ${{ secrets.SLNE_RELEASES_REPO_PASSWORD }}
14-
MODULE_REGEX: "surf-npc-api.*-all\\.jar$"
14+
MODULE_REGEX: "surf-npc-api.*-all\\.jar$|surf-npc-bukkit.*-all\\.jar$"
1515
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
1616

1717
jobs:

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.7-1.0.0-SNAPSHOT
4+
version=1.21.7-1.0.1-SNAPSHOT

surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/BukkitMain.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ import dev.slne.surf.npc.api.npc.property.NpcPropertyType
88
import dev.slne.surf.npc.bukkit.command.NpcCommand
99
import dev.slne.surf.npc.bukkit.listener.ConnectionListener
1010
import dev.slne.surf.npc.bukkit.listener.NpcListener
11-
import dev.slne.surf.npc.bukkit.property.impl.BooleanPropertyType
12-
import dev.slne.surf.npc.bukkit.property.impl.ComponentPropertyType
13-
import dev.slne.surf.npc.bukkit.property.impl.DoublePropertyType
14-
import dev.slne.surf.npc.bukkit.property.impl.FloatPropertyType
15-
import dev.slne.surf.npc.bukkit.property.impl.IntPropertyType
11+
import dev.slne.surf.npc.bukkit.npc.property.impl.BooleanPropertyType
12+
import dev.slne.surf.npc.bukkit.npc.property.impl.ComponentPropertyType
13+
import dev.slne.surf.npc.bukkit.npc.property.impl.DoublePropertyType
14+
import dev.slne.surf.npc.bukkit.npc.property.impl.FloatPropertyType
15+
import dev.slne.surf.npc.bukkit.npc.property.impl.IntPropertyType
16+
import dev.slne.surf.npc.bukkit.npc.property.impl.LongPropertyType
17+
import dev.slne.surf.npc.bukkit.npc.property.impl.NamedTextColorPropertyType
1618
import dev.slne.surf.npc.bukkit.npc.property.impl.NpcLocationPropertyType
17-
import dev.slne.surf.npc.bukkit.property.impl.LongPropertyType
18-
import dev.slne.surf.npc.bukkit.property.impl.NamedTextColorPropertyType
19-
import dev.slne.surf.npc.bukkit.property.impl.NpcRotationPropertyType
20-
import dev.slne.surf.npc.bukkit.property.impl.StringPropertyType
21-
import dev.slne.surf.npc.bukkit.property.impl.UuidPropertyType
19+
import dev.slne.surf.npc.bukkit.npc.property.impl.NpcRotationPropertyType
20+
import dev.slne.surf.npc.bukkit.npc.property.impl.StringPropertyType
21+
import dev.slne.surf.npc.bukkit.npc.property.impl.UuidPropertyType
2222
import dev.slne.surf.npc.core.property.propertyTypeRegistry
2323
import dev.slne.surf.npc.core.service.storageService
2424

surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/api/BukkitSurfNpcApi.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
11
package dev.slne.surf.npc.bukkit.api
22

33
import com.google.auto.service.AutoService
4-
54
import dev.slne.surf.npc.api.SurfNpcApi
65
import dev.slne.surf.npc.api.npc.Npc
76
import dev.slne.surf.npc.api.npc.location.NpcLocation
87
import dev.slne.surf.npc.api.npc.property.NpcProperty
98
import dev.slne.surf.npc.api.npc.property.NpcPropertyType
10-
import dev.slne.surf.npc.api.result.NpcCreationResult
11-
import dev.slne.surf.npc.api.result.NpcDeletionResult
129
import dev.slne.surf.npc.api.npc.rotation.NpcRotation
1310
import dev.slne.surf.npc.api.npc.rotation.NpcRotationType
1411
import dev.slne.surf.npc.api.npc.skin.NpcSkin
12+
import dev.slne.surf.npc.api.result.NpcCreationResult
13+
import dev.slne.surf.npc.api.result.NpcDeletionResult
1514
import dev.slne.surf.npc.bukkit.npc.location.BukkitNpcLocation
16-
import dev.slne.surf.npc.bukkit.property.BukkitNpcProperty
17-
import dev.slne.surf.npc.bukkit.rotation.BukkitNpcRotation
18-
import dev.slne.surf.npc.bukkit.skin.BukkitSNpcSkinData
15+
import dev.slne.surf.npc.bukkit.npc.property.BukkitNpcProperty
16+
import dev.slne.surf.npc.bukkit.npc.rotation.BukkitNpcRotation
17+
import dev.slne.surf.npc.bukkit.npc.skin.BukkitSNpcSkinData
1918
import dev.slne.surf.npc.bukkit.util.skinDataFromName
2019
import dev.slne.surf.npc.core.controller.npcController
2120
import dev.slne.surf.npc.core.property.propertyTypeRegistry
22-
2321
import it.unimi.dsi.fastutil.objects.ObjectList
2422
import it.unimi.dsi.fastutil.objects.ObjectSet
25-
2623
import net.kyori.adventure.text.Component
2724
import net.kyori.adventure.util.Services
28-
29-
import java.util.UUID
25+
import java.util.*
3026

3127
@AutoService(SurfNpcApi::class)
3228
class BukkitSurfNpcApi : SurfNpcApi, Services.Fallback {

surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/command/sub/NpcCreateCommand.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ import dev.jorel.commandapi.kotlindsl.getValue
66
import dev.jorel.commandapi.kotlindsl.playerExecutor
77
import dev.jorel.commandapi.kotlindsl.stringArgument
88
import dev.jorel.commandapi.kotlindsl.textArgument
9-
10-
import dev.slne.surf.npc.api.result.NpcCreationResult
119
import dev.slne.surf.npc.api.npc.rotation.NpcRotationType
10+
import dev.slne.surf.npc.api.result.NpcCreationResult
1211
import dev.slne.surf.npc.bukkit.command.argument.rotationTypeArgument
1312
import dev.slne.surf.npc.bukkit.npc.location.BukkitNpcLocation
13+
import dev.slne.surf.npc.bukkit.npc.rotation.BukkitNpcRotation
1414
import dev.slne.surf.npc.bukkit.plugin
15-
import dev.slne.surf.npc.bukkit.rotation.BukkitNpcRotation
1615
import dev.slne.surf.npc.bukkit.util.PermissionRegistry
1716
import dev.slne.surf.npc.bukkit.util.skinDataFromName
1817
import dev.slne.surf.npc.core.controller.npcController
1918
import dev.slne.surf.surfapi.core.api.messages.adventure.sendText
20-
2119
import net.kyori.adventure.text.minimessage.MiniMessage
2220

2321
class NpcCreateCommand(commandName: String) : CommandAPICommand(commandName) {
@@ -34,7 +32,7 @@ class NpcCreateCommand(commandName: String) : CommandAPICommand(commandName) {
3432
val rotationType: NpcRotationType by args
3533
val location = player.location
3634

37-
if(!this.isValidName(name)) {
35+
if (!this.isValidName(name)) {
3836
player.sendText {
3937
appendPrefix()
4038
error("Der Npc Name ist ungültig.")
@@ -63,15 +61,15 @@ class NpcCreateCommand(commandName: String) : CommandAPICommand(commandName) {
6361

6462
val npc = npcController.getNpc(uniqueName)
6563

66-
if(npc == null) {
64+
if (npc == null) {
6765
player.sendText {
6866
appendPrefix()
6967
error("Der Npc konnte nicht erstellt werden: ${npcResult.name}")
7068
}
7169
return@launch
7270
}
7371

74-
if(npcResult == NpcCreationResult.SUCCESS) {
72+
if (npcResult == NpcCreationResult.SUCCESS) {
7573
player.sendText {
7674
appendPrefix()
7775
success("Der Npc wurde erfolgreich erstellt.")

surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/command/sub/edit/NpcEditDisplayNameCommand.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import dev.slne.surf.npc.api.npc.Npc
88
import dev.slne.surf.npc.api.npc.property.NpcProperty
99
import dev.slne.surf.npc.api.npc.property.NpcPropertyType
1010
import dev.slne.surf.npc.bukkit.command.argument.npcArgument
11-
import dev.slne.surf.npc.bukkit.property.BukkitNpcProperty
11+
import dev.slne.surf.npc.bukkit.npc.property.BukkitNpcProperty
1212
import dev.slne.surf.npc.bukkit.util.PermissionRegistry
1313
import dev.slne.surf.npc.bukkit.util.miniMessage
1414
import dev.slne.surf.npc.core.property.propertyTypeRegistry
@@ -25,11 +25,14 @@ class NpcEditDisplayNameCommand(commandName: String) : CommandAPICommand(command
2525

2626
val name = miniMessage.deserialize(displayName)
2727

28-
npc.addProperty(BukkitNpcProperty(
29-
NpcProperty.Internal.DISPLAYNAME,
30-
name,
31-
propertyTypeRegistry.get(NpcPropertyType.Types.COMPONENT) ?: return@playerExecutor
32-
))
28+
npc.addProperty(
29+
BukkitNpcProperty(
30+
NpcProperty.Internal.DISPLAYNAME,
31+
name,
32+
propertyTypeRegistry.get(NpcPropertyType.Types.COMPONENT)
33+
?: return@playerExecutor
34+
)
35+
)
3336

3437
npc.refresh()
3538

surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/command/sub/edit/NpcEditRotationCommand.kt

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import dev.slne.surf.npc.api.npc.property.NpcPropertyType
99
import dev.slne.surf.npc.api.npc.rotation.NpcRotationType
1010
import dev.slne.surf.npc.bukkit.command.argument.npcArgument
1111
import dev.slne.surf.npc.bukkit.command.argument.rotationTypeArgument
12-
import dev.slne.surf.npc.bukkit.property.BukkitNpcProperty
13-
import dev.slne.surf.npc.bukkit.rotation.BukkitNpcRotation
12+
import dev.slne.surf.npc.bukkit.npc.property.BukkitNpcProperty
13+
import dev.slne.surf.npc.bukkit.npc.rotation.BukkitNpcRotation
1414
import dev.slne.surf.npc.bukkit.util.PermissionRegistry
1515
import dev.slne.surf.npc.core.property.propertyTypeRegistry
1616
import dev.slne.surf.surfapi.core.api.messages.adventure.sendText
@@ -24,20 +24,25 @@ class NpcEditRotationCommand(commandName: String) : CommandAPICommand(commandNam
2424
val npc: Npc by args
2525
val rotationType: NpcRotationType by args
2626

27-
npc.addProperty(BukkitNpcProperty(
28-
NpcProperty.Internal.ROTATION_TYPE,
29-
rotationType == NpcRotationType.PER_PLAYER,
30-
propertyTypeRegistry.get(NpcPropertyType.Types.BOOLEAN) ?: return@playerExecutor
31-
))
27+
npc.addProperty(
28+
BukkitNpcProperty(
29+
NpcProperty.Internal.ROTATION_TYPE,
30+
rotationType == NpcRotationType.PER_PLAYER,
31+
propertyTypeRegistry.get(NpcPropertyType.Types.BOOLEAN) ?: return@playerExecutor
32+
)
33+
)
3234

33-
if(rotationType == NpcRotationType.FIXED) {
34-
npc.addProperty(BukkitNpcProperty(
35-
NpcProperty.Internal.ROTATION_FIXED,
36-
BukkitNpcRotation(
37-
player.yaw, player.pitch
38-
),
39-
propertyTypeRegistry.get(NpcPropertyType.Types.NPC_ROTATION) ?: return@playerExecutor
40-
))
35+
if (rotationType == NpcRotationType.FIXED) {
36+
npc.addProperty(
37+
BukkitNpcProperty(
38+
NpcProperty.Internal.ROTATION_FIXED,
39+
BukkitNpcRotation(
40+
player.yaw, player.pitch
41+
),
42+
propertyTypeRegistry.get(NpcPropertyType.Types.NPC_ROTATION)
43+
?: return@playerExecutor
44+
)
45+
)
4146
}
4247

4348
npc.refresh()

surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/command/sub/edit/NpcEditSkinCommand.kt

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import dev.slne.surf.npc.api.npc.Npc
99
import dev.slne.surf.npc.api.npc.property.NpcProperty
1010
import dev.slne.surf.npc.api.npc.property.NpcPropertyType
1111
import dev.slne.surf.npc.bukkit.command.argument.npcArgument
12+
import dev.slne.surf.npc.bukkit.npc.property.BukkitNpcProperty
1213
import dev.slne.surf.npc.bukkit.plugin
13-
import dev.slne.surf.npc.bukkit.property.BukkitNpcProperty
1414
import dev.slne.surf.npc.bukkit.util.PermissionRegistry
1515
import dev.slne.surf.npc.bukkit.util.skinDataFromName
1616
import dev.slne.surf.npc.core.property.propertyTypeRegistry
@@ -36,21 +36,27 @@ class NpcEditSkinCommand(commandName: String) : CommandAPICommand(commandName) {
3636
val skinData = skinDataFromName(skinPlayer)
3737

3838

39-
npc.addProperty(BukkitNpcProperty(
40-
NpcProperty.Internal.SKIN_OWNER,
41-
skinData.ownerName,
42-
propertyTypeRegistry.get(NpcPropertyType.Types.STRING) ?: return@launch
43-
))
44-
npc.addProperty(BukkitNpcProperty(
45-
NpcProperty.Internal.SKIN_TEXTURE,
46-
skinData.value,
47-
propertyTypeRegistry.get(NpcPropertyType.Types.STRING) ?: return@launch
48-
))
49-
npc.addProperty(BukkitNpcProperty(
50-
NpcProperty.Internal.SKIN_SIGNATURE,
51-
skinData.signature,
52-
propertyTypeRegistry.get(NpcPropertyType.Types.STRING) ?: return@launch
53-
))
39+
npc.addProperty(
40+
BukkitNpcProperty(
41+
NpcProperty.Internal.SKIN_OWNER,
42+
skinData.ownerName,
43+
propertyTypeRegistry.get(NpcPropertyType.Types.STRING) ?: return@launch
44+
)
45+
)
46+
npc.addProperty(
47+
BukkitNpcProperty(
48+
NpcProperty.Internal.SKIN_TEXTURE,
49+
skinData.value,
50+
propertyTypeRegistry.get(NpcPropertyType.Types.STRING) ?: return@launch
51+
)
52+
)
53+
npc.addProperty(
54+
BukkitNpcProperty(
55+
NpcProperty.Internal.SKIN_SIGNATURE,
56+
skinData.signature,
57+
propertyTypeRegistry.get(NpcPropertyType.Types.STRING) ?: return@launch
58+
)
59+
)
5460
npc.refresh()
5561

5662
player.sendText {

surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/command/sub/property/NpcPropertyAddCommand.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import dev.jorel.commandapi.CommandAPICommand
44
import dev.jorel.commandapi.kotlindsl.getValue
55
import dev.jorel.commandapi.kotlindsl.playerExecutor
66
import dev.jorel.commandapi.kotlindsl.stringArgument
7-
87
import dev.slne.surf.npc.api.npc.Npc
98
import dev.slne.surf.npc.api.npc.property.NpcPropertyType
109
import dev.slne.surf.npc.bukkit.command.argument.npcArgument
1110
import dev.slne.surf.npc.bukkit.command.argument.npcPropertyTypeArgument
12-
import dev.slne.surf.npc.bukkit.property.BukkitNpcProperty
11+
import dev.slne.surf.npc.bukkit.npc.property.BukkitNpcProperty
1312
import dev.slne.surf.npc.bukkit.util.PermissionRegistry
1413
import dev.slne.surf.surfapi.core.api.messages.adventure.sendText
1514

@@ -28,14 +27,16 @@ class NpcPropertyAddCommand(commandName: String) : CommandAPICommand(commandName
2827

2928
val exists = npc.hasProperty(key)
3029

31-
npc.addProperty(BukkitNpcProperty(
32-
key, propertyType.decode(value), propertyType
33-
))
30+
npc.addProperty(
31+
BukkitNpcProperty(
32+
key, propertyType.decode(value), propertyType
33+
)
34+
)
3435

3536
player.sendText {
3637
appendPrefix()
3738

38-
if(exists) {
39+
if (exists) {
3940
success("Die Property '${key}' wurde erfolgreich dem NPC '${npc.uniqueName}' neu gesetzt.")
4041
} else {
4142
success("Die Property '${key}' wurde erfolgreich zum NPC '${npc.uniqueName}' hinzugefügt.")

0 commit comments

Comments
 (0)