-
- Notifications
You must be signed in to change notification settings - Fork 414
Fix and enhance EffOpenInventory #7508
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
Fix and enhance EffOpenInventory #7508
Conversation
Co-authored-by: Ayham Al Ali <20037329+AyhamAl-Ali@users.noreply.github.com>
…ript into fix/open-inventory
Co-authored-by: Patrick Miller <apickledwalrus@gmail.com>
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
| It looks mostly fine I think. |
Co-authored-by: Moderocky <admin@moderocky.com>
| EventValues.registerEventValue(InventorySectionEvent.class, Player[].class, InventorySectionEvent::getPlayers); | ||
| Skript.registerSection(EffSecOpenInventory.class, | ||
| "(show|create|open) %inventory/inventorytype% (to|for) %players%", | ||
| "open [a[n]] " + OpenableInventorySyntax.construct() + " [view|window|inventory] (to|for) %players%", |
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 allows open target block's inventory inventory to me
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.
Existing syntax, let me know if you want it to break existing syntax.
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.
It was not existing. The prior pattern was (open|show) (...|%-inventory/inventorytype%) (to|for) %players%. That doesn't allow open target block's inventory inventory to me. Sorry for the delayed response, I lost track of this notification in github.
| } | ||
| | ||
| private @Nullable OpenableInventorySyntax syntax; | ||
| private @Nullable Expression<?> object; |
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.
| private @Nullable Expression<?> object; | |
| private @Nullable Expression<?> inventoryObject; |
needs a more descriptive name
| if (open && hasSection()) | ||
| trigger = loadCode(sectionNode, "open inventory", InventorySectionEvent.class); | ||
| | ||
| return true; |
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.
There's no check to disallow
close player's inventory: do something | if (open && hasSection()) | ||
| trigger = loadCode(sectionNode, "open inventory", InventorySectionEvent.class); |
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.
Doesn't load code if using open %inventory/inventorytype%
| EventValues.registerEventValue(InventorySectionEvent.class, Inventory.class, InventorySectionEvent::getInventory); | ||
| EventValues.registerEventValue(InventorySectionEvent.class, Player[].class, InventorySectionEvent::getPlayers); | ||
| Skript.registerSection(EffSecOpenInventory.class, | ||
| "(show|create|open) %inventory/inventorytype% (to|for) %players%", |
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.
open an anvil inventory uses pattern 0
open an anvil uses pattern 1
These should both follow the same code path.
| for (Player player : players) | ||
| player.openInventory(inventory); | ||
| | ||
| } else { |
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.
The section trigger is never run in this path. This is the only path where the section trigger even exists.
| return super.walk(event, false); | ||
| | ||
| Player[] players = this.players.getArray(event); | ||
| if (players.length > 0 && trigger != null) { |
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.
Due to earlier errors, the trigger will always be null since loadCode was never called.
| @Override | ||
| public String toString(@Nullable Event event, boolean debug) { | ||
| if (object != null) | ||
| return "show " + object.toString(event, debug) + " to " + players.toString(event, debug); |
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.
show isn't always accurate
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
| Inactivity |
Continuation #5531
See split commit Modify EffOpenInventory for easy reviewing to allow for easier reviewing of what was changed in EffOpenInventory before rename to EffSecOpenInventory.