Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the PlayerArmorStandManipulate event #2601

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

heypr
Copy link
Contributor

@heypr heypr commented Feb 27, 2024

if (!path.tryObjectSwitch("player_item", playerItem)) {
return false;
}
if (!path.tryObjectSwitch("slot", new ElementTag(event.getSlot()))) {
Copy link
Member

Choose a reason for hiding this comment

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

Enum switches should use runGenericSwitchCheck (also applies to the other one)

//
// @Switch armor_stand_item:<item> to only process the event if the armor stand is holding a specific item.
// @Switch hand:<hand> to only process the event if the player is using a specific hand to interact with the armor stand. Available only on MC versions 1.19+.
// @Switch player_item:<item> to only process the event if the player is holding a specific item.
Copy link
Member

Choose a reason for hiding this comment

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

Switch meta should specify it's a matcher, e.g. something like player_item:<item> to only process the event if the item held by the player matches the specified item matcher.

// @Switch slot:<slot> to only process the event if the armor stand's item slot that was interacted with is the specified slot.
//
// @Context
// <context.armor_stand_item> returns the ItemTag held by the armor stand.
Copy link
Member

Choose a reason for hiding this comment

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

Should verify what this item actually is and update meta accordingly, see discussion on Discord


@Override
public boolean matches(ScriptPath path) {
if (!runInCheck(path, event.getPlayer().getLocation())) {
Copy link
Member

Choose a reason for hiding this comment

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

Probably makes more sense to use the armor stand's location here? the in: switch with this event would probably be used for stuff like protecting armor stands in a specific area

if (!path.tryObjectSwitch("player_item", playerItem)) {
return false;
}
if (!runGenericSwitchCheck(path,"slot", event.getSlot().name())) {
Copy link
Member

Choose a reason for hiding this comment

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

Missing space between args (on the other runGenericSwitchCheck as well)


public PlayerArmorStandManipulateScriptEvent() {
registerCouldMatcher("player edits armor stand");
registerSwitches("armor_stand_item", "hand", "player_item", "slot");
Copy link
Member

Choose a reason for hiding this comment

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

Should have some switch/matcher for the armor stand itself as well


// <--[event]
// @Events
// player edits <'armor_stand'>
Copy link
Member

Choose a reason for hiding this comment

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

this event line is extremely liable to conflict with events, currently it conflicts with 1 (player edits book)

@tal5
Copy link
Member

tal5 commented May 4, 2024

LGTM, although manipulates is a bit inconsistent with other event names imo - now that the event line has a hard-coded armor stand (I.e. won't conflict), I'd probably do edits or changes

@mcmonkey4eva
Copy link
Member

Maybe player changes armor stand item from:item to:item (ie the line is player changes armor stand item but swap the player/armorstand _item switches to from/to so it reads really cleanly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants