-
-
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 4 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 | ||
|---|---|---|---|---|
| @@ -1,17 +1,18 @@ | ||||
| package ch.njol.skript.effects; | ||||
|
|
||||
| import ch.njol.skript.Skript; | ||||
| import ch.njol.skript.doc.Description; | ||||
| import ch.njol.skript.doc.Example; | ||||
| import ch.njol.skript.doc.Name; | ||||
| 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; | ||||
| import org.jetbrains.annotations.Nullable; | ||||
| import org.skriptlang.skript.registration.SyntaxInfo; | ||||
| import org.skriptlang.skript.registration.SyntaxRegistry; | ||||
|
|
||||
| @Name("Feed") | ||||
| @Description("Feeds the specified players.") | ||||
|
|
@@ -20,41 +21,43 @@ | |||
| @Since("2.2-dev34") | ||||
| public class EffFeed extends Effect { | ||||
|
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. This class should also be moved to the PlayerModule directory. specifically |
||||
|
|
||||
| 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) : ""); | ||||
| } | ||||
| public static void register(SyntaxRegistry registry) { | ||||
| registry.register(SyntaxRegistry.EFFECT, SyntaxInfo.builder(EffFeed.class) | ||||
| .addPatterns("feed %players% [by %-number% [beef[s]]]") | ||||
|
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. I believe someone already asked this in another pr or at some point but why is there beef in the syntax it just seems off
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 its optional though
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. well atleast imo it should be removed as its kind of misleading as if you eat beef/steak ingame it feeds by 6 health so if you do though for this pr probably not best idea as it'd cause breaking changes
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. Beefs, as that's what the hunger bars could be refered to, don't see the use in removing it, would just cause it to break for anyone using it. |
||||
| .supplier(EffFeed::new) | ||||
| .build()); | ||||
| } | ||||
|
|
||||
| @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 = 0; | ||||
|
TheMug06 marked this conversation as resolved.
|
||||
|
|
||||
| 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 |
||||
| } | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package org.skriptlang.skript.bukkit.entity.player; | ||
|
|
||
| import ch.njol.skript.Skript; | ||
| import ch.njol.skript.effects.EffFeed; | ||
| import ch.njol.skript.lang.util.SimpleEvent; | ||
| import io.papermc.paper.event.player.AsyncChatEvent; | ||
| import org.skriptlang.skript.addon.AddonModule; | ||
|
|
@@ -23,6 +24,7 @@ protected void loadSelf(SkriptAddon addon) { | |
| register(addon, | ||
| EffBan::register, | ||
| EffKick::register, | ||
| EffFeed::register, | ||
|
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 be before EffKick I believe |
||
| ExprChatFormat::register, | ||
| ExprChatMessage::register, | ||
| ExprChatRecipients::register, | ||
|
|
||
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 be in org/skriptlang/skript/bukkit/entity/player/elements/effects