Skip to content

ExprTool - Cleanup & Additional Test#7710

Merged
sovdeeth merged 16 commits into
SkriptLang:dev/featurefrom
Fusezion:enhancement/add-mainhand-to-tool
Apr 16, 2025
Merged

ExprTool - Cleanup & Additional Test#7710
sovdeeth merged 16 commits into
SkriptLang:dev/featurefrom
Fusezion:enhancement/add-mainhand-to-tool

Conversation

@Fusezion
Copy link
Copy Markdown
Contributor

@Fusezion Fusezion commented Mar 16, 2025

Description

This PR aims to clean up the ExprTool class as well as include some more test for it.
The patterns have been split to hopefully increase readability of the pattern itself making it clear what is what.
Additionally a new method to the BukkitUtils class has been added to get equipment slot from their indices as well as the indices of the slots themselves.

I will say the handling of the events in this expression does not make any sense to happen, these should have been event-values, however it's sadly too late to change them.


Target Minecraft Versions: any
Requirements: none
Related Issues: #5700

@Fusezion Fusezion changed the title Enhancement/add mainhand to tool ExprTool - Add Mainhand/Offhand patterns Mar 16, 2025
Comment thread src/main/java/ch/njol/skript/expressions/ExprTool.java
Comment thread src/main/java/ch/njol/skript/expressions/ExprTool.java Outdated
Comment thread src/main/java/ch/njol/skript/expressions/ExprTool.java Outdated
@Efnilite Efnilite added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Mar 16, 2025
Fusezion and others added 2 commits March 16, 2025 08:44
Add initial suggestions

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
@Fusezion Fusezion requested a review from Efnilite March 16, 2025 12:52
@Efnilite Efnilite added feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. and removed feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. labels Mar 16, 2025
@sovdeeth
Copy link
Copy Markdown
Member

I'm a little apprehensive about using just main hand and off hand for this. There has been prior conversation (i don't think it went anywhere) about being able to detect which hand was used in a click event and using main hand and off hand as ways to differentiate the two. Do you think it's worth keeping those patterns unused for possible future use and still requiring tool/item? If we don't, it'll make any future reassignment a breaking change.

I personally think that tool/item should remain required as this expression is specifically about the item, not the hand itself.

@Fusezion
Copy link
Copy Markdown
Contributor Author

I'm a little apprehensive about using just main hand and off hand for this. There has been prior conversation (i don't think it went anywhere) about being able to detect which hand was used in a click event and using main hand and off hand as ways to differentiate the two.

I wouldn't see why the team would want to make a whole new comparison for handling that in click when it would likely be much easier to add an event-value for click type with left/right mouse button.

Do you think it's worth keeping those patterns unused for possible future use and still requiring tool/item? If we don't, it'll make any future reassignment a breaking change.

I'm still not too sure on changing it, main hand of %entity% makes sense howevr mainhand item/tool of %entity% doesn't
offhand tool/item, I can revert the change but mainhand doesn't really have a good counter part

@sovdeeth
Copy link
Copy Markdown
Member

I wouldn't see why the team would want to make a whole new comparison for handling that in click when it would likely be much easier to add an event-value for click type with left/right mouse button.

Using main/offhand isn't the same as left/right click. If you're holding a sword in the main hand, torch in the offhand, and you click place, it will use the offhand. But if the sword has a block component or whatever, it'll block with the sword. It's not that simple,

I'm still not too sure on changing it, main hand of %entity% makes sense howevr mainhand item/tool of %entity% doesn't
offhand tool/item, I can revert the change but mainhand doesn't really have a good counter part

Well, you just do [main hand] (tool|weapon...). I also don't think we should be allowing mainhand. We shouldn't really be allowing offhand either, but that ship already sailed.

@sovdeeth sovdeeth requested a review from a team as a code owner March 22, 2025 17:44
@sovdeeth sovdeeth requested review from abandonedaccount6235 and sovdeeth and removed request for a team March 22, 2025 17:44
@Fusezion Fusezion changed the title ExprTool - Add Mainhand/Offhand patterns ExprTool - Clean up & Test Mar 23, 2025
Copy link
Copy Markdown
Contributor Author

@Fusezion Fusezion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this PR to remove the option of main hand of %entity% and off hand of %entity% and am now just marking it as a class cleanup.

There's only one part in this that confuses me and leads to improper behavior

Comment thread src/main/java/ch/njol/skript/expressions/ExprTool.java
@Fusezion Fusezion changed the title ExprTool - Clean up & Test ExprTool - Cleanup & Additional Test Mar 23, 2025
Comment thread src/main/java/ch/njol/skript/expressions/ExprTool.java Outdated
Comment thread src/main/java/ch/njol/skript/expressions/ExprTool.java Outdated
Comment thread src/main/java/ch/njol/skript/bukkitutil/BukkitUtils.java Outdated
@Fusezion Fusezion requested a review from Efnilite March 23, 2025 17:35
Comment thread src/main/java/ch/njol/skript/bukkitutil/BukkitUtils.java Outdated
Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
@Fusezion Fusezion requested a review from Efnilite March 24, 2025 18:30
@sovdeeth sovdeeth added the feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version. label Apr 6, 2025
@sovdeeth sovdeeth merged commit f02494f into SkriptLang:dev/feature Apr 16, 2025
5 checks passed
sovdeeth added a commit that referenced this pull request Apr 24, 2025
* Initial Commit

* Fix Elements

* Fix Entity Spawning

* Update EntityData.java

* Skip `-` prefix variable names when saving. (Ephemeral variables) (#7495)

* Skip minus sign names when saving.

* Remove minus sign from tokens list instead.

* move check to before serialization

---------

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

* [WIP] Add on screen kick message expr (#7658)

* Add kick message expr

* Add proper placeholder for version

* Code clean up

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>

* We only support 1.19.4+

* use deprecated api

* resolve suggestions

* mark method as nullable

* remove minimessage entirely

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>

* shorter import

* implement EventRestrictedSyntax

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>

* apply changes

* implement suggestions

* Update src/main/java/ch/njol/skript/expressions/ExprOnScreenKickMessage.java

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

* Update src/main/java/ch/njol/skript/expressions/ExprOnScreenKickMessage.java

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

* ExprTool - Cleanup & Additional Test (#7710)

* ExprTool.java - add mainhand and offhand

* ExprTool.sk - Add basic testing

* ExprTool.sk - new line

* Apply suggestions from code review

Add initial suggestions

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>

* ExprTool.java - Change toString to SSB

* Remove support for only "offhand" and "mainhand"

* Move patterns back into the method

* Update src/main/java/ch/njol/skript/expressions/ExprTool.java

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

* Move equipment slot map to BukkitUtils

* Requested changes

* Update to a BiMap for equipmentslot

* Update src/main/java/ch/njol/skript/bukkitutil/BukkitUtils.java

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>

* Changes

* Remove Feature Changes

* Requested Changes

* Update EntityUtils.java

* Requested Changes

---------

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>
Co-authored-by: Moderocky <admin@moderocky.com>
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
Co-authored-by: nopeless <38830903+nopeless@users.noreply.github.com>
Co-authored-by: Fusezion <fusezionstream@gmail.com>
Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
@Fusezion Fusezion deleted the enhancement/add-mainhand-to-tool branch May 29, 2025 07:07
erenkarakal pushed a commit to erenkarakal/Skript that referenced this pull request Nov 26, 2025
* ExprTool.java - add mainhand and offhand

* ExprTool.sk - Add basic testing

* ExprTool.sk - new line

* Apply suggestions from code review

Add initial suggestions

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>

* ExprTool.java - Change toString to SSB

* Remove support for only "offhand" and "mainhand"

* Move patterns back into the method

* Update src/main/java/ch/njol/skript/expressions/ExprTool.java

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

* Move equipment slot map to BukkitUtils

* Requested changes

* Update to a BiMap for equipmentslot

* Update src/main/java/ch/njol/skript/bukkitutil/BukkitUtils.java

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
erenkarakal pushed a commit to erenkarakal/Skript that referenced this pull request Nov 26, 2025
* Initial Commit

* Fix Elements

* Fix Entity Spawning

* Update EntityData.java

* Skip `-` prefix variable names when saving. (Ephemeral variables) (SkriptLang#7495)

* Skip minus sign names when saving.

* Remove minus sign from tokens list instead.

* move check to before serialization

---------

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

* [WIP] Add on screen kick message expr (SkriptLang#7658)

* Add kick message expr

* Add proper placeholder for version

* Code clean up

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>

* We only support 1.19.4+

* use deprecated api

* resolve suggestions

* mark method as nullable

* remove minimessage entirely

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>

* shorter import

* implement EventRestrictedSyntax

* Update src/main/java/ch/njol/skript/expressions/ExprKickMessage.java

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>

* apply changes

* implement suggestions

* Update src/main/java/ch/njol/skript/expressions/ExprOnScreenKickMessage.java

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

* Update src/main/java/ch/njol/skript/expressions/ExprOnScreenKickMessage.java

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

* ExprTool - Cleanup & Additional Test (SkriptLang#7710)

* ExprTool.java - add mainhand and offhand

* ExprTool.sk - Add basic testing

* ExprTool.sk - new line

* Apply suggestions from code review

Add initial suggestions

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>

* ExprTool.java - Change toString to SSB

* Remove support for only "offhand" and "mainhand"

* Move patterns back into the method

* Update src/main/java/ch/njol/skript/expressions/ExprTool.java

Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

* Move equipment slot map to BukkitUtils

* Requested changes

* Update to a BiMap for equipmentslot

* Update src/main/java/ch/njol/skript/bukkitutil/BukkitUtils.java

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>

* Changes

* Remove Feature Changes

* Requested Changes

* Update EntityUtils.java

* Requested Changes

---------

Co-authored-by: SirSmurfy2 <82696841+TheAbsolutionism@users.noreply.github.com>
Co-authored-by: Moderocky <admin@moderocky.com>
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
Co-authored-by: nopeless <38830903+nopeless@users.noreply.github.com>
Co-authored-by: Fusezion <fusezionstream@gmail.com>
Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature-ready A PR/issue that has been approved, tested and can be merged/closed in the next feature version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants