Skip to content

Commit

Permalink
Merge pull request #612 from Shynixn/development
Browse files Browse the repository at this point in the history
Merge changes to master --release
  • Loading branch information
Shynixn authored Aug 30, 2024
2 parents 840018d + 7251d7d commit d01e193
Show file tree
Hide file tree
Showing 21 changed files with 315 additions and 52 deletions.
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
Shynixn Plugin Distribution LICENCE

All terms and conditions of the GNU GENERAL PUBLIC LICENSE Version 3.0 below apply. The Shynixn Plugin Distribution LICENCE
further restricts what you are allowed to do. Even if certain points are allowed under the GNU GENERAL PUBLIC LICENSE Version 3.0,
the Shynixn Plugin Distribution LICENCE overrules them.

You are not allowed to redistribute the PetBlocks binary files under any circumstances.
The plugin binary files are PetBlocks.jar, PetBlocks-Legacy.jar and PetBlocks-Premium.jar.

Commercial usage of this plugin is only allowed by obtaining a licence of a particular version of the PetBlocks-Legacy.jar or PetBlocks-Premium.jar plugin.
e.g. being an actively paying subscribed member of the Patreon https://www.patreon.com/Shynixn at the time this particular version was available.
You do not have any rights on any potential future released versions. You need to obtain a new licence for each individual version.

GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "com.github.shynixn"
version = "9.12.0"
version = "9.13.0"

repositories {
mavenCentral()
Expand Down 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
45 changes: 45 additions & 0 deletions docs/wiki/docs/particleexample.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Selectable particle effects

This is a tutorial to get into building selectable parts for pets. It can also be used
to define selectable sounds, potion effects, etc.

## 1. Edit the pet template

Add a basic vanilla particle command as action to one of the loops. In this case the ``idle`` loop.

* Instead of absolute coordinates we use the pet coordinate placeholders.
* The placeholder ``%petblocks_js_mypart%`` is a custom placeholder defined by you, which stores the **currently selected particle**. You can also name it ``%petblocks_js_mysound%`` to store sound names for example.
* The condition checks if the placeholder can actually be resolved e.g. a particle has been set.

```yaml
loops:
idle:
actions:
- name: "Play particle effect"
condition:
type: STRING_NOT_CONTAINS
left: "%petblocks_js_mypart%"
right: "petblocks_js_mypart"
type: "COMMAND"
level: "SERVER"
run:
- "/particle %petblocks_js_mypart% %petblocks_pet_locationX% %petblocks_pet_locationY% %petblocks_pet_locationZ%"
```
## 2. Adjust vanilla command settings
A vanilla command may automatically log to the console and to the chat of every op player. You can disable the output for op players using vanilla game rules such as ``gamerule sendCommandFeedback false``, ``/gamerule logAdminCommands false``, ``/gamerule commandBlockOutput false``. If you want to hide the output in your console, you need to install a LogFilter plugin.
## 3. Check if it works ingame
Execute the following commands and take a look if the pet displays heart particles.
```
/petblocks reload
/petblocks variable pet mypart heart
```

## 4. GUI buttons

Open the GUI of petblocks or your favourite GUI plugin and add a button where the command ``/petblocks variable pet mypart heart %petblocks_owner_name%`` is executed with server level permissions.
You can add more particles by creating new buttons with new commands e.g. ``/petblocks variable pet mypart angry_villager %petblocks_owner_name%``
2 changes: 1 addition & 1 deletion docs/wiki/docs/permission.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The following permissions are available in PetBlocks.
* User: A permission all players can have.
* Admin/User: Depending on your server, you may give this permission to your players. If you are not sure, try to build
your server around **not giving this permission** to your players.
* Admin: A permission only Admins should have.
* Admin: A permission only admins should have.

### Minimum Required Permissions

Expand Down
13 changes: 3 additions & 10 deletions docs/wiki/docs/receivingpets.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
Once you have setup the permission, join your server. The PetBlocks default configuration creates a pet
with template ``classic`` for you and makes it spawn in front of you. If you cannot see the pet, try executing ``/petblocks call pet`` or review your permissions again.


**Make sure your players have this permission to see their pet:**
```
petblocks.pet.spawn
petblocks.pet.amount.1
```

The next step is to decide, how you want your players to receive a pet. There are multiple options below.

## Receiving a pet on first join

This is enabled per default and can be changed in the ``config.yml`` under ``pet/receivePetsOnJoin``. This creates a new database entry for each joining player, regardless if he has the spawn permission or not.
The player requires the minimum ``petblocks.pet.spawn`` to see their pet.
!!! note "Important"
Make sure you have given your players the minimum required permissions before you continue.

This is enabled per default and can be changed in the ``config.yml`` under ``pet/receivePetsOnJoin``. This creates a new database entry for each joining player, regardless if he has the spawn permission or not.
If you want to receive no pets on join and unlock pets later own (e.g. for shops or VIP perks), change this to:

```
Expand All @@ -38,7 +32,6 @@ pet:
In order to configure, if the pet should automatically spawn in front of the player on creation, open the template
``plugins/PetBlocks/pets/pet_classic.yml``. Set ``pet/spawned`` to ``true`` or ``false``.


## Receiving pets using a shop

There are many ways how you can handle it. These are just examples below:
Expand Down
2 changes: 2 additions & 0 deletions docs/wiki/docs/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ Actions can optionally have conditions, which support the following types:
* ``STRING_EQUALS``
* ``STRING_NOT_EQUALS``
* ``STRING_CONTAINS``
* ``STRING_NOT_CONTAINS``
* ``STRING_EQUALS_IGNORE_CASE``
* ``STRING_NOT_EQUALS_IGNORE_CASE``
* ``NUMBER_GREATER_THAN``
Expand Down
3 changes: 2 additions & 1 deletion docs/wiki/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ nav:
- 'PetBlocks Wiki':
- Introduction: README.md
- Permission: permission.md
- Giving pets to players: receivingpets.md
- Commands: commands.md
- Giving Pets to Players: receivingpets.md
- Templates: template.md
- GUI: gui.md
- PlaceHolders: placeholders.md
- Custom Models: custommodels.md
- Selectable particle effects: particleexample.md
- Developer Api: api.md
- 'FAQ': faq.md
theme:
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import java.util.logging.Level
* Author Shynixn
*/
class PetBlocksPlugin : JavaPlugin() {
companion object {
var languageFiles = arrayOf("en_us", "es_es")
}
private val prefix: String = ChatColor.BLUE.toString() + "[PetBlocks] " + ChatColor.WHITE
private lateinit var mainModule: PetBlocksDependencyInjectionModule
private lateinit var shyGuiModule: ShyGUIDependencyInjectionModule
Expand Down Expand Up @@ -96,7 +99,7 @@ class PetBlocksPlugin : JavaPlugin() {

// Register Language
val language = config.getString("language")!!
reloadTranslation(language, PetBlocksLanguage::class.java, "en_us")
reloadTranslation(language, PetBlocksLanguage::class.java, *languageFiles)
logger.log(Level.INFO, "Loaded language file $language.properties.")

// ShyGUI Module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.github.shynixn.petblocks.enumeration
enum class PetActionConditionType {
NONE,
STRING_EQUALS,
STRING_CONTAINS,
STRING_NOT_CONTAINS,
STRING_NOT_EQUALS,
STRING_EQUALS_IGNORE_CASE,
STRING_NOT_EQUALS_IGNORE_CASE,
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 @@ -10,6 +10,7 @@ import com.github.shynixn.mcutils.common.repository.CacheRepository
import com.github.shynixn.mcutils.database.api.CachePlayerRepository
import com.github.shynixn.petblocks.PetBlocksDependencyInjectionModule
import com.github.shynixn.petblocks.PetBlocksLanguage
import com.github.shynixn.petblocks.PetBlocksPlugin.Companion.languageFiles
import com.github.shynixn.petblocks.contract.DependencyHeadDatabaseService
import com.github.shynixn.petblocks.contract.Pet
import com.github.shynixn.petblocks.contract.PetService
Expand Down Expand Up @@ -764,7 +765,24 @@ class PetBlocksCommandExecutor @Inject constructor(
templateRepository.clearCache()
plugin.saveDefaultConfig()
plugin.reloadConfig()
configurationService.reload()
val language = plugin.config.getString("language")!!
plugin.reloadTranslation(language, PetBlocksLanguage::class.java, *languageFiles)
val templates = templateRepository.getAll()

// Updates the templates.
for (player in petService.getCache().keys) {
val pets = petService.getCache()[player]

if (pets != null) {
for (pet in pets) {
val newTemplate = templates.firstOrNull { e -> e.name == pet.template.name }
if (newTemplate != null) {
pet.template = newTemplate
}
}
}
}

Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "petblocksgui reload")
sender.sendMessage(PetBlocksLanguage.reloadMessage)
}
Expand Down Expand Up @@ -965,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
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,32 @@ class PetActionExecutionServiceImpl @Inject constructor(
}

return conditionResult
} else {
}
else if (conditionType == PetActionConditionType.STRING_CONTAINS) {
val conditionResult = leftEscaped.contains(rightEscaped)

if (action.debug) {
plugin.logger.log(
Level.INFO,
"End evaluating condition, $leftEscaped contains $rightEscaped -> ${conditionResult}."
)
}

return conditionResult
}
else if (conditionType == PetActionConditionType.STRING_NOT_CONTAINS) {
val conditionResult = !leftEscaped.contains(rightEscaped)

if (action.debug) {
plugin.logger.log(
Level.INFO,
"End evaluating condition, $leftEscaped not contains $rightEscaped -> ${conditionResult}."
)
}

return conditionResult
}
else {
val leftNumber = leftEscaped.toDoubleOrNull()

if (leftNumber == null) {
Expand Down
Loading

0 comments on commit d01e193

Please sign in to comment.