-
-
Notifications
You must be signed in to change notification settings - Fork 20
Added EffMakePlayerBreakBlock #889
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
base: dev/feature
Are you sure you want to change the base?
Conversation
Fusezion
left a comment
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.
Just a quick once over
src/main/java/com/shanebeestudios/skbee/elements/other/effects/EffMakePlayerBreakBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/com/shanebeestudios/skbee/elements/other/effects/EffMakePlayerBreakBlock.java
Outdated
Show resolved
Hide resolved
src/main/java/com/shanebeestudios/skbee/elements/other/effects/EffMakePlayerBreakBlock.java
Outdated
Show resolved
Hide resolved
src/test/scripts/elements/other/effects/EffMakePlayerBreakBlock.sk
Outdated
Show resolved
Hide resolved
src/main/java/com/shanebeestudios/skbee/elements/other/effects/EffMakePlayerBreakBlock.java
Outdated
Show resolved
Hide resolved
…/EffMakePlayerBreakBlock.java Co-authored-by: Fusezion <fusezionstream@gmail.com>
ShaneBeee
left a comment
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.
Just some food for thought.
| protected void execute(Event event) { | ||
| Player player = this.player.getSingle(event); | ||
| if (player == null) return; | ||
| this.blocks.stream(event).forEach(player::breakBlock); |
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.
One thing to consider here.
As discussed in the issue, the problem with this effect is that it doesn't play the sound or show the particles.
You could in theory use the Block#breakNaturally(ItemStack, (bool)trigger effects/exp) method to ensure it does.
for the item, just grab the players item in hand (or off hand).
I think you stated the event isn't called for that method tho, so you'd have to call it here as well.
Just something to think about.
Thoughts?!?!
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.
Hmm, if it is just calling the block break event in addition to breakNaturally then I think it should just be merged into the existing effect tbh
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.
since its worded so differently (the effect itself) im ok with it being its own effect.
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.
We could change the wording (optionally add as %player% to the end of the effect), I don't see a point of having two effects which do the exact same thing except one also calls an event
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.
that is true. could do an option like use item or player.
or just have two patterns:
break %blocks% [naturally] with effects [exp:[and] with (experience|exp|xp)] [using %-itemtype%]
and
make %player% break %blocks% [with effects]
I dunno if the pattern should include the event call?!?!?
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.
I think a single pattern makes more sense, so either using %itemtype% or as %player%
I don't think it is necessary to mention the event in the pattern, in the documentation is good enough imo.
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.
thats true, you could do
[(using %-itemtype%|by %-player%]
or something like that.
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.
Okay I've just combined the effects into one, using two patterns since I couldn't find a good way to determine if an item type or player was being used otherwise.
Thoughts?
Personally not too happy about "The triggered on break event can be cancelled, however drops and other variables cannot be modified" but there isn't really any workarounds.
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.
I'm not sure how I feel about one pattern calling the event, and the other not.
I think 1 of 2 things should happen here:
- Revert back to using a separate effect
- Have an option to call the event in the pattern (eww ... I know right?!?!)
Let's see what fuse has to say.
src/main/java/com/shanebeestudios/skbee/elements/other/effects/EffMakePlayerBreakBlock.java
Outdated
Show resolved
Hide resolved
| BlockBreakEvent breakEvent = new BlockBreakEvent(block, thePlayer); | ||
| Bukkit.getPluginManager().callEvent(breakEvent); | ||
| if (!breakEvent.isCancelled()) { |
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.
I THINK this can be shortened
| BlockBreakEvent breakEvent = new BlockBreakEvent(block, thePlayer); | |
| Bukkit.getPluginManager().callEvent(breakEvent); | |
| if (!breakEvent.isCancelled()) { | |
| if (new BlockBreakEvent(block, thePlayer).callEvent()) { |
| protected void execute(Event event) { | ||
| Player player = this.player.getSingle(event); | ||
| if (player == null) return; | ||
| this.blocks.stream(event).forEach(player::breakBlock); |
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.
I'm not sure how I feel about one pattern calling the event, and the other not.
I think 1 of 2 things should happen here:
- Revert back to using a separate effect
- Have an option to call the event in the pattern (eww ... I know right?!?!)
Let's see what fuse has to say.
|
Hey any update on this regarding reverting back to a separate effect or calling the event in the pattern? |
|
Honestly whoops, didn't realize you wanted my follow up kind of left it to Shane. Alright so after reading over the code and it does look like you at least considered what happens if its cancelled 🎊 As for the comment about splitting patterns into unique effects at this point I don't see much reason to do so. I get the concern about making one pattern do X while the other does Y but this is also done all over the place even in skript tho sometimes as a means to mitigate collisions & keep everything centralized which I believe is what this is doing anyways. Strongly against adding an optional to "call" the event especially if it requires a player in the first place. |
Fusezion
left a comment
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.
meant to mark my review as the above
|
I'm not sure if it calls BlockDropItemEvent or not tbh. though I don't think it matters
I agree about the statistic, I'll confirm that block break event isn't updating it and update it myself in that case. I agree with your take on the pattern, I'll keep that as is unless @ShaneBeee has any more concerns. Will push something either monday or tuesday |
ShaneBeee
left a comment
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.
I'll agree with Fuse on this.
I'm not too picky. I just want to make sure everything works.
Just one small nitpick:
| String item = this.itemType != null ? (" using " + this.itemType.toString(e, d)) : ""; | ||
| String player = this.player != null ? (" as " + this.player.toString(e, d)) : ""; | ||
| return "break " + blocks + " naturally with effects" + xp + item + player; |
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.
One little nitpick.
The pattern is break block naturally as player with effects and with xp
Yep the toString would come out as
break block naturally with effects and with xp as player
While this isn't really a big deal, I still think it should match the pattern.
To make things easier on yourself you could use the SyntaxStringBuilder class from Skript.
Describe your changes
This PR adds EffMakePlayerBreakBlock. It forces the player to break blocks using Player#breakBlock
Target Minecraft Versions: any
Requirements: none
Related Issues: #888
Checklist before requesting a review