From 212c9421763f0ecca1d1423d75762742bb3ae931 Mon Sep 17 00:00:00 2001 From: Shynixn Date: Sat, 13 Jul 2024 17:00:04 +0200 Subject: [PATCH 1/3] #586 Added rideSneak event. --- .gitignore | 3 +++ build.gradle.kts | 10 +++++----- docs/wiki/docs/template.md | 14 ++++++++++---- .../github/shynixn/petblocks/impl/PetEntityImpl.kt | 14 ++++++++++++-- .../shynixn/petblocks/impl/listener/PetListener.kt | 2 +- src/main/resources/pets/pet_classic.yml | 8 ++++++++ src/main/resources/pets/pet_flying_dolphin.yml | 8 ++++++++ src/main/resources/pets/pet_mining.yml | 9 +++++++++ 8 files changed, 56 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 0da422cec..355fb6b53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ /petblocks-bukkit-api/build/ /petblocks-bukkit-plugin/build/ +.idea +.gradle +build diff --git a/build.gradle.kts b/build.gradle.kts index 6c44cb38f..21962821d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,10 +31,10 @@ dependencies { compileOnly("com.arcaniax:HeadDatabase-API:1.3.1") // Library dependencies with legacy compatibility, we can use more up-to-date version in the plugin.yml - implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.16.0") - implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.16.0") - runtimeOnly("com.github.shynixn.mccoroutine:mccoroutine-folia-api:2.16.0") - runtimeOnly("com.github.shynixn.mccoroutine:mccoroutine-folia-core:2.16.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:2.18.0") + implementation("com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:2.18.0") + runtimeOnly("com.github.shynixn.mccoroutine:mccoroutine-folia-api:2.18.0") + runtimeOnly("com.github.shynixn.mccoroutine:mccoroutine-folia-core:2.18.0") implementation("com.google.inject:guice:5.0.1") implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.3.0") implementation("com.fasterxml.jackson.core:jackson-databind:2.2.3") @@ -47,7 +47,7 @@ dependencies { // Custom dependencies implementation("com.github.shynixn.shygui:shygui:1.0.0") implementation("com.github.shynixn.mcutils:common:2024.19") - implementation("com.github.shynixn.mcutils:packet:2024.30") + implementation("com.github.shynixn.mcutils:packet:2024.32") implementation("com.github.shynixn.mcutils:database:2024.2") implementation("com.github.shynixn.mcutils:pathfinder:2024.3") implementation("com.github.shynixn.mcutils:guice:2024.2") diff --git a/docs/wiki/docs/template.md b/docs/wiki/docs/template.md index 8abf14075..350ea5c98 100644 --- a/docs/wiki/docs/template.md +++ b/docs/wiki/docs/template.md @@ -18,10 +18,16 @@ Example for static values are ``name``, ``version`` and all initial pet settings ## Events -Events define what happens on certain events. Currently only leftClick and rightClick on the pet is supported. These -actions get -executed when a player left-clicks on the pet. However, it may not be the owner, who clicks on a pet, therefore it needs -to be checked if you only want to allow certain actions for the owner of the pet. +Events define what actions to execute on certain events. + +The following events are supported: + +* leftClick +* rightClick +* ridingSneak + +For example the ``leftClick`` event gets executed when a player left-clicks on the pet. However, it may not be the owner, who clicks on a pet, therefore you need +to check if the player is the owner first as a condition. Example: diff --git a/src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt b/src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt index 3272fb4b7..0ce71fec9 100644 --- a/src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt +++ b/src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt @@ -31,7 +31,6 @@ import org.bukkit.* import org.bukkit.block.Block import org.bukkit.entity.Player import org.bukkit.plugin.Plugin -import org.bukkit.util.Vector import java.util.* import java.util.logging.Level import kotlin.collections.ArrayList @@ -60,6 +59,7 @@ class PetEntityImpl( private var cancellationTokenLoop = CancellationToken() private var cancellationTokenLongRunning = CancellationToken() private var lastRideUpdate = 0L + private var lastSneakUpdate = 0L var isBreakingBlock = false // Mover @@ -321,7 +321,7 @@ class PetEntityImpl( /** * Gets called when the player is riding the entity. */ - fun ride(player: Player, forward: Double, isJumping: Boolean) { + fun ride(player: Player, forward: Double, isJumping: Boolean, isSneaking: Boolean) { cancellationTokenLongRunning.isCancelled = true val current = Date().time @@ -362,6 +362,16 @@ class PetEntityImpl( physicsComponent.position.pitch = 0.0 physicsComponent.position.yaw = player.location.yaw.toDouble() } + + if (isSneaking && current - lastSneakUpdate >= 200) { + lastSneakUpdate = current + val sneakEvent = pet.template.events["ridingSneak"] + if (sneakEvent != null) { + plugin.launch(plugin.minecraftDispatcher + object : CoroutineTimings() {}) { + petActionExecutionService.executeAction(player, pet, sneakEvent, CancellationToken()) + } + } + } } private fun isOnGround(location: Location): Boolean { diff --git a/src/main/java/com/github/shynixn/petblocks/impl/listener/PetListener.kt b/src/main/java/com/github/shynixn/petblocks/impl/listener/PetListener.kt index 9cc1e86e0..3809b907f 100644 --- a/src/main/java/com/github/shynixn/petblocks/impl/listener/PetListener.kt +++ b/src/main/java/com/github/shynixn/petblocks/impl/listener/PetListener.kt @@ -101,7 +101,7 @@ class PetListener @Inject constructor( if (packet is PacketInSteerVehicle) { plugin.launch { val physicObject = physicObjectService.findPhysicObjectById(packet.entityId) as PetEntityImpl? - physicObject?.ride(event.player, packet.forward, packet.isJumping) + physicObject?.ride(event.player, packet.forward, packet.isJumping, packet.isShift) } return } diff --git a/src/main/resources/pets/pet_classic.yml b/src/main/resources/pets/pet_classic.yml index 0952fe3ad..56fe9df9e 100644 --- a/src/main/resources/pets/pet_classic.yml +++ b/src/main/resources/pets/pet_classic.yml @@ -109,6 +109,14 @@ events: run: - "/petblocks select %petblocks_pet_name%" - "/petblock" + ridingSneak: + # Gets called when an owner presses SHIFT while riding their pet. + actions: + - name: "Dismount the pet" + type: "COMMAND" + level: "PLAYER" + run: + - "/petblocks unmount %petblocks_pet_name%" # # Defines the action a pet should perform in an interval on its own. diff --git a/src/main/resources/pets/pet_flying_dolphin.yml b/src/main/resources/pets/pet_flying_dolphin.yml index 8420d2938..b51873d7e 100644 --- a/src/main/resources/pets/pet_flying_dolphin.yml +++ b/src/main/resources/pets/pet_flying_dolphin.yml @@ -109,6 +109,14 @@ events: run: - "/petblocks select %petblocks_pet_name%" - "/petblock" + ridingSneak: + # Gets called when an owner presses SHIFT while riding their pet. + actions: + - name: "Dismount the pet" + type: "COMMAND" + level: "PLAYER" + run: + - "/petblocks unmount %petblocks_pet_name%" # # Defines the action a pet should perform in an interval on its own. diff --git a/src/main/resources/pets/pet_mining.yml b/src/main/resources/pets/pet_mining.yml index c32186ffb..30253e987 100644 --- a/src/main/resources/pets/pet_mining.yml +++ b/src/main/resources/pets/pet_mining.yml @@ -121,6 +121,15 @@ events: - "/tell %petblocks_owner_name% Pet %petblocks_pet_displayName% &rstarts to mine a tunnel." - "/petblocks snap %petblocks_pet_name% %petblocks_owner_name%" # Snap is useful for straight tunnels. - "/petblocks loop %petblocks_pet_name% mineTunnel2x2 %petblocks_owner_name%" + ridingSneak: + # Gets called when an owner presses SHIFT while riding their pet. + actions: + - name: "Dismount the pet" + type: "COMMAND" + level: "PLAYER" + run: + - "/petblocks unmount %petblocks_pet_name%" + # # Defines the action a pet should perform in an interval on its own. # From 5ee5e5e4d3f4251cada4aa7ddfdc6f5683e0dea1 Mon Sep 17 00:00:00 2001 From: Shynixn Date: Sat, 13 Jul 2024 17:29:51 +0200 Subject: [PATCH 2/3] #588 Set pet to auto hide while the owner is flying. --- docs/wiki/docs/commands.md | 2 +- docs/wiki/docs/placeholders.md | 36 +++++++++---------- .../petblocks/enumeration/PetVisibility.kt | 3 +- .../petblocks/enumeration/PlaceHolder.kt | 3 +- .../shynixn/petblocks/impl/PetEntityImpl.kt | 13 ------- .../github/shynixn/petblocks/impl/PetImpl.kt | 2 +- .../PetBlocksCommandExecutor.kt | 2 +- .../petblocks/impl/physic/PlayerComponent.kt | 18 ++++++++-- .../provider/PetBlocksPlaceHolderProvider.kt | 2 ++ src/main/resources/lang/en_us.properties | 2 +- src/main/resources/pets/pet_classic.yml | 16 +++++++++ .../resources/pets/pet_flying_dolphin.yml | 16 +++++++++ src/main/resources/pets/pet_mining.yml | 16 +++++++++ 13 files changed, 91 insertions(+), 40 deletions(-) diff --git a/docs/wiki/docs/commands.md b/docs/wiki/docs/commands.md index 8c126bc73..7e203136d 100644 --- a/docs/wiki/docs/commands.md +++ b/docs/wiki/docs/commands.md @@ -281,7 +281,7 @@ Allows values should be set in the ``config.yml``. Changes who can see the pet. * Name: Identifier of a pet -* Types: Possibles values: ``ALL``, ``OWNER`` +* Types: Possibles values: ``ALL``, ``OWNER``, ``NOBODY`` * Player: Optional player_name/player_UUID parameter targeting a player from the console or command block. ### /petblocks loop diff --git a/docs/wiki/docs/placeholders.md b/docs/wiki/docs/placeholders.md index b00e1dc07..8f23ffaf4 100644 --- a/docs/wiki/docs/placeholders.md +++ b/docs/wiki/docs/placeholders.md @@ -7,24 +7,24 @@ The following placeholders are available in PetBlocks and can also be used via P This results into placeholders such as e.g. ``%petblocks_pet_displayName_1%`` or ``%petblocks_pet_displayName_selected%``. This is only relevant in external plugins. For actions in PetBlocks, you can directly use the placeholders below. -| Player PlaceHolders | Description | -|---------------------------------|-------------------------------------------------| -| %petblocks_owner_name% | Player name of the owner of a pet. | -| %petblocks_owner_displayName% | Player displayName of the owner of a pet. | -| %petblocks_owner_locationWorld% | Name of the world the owner of a pet is inside. | -| %petblocks_owner_locationX% | X coordinate of the owner of a pet. | -| %petblocks_owner_locationY% | Y coordinate of the owner of a pet. | -| %petblocks_owner_locationZ% | Z coordinate of the owner of a pet. | -| %petblocks_owner_locationYaw% | Yaw rotation of the owner of a pet. | -| %petblocks_owner_locationPitch% | Yaw rotation of the owner of a pet. | -| %petblocks_owner_itemMainHand_type% | Name of the item type in the owner's main hand | +| Player PlaceHolders | Description | +|--------------------------------|------------------------------------------------------| +| %petblocks_owner_name% | Player name of the owner of a pet. | +| %petblocks_owner_displayName% | Player displayName of the owner of a pet. | +| %petblocks_owner_locationWorld% | Name of the world the owner of a pet is inside. | +| %petblocks_owner_locationX% | X coordinate of the owner of a pet. | +| %petblocks_owner_locationY% | Y coordinate of the owner of a pet. | +| %petblocks_owner_locationZ% | Z coordinate of the owner of a pet. | +| %petblocks_owner_locationYaw% | Yaw rotation of the owner of a pet. | +| %petblocks_owner_locationPitch% | Yaw rotation of the owner of a pet. | +| %petblocks_owner_itemMainHand_type% | Name of the item type in the owner's main hand | +| %petblocks_owner_isFlying% | True if the owner is currently flying, false if not. | | Pet PlaceHolders | Description | |---------------------------------|----------------------------------------------------------------------------------------------------| | %petblocks_pet_name% | Id of a pet | | %petblocks_pet_displayName% | Displayname of a pet | | %petblocks_pet_distanceToOwner% | Distance from the pet to the owner. If the owner is in another world, this value becomes very high. | -| %petblocks_pet_exists% | True if the pet exists, false if not. | | %petblocks_pet_isSpawned% | True if the pet is spawned, false if not. | | %petblocks_pet_template% | Name of the template a pet uses. | | %petblocks_pet_visibility% | Visibility Type a pet uses. | @@ -49,13 +49,13 @@ The following placeholders are available in PetBlocks and can also be used via P | %petblocks_eventPlayer_name% | Player name of the event trigger player. | | %petblocks_eventPlayer_displayName% | Player displayName of the event trigger player. | | %petblocks_eventPlayer_locationWorld% | Name of the world event trigger player of a pet is inside. | -| %petblocks_eventPlayer_locationX% | X coordinate of the event trigger player. | -| %petblocks_eventPlayer_locationY% | Y coordinate of the event trigger player. | -| %petblocks_eventPlayer_locationZ% | Z coordinate of the event trigger player. | -| %petblocks_eventPlayer_locationYaw% | Yaw rotation of the event trigger player. | -| %petblocks_eventPlayer_locationPitch% | Yaw rotation of the event trigger player. | +| %petblocks_eventPlayer_locationX% | X coordinate of the event trigger player. | +| %petblocks_eventPlayer_locationY% | Y coordinate of the event trigger player. | +| %petblocks_eventPlayer_locationZ% | Z coordinate of the event trigger player. | +| %petblocks_eventPlayer_locationYaw% | Yaw rotation of the event trigger player. | +| %petblocks_eventPlayer_locationPitch% | Yaw rotation of the event trigger player. | | %petblocks_eventPlayer_itemMainHand_type% | Name of the item type in the players's main hand | - +| %petblocks_eventPlayer_isFlying% | True if the player is currently flying, false if not. | | GUI PlaceHolders | Description | |-------------------------------------------|------------------------------------------------------------| diff --git a/src/main/java/com/github/shynixn/petblocks/enumeration/PetVisibility.kt b/src/main/java/com/github/shynixn/petblocks/enumeration/PetVisibility.kt index 4341f725d..cdb251cf3 100644 --- a/src/main/java/com/github/shynixn/petblocks/enumeration/PetVisibility.kt +++ b/src/main/java/com/github/shynixn/petblocks/enumeration/PetVisibility.kt @@ -2,5 +2,6 @@ package com.github.shynixn.petblocks.enumeration enum class PetVisibility { ALL, - OWNER + OWNER, + NOBODY } diff --git a/src/main/java/com/github/shynixn/petblocks/enumeration/PlaceHolder.kt b/src/main/java/com/github/shynixn/petblocks/enumeration/PlaceHolder.kt index aca0d14ce..330b94632 100644 --- a/src/main/java/com/github/shynixn/petblocks/enumeration/PlaceHolder.kt +++ b/src/main/java/com/github/shynixn/petblocks/enumeration/PlaceHolder.kt @@ -11,6 +11,7 @@ enum class PlaceHolder(val fullPlaceHolder: String) { PLAYER_OWNER_LOCATION_YAW("%petblocks_owner_locationYaw%"), PLAYER_OWNER_LOCATION_PITCH("%petblocks_owner_locationPitch%"), PLAYER_OWNER_ITEMMAINHAND_TYPE("%petblocks_owner_itemMainHand_type%"), + PLAYER_OWNER_ISFLYING("%petblocks_owner_isFlying%"), // Event Player EVENT_PLAYER_OWNER_NAME("%petblocks_eventPlayer_name%"), @@ -22,12 +23,12 @@ enum class PlaceHolder(val fullPlaceHolder: String) { EVENT_PLAYER_OWNER_LOCATION_YAW("%petblocks_eventPlayer_locationYaw%"), EVENT_PLAYER_OWNER_LOCATION_PITCH("%petblocks_eventPlayer_locationPitch%"), EVENT_PLAYER_OWNER_ITEMMAINHAND_TYPE("%petblocks_eventPlayer_itemMainHand_type%"), + EVENT_PLAYER_OWNER_ISFLYING("%petblocks_eventPlayer_isFlying%"), // Pet PlaceHolders PET_NAME("%petblocks_pet_name%"), PET_DISPLAYNAME("%petblocks_pet_displayName%"), PET_DISTANCETOOWNER("%petblocks_pet_distanceToOwner%"), - PET_EXISTS("%petblocks_pet_exists%"), PET_ISSPAWNED("%petblocks_pet_isSpawned%"), PET_TEMPLATE("%petblocks_pet_template%"), PET_VISIBILITY("%petblocks_pet_visibility%"), diff --git a/src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt b/src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt index 0ce71fec9..ba936ceb5 100644 --- a/src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt +++ b/src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt @@ -379,19 +379,6 @@ class PetEntityImpl( return rayTraceResult.hitBlock } - /** - * If owner parameter is not null, only the owner receives packets. - */ - fun updateVisibility(visibility: PetVisibility, owner: Player, location: Location) { - for (player in playerComponent.visiblePlayers) { - if (visibility == PetVisibility.OWNER && player != owner) { - playerComponent.onRemoveMinecraft.forEach { e -> e.invoke(player, location) } - } else if (visibility == PetVisibility.ALL && player != owner) { - playerComponent.onSpawnMinecraft.forEach { e -> e.invoke(player, location) } - } - } - } - /** * Updates the displayName in the world. */ diff --git a/src/main/java/com/github/shynixn/petblocks/impl/PetImpl.kt b/src/main/java/com/github/shynixn/petblocks/impl/PetImpl.kt index cd25960e2..d3c33c48d 100644 --- a/src/main/java/com/github/shynixn/petblocks/impl/PetImpl.kt +++ b/src/main/java/com/github/shynixn/petblocks/impl/PetImpl.kt @@ -176,7 +176,7 @@ class PetImpl( petMeta.visibility = value if (previousVisibility != value && petEntity != null) { - petEntity!!.updateVisibility(visibility, player, location) + petEntity!!.playerComponent.forceMinecraftTick() } } diff --git a/src/main/java/com/github/shynixn/petblocks/impl/commandexecutor/PetBlocksCommandExecutor.kt b/src/main/java/com/github/shynixn/petblocks/impl/commandexecutor/PetBlocksCommandExecutor.kt index ab1ee537f..94aa8ed42 100644 --- a/src/main/java/com/github/shynixn/petblocks/impl/commandexecutor/PetBlocksCommandExecutor.kt +++ b/src/main/java/com/github/shynixn/petblocks/impl/commandexecutor/PetBlocksCommandExecutor.kt @@ -915,7 +915,7 @@ class PetBlocksCommandExecutor @Inject constructor( sender: CommandSender, pet: Pet, visibility: PetVisibility ) { pet.visibility = visibility - sender.sendPluginMessage(String.format(PetBlocksLanguage.visibilityChangedMessage, visibility.name)) + sender.sendPluginMessage(String.format(PetBlocksLanguage.visibilityChangedMessage, pet.name, visibility)) } private fun setPetLoop(sender: CommandSender, pet: Pet, loop: String) { diff --git a/src/main/java/com/github/shynixn/petblocks/impl/physic/PlayerComponent.kt b/src/main/java/com/github/shynixn/petblocks/impl/physic/PlayerComponent.kt index 2a81df080..0841156c4 100644 --- a/src/main/java/com/github/shynixn/petblocks/impl/physic/PlayerComponent.kt +++ b/src/main/java/com/github/shynixn/petblocks/impl/physic/PlayerComponent.kt @@ -20,7 +20,7 @@ class PlayerComponent( * Render distance blocks. */ renderDistanceBlocks: Int = 70, - private val pet : Pet + private val pet: Pet ) : PhysicComponent { var lastTimeRenderUpdate = 0L @@ -38,6 +38,14 @@ class PlayerComponent( */ val onRemoveMinecraft: MutableList<(Player, Location) -> Unit> = arrayListOf() + /** + * Forces to perform rendering logic immediately. + */ + fun forceMinecraftTick() { + lastTimeRenderUpdate = 0L + tickMinecraft() + } + override fun tickMinecraft() { val currentTime = Date().time @@ -47,11 +55,15 @@ class PlayerComponent( val players = HashSet() val location = physicsComponent.position.toLocation() for (player in location.world!!.players) { + if (pet.visibility == PetVisibility.NOBODY) { + continue + } + if (player.location.distanceSquared(location) <= renderVisibilityDistance) { if (!visiblePlayers.contains(player)) { - if( pet.visibility == PetVisibility.ALL){ + if (pet.visibility == PetVisibility.ALL) { onSpawnMinecraft.forEach { e -> e.invoke(player, location) } - }else if(pet.visibility == PetVisibility.OWNER && player == pet.player){ + } else if (pet.visibility == PetVisibility.OWNER && player == pet.player) { onSpawnMinecraft.forEach { e -> e.invoke(player, location) } } diff --git a/src/main/java/com/github/shynixn/petblocks/impl/provider/PetBlocksPlaceHolderProvider.kt b/src/main/java/com/github/shynixn/petblocks/impl/provider/PetBlocksPlaceHolderProvider.kt index b12f9ee0c..cbd8b4968 100644 --- a/src/main/java/com/github/shynixn/petblocks/impl/provider/PetBlocksPlaceHolderProvider.kt +++ b/src/main/java/com/github/shynixn/petblocks/impl/provider/PetBlocksPlaceHolderProvider.kt @@ -68,6 +68,7 @@ class PetBlocksPlaceHolderProvider( ) } registerPlayerPlaceHolder(PlaceHolder.PLAYER_OWNER_ITEMMAINHAND_TYPE) { player -> "minecraft:" + player.inventory.itemInMainHand.type.name.lowercase() } + registerPlayerPlaceHolder(PlaceHolder.PLAYER_OWNER_ISFLYING) { player -> player.isFlying.toString() } // Event Player registerPlayerPlaceHolder(PlaceHolder.EVENT_PLAYER_OWNER_NAME) { player: Player -> player.name } @@ -109,6 +110,7 @@ class PetBlocksPlaceHolderProvider( ) } registerPlayerPlaceHolder(PlaceHolder.EVENT_PLAYER_OWNER_ITEMMAINHAND_TYPE) { player -> "minecraft:" + player.inventory.itemInMainHand.type.name.lowercase() } + registerPlayerPlaceHolder(PlaceHolder.EVENT_PLAYER_OWNER_ISFLYING) { player -> player.isFlying.toString() } // Pet registerPetPlaceHolder(PlaceHolder.PET_NAME) { pet -> pet.name } diff --git a/src/main/resources/lang/en_us.properties b/src/main/resources/lang/en_us.properties index b70778bdb..747c2a8e0 100644 --- a/src/main/resources/lang/en_us.properties +++ b/src/main/resources/lang/en_us.properties @@ -9,7 +9,7 @@ petCalledMessage=[&9PetBlocks&f] Pet with name %1$1s has been called. petSpawnedMessage=[&9PetBlocks&f] Pet with name %1$1s has been spawned. petDespawnedMessage=[&9PetBlocks&f] Pet with name %1$1s has been removed. visibilityTypeNotFoundMessage=[&9PetBlocks&f] &cOnly the visibility types %1$1s are supported. -visibilityChangedMessage=[&9PetBlocks&f] The visibility of pet %1$1s has been changed. +visibilityChangedMessage=[&9PetBlocks&f] The visibility of pet %1$1s has been changed to %2$1s. petSkinTypeChangedMessage=[&9PetBlocks&f] The skinType of pet %1$1s has been changed. petSkinNbtChanged=[&9PetBlocks&f] The skin of pet %1$1s has been changed. petSkinTypeNotFound=[&9PetBlocks&f] &cMaterial %1$1s not found. diff --git a/src/main/resources/pets/pet_classic.yml b/src/main/resources/pets/pet_classic.yml index 56fe9df9e..376566445 100644 --- a/src/main/resources/pets/pet_classic.yml +++ b/src/main/resources/pets/pet_classic.yml @@ -153,6 +153,22 @@ loops: level: "SERVER" run: - "/petblocks moveToOwner %petblocks_pet_name% 0.2 %petblocks_owner_name%" + - name: "Hide the pet while player is flying" + condition: + type: JAVASCRIPT + js: "%petblocks_owner_isFlying% && '%petblocks_pet_visibility%' != 'NOBODY'" + type: "COMMAND" + level: "SERVER" + run: + - "/petblocks visibility %petblocks_pet_name% NOBODY %petblocks_owner_name%" + - name: "Show the pet while player is not flying" + condition: + type: JAVASCRIPT + js: "!%petblocks_owner_isFlying% && '%petblocks_pet_visibility%' == 'NOBODY'" + type: "COMMAND" + level: "SERVER" + run: + - "/petblocks visibility %petblocks_pet_name% ALL %petblocks_owner_name%" - name: "Switch to idle if the pet is beside the player" condition: type: NUMBER_LESS_THAN diff --git a/src/main/resources/pets/pet_flying_dolphin.yml b/src/main/resources/pets/pet_flying_dolphin.yml index b51873d7e..83f450109 100644 --- a/src/main/resources/pets/pet_flying_dolphin.yml +++ b/src/main/resources/pets/pet_flying_dolphin.yml @@ -153,6 +153,22 @@ loops: level: "SERVER" run: - "/petblocks moveToOwner %petblocks_pet_name% 0.2 %petblocks_owner_name%" + - name: "Hide the pet while player is flying" + condition: + type: JAVASCRIPT + js: "%petblocks_owner_isFlying% && '%petblocks_pet_visibility%' != 'NOBODY'" + type: "COMMAND" + level: "SERVER" + run: + - "/petblocks visibility %petblocks_pet_name% NOBODY %petblocks_owner_name%" + - name: "Show the pet while player is not flying" + condition: + type: JAVASCRIPT + js: "!%petblocks_owner_isFlying% && '%petblocks_pet_visibility%' == 'NOBODY'" + type: "COMMAND" + level: "SERVER" + run: + - "/petblocks visibility %petblocks_pet_name% ALL %petblocks_owner_name%" - name: "Switch to idle if the pet is beside the player" condition: type: NUMBER_LESS_THAN diff --git a/src/main/resources/pets/pet_mining.yml b/src/main/resources/pets/pet_mining.yml index 30253e987..bbe9b3c8f 100644 --- a/src/main/resources/pets/pet_mining.yml +++ b/src/main/resources/pets/pet_mining.yml @@ -165,6 +165,22 @@ loops: level: "SERVER" run: - "/petblocks moveToOwner %petblocks_pet_name% 0.2 %petblocks_owner_name%" + - name: "Hide the pet while player is flying" + condition: + type: JAVASCRIPT + js: "%petblocks_owner_isFlying% && '%petblocks_pet_visibility%' != 'NOBODY'" + type: "COMMAND" + level: "SERVER" + run: + - "/petblocks visibility %petblocks_pet_name% NOBODY %petblocks_owner_name%" + - name: "Show the pet while player is not flying" + condition: + type: JAVASCRIPT + js: "!%petblocks_owner_isFlying% && '%petblocks_pet_visibility%' == 'NOBODY'" + type: "COMMAND" + level: "SERVER" + run: + - "/petblocks visibility %petblocks_pet_name% ALL %petblocks_owner_name%" - name: "Switch to idle if the pet is beside the player" condition: type: NUMBER_LESS_THAN From d762ae1f8d6457e81db208ede458af234d9451fe Mon Sep 17 00:00:00 2001 From: Shynixn Date: Sat, 13 Jul 2024 17:30:33 +0200 Subject: [PATCH 3/3] #588 Updated to release version. --- build.gradle.kts | 2 +- .../java/com/github/shynixn/petblocks/PetBlocksLanguage.kt | 4 ++-- src/main/resources/plugin-legacy.yml | 2 +- src/main/resources/plugin.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 21962821d..bf65ad465 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "com.github.shynixn" -version = "9.9.0" +version = "9.10.0" repositories { mavenCentral() diff --git a/src/main/java/com/github/shynixn/petblocks/PetBlocksLanguage.kt b/src/main/java/com/github/shynixn/petblocks/PetBlocksLanguage.kt index 36ebedf4f..afcb2fccf 100644 --- a/src/main/java/com/github/shynixn/petblocks/PetBlocksLanguage.kt +++ b/src/main/java/com/github/shynixn/petblocks/PetBlocksLanguage.kt @@ -130,8 +130,8 @@ object PetBlocksLanguage { /** Makes the owner wear the pet. **/ var hatCommandHint : String = "Makes the owner wear the pet." - /** [&9PetBlocks&f] The visibility of pet %1$1s has been changed. **/ - var visibilityChangedMessage : String = "[&9PetBlocks&f] The visibility of pet %1$1s has been changed." + /** [&9PetBlocks&f] The visibility of pet %1$1s has been changed to %2$1s. **/ + var visibilityChangedMessage : String = "[&9PetBlocks&f] The visibility of pet %1$1s has been changed to %2$1s." /** [&9PetBlocks&f] &cYou do not have permission to edit the pets of other players. **/ var manipulateOtherMessage : String = "[&9PetBlocks&f] &cYou do not have permission to edit the pets of other players." diff --git a/src/main/resources/plugin-legacy.yml b/src/main/resources/plugin-legacy.yml index 3fe017b7b..3e748d45b 100644 --- a/src/main/resources/plugin-legacy.yml +++ b/src/main/resources/plugin-legacy.yml @@ -1,5 +1,5 @@ name: PetBlocks -version: 9.9.0 +version: 9.10.0 author: Shynixn main: com.github.shynixn.petblocks.PetBlocksPlugin softdepend: [ PlaceholderAPI, HeadDatabase] diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index fe3dfc91d..57abdf605 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: PetBlocks -version: 9.9.0 +version: 9.10.0 author: Shynixn main: com.github.shynixn.petblocks.PetBlocksPlugin softdepend: [ PlaceholderAPI, HeadDatabase]