-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
🚀 Added %itemtypes% dyed %color%
expression & ExprColorOf Improvements
#4335
🚀 Added %itemtypes% dyed %color%
expression & ExprColorOf Improvements
#4335
Conversation
- Also fixed `color of` not working (getting and setting) with potions, maps and leather armor meta - Improved changers of `color of` expr
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.
Nothing too major. I also wonder if it would be beneficial to have some sort of dye utility methods (since there is a lot of repetition when it comes to the instanceof checks and such)
Co-authored-by: APickledWalrus <[email protected]>
%itemtypes% dyed %color%
expression%itemtypes% dyed %color%
expression & ExprColorOf Improvements
This PR now fixes the issue of grabbing block colors, see #5682 |
Closing due to 7+ months of inactivity |
- RGB pattern now don't require a space after the commas - renamed couple variables - added a fail shortcut for dying blocks with RGB - Removed color-color comparator as it's not the proper fix, it should be fixed in CondCompare
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 the best at reviewing so I'll leave the more important reviews to the team, this was just something I noticed right away
eeee8b4
to
e66ad6f
Compare
kept as a band aid fix until we fix it properly due to it breaking this PR
String hand = offHand ? "off hand" : ""; | ||
return String.format("%s tool of %s", hand, getExpr().toString(e, debug)); | ||
public String toString(final @Nullable Event event, final boolean debug) { | ||
return offHand ? "off hand " : "" + "tool of " + getExpr().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.
return offHand ? "off hand " : "" + "tool of " + getExpr().toString(event, debug); | |
return (offHand ? "off hand " : "") + "tool of " + getExpr().toString(event, debug); |
// TODO FIX | ||
// this approach has couple issues, users can't use multiple types in source like | ||
// 'broadcast colors of ((trailing burst firework colored blue and red) and targeted block)' and second | ||
// this check doesn't work with variables as it's not converted yet |
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.
what do you mean by not converted yet?
protected Color[] get(Event e, Object[] source) { | ||
protected Color[] get(Event event, Object[] source) { | ||
// TODO FIX | ||
// this approach has couple issues, users can't use multiple types in source like |
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.
would this be resolved by instead using a SimplePropertyExpression here? is there a reason it couldn't be one?
public class ExprColorOf extends PropertyExpression<Object, Color> { | ||
|
||
private static final boolean MAPS_AND_POTIONS_COLORS = Skript.methodExists(PotionMeta.class, "setColor", org.bukkit.Color.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.
This method seems to exist on 1.13 https://jd.papermc.io/paper/1.13/org/bukkit/inventory/meta/PotionMeta.html#setColor-org.bukkit.Color-
return ColorRGB.fromBukkitOrRgbColor(mapMeta.getColor()); | ||
} else if (meta instanceof PotionMeta && MAPS_AND_POTIONS_COLORS) { | ||
PotionMeta potionMeta = (PotionMeta) meta; | ||
if (potionMeta.getColor() != 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.
if (potionMeta.getColor() != null) | |
if (potionMeta.hasColor()) |
You need to use this check per the javadoc of getColor
switch (mode) { // items/blocks/entities only accept these change modes | ||
case RESET: | ||
case DELETE: | ||
case SET: | ||
return CollectionUtils.array(Color.class); | ||
} | ||
|
||
return 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.
switch (mode) { // items/blocks/entities only accept these change modes | |
case RESET: | |
case DELETE: | |
case SET: | |
return CollectionUtils.array(Color.class); | |
} | |
return null; | |
switch (mode) { // items/blocks/entities only accept these change modes | |
case RESET: | |
case DELETE: | |
case SET: | |
return CollectionUtils.array(Color.class); | |
default: | |
return null; | |
} |
I think you can do this (can eventually be converted to a switch expression in the future)
"since different colored beds are different materials. " + | ||
"Instead, set the block to right material, such as a blue bed."); // Let's just assume it's a bed | ||
} catch (Exception ex) { | ||
// TODO remove this as it's too old now |
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.
is there a reason not to remove it in this PR?
Material newBlock = setMaterialColor(block.getType(), color); | ||
if (newBlock == null) | ||
continue; | ||
block.setType(newBlock); |
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.
how does this affect the BlockData (e.g. bed half)
"give player leather chestplate dyed red", | ||
"give player potion of invisibility dyed rgb 200, 70, 88", | ||
"give player filled map colored rgb(20, 60, 70)", | ||
"give player wool painted red" |
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.
"give player leather chestplate dyed red", | |
"give player potion of invisibility dyed rgb 200, 70, 88", | |
"give player filled map colored rgb(20, 60, 70)", | |
"give player wool painted red" | |
"give player leather chestplate dyed red", | |
"give player potion of invisibility dyed rgb 200, 70, 88", | |
"give player filled map colored rgb(20, 60, 70)", | |
"give player wool painted red" |
I think one line is okay for these annotations
@Since("INSERT VERSION") | ||
public class ExprDyed extends SimpleExpression<ItemType> { | ||
|
||
private static final boolean MAPS_AND_POTIONS_COLORS = Skript.methodExists(PotionMeta.class, "setColor", org.bukkit.Color.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.
This method seems to exist on 1.13 https://jd.papermc.io/paper/1.13/org/bukkit/inventory/meta/PotionMeta.html#setColor-org.bukkit.Color-
Description
This PR aims to add a new helpful expression to return itemtypes with colors directly using this pattern
%itemtypes% (dyed|with color [of]) %color%
It also comes with some improvements and fixes to
ExprColorOf
:color of
not working (getting and setting) with potions, maps and leather armor metacolor of
not working (getting and setting) with blocks in MC 1.14+Quick showcase of this PR's results
in the 2nd image the held item is the 2nd hotbar slot and the new given item is the 4th hotbar slot
Target Minecraft Versions: Any (HEX/RGB 1.16+)
Requirements: None
Related Issues: