-
-
Notifications
You must be signed in to change notification settings - Fork 454
Fix EffFeed #8702
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/patch
Are you sure you want to change the base?
Fix EffFeed #8702
Changes from 3 commits
cb0e612
8ec0eb3
74536cb
ba917ab
2cd1018
7018aaa
cf6e919
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |||
| import ch.njol.skript.doc.Since; | ||||
| import ch.njol.skript.lang.Effect; | ||||
| import ch.njol.skript.lang.Expression; | ||||
| import ch.njol.skript.lang.SkriptParser; | ||||
| import ch.njol.skript.lang.SkriptParser.ParseResult; | ||||
| import ch.njol.util.Kleenean; | ||||
| import org.bukkit.entity.Player; | ||||
| import org.bukkit.event.Event; | ||||
|
|
@@ -20,41 +20,40 @@ | |||
| @Since("2.2-dev34") | ||||
| public class EffFeed extends Effect { | ||||
|
|
||||
| static { | ||||
| Skript.registerEffect(EffFeed.class, "feed [the] %players% [by %-number% [beef[s]]]"); | ||||
| } | ||||
|
|
||||
| @SuppressWarnings("null") | ||||
| private Expression<Player> players; | ||||
| @Nullable | ||||
| private Expression<Number> beefs; | ||||
|
|
||||
| @Override | ||||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) { | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should use |
||||
| players = (Expression<Player>) exprs[0]; | ||||
| beefs = (Expression<Number>) exprs[1]; | ||||
| return true; | ||||
| } | ||||
|
|
||||
| @Override | ||||
| protected void execute(Event e) { | ||||
| int level = 20; | ||||
|
|
||||
| if (beefs != null) { | ||||
| Number n = beefs.getSingle(e); | ||||
| if (n == null) | ||||
| return; | ||||
| level = n.intValue(); | ||||
| } | ||||
| for (Player player : players.getArray(e)) { | ||||
| player.setFoodLevel(player.getFoodLevel() + level); | ||||
| } | ||||
| } | ||||
|
|
||||
| @Override | ||||
| public String toString(@Nullable Event e, boolean debug) { | ||||
| return "feed " + players.toString(e, debug) + (beefs != null ? " by " + beefs.toString(e, debug) : ""); | ||||
| } | ||||
| static { | ||||
| Skript.registerEffect(EffFeed.class, "feed [the] %players% [by %-number% [beef[s]]]"); | ||||
|
hotpoc marked this conversation as resolved.
Outdated
hotpoc marked this conversation as resolved.
Outdated
|
||||
| } | ||||
|
|
||||
| @SuppressWarnings("null") | ||||
| private Expression<Player> players; | ||||
|
hotpoc marked this conversation as resolved.
Outdated
|
||||
| @Nullable | ||||
| private Expression<Number> beefs; | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just my thoughts but why is this named beefs? couldn't it be named something like amount
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i dont know bro
hotpoc marked this conversation as resolved.
Outdated
|
||||
|
|
||||
| @Override | ||||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||||
| players = (Expression<Player>) exprs[0]; | ||||
| beefs = (Expression<Number>) exprs[1]; | ||||
| return true; | ||||
| } | ||||
|
|
||||
| @Override | ||||
| protected void execute(Event e) { | ||||
|
hotpoc marked this conversation as resolved.
Outdated
|
||||
| int foodAmount = 20; | ||||
|
|
||||
| if (beefs != null) { | ||||
| Number n = beefs.getSingle(e); | ||||
| if (n != null) | ||||
| foodAmount = n.intValue(); | ||||
|
Comment on lines
+46
to
+48
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would retain the behavior of terminating if |
||||
| } | ||||
| for (Player player : players.getArray(e)) { | ||||
| player.setFoodLevel(beefs == null ? 20 : player.getFoodLevel() + foodAmount); | ||||
| } | ||||
| } | ||||
|
|
||||
| @Override | ||||
| public String toString(@Nullable Event e, boolean debug) { | ||||
|
hotpoc marked this conversation as resolved.
Outdated
|
||||
| return "feed " + players.toString(e, debug) + (beefs != null ? " by " + beefs.toString(e, debug) : ""); | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could use SyntaxStringBuilder |
||||
| } | ||||
|
|
||||
|
|
||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
extraneous space |
||||
| } | ||||
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 class should also be moved to the PlayerModule directory. specifically
org/skriptlang/skript/bukkit/entity/player/elements/effects