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=1.6.6
version=1.6.7
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 10 additions & 21 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface SurfNpcApi {
displayName: Component,
uniqueName: String,
type: EntityType,
useTransparentBackground: Boolean = false,
location: Location,
viewers: ObjectSet<UUID>? = null,
rotationType: NpcRotationType = NpcRotationType.PER_PLAYER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class NpcDslBuilder {

lateinit var type: EntityType

var useTransparentNametagBackground = false

/**
* The location of the NPC.
*/
Expand Down Expand Up @@ -105,6 +107,10 @@ class NpcDslBuilder {
this.scale = scale
}

fun useTransparentNametagBackground(useTransparentNametagBackground: Boolean = true) {
this.useTransparentNametagBackground = useTransparentNametagBackground
}


/**
* Configures the skin of the NPC using a DSL block.
Expand Down Expand Up @@ -171,11 +177,12 @@ fun npc(block: NpcDslBuilder.() -> Unit): Npc {
displayName = SurfComponentBuilder.builder().apply(builder.displayName).build(),
uniqueName = builder.uniqueName,
type = builder.type,
skin = builder.skin,
useTransparentBackground = builder.useTransparentNametagBackground,
location = builder.location,
viewers = builder.viewers,
rotationType = builder.rotationType,
persistent = builder.persistent,
skin = builder.skin,
)

npc.setScale(builder.scale)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ data class Npc(
val npcUuid: UUID,
val nameTagId: Int,
val nameTagUuid: UUID,
val transparentNameTag: Boolean,
val properties: Object2ObjectMap<String, NpcProperty>,
val viewers: ObjectSet<UUID>?,
val npcSittingId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class SurfNpcExamplePlugin() : SuspendingJavaPlugin() {
}
}

useTransparentNametagBackground()

scale(2.0)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import dev.slne.surf.npc.api.SurfNpcApi
import dev.slne.surf.npc.api.event.NpcInteractEvent
import dev.slne.surf.npc.api.npc.property.NpcProperty
import dev.slne.surf.npc.api.npc.property.NpcPropertyType
import dev.slne.surf.npc.api.npc.skin.NpcSkin
import dev.slne.surf.npc.api.util.addEventHandler
import dev.slne.surf.npc.example.listener.ExampleNpcListener
import net.kyori.adventure.text.minimessage.MiniMessage
Expand All @@ -23,8 +22,7 @@ class SurfNpcExamplePlugin : SuspendingJavaPlugin() {
.deserialize("<rainbow>Example Npc by surf-npc-example"),
uniqueName = "example_npc",
type = EntityType.MANNEQUIN,
location = Location(Bukkit.getWorlds().first(), 0.0, 0.0, 0.0),
skin = NpcSkin.empty()
location = Location(Bukkit.getWorlds().first(), 0.0, 0.0, 0.0)
)

SurfNpcApi.addProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,22 @@ sealed class BukkitPackets {
)
}

data class NameTagMetaDataPacket(val entityId: Int, val displayName: Component) :
data class NameTagMetaDataPacket(
val entityId: Int,
val displayName: Component,
val transparentBackground: Boolean
) :
NpcNameTagPackets() {
override fun build() = WrapperPlayServerEntityMetadata(
entityId,
listOf(
buildMetaData(23, EntityDataTypes.ADV_COMPONENT, displayName),
buildMetaData(15, EntityDataTypes.BYTE, 3.toByte())
)
buildList {
add(buildMetaData(23, EntityDataTypes.ADV_COMPONENT, displayName))
add(buildMetaData(15, EntityDataTypes.BYTE, 3.toByte()))

if (transparentBackground) {
add(buildMetaData(25, EntityDataTypes.INT, 0))
}
}
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class PaperSurfNpcApi : SurfNpcApi, Services.Fallback {
displayName: Component,
uniqueName: String,
type: EntityType,
useTransparentBackground: Boolean,
location: Location,
viewers: ObjectSet<UUID>?,
rotationType: NpcRotationType,
Expand All @@ -37,6 +38,7 @@ class PaperSurfNpcApi : SurfNpcApi, Services.Fallback {
displayName,
uniqueName,
type,
useTransparentBackground,
location,
viewers,
rotationType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data class NpcConfig(
var entityType: EntityType = EntityType.ZOMBIE,
var nameTagId: Int = 0,
var nameTagUuid: UUID = UUID.randomUUID(),
var transparentNameTag: Boolean = false,
var uniqueName: String = "",
var sittingId: Int = 0,
var sittingUuid: UUID = UUID.randomUUID(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class NpcController {
displayName: Component,
uniqueName: String,
type: EntityType,
useTransparentBackground: Boolean = false,
location: Location,
viewers: ObjectSet<UUID>? = null,
rotationType: NpcRotationType = NpcRotationType.PER_PLAYER,
Expand All @@ -62,6 +63,7 @@ class NpcController {
npcUuid = UUID.randomUUID(),
nameTagId = random.nextInt(),
nameTagUuid = UUID.randomUUID(),
useTransparentBackground,
properties = mutableObject2ObjectMapOf<String, NpcProperty>(),
viewers = viewers,
npcSittingId = npcs.size + 1,
Expand Down Expand Up @@ -153,7 +155,8 @@ class NpcController {
).build().sendPacket(uuid)
BukkitPackets.NpcNameTagPackets.NameTagMetaDataPacket(
npc.nameTagId,
npc.getDisplayName()
npc.getDisplayName(),
npc.transparentNameTag
).build()
.sendPacket(uuid)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class NpcStorageService {
npcSittingUuid = config.sittingUuid,
viewers = if (config.viewerAmount == -1) null
else config.viewers.toMutableObjectSet(),
properties = mutableObject2ObjectMapOf()
properties = mutableObject2ObjectMapOf(),
transparentNameTag = config.transparentNameTag
)

config.properties.forEach { (key, prop) ->
Expand Down Expand Up @@ -89,6 +90,7 @@ class NpcStorageService {
npcUuid = npc.npcUuid
nameTagId = npc.nameTagId
nameTagUuid = npc.nameTagUuid
transparentNameTag = npc.transparentNameTag
uniqueName = npc.uniqueName
sittingId = npc.npcSittingId
sittingUuid = npc.npcSittingUuid
Expand Down
Loading