Skip to content

Commit

Permalink
#570 Added support for other entity types.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Jan 19, 2024
1 parent b86b215 commit 564bfa9
Show file tree
Hide file tree
Showing 20 changed files with 557 additions and 158 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ dependencies {
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.4.3")

// Custom dependencies
implementation("com.github.shynixn.mcutils:common:1.0.44")
implementation("com.github.shynixn.mcutils:packet:1.0.68")
implementation("com.github.shynixn.mcutils:common:1.0.47")
implementation("com.github.shynixn.mcutils:packet:1.0.72")
implementation("com.github.shynixn.mcutils:database:1.0.14")
implementation("com.github.shynixn.mcutils:pathfinder:1.0.19")

Expand Down
35 changes: 35 additions & 0 deletions docs/wiki/docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,38 @@ Rotates the pet relative to its current rotation.
* Direction: LEFT, RIGHT, UP, DOWN
* Angle: Angle in degrees e.g. 45, 90
* Player: Optional player_name/player_UUID parameter targeting a player from the console or command block.

### /petblocks entitytype

```
/petblocks entitytype <name> <entityType> [player]
```

Changes the entity type of the pet. The default type is minecraft:armor_stand

* Name: Identifier of a pet
* EntityType: An entitytype in the minecraft format. e.g. minecraft:bee, minecraft:dolphin, minecraft:armor_stand
* Player: Optional player_name/player_UUID parameter targeting a player from the console or command block.

### /petblocks entityvisible

```
/petblocks entityvisible <name> <true/false> [player]
```

Changes if the body of an entity is visible. For armorstands this is false, for most of the other entities this should be true.

* Name: Identifier of a pet
* Player: Optional player_name/player_UUID parameter targeting a player from the console or command block.

### /petblocks groundoffset

```
/petblocks groundoffset <name> <offset> [player]
```

Changes the offset of the body of the entity to the ground. Useful when configuring different entity types.

* Name: Identifier of a pet
* Offset: A numeric comma value. e.g. 0.3, -0.3, 1.0
* Player: Optional player_name/player_UUID parameter targeting a player from the console or command block.
75 changes: 39 additions & 36 deletions docs/wiki/docs/permission.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PetBlocksDependencyInjectionBinder(private val plugin: PetBlocksPlugin) :
// Repositories
val templateRepositoryImpl = YamlFileRepositoryImpl<PetTemplate>(plugin,
"pets",
listOf(Pair("pets/pet_classic.yml", "pet_classic.yml"),Pair("pets/pet_mining.yml", "pet_mining.yml")),
listOf(Pair("pets/pet_classic.yml", "pet_classic.yml"),Pair("pets/pet_mining.yml", "pet_mining.yml"),Pair("pets/pet_flying_dolphin.yml", "pet_flying_dolphin.yml")),
emptyList(),
object : TypeReference<PetTemplate>() {})
val cacheTemplateRepository = CachedRepositoryImpl(templateRepositoryImpl)
Expand Down
134 changes: 73 additions & 61 deletions src/main/java/com/github/shynixn/petblocks/PetBlocksLanguage.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,75 @@
package com.github.shynixn.petblocks

object PetBlocksLanguage {
/** [&9PetBlocks&f] Pet with name %1$1s has been spawned. **/
var petSpawnedMessage : String = "[&9PetBlocks&f] Pet with name %1$1s has been spawned."

/** [&9PetBlocks&f] &cYou do not have permission to have %1$1s pet(s). **/
var petAmountNotAllowed : String = "[&9PetBlocks&f] &cYou do not have permission to have %1$1s pet(s)."

/** [&9PetBlocks&f] &cLoop %1$1s not found. **/
var petLoopNotFound : String = "[&9PetBlocks&f] &cLoop %1$1s not found."

/** [&9PetBlocks&f] Selected pet %1$1s. **/
var petSelectedMessage : String = "[&9PetBlocks&f] Selected pet %1$1s."

/** [&9PetBlocks&f] &cPetBlocks-Premium is required to spawn multiple pets per player. **/
var premiumMultiplePets : String = "[&9PetBlocks&f] &cPetBlocks-Premium is required to spawn multiple pets per player."

/** [&9PetBlocks&f] &cPlayer %1$1s not found. **/
var playerNotFoundMessage : String = "[&9PetBlocks&f] &cPlayer %1$1s not found."

/** [&9PetBlocks&f] &cCannot parse number %1$1s. **/
var cannotParseNumberMessage : String = "[&9PetBlocks&f] &cCannot parse number %1$1s."

/** [&9PetBlocks&f] Pet has been moved. **/
var petVelocityAppliedMessage : String = "[&9PetBlocks&f] Pet has been moved."

/** [&9PetBlocks&f] Started riding pet %1$1s. **/
var petRideMessage : String = "[&9PetBlocks&f] Started riding pet %1$1s."

/** [&9PetBlocks&f] Started hat pet %1$1s. **/
var petHatMessage : String = "[&9PetBlocks&f] Started hat pet %1$1s."

/** [&9PetBlocks&f] Pet is looking at a location. **/
var petLookAtMessage : String = "[&9PetBlocks&f] Pet is looking at a location."

/** [&9PetBlocks&f] &cPet with name %1$1s already exists. **/
var petNameExistsMessage : String = "[&9PetBlocks&f] &cPet with name %1$1s already exists."

/** [&9PetBlocks&f] &cThe groundOffset value %1$1s cannot be parsed. **/
var groundOffsetCannotBeParsed : String = "[&9PetBlocks&f] &cThe groundOffset value %1$1s cannot be parsed."

/** [&9PetBlocks&f] Pet is walking forward. **/
var petMoveForwardMessage : String = "[&9PetBlocks&f] Pet is walking forward."

/** [&9PetBlocks&f] The pet entity visibility has been changed to %1$1s. **/
var entityVisibilityChangedMessage : String = "[&9PetBlocks&f] The pet entity visibility has been changed to %1$1s."

/** No pet. **/
var placeHolderPetNotFound : String = "No pet."

/** [&9PetBlocks&f] &cOnly the visibility types %1$1s are supported. **/
var visibilityTypeNotFoundMessage : String = "[&9PetBlocks&f] &cOnly the visibility types %1$1s are supported."

/** [&9PetBlocks&f] Pet with name %1$1s has been created. **/
var petCreatedMessage : String = "[&9PetBlocks&f] Pet with name %1$1s has been created."

/** [&9PetBlocks&f] Pet has been teleported. **/
var petTeleportedMessage : String = "[&9PetBlocks&f] Pet has been teleported."

/** [&9PetBlocks&f] &cThis pet name is not allowed. **/
var petCharacterNotAllowed : String = "[&9PetBlocks&f] &cThis pet name is not allowed."

/** [&9PetBlocks&f] Changed pet %1$1s to template %2$1s. **/
var petTemplateChangeMessage : String = "[&9PetBlocks&f] Changed pet %1$1s to template %2$1s."

/** [&9PetBlocks&f] &cTemplate %1$1s not found. **/
var templateNotFoundMessage : String = "[&9PetBlocks&f] &cTemplate %1$1s not found."

/** [&9PetBlocks&f] The pet has been snapped to a coordinate axe. **/
var snapMessage : String = "[&9PetBlocks&f] The pet has been snapped to a coordinate axe."

/** [&9PetBlocks&f] &cThe speed value %1$1s cannot be parsed. **/
var speedCannotBeParsed : String = "[&9PetBlocks&f] &cThe speed value %1$1s cannot be parsed."

Expand All @@ -10,15 +79,12 @@ object PetBlocksLanguage {
/** [&9PetBlocks&f] The pet has been rotated. **/
var rotationRelMessage : String = "[&9PetBlocks&f] The pet has been rotated."

/** [&9PetBlocks&f] Pet with name %1$1s has been spawned. **/
var petSpawnedMessage : String = "[&9PetBlocks&f] Pet with name %1$1s has been spawned."
/** [&9PetBlocks&f] The pet entity type has been changed to %1$1s. **/
var entityTypeChangeMessage : String = "[&9PetBlocks&f] The pet entity type has been changed to %1$1s."

/** [&9PetBlocks&f] &cThe plugin HeadDatabase is not loaded. **/
var headDatabasePluginNotLoaded : String = "[&9PetBlocks&f] &cThe plugin HeadDatabase is not loaded."

/** [&9PetBlocks&f] &cYou do not have permission to have %1$1s pet(s). **/
var petAmountNotAllowed : String = "[&9PetBlocks&f] &cYou do not have permission to have %1$1s pet(s)."

/** [&9PetBlocks&f] The skinType of pet %1$1s has been changed. **/
var petSkinTypeChangedMessage : String = "[&9PetBlocks&f] The skinType of pet %1$1s has been changed."

Expand All @@ -34,24 +100,12 @@ object PetBlocksLanguage {
/** [&9PetBlocks&f] &cWorld %1$1s not found. **/
var worldNotFoundMessage : String = "[&9PetBlocks&f] &cWorld %1$1s not found."

/** [&9PetBlocks&f] &cLoop %1$1s not found. **/
var petLoopNotFound : String = "[&9PetBlocks&f] &cLoop %1$1s not found."

/** [&9PetBlocks&f] Selected pet %1$1s. **/
var petSelectedMessage : String = "[&9PetBlocks&f] Selected pet %1$1s."

/** [&9PetBlocks&f] &cOnly the direction types %1$1s are supported. **/
var petRotationTypeNotFound : String = "[&9PetBlocks&f] &cOnly the direction types %1$1s are supported."

/** [&9PetBlocks&f] Pet with name %1$1s has been removed. **/
var petDespawnedMessage : String = "[&9PetBlocks&f] Pet with name %1$1s has been removed."

/** [&9PetBlocks&f] &cPetBlocks-Premium is required to spawn multiple pets per player. **/
var premiumMultiplePets : String = "[&9PetBlocks&f] &cPetBlocks-Premium is required to spawn multiple pets per player."

/** [&9PetBlocks&f] &cPlayer %1$1s not found. **/
var playerNotFoundMessage : String = "[&9PetBlocks&f] &cPlayer %1$1s not found."

/** [&9PetBlocks&f] &cPet with name %1$1s not found. **/
var petNotFoundMessage : String = "[&9PetBlocks&f] &cPet with name %1$1s not found."

Expand All @@ -61,45 +115,21 @@ object PetBlocksLanguage {
/** [&9PetBlocks&f] Pet with name %1$1s has been deleted. **/
var petDeletedMessage : String = "[&9PetBlocks&f] Pet with name %1$1s has been deleted."

/** [&9PetBlocks&f] &cCannot parse number %1$1s. **/
var cannotParseNumberMessage : String = "[&9PetBlocks&f] &cCannot parse number %1$1s."

/** [&9PetBlocks&f] Pet has been moved. **/
var petVelocityAppliedMessage : String = "[&9PetBlocks&f] Pet has been moved."

/** [&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] Started riding pet %1$1s. **/
var petRideMessage : String = "[&9PetBlocks&f] Started riding pet %1$1s."

/** [&9PetBlocks&f] Pet with name %1$1s has been called. **/
var petCalledMessage : String = "[&9PetBlocks&f] Pet with name %1$1s has been called."

/** [&9PetBlocks&f] Started hat pet %1$1s. **/
var petHatMessage : String = "[&9PetBlocks&f] Started hat pet %1$1s."

/** [&9PetBlocks&f] &cPet with name %1$1s already exists. **/
var petNameExistsMessage : String = "[&9PetBlocks&f] &cPet with name %1$1s already exists."

/** [&9PetBlocks&f] Pet is looking at a location. **/
var petLookAtMessage : String = "[&9PetBlocks&f] Pet is looking at a location."

/** [&9PetBlocks&f] &cCannot parse template file. See console log for details. **/
var errorLoadingTemplatesMessage : String = "[&9PetBlocks&f] &cCannot parse template file. See console log for details."

/** [&9PetBlocks&f] Cancelled action. **/
var cancelMessage : String = "[&9PetBlocks&f] Cancelled action."

/** [&9PetBlocks&f] Pet is walking forward. **/
var petMoveForwardMessage : String = "[&9PetBlocks&f] Pet is walking forward."

/** [&9PetBlocks&f] PetBlocks has been reloaded. **/
var reloadMessage : String = "[&9PetBlocks&f] PetBlocks has been reloaded."

/** No pet. **/
var placeHolderPetNotFound : String = "No pet."

/** [&9PetBlocks&f] Stopped mounting pet %1$1s. **/
var petUnmountMessage : String = "[&9PetBlocks&f] Stopped mounting pet %1$1s."

Expand All @@ -109,30 +139,12 @@ object PetBlocksLanguage {
/** [&9PetBlocks&f] &cCannot parse nbt %1$1s. **/
var cannotParseNbtMessage : String = "[&9PetBlocks&f] &cCannot parse nbt %1$1s."

/** [&9PetBlocks&f] &cOnly the visibility types %1$1s are supported. **/
var visibilityTypeNotFoundMessage : String = "[&9PetBlocks&f] &cOnly the visibility types %1$1s are supported."

/** [&9PetBlocks&f] Pet with name %1$1s has been created. **/
var petCreatedMessage : String = "[&9PetBlocks&f] Pet with name %1$1s has been created."

/** [&9PetBlocks&f] Pet has been teleported. **/
var petTeleportedMessage : String = "[&9PetBlocks&f] Pet has been teleported."

/** [&9PetBlocks&f] &cThis pet name is not allowed. **/
var petCharacterNotAllowed : String = "[&9PetBlocks&f] &cThis pet name is not allowed."

/** [&9PetBlocks&f] Changed pet %1$1s to template %2$1s. **/
var petTemplateChangeMessage : String = "[&9PetBlocks&f] Changed pet %1$1s to template %2$1s."

/** [&9PetBlocks&f] &cTemplate %1$1s not found. **/
var templateNotFoundMessage : String = "[&9PetBlocks&f] &cTemplate %1$1s not found."
/** [&9PetBlocks&f] The groundOffset of the pet has been changed. **/
var groundOffsetChangedMessage : String = "[&9PetBlocks&f] The groundOffset of the pet has been changed."

/** [&9PetBlocks&f] Pet is walking to location. **/
var petWalkToLocationMessage : String = "[&9PetBlocks&f] Pet is walking to location."

/** [&9PetBlocks&f] &cOnly the drop types %1$1s are supported. **/
var dropTypeNotFound : String = "[&9PetBlocks&f] &cOnly the drop types %1$1s are supported."

/** [&9PetBlocks&f] The pet has been snapped to a coordinate axe. **/
var snapMessage : String = "[&9PetBlocks&f] The pet has been snapped to a coordinate axe."
}
16 changes: 16 additions & 0 deletions src/main/java/com/github/shynixn/petblocks/contract/Pet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,27 @@ interface Pet {
*/
var template: PetTemplate

/**
* Gets or sets the entity type.
* e.g. minecraft:armor_stand, minecraft:pig
*/
var entityType: String

/**
* Entity Visibility state.
*/
var isEntityVisible: Boolean

/**
* Gets the direction the pet could snap to.
*/
val direction: PetCoordinateAxeType

/**
* Offset from the ground.
*/
var groundOffset : Double

/**
* Calculated variables which can be used in subsequent operations by placeholders.
*/
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/com/github/shynixn/petblocks/entity/PetMeta.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.shynixn.petblocks.entity
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.github.shynixn.mcutils.common.Vector3d
import com.github.shynixn.mcutils.common.item.Item
import com.github.shynixn.mcutils.packet.api.meta.enumeration.EntityType
import com.github.shynixn.petblocks.enumeration.PetRidingState
import com.github.shynixn.petblocks.enumeration.PetVisibility

Expand Down Expand Up @@ -50,10 +51,20 @@ class PetMeta {
*/
var loop: String = ""

/**
* Entity type.
*/
var entityType: String = EntityType.ARMOR_STAND.id117

/**
* Entity Visibility state.
*/
var isEntityVisible: Boolean = false

/**
* Physic settings.
*/
var physics : PhysicSettings = PhysicSettings()
var physics: PhysicSettings = PhysicSettings()

/**
* Last persisted location of the pet.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.shynixn.petblocks.entity

import com.github.shynixn.mcutils.common.item.Item
import com.github.shynixn.mcutils.packet.api.meta.enumeration.EntityType
import com.github.shynixn.petblocks.enumeration.PetRidingState
import com.github.shynixn.petblocks.enumeration.PetVisibility

Expand All @@ -20,6 +21,16 @@ class PetTemplatePet {
*/
var visibility: PetVisibility = PetVisibility.ALL

/**
* Entity type.
*/
var entityType: String = EntityType.ARMOR_STAND.id117

/**
* Entity Visibility state.
*/
var entityVisible: Boolean = false

/**
* Riding state.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ enum class Permission(val text: String) {
SNAP("petblocks.pet.snap"),
MOVEREL("petblocks.pet.moveRel"),
ROTATEREL("petblocks.pet.rotateRel"),
ENTITYTYPE("petblocks.pet.entityType"),
ENTITYVISIBILITY("petblocks.pet.entityVisibility"),
GROUNDOFFSET("petblocks.pet.groundOffset"),
// Dynamic
DYN_AMOUNT("petblocks.pet.amount."),
DYN_TEMPLATE("petblocks.pet.template."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import com.github.shynixn.mccoroutine.bukkit.CoroutineTimings
import com.github.shynixn.mccoroutine.bukkit.launch
import com.github.shynixn.mccoroutine.bukkit.minecraftDispatcher
import com.github.shynixn.mccoroutine.bukkit.ticks
import com.github.shynixn.mcutils.common.CancellationToken
import com.github.shynixn.mcutils.common.Vector3d
import com.github.shynixn.mcutils.common.*
import com.github.shynixn.mcutils.common.physic.PhysicObject
import com.github.shynixn.mcutils.common.physic.PhysicObjectDispatcher
import com.github.shynixn.mcutils.common.toLocation
import com.github.shynixn.mcutils.common.toVector3d
import com.github.shynixn.mcutils.packet.api.PacketService
import com.github.shynixn.mcutils.pathfinder.api.PathfinderResult
import com.github.shynixn.mcutils.pathfinder.api.PathfinderResultType
Expand Down Expand Up @@ -369,7 +366,7 @@ class PetEntityImpl(
/**
* Updates the displayName in the world.
*/
fun updateDisplayName() {
fun updateMetaData() {
for (player in playerComponent.visiblePlayers) {
entityComponent.updateMetaData(player)
}
Expand Down
Loading

0 comments on commit 564bfa9

Please sign in to comment.