Skip to content

Commit

Permalink
Requested Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAbsolutionism committed Dec 29, 2024
1 parent e09a70e commit 6ae56aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/main/java/ch/njol/skript/expressions/ExprBannerItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@Name("Banner Pattern Item")
@Description({
"Gets the item from a banner pattern type.",
"NOTE: Not all banner pattern types have an item.",
"Note that not all banner pattern types have an item.",
})
@Examples({
"set {_item} to creeper charged banner pattern item",
Expand All @@ -36,7 +36,7 @@
@Since("INSERT VERSION")
public class ExprBannerItem extends SimpleExpression<ItemType> {

private static Map<Object, Material> bannerMaterials = new HashMap<>();
private static final Map<Object, Material> bannerMaterials = new HashMap<>();
private static boolean PATTERN_TYPE_IS_REGISTRY = false;

static {
Expand Down
36 changes: 13 additions & 23 deletions src/main/java/ch/njol/skript/expressions/ExprBannerPatterns.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@

@Name("Banner Patterns")
@Description({
"Banner patterns of a banner.",
"NOTE: In order to set a specific position of a banner, there needs to be that many patterns on the banner.",
"Gets or sets the banner patterns of a banner.",
"In order to set a specific position of a banner, there needs to be that many patterns already on the banner.",
"This expression will add filler patterns to the banner to allow the specified position to be set.",
"Example, setting the 3rd banner pattern of a banner that has no patterns on it, will internally add 3 base patterns to "
+ "the banner allowing the 3rd banner pattern to be set"
"For Example, setting the 3rd banner pattern of a banner that has no patterns on it, will internally add 3 base patterns, "
+ "allowing the 3rd banner pattern to be set."
})
@Examples({
"broadcast banner patterns of {_banneritem}",
Expand Down Expand Up @@ -104,7 +104,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
}

/**
* Gets the appropriate {@link Consumer<BannerMeta>} to be used within the {@link #change(Event, Object[], ChangeMode)}
* Gets the appropriate {@link Consumer<BannerMeta>} to be used within {@link #change(Event, Object[], ChangeMode)}.
* @param mode The {@link ChangeMode} to get the consumer matching the behavior
* @param placement The specific pattern to set {@code pattern}
* @param pattern The pattern to be applied
Expand All @@ -130,7 +130,7 @@ private Consumer<BannerMeta> getPlacementMetaChanger(ChangeMode mode, int placem
}

/**
* Gets the appropriate {@link Consumer<Banner>} to be used within the {@link #change(Event, Object[], ChangeMode)}
* Gets the appropriate {@link Consumer<Banner>} to be used within {@link #change(Event, Object[], ChangeMode)}.
* @param mode The {@link ChangeMode} to get the consumer matching the behavior
* @param placement The specific pattern to set {@code pattern}
* @param pattern The pattern to be applied
Expand All @@ -156,7 +156,7 @@ private Consumer<Banner> getPlacementBlockChanger(ChangeMode mode, int placement
}

/**
* Gets the appropriate {@link Consumer<BannerMeta>} to be used within the {@link #change(Event, Object[], ChangeMode)}
* Gets the appropriate {@link Consumer<BannerMeta>} to be used within {@link #change(Event, Object[], ChangeMode)}.
* @param mode The {@link ChangeMode} to get the consumer matching the behavior
* @param patterns Patterns to be added, removed, or set to corresponding with the {@code mode}
* @return {@link Consumer<BannerMeta>} to be applied to objects within {@link #change(Event, Object[], ChangeMode)}
Expand All @@ -182,7 +182,7 @@ private Consumer<BannerMeta> getAllMetaChanger(ChangeMode mode, List<Pattern> pa
}

/**
* Gets the appropriate {@link Consumer<Banner>} to be used within the {@link #change(Event, Object[], ChangeMode)}
* Gets the appropriate {@link Consumer<Banner>} to be used within {@link #change(Event, Object[], ChangeMode)}.
* @param mode The {@link ChangeMode} to get the consumer matching the behavior
* @param patterns Patterns to be added, removed, or set to corresponding with the {@code mode}
* @return {@link Consumer<Banner>} to be applied to objects within {@link #change(Event, Object[], ChangeMode)}
Expand Down Expand Up @@ -210,26 +210,16 @@ private Consumer<Banner> getAllBlockChanger(ChangeMode mode, List<Pattern> patte
@Override
public Class<?> @Nullable [] acceptChange(ChangeMode mode) {
return switch (mode) {
case SET, DELETE -> {
if (patternNumber != null)
yield CollectionUtils.array(Pattern.class);
yield CollectionUtils.array(Pattern[].class);
}
case REMOVE, ADD -> {
if (patternNumber != null)
yield null;
yield CollectionUtils.array(Pattern[].class);
}
case SET, DELETE -> (patternNumber != null) ? CollectionUtils.array(Pattern.class) : CollectionUtils.array(Pattern[].class);
case REMOVE, ADD -> (patternNumber != null) ? null : CollectionUtils.array(Pattern[].class);
default -> null;
};
}

@Override
public void change(Event event, Object @Nullable [] delta, ChangeMode mode) {
Pattern[] patterns = (Pattern[]) delta;
int placement = 0;
if (patternNumber != null)
placement = patternNumber.getSingle(event);
int placement = patternNumber == null ? 0 : patternNumber.getSingle(event);
List<Pattern> patternList = patterns != null ? Arrays.stream(patterns).toList() : new ArrayList<>();

Consumer<BannerMeta> metaChanger = null;
Expand Down Expand Up @@ -280,11 +270,11 @@ public Class<Pattern> getReturnType() {
public String toString(@Nullable Event event, boolean debug) {
SyntaxStringBuilder builder = new SyntaxStringBuilder(event, debug);
if (patternNumber != null) {
builder.append(patternNumber, "banner pattern");
builder.append("banner pattern", patternNumber);
} else {
builder.append("banner patterns");
}
builder.append(objects);
builder.append("of", objects);
return builder.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.jetbrains.annotations.Nullable;

@Name("Banner Pattern")
@Description("Create a new banner pattern.")
@Description("Creates a new banner pattern.")
@Examples({
"set {_pattern} to a creeper banner pattern colored red",
"add {_pattern} to banner patterns of {_banneritem}",
Expand Down

0 comments on commit 6ae56aa

Please sign in to comment.