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
base: dev
Are you sure you want to change the base?
Conversation
...main/java/com/denizenscript/denizen/events/player/PlayerArmorStandManipulateScriptEvent.java
Show resolved
Hide resolved
if (!path.tryObjectSwitch("player_item", playerItem)) { | ||
return false; | ||
} | ||
if (!path.tryObjectSwitch("slot", new ElementTag(event.getSlot()))) { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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())) { |
There was a problem hiding this comment.
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())) { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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'> |
There was a problem hiding this comment.
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
)
LGTM, although |
Maybe |
PlayerArmorStandManipulate
event #2600