Skip to content

Commit

Permalink
#606 Added sneak leftclick + rightclick.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Aug 30, 2024
1 parent 0ced01a commit 86fc9e0
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 33 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ dependencies {

// Custom dependencies
implementation("com.github.shynixn.shygui:shygui:1.0.0")
implementation("com.github.shynixn.mcutils:common:2024.21")
implementation("com.github.shynixn.mcutils:common:2024.23")
implementation("com.github.shynixn.mcutils:packet:2024.33")
implementation("com.github.shynixn.mcutils:database:2024.2")
implementation("com.github.shynixn.mcutils:database:2024.3")
implementation("com.github.shynixn.mcutils:pathfinder:2024.3")
implementation("com.github.shynixn.mcutils:guice:2024.2")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.shynixn.petblocks

import com.fasterxml.jackson.core.type.TypeReference
import com.github.shynixn.mccoroutine.bukkit.minecraftDispatcher
import com.github.shynixn.mcutils.common.ConfigurationService
import com.github.shynixn.mcutils.common.ConfigurationServiceImpl
import com.github.shynixn.mcutils.common.chat.ChatMessageService
Expand Down Expand Up @@ -69,7 +70,8 @@ class PetBlocksDependencyInjectionModule(
val configSelectedRepository = ConfigSelectedRepositoryImpl<PlayerInformation>(plugin,
"PetBlocks",
plugin.dataFolder.toPath().resolve("PetBlocks.sqlite"),
object : TypeReference<PlayerInformation>() {})
object : TypeReference<PlayerInformation>() {}, plugin.minecraftDispatcher
)
val playerDataRepository = AutoSavePlayerDataRepositoryImpl(
1000 * 60L * autoSaveMinutes, CachePlayerDataRepositoryImpl(configSelectedRepository, plugin), plugin
)
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/com/github/shynixn/petblocks/PetBlocksLanguage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ object PetBlocksLanguage {
/** Toggles the pet spawn state. **/
var toggleCommandHint : String = "Toggles the pet spawn state."

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

/** Makes the pet walk to a given location. **/
var moveToCommandHint : String = "Makes the pet walk to a given location."
Expand Down Expand Up @@ -82,8 +82,8 @@ object PetBlocksLanguage {
/** Despawns the pet if it has not already despawned. **/
var deSpawnCommandHint : String = "Despawns the pet if it has not already despawned."

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

/** [&9PetBlocks&f] The pet has been rotated. **/
var rotationRelMessage : String = "[&9PetBlocks&f] The pet has been rotated."
Expand All @@ -103,8 +103,8 @@ object PetBlocksLanguage {
/** [&9PetBlocks&f] &cWorld %1$1s not found. **/
var worldNotFoundMessage : String = "[&9PetBlocks&f] &cWorld %1$1s not found."

/** [&9PetBlocks&f] The name of pet %1$1s has been changed to %2$1s. **/
var petNameChangeMessage : String = "[&9PetBlocks&f] The name of pet %1$1s has been changed to %2$1s."
/** [&9PetBlocks&f] The name of the pet has been changed to %1$1s. **/
var petNameChangeMessage : String = "[&9PetBlocks&f] The name of the pet has been changed to %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."
Expand All @@ -130,14 +130,14 @@ object PetBlocksLanguage {
/** [&9PetBlocks&f] &cPet with name %1$1s not found. **/
var petNotFoundMessage : String = "[&9PetBlocks&f] &cPet with name %1$1s not found."

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

/** 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 to %2$1s. **/
var visibilityChangedMessage : String = "[&9PetBlocks&f] The visibility of pet %1$1s has been changed to %2$1s."
/** [&9PetBlocks&f] The visibility of pet has been changed to %1$1s. **/
var visibilityChangedMessage : String = "[&9PetBlocks&f] The visibility of pet has been changed to %1$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."
Expand Down Expand Up @@ -196,8 +196,8 @@ object PetBlocksLanguage {
/** [&9PetBlocks&f] Pet has been moved. **/
var petVelocityAppliedMessage : String = "[&9PetBlocks&f] Pet has been moved."

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

/** Changes which loop from the template is being executed by the pet. An example loop is idle. **/
var loopCommandHint : String = "Changes which loop from the template is being executed by the pet. An example loop is idle."
Expand Down Expand Up @@ -229,8 +229,8 @@ object PetBlocksLanguage {
/** Makes the owner select one of his pets as primary pet. This is only helpful if a single player has got multiple pets in PetBlocks-Premium. **/
var selectCommandHint : String = "Makes the owner select one of his pets as primary pet. This is only helpful if a single player has got multiple pets in PetBlocks-Premium."

/** [&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] Changed pet to template %2$1s. **/
var petTemplateChangeMessage : String = "[&9PetBlocks&f] Changed pet to template %2$1s."

/** Opens the GUI menu with the given name. **/
var openCommandHint : String = "Opens the GUI menu with the given name."
Expand All @@ -253,8 +253,8 @@ object PetBlocksLanguage {
/** [&9PetBlocks&f] &cThe plugin HeadDatabase is not loaded. **/
var headDatabasePluginNotLoaded : String = "[&9PetBlocks&f] &cThe plugin HeadDatabase is not loaded."

/** [&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."
/** [&9PetBlocks&f] The skinType of pet has been changed. **/
var petSkinTypeChangedMessage : String = "[&9PetBlocks&f] The skinType of pet has been changed."

/** [&9PetBlocks&f] Count: %1$1d Names: %2$1s **/
var petListMessage : String = "[&9PetBlocks&f] Count: %1$1d Names: %2$1s"
Expand Down Expand Up @@ -292,8 +292,8 @@ object PetBlocksLanguage {
/** [&9PetBlocks&f] PetBlocks has been reloaded. **/
var reloadMessage : String = "[&9PetBlocks&f] PetBlocks has been reloaded."

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

/** [&9PetBlocks&f] &cCannot parse nbt %1$1s. **/
var cannotParseNbtMessage : String = "[&9PetBlocks&f] &cCannot parse nbt %1$1s."
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/github/shynixn/petblocks/impl/PetEntityImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ class PetEntityImpl(

lastClickTimeStamp = currentDateTime

val rightClickEvent = pet.template.events["rightClick"]
val key = if (player.isSneaking) {
"rightClickSneak"
} else {
"rightClick"
}
val rightClickEvent = pet.template.events[key]
if (rightClickEvent != null) {
plugin.launch(plugin.minecraftDispatcher + object : CoroutineTimings() {}) {
petActionExecutionService.executeAction(player, pet, rightClickEvent, CancellationToken())
Expand All @@ -211,7 +216,12 @@ class PetEntityImpl(

lastClickTimeStamp = currentDateTime

val leftClickEvent = pet.template.events["leftClick"]
val key = if (player.isSneaking) {
"leftClickSneak"
} else {
"leftClick"
}
val leftClickEvent = pet.template.events[key]
if (leftClickEvent != null) {
plugin.launch(plugin.minecraftDispatcher + object : CoroutineTimings() {}) {
petActionExecutionService.executeAction(player, pet, leftClickEvent, CancellationToken())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ class PetBlocksCommandExecutor @Inject constructor(
sender: CommandSender, pet: Pet, visibility: PetVisibility
) {
pet.visibility = visibility
sender.sendPluginMessage(String.format(PetBlocksLanguage.visibilityChangedMessage, pet.name, visibility))
sender.sendPluginMessage(String.format(PetBlocksLanguage.visibilityChangedMessage, visibility))
}

private fun setPetLoop(sender: CommandSender, pet: Pet, loop: String) {
Expand Down
18 changes: 9 additions & 9 deletions src/main/resources/lang/en_us.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ petNotFoundMessage=[&9PetBlocks&f] &cPet with name %1$1s not found.
petNameExistsMessage=[&9PetBlocks&f] &cPet with name %1$1s already exists.
petCreatedMessage=[&9PetBlocks&f] Pet with name %1$1s has been created.
petDeletedMessage=[&9PetBlocks&f] Pet with name %1$1s has been deleted.
petNameChangeMessage=[&9PetBlocks&f] The name of pet %1$1s has been changed to %2$1s.
petNameChangeMessage=[&9PetBlocks&f] The name of the pet has been changed to %1$1s.
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 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.
visibilityChangedMessage=[&9PetBlocks&f] The visibility of pet has been changed to %1$1s.
petSkinTypeChangedMessage=[&9PetBlocks&f] The skinType of pet has been changed.
petSkinNbtChanged=[&9PetBlocks&f] The skin of pet has been changed.
petSkinTypeNotFound=[&9PetBlocks&f] &cMaterial %1$1s not found.
petListMessage=[&9PetBlocks&f] Count: %1$1d Names: %2$1s
petRideMessage=[&9PetBlocks&f] Started riding pet %1$1s.
petUnmountMessage=[&9PetBlocks&f] Stopped mounting pet %1$1s.
petHatMessage=[&9PetBlocks&f] Started hat pet %1$1s.
petRideMessage=[&9PetBlocks&f] Started riding pet.
petUnmountMessage=[&9PetBlocks&f] Stopped mounting pet.
petHatMessage=[&9PetBlocks&f] Started hat pet.
worldNotFoundMessage=[&9PetBlocks&f] &cWorld %1$1s not found.
petLookAtMessage=[&9PetBlocks&f] Pet is looking at a location.
petWalkToLocationMessage=[&9PetBlocks&f] Pet is walking to location.
Expand All @@ -29,8 +29,8 @@ petCharacterNotAllowed=[&9PetBlocks&f] &cThis pet name is not allowed.
reloadMessage=[&9PetBlocks&f] PetBlocks has been reloaded.
petLoopNotFound=[&9PetBlocks&f] &cLoop %1$1s not found.
premiumMultiplePets=[&9PetBlocks&f] &cPetBlocks-Premium is required to spawn multiple pets per player.
petLoopChangedMessage=[&9PetBlocks&f] Changed pet %1$1s to loop %2$1s.
petTemplateChangeMessage=[&9PetBlocks&f] Changed pet %1$1s to template %2$1s.
petLoopChangedMessage=[&9PetBlocks&f] Changed pet to loop %2$1s.
petTemplateChangeMessage=[&9PetBlocks&f] Changed pet to template %2$1s.
petAmountNotAllowed=[&9PetBlocks&f] &cYou do not have permission to have %1$1s pet(s).
petSelectedMessage=
templateNotAllowed=[&9PetBlocks&f] &cYou do not have permission for template %1$1s.
Expand Down
23 changes: 23 additions & 0 deletions src/main/resources/pets/pet_classic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,30 @@ events:
level: "SERVER"
run:
- "/petblocks velocity %petblocks_pet_name% %petblocks_js_jsonKnockback_x% 0.2 %petblocks_js_jsonKnockback_z% %petblocks_eventPlayer_name%"
leftClickSneak:
actions: # You can add/remove actions as you want here.
- name: "Open the pet GUI"
condition:
type: STRING_EQUALS
left: "%petblocks_eventPlayer_name%"
right: "%petblocks_owner_name%"
type: "COMMAND"
level: "PLAYER"
run:
- "/petblocks select %petblocks_pet_name%"
- "/petblock"
rightClick:
actions: # You can add/remove actions as you want here.
- name: "Start riding pet"
condition:
type: STRING_EQUALS
left: "%petblocks_eventPlayer_name%"
right: "%petblocks_owner_name%"
type: "COMMAND"
level: "PLAYER"
run:
- "/petblocks ride %petblocks_pet_name%"
rightClickSneak:
actions: # You can add/remove actions as you want here.
- name: "Open the pet GUI"
condition:
Expand Down
23 changes: 23 additions & 0 deletions src/main/resources/pets/pet_flying_dolphin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,30 @@ events:
level: "SERVER"
run:
- "/petblocks velocity %petblocks_pet_name% %petblocks_js_jsonKnockback_x% 0.2 %petblocks_js_jsonKnockback_z% %petblocks_eventPlayer_name%"
leftClickSneak:
actions: # You can add/remove actions as you want here.
- name: "Open the pet GUI"
condition:
type: STRING_EQUALS
left: "%petblocks_eventPlayer_name%"
right: "%petblocks_owner_name%"
type: "COMMAND"
level: "PLAYER"
run:
- "/petblocks select %petblocks_pet_name%"
- "/petblock"
rightClick:
actions: # You can add/remove actions as you want here.
- name: "Start riding pet"
condition:
type: STRING_EQUALS
left: "%petblocks_eventPlayer_name%"
right: "%petblocks_owner_name%"
type: "COMMAND"
level: "PLAYER"
run:
- "/petblocks ride %petblocks_pet_name%"
rightClickSneak:
actions: # You can add/remove actions as you want here.
- name: "Open the pet GUI"
condition:
Expand Down

0 comments on commit 86fc9e0

Please sign in to comment.