diff --git a/gradle.properties b/gradle.properties index e4d8b9a..d4e255c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d997cfc..b1b8ef5 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c385eaa..b52fb7e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 \ No newline at end of file +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 0262dcb..b9bb139 100755 --- a/gradlew +++ b/gradlew @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/gradlew.bat b/gradlew.bat index c4bdd3a..24c62d5 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -23,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -51,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -65,7 +65,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line @@ -73,21 +73,10 @@ goto fail @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/SurfNpcApi.kt b/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/SurfNpcApi.kt index 09e781d..1589f53 100644 --- a/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/SurfNpcApi.kt +++ b/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/SurfNpcApi.kt @@ -21,6 +21,7 @@ interface SurfNpcApi { displayName: Component, uniqueName: String, type: EntityType, + useTransparentBackground: Boolean = false, location: Location, viewers: ObjectSet? = null, rotationType: NpcRotationType = NpcRotationType.PER_PLAYER, diff --git a/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/dsl/NpcDslBuilder.kt b/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/dsl/NpcDslBuilder.kt index 0272f41..c073642 100644 --- a/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/dsl/NpcDslBuilder.kt +++ b/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/dsl/NpcDslBuilder.kt @@ -40,6 +40,8 @@ class NpcDslBuilder { lateinit var type: EntityType + var useTransparentNametagBackground = false + /** * The location of the NPC. */ @@ -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. @@ -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) diff --git a/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/npc/Npc.kt b/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/npc/Npc.kt index cb9e6af..d5748b2 100644 --- a/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/npc/Npc.kt +++ b/surf-npc-api/src/main/kotlin/dev/slne/surf/npc/api/npc/Npc.kt @@ -41,6 +41,7 @@ data class Npc( val npcUuid: UUID, val nameTagId: Int, val nameTagUuid: UUID, + val transparentNameTag: Boolean, val properties: Object2ObjectMap, val viewers: ObjectSet?, val npcSittingId: Int, diff --git a/surf-npc-example-dsl/src/main/kotlin/dev/slne/surf/npc/example/SurfNpcExamplePlugin.kt b/surf-npc-example-dsl/src/main/kotlin/dev/slne/surf/npc/example/SurfNpcExamplePlugin.kt index 3f7efd4..dd5a15a 100644 --- a/surf-npc-example-dsl/src/main/kotlin/dev/slne/surf/npc/example/SurfNpcExamplePlugin.kt +++ b/surf-npc-example-dsl/src/main/kotlin/dev/slne/surf/npc/example/SurfNpcExamplePlugin.kt @@ -58,6 +58,8 @@ class SurfNpcExamplePlugin() : SuspendingJavaPlugin() { } } + useTransparentNametagBackground() + scale(2.0) /** diff --git a/surf-npc-example/src/main/kotlin/dev/slne/surf/npc/example/SurfNpcExamplePlugin.kt b/surf-npc-example/src/main/kotlin/dev/slne/surf/npc/example/SurfNpcExamplePlugin.kt index dd6bfe2..e2d2c64 100644 --- a/surf-npc-example/src/main/kotlin/dev/slne/surf/npc/example/SurfNpcExamplePlugin.kt +++ b/surf-npc-example/src/main/kotlin/dev/slne/surf/npc/example/SurfNpcExamplePlugin.kt @@ -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 @@ -23,8 +22,7 @@ class SurfNpcExamplePlugin : SuspendingJavaPlugin() { .deserialize("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( diff --git a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/PaperPackets.kt b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/PaperPackets.kt index 740014c..41ca526 100644 --- a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/PaperPackets.kt +++ b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/PaperPackets.kt @@ -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)) + } + } ) } diff --git a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/api/PaperSurfNpcApi.kt b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/api/PaperSurfNpcApi.kt index a2d49f8..ee8bb4d 100644 --- a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/api/PaperSurfNpcApi.kt +++ b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/api/PaperSurfNpcApi.kt @@ -28,6 +28,7 @@ class PaperSurfNpcApi : SurfNpcApi, Services.Fallback { displayName: Component, uniqueName: String, type: EntityType, + useTransparentBackground: Boolean, location: Location, viewers: ObjectSet?, rotationType: NpcRotationType, @@ -37,6 +38,7 @@ class PaperSurfNpcApi : SurfNpcApi, Services.Fallback { displayName, uniqueName, type, + useTransparentBackground, location, viewers, rotationType, diff --git a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/config/NpcConfig.kt b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/config/NpcConfig.kt index 21e8425..1cda4f0 100644 --- a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/config/NpcConfig.kt +++ b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/config/NpcConfig.kt @@ -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(), diff --git a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/controller/NpcController.kt b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/controller/NpcController.kt index 9fdc6a0..a546386 100644 --- a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/controller/NpcController.kt +++ b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/controller/NpcController.kt @@ -49,6 +49,7 @@ class NpcController { displayName: Component, uniqueName: String, type: EntityType, + useTransparentBackground: Boolean = false, location: Location, viewers: ObjectSet? = null, rotationType: NpcRotationType = NpcRotationType.PER_PLAYER, @@ -62,6 +63,7 @@ class NpcController { npcUuid = UUID.randomUUID(), nameTagId = random.nextInt(), nameTagUuid = UUID.randomUUID(), + useTransparentBackground, properties = mutableObject2ObjectMapOf(), viewers = viewers, npcSittingId = npcs.size + 1, @@ -153,7 +155,8 @@ class NpcController { ).build().sendPacket(uuid) BukkitPackets.NpcNameTagPackets.NameTagMetaDataPacket( npc.nameTagId, - npc.getDisplayName() + npc.getDisplayName(), + npc.transparentNameTag ).build() .sendPacket(uuid) diff --git a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/service/StorageService.kt b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/service/StorageService.kt index 0d21191..8942ab8 100644 --- a/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/service/StorageService.kt +++ b/surf-npc-paper/src/main/kotlin/dev/slne/surf/npc/paper/service/StorageService.kt @@ -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) -> @@ -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