ItemJoin

ItemJoin

157k Downloads

[Suggest] Some features.

momoservertw opened this issue · 6 comments

commented

ItemJoin is very powerful and efficiency now. There may no any important things to do. If you want to add more feature, you can look at it. Thank you for spending a lot of time updating ItemJoin.

1. Custom disposable conditions. [ COMPLETED ]
Only some situation will execute commands and consume that item. It can be very useful to create a special item for other plugin. For example, a pet skill ticket. If player has a pet, it will change his pet's skill. Otherwise it will show a failure message.

- '%mypet_has_pet%:equal:true'
- '%other_placeholder%:notequal:VALUE'
- '%other_placeholder%:over:100'
- '%other_placeholder%:under:200'

fail-message: '&cYou need to summon your pet.'

Some placeholder equal null. You need to check it, if the value equal "".
%other_placeholder%:equal:

2. More triggers. [ COMPLETED ]

mobs-drop:
- 'ZOMBIE:0.001'
- 'Crazy_Zombie:0.002'
  • Break blocks
blocks-drop:
- 'DIAMOND_ORE:0.1'
- 'GOLD_ORE:0.01'

3. Random commands.
More custom way to select a command.

- <chance:0.1> say 0.1 / ( 0.9 + 0.1 + 0.2 ) * 100% = 8.3%
- <chance:0.2> say 0.2 / ( 0.9 + 0.1 + 0.2 ) * 100% = 16.7%

This is an example

    double radomTotalChance = Math.round(Math.random() * totalChance);
    for (String command : commandList){
        // To get that command's change. I don't know how to get it from "<chance:0.9>".
        double chance = ConfigHandler.getConfig("config.yml").getDouble(command + ".chance");
        // Compare the chance and the number below total chance.
        if (chance >= radomTotalChance) {
            return ExecuteCommand;
        }
        // To minus the chance and let it no longer be included in the total chance.
        // For example, a random number below "1.2" is "1.15".
        // If it is over "0.9", it will minus 0.9 and change to "0.25".
        // If it is over "0.1", it will minus 0.1 and change to "0.15".
        // It is under "0.2" then execute commands.
        radomTotalChance -= chance;
    }

4. Custom food [ COMPLETED ]
ItemJoin can custom the golden apple, but it will be more interesting if we can add any potion effect by click a custom item like a skull 'Apple Cake'. And using less CPU performance if we directly using the Spigot API, not commands. The potion effect's format could be the golden apple's.

5. Better Commands [ COMPLETED ]
I am using the menu plugin "BossShopPro" which has some great command types.
You can refer to it~ The command type of inventory will be more abundant!

  • inventory-left
  • inventory-right
  • inventory-middle (Mouse wheel)
  • inventory-shift-left
  • inventory-shift-right
  • inventory-shift-middle (BossShop does not have this feature, but maybe you can try it?)

In addition, is it possible to add the "Middle-Click" when players use the mouse wheel.
And it may be clearer to distinguish the Click action from the Inventory action?

6. Conditions for Each Command Execution [ COMPLETED ]
Examples;

inventory-left-condition:
- '%mypet_has_pet%:equal:true'
- '%other_placeholder%:notequal:VALUE'
- '%other_placeholder%:over:100'
- '%other_placeholder%:under:200'
inventory-shift-right-condition:
- '%mypet_has_pet%:equal:true'
- '%other_placeholder%:notequal:VALUE'
- '%other_placeholder%:over:100'
- '%other_placeholder%:under:200'

fail-message: '&cYou need to summon your pet.'

commented

Okay so currently I have added all requested features for no.3 (Recipes, Mobs-Drop. and Blocks-Drop) available in the latest snapshot for testing; http://ci.craftationgaming.com/job/ItemJoin/430/

Here is how you should set up each use-case (you can do this in the /itemjoin menu WAY easier.)

  • Mobs Drop
    • You can now specify a list of mobs and their probability of dropping the custom item.
    • A probability of 1.0 is the max probability and is considered to be 100%.
    • Formatting is ENTITY:PROBABILITY.
    • The Entity expects an entity type input, obviously all entities will not work such as an ender pearl. The entity input should be a physical mob. List of entities here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/EntityType.html
    • Recommendations (not required): Set triggers to DISABLED to prevent players from getting the items on join. Set the slot of ARBITRARY--there is no real reason for this but it can help with compatibility in the future.
  mobs-item:
    id: IRON_SWORD
    slot: ARBITRARY
    name: '&cStolen Sword'
    lore:
    - '&7Pulled from the ashes of chaos.'
    mobs-drop:
    - 'ZOMBIE:0.001'
    - 'PIG:0.3'
    triggers: DISABLED
    enabled-worlds: world, world_the_end
  • Blocks Drop
    • You can now specify a list of mobs and their probability of dropping the custom item.
    • A probability of 1.0 is the max probability and is considered to be 100%.
    • Formatting is MATERIAL:PROBABILITY.
    • The Material expects a block type input, obviously all materials will not work such as a COOKED_STEAK. The block input should be a physical block. List of materials here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
    • Recommendations (not required): Set triggers to DISABLED to prevent players from getting the items on join. Set the slot of ARBITRARY--there is no real reason for this but it can help with compatibility in the future.
  blocks-item:
    id: DIAMOND_BLOCK
    slot: ARBITRARY
    name: '&aSurprise!'
    mobs-drop:
    - 'ZOMBIE:0.001'
    - 'PIG:0.3'
    triggers: DISABLED
    enabled-worlds: All
  • Custom Recipe.
    • You can now specify a recipe for a custom item.
    • To define a recipe, you must specify the shape with the ingredient characters, as well as the ingredients with their characters. The ingredients expect a single character followed by the material input. See the example item below.
    • Recipe shapes are quite diverse and can be defined in unique shapes as shown.
    • X Stands for Air, do NOT include X in the 'ingredients' below.
    • Examples of Recipe usages:
    recipe:
    - 'XGX'
    - 'IDI'
    - 'XGX'
    recipe:
    - 'XG'
    - 'XD'
    recipe:
    - 'XGX'
    - 'IDI'
    recipe:
    - 'G'
    - 'D'
    - 'G'
  recipe-item:
    id: BEDROCK
    slot: ARBITRARY
    name: '&6Essence'
    lore:
    - '&7Shhhh don''t tell anyone...'
    recipe:
    # X Stands for Air, do NOT include X in the 'ingredients' below.
    - 'XGX' # First row in the crafting table
    - 'IDI' # Second row in the crafting table
    - 'XGX' # Third row in the crafting table
    ingredients:
    # Format: LETTER:ITEMID
    - 'G:GOLD_INGOT' # G Stands for Gold Ingot.
    - 'I:IRON_INGOT' # I Stands for Iron Ingot.
    - 'D:DIAMOND' # D Stands for Diamond, you can use any letter here and the ITEMID can be numerical.
    triggers: DISABLED

Additional info can be found here; https://github.com/RockinChaos/ItemJoin/wiki/DevLog

commented

Snapshot b509 now contains the requested (5. Better Commands).
Link; http://ci.craftationgaming.com/job/ItemJoin/509/

Things to note;
1.) Shift-Middle-Click could not be implemented as it is never detected server or client-side.
2.) Creative Mode has been entirely separated from the commands and now has it's own command action since creative mode has been known to be buggy. Something to note about this though is that if this action is defined, any creative mode action will trigger the command as it cannot tell the difference between left/right-click, shifting, or middle-click. This is because MD_5 hardcoded creative mode to always output that the place is left-clicking.

Here are the current command actions, these changes are reflected in the DevLog.

  • ItemCommands (Command Actions) has been rewritten.
    • This means any prior command actions such as multi-click will no longer function.
    • Please see the list below for proper command actions;
    • Interact - Actions performed with the player's inventory closed, usually with the item in their hand.
    • Inventory - Actions performed with the player's inventory open, usually clicking the item with their cursor.
    • The Commands:
    • interact - Executes the commands when the player is left or right clicking a block or the air with the item in their hand.
    • interact-air - Executes the commands when the player is left or right clicking the air with the item in their hand.
    • interact-block - Executes the commands when the player is left or right clicking a block with the item in their hand.
    • interact-left - Executes the commands when the player is left clicking a block or the air with the item in their hand.
    • interact-air-left - Executes the commands when the player is left clicking the air with the item in their hand.
    • interact-block-left - Executes the commands when the player is left clicking a block with the item in their hand.
    • interact-right - Executes the commands when the player is right clicking a block or the air with the item in their hand.
    • interact-air-right - Executes the commands when the player is right clicking the air with the item in their hand.
    • interact-block-right - Executes the commands when the player is right clicking a block with the item in their hand.
    • inventory - Executes the command when the player is middle-mouse, left, right, shift-left, shift-right clicking the item in their inventory.
    • inventory-middle - Executes the command when the player is middle-mouse clicking the item in their inventory.
    • inventory-creative - Executes the command when the player is in creative mode and clicks the item in their inventory, any click action will trigger this event.
    • inventory-left - Executes the command when the player is left clicking the item in their inventory.
    • inventory-right - Executes the command when the player is right clicking the item in their inventory.
    • inventory-shift-left - Executes the command when the player is shift-left clicking the item in their inventory.
    • inventory-shift-right - Executes the command when the player is shift-right clicking the item in their inventory.
    • inventory-swap-cursor - Executes the command when the player is swapping the item on their cursor with the item in their inventory.
    • on-receive - Executes the commands when the player receives the item for every x second(s) for every x number of times.
      • Every x second(s) is defined by setting the wait value as the commands-cooldown.
      • The every x number of times is defined by adding commands-receive to the item and setting a numerical value.
    • on-hold - Executes the commands every x second(s) while the player is holding the item.
      • Every x second(s) is defined by setting the wait value as the commands-cooldown.
    • on-equip - Executes the commands when equipping the item into an armor slot.
    • un-equip - Executes the commands when unequipping the item from an armor slot.
    • on-death - Executes the command when the player holding the item in their inventory dies.
    • physical - Executes the command if a player steps on a pressure plate, hits a mob, opens a chest, or any other physical actions with that item in the player's hand.

Also note, commands-type has been removed.

commented

Another update, the Snapshot b603 now contains (6. Conditions for Each Command Execution) and (1. Custom disposable conditions.) as well as trigger-conditions.
Link; https://ci.craftationgaming.com/job/ItemJoin/603/

These can be defined as a list or single object, the fail message is also optional. For the action to perform you only need to have met ONE of the conditions listed.

1.) Disposable conditions are exactly as described above, simply define them as such;

disposable-conditions:
- '%mypet_has_pet%:equal:true'
- '%other_placeholder%:notequal:VALUE'
- '%other_placeholder%:over:100'
- '%other_placeholder%:under:200'

disposable-fail-message: '&cYou need to summon your pet.'

I wasn't quite sure if you wanted this to PREVENT the command from executing, from what I can tell above is that you want it to execute but not consume under certain conditions so I made the consumption of the item independent from the command execution.

2.) Command conditions are also exactly as described above, however, they do not share a single fail message, you can define individual ones for each condition TYPE, such as interact-conditions can have an interact-fail-message or inventory-left can have an inventory-left-fail-message

inventory-left-conditions:
- '%mypet_has_pet%:equal:true'
- '%other_placeholder%:notequal:VALUE'
- '%other_placeholder%:over:100'
- '%other_placeholder%:under:200'

inventory-left-fail-message: '&cYou need to summon your pet.'

3.) Triggers now can be defined with a condition, (these are shared so it is essentially the condition requirement to GET the item), the ij get command respects these requirements.

trigger-conditions:
- '%mypet_has_pet%:equal:true'
- '%other_placeholder%:notequal:VALUE'
- '%other_placeholder%:over:100'
- '%other_placeholder%:under:200'

trigger-fail-message: '&cYou need to summon your pet.'

Enjoy!

commented

Thanks for adding lots of feature~
The condition idea is very wonderful.
But I test the interact condition is not work correctly.

This is the test video:
https://youtu.be/ncw8pcXYayI

The test configuration:
https://pastebin.com/4XRW6RYt

Paper version: git-Paper-439 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
ItemJoin version: v5.1.1-SNAPSHOT-b603 (Video)
ItemJoin version: v5.1.1-SNAPSHOT-b660

Wish you have a nice day. >.0

commented

Thanks for adding lots of feature~
The condition idea is very wonderful.
But I test the interact condition is not work correctly.

This is the test video:
https://youtu.be/ncw8pcXYayI

The test configuration:
https://pastebin.com/4XRW6RYt

Paper version: git-Paper-439 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
ItemJoin version: v5.1.1-SNAPSHOT-b603 (Video)
ItemJoin version: v5.1.1-SNAPSHOT-b660

Wish you have a nice day. >.0

Apologies, I completely forgot to implement Placeholder translation.

The latest snapshot should fix this issue. Please NOTE though, this snapshot contains major changes, notably I have refactored conditions to now end in an S such as interact-condition is now interact-conditions. This was done as it was confusing people since it is technically a listed object. Lastly, the commands identifier was removed for listing commands.

So commands which resembled;

    commands:
      interact-right:
      - 'player: deluxemenus open navigation4'

Should now look like;

    interact-right:
    - 'player: deluxemenus open navigation4'

Do make sure you implement proper YAML formatting as when you remove the commands node there is two spaces in-front of the interact-right node you need to remove.

PS: Thanks for the donation from earlier, I updated the pages to reflect your new contribution amount :)

Link: https://ci.craftationgaming.com/job/ItemJoin/663/
Remember to remove your old ItemJoin.jar file.

commented

Added custom foods as request in the latest snapshot. They use the existing system that the custom apples use so simply define them using the potion-effects option.
Example; potion-effects: JUMP:2:120, NIGHT_VISION:2:400, GLOWING:1:410, REGENERATION:1:160

This will work for All consumable foods and for skull items.

Do note this previously was called potion-effect but is now refactored to be potion-effects

Link; https://ci.craftationgaming.com/job/ItemJoin/716/
Remember to remove your old ItemJoin.jar file

Last up... better random commands!