Skip to content

Commit

Permalink
chore(text-minimessage): Make phase uniformly a double
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Apr 9, 2023
1 parent f02a1ba commit cc0d7b7
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class GradientTag extends AbstractColorChangingTag {
private @Range(from = -1, to = 1) double phase;

static Tag create(final ArgumentQueue args, final Context ctx) {
float phase = 0;
double phase = 0;
final List<TextColor> textColors;
if (args.hasNext()) {
textColors = new ArrayList<>();
Expand All @@ -68,9 +68,9 @@ static Tag create(final ArgumentQueue args, final Context ctx) {
if (!args.hasNext()) {
final OptionalDouble possiblePhase = arg.asDouble();
if (possiblePhase.isPresent()) {
phase = (float) possiblePhase.getAsDouble();
if (phase < -1f || phase > 1f) {
throw ctx.newException(String.format("Gradient phase is out of range (%s). Must be in the range [-1.0f, 1.0f] (inclusive).", phase), args);
phase = possiblePhase.getAsDouble();
if (phase < -1d || phase > 1d) {
throw ctx.newException(String.format("Gradient phase is out of range (%s). Must be in the range [-1.0, 1.0] (inclusive).", phase), args);
}
break;
}
Expand All @@ -90,7 +90,7 @@ static Tag create(final ArgumentQueue args, final Context ctx) {
return new GradientTag(phase, textColors);
}

private GradientTag(final float phase, final List<TextColor> colors) {
private GradientTag(final double phase, final List<TextColor> colors) {
if (colors.isEmpty()) {
this.colors = new TextColor[]{TextColor.color(0xffffff), TextColor.color(0x000000)};
} else {
Expand Down

0 comments on commit cc0d7b7

Please sign in to comment.