Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryCarrade committed Nov 26, 2020
1 parent dd6463c commit cfcfb1b
Show file tree
Hide file tree
Showing 35 changed files with 1,086 additions and 1,369 deletions.
478 changes: 218 additions & 260 deletions src/main/java/fr/zcraft/quartzteams/QuartzTeam.java

Large diffs are not rendered by default.

248 changes: 98 additions & 150 deletions src/main/java/fr/zcraft/quartzteams/QuartzTeams.java

Large diffs are not rendered by default.

47 changes: 24 additions & 23 deletions src/main/java/fr/zcraft/quartzteams/QuartzTeamsBanners.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* pris connaissance de la licence CeCILL, et que vous en avez accepté les
* termes.
*/

package fr.zcraft.quartzteams;

import static fr.zcraft.quartzlib.tools.items.TextualBanners.getBannerMeta;
Expand All @@ -49,55 +50,55 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;

public class QuartzTeamsBanners
{
public class QuartzTeamsBanners {
private static final Map<String, BannerMeta> specialBanners = new HashMap<>();

static
{
specialBanners.put("banana", getBannerMeta(DyeColor.WHITE, Arrays.asList(new Pattern(DyeColor.YELLOW, PatternType.MOJANG), new Pattern(DyeColor.BROWN, PatternType.STRIPE_DOWNRIGHT), new Pattern(DyeColor.WHITE, PatternType.CIRCLE_MIDDLE), new Pattern(DyeColor.WHITE, PatternType.STRIPE_TOP), new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR), new Pattern(DyeColor.WHITE, PatternType.STRIPE_TOP))));
static {
specialBanners.put("banana", getBannerMeta(DyeColor.WHITE,
Arrays.asList(new Pattern(DyeColor.YELLOW, PatternType.MOJANG),
new Pattern(DyeColor.BROWN, PatternType.STRIPE_DOWNRIGHT),
new Pattern(DyeColor.WHITE, PatternType.CIRCLE_MIDDLE),
new Pattern(DyeColor.WHITE, PatternType.STRIPE_TOP),
new Pattern(DyeColor.WHITE, PatternType.HALF_VERTICAL_MIRROR),
new Pattern(DyeColor.WHITE, PatternType.STRIPE_TOP))));
}

public static ItemStack getDefaultBanner(final String name, final DyeColor color)
{
if (QuartzTeams.settings().bannerAllowSpecialShapes())
{
public static ItemStack getDefaultBanner(final String name, final DyeColor color) {
if (QuartzTeams.settings().bannerAllowSpecialShapes()) {
final String lowerName = name.toLowerCase();

if (lowerName.contains("banana") || lowerName.contains("banane"))
{
if (lowerName.contains("banana") || lowerName.contains("banane")) {
return getSpecialBanner("banana", color != DyeColor.YELLOW ? color : DyeColor.GREEN);
}
}

if (QuartzTeams.settings().bannerShapeWriteLetter())
{
if (QuartzTeams.settings().bannerShapeWriteLetter()) {
return TextualBanners.getCharBanner(
Character.toUpperCase(TextUtils.getInitialLetter(name)),
color,
QuartzTeams.settings().bannerShapeAddBorder()
);
}
else
{
} else {
return new ItemStack(ItemUtils.colorize(ColorableMaterial.BANNER, color));
}
}

private static ItemStack getSpecialBanner(final String name, final DyeColor background)
{
private static ItemStack getSpecialBanner(final String name, final DyeColor background) {
// TODO update when QuartzLib banners are updated
final BannerMeta meta = specialBanners.get(name);
if (meta == null) throw new IllegalArgumentException("Unknown special banner " + name);
if (meta == null) {
throw new IllegalArgumentException("Unknown special banner " + name);
}

List<Pattern> patterns = meta.getPatterns();

for (int i = 0; i < patterns.size(); i++)
{
DyeColor patternColor = patterns.get(i).getColor().equals(DyeColor.WHITE) ? background : patterns.get(i).getColor();
for (int i = 0; i < patterns.size(); i++) {
DyeColor patternColor =
patterns.get(i).getColor().equals(DyeColor.WHITE) ? background : patterns.get(i).getColor();
patterns.set(i, new Pattern(patternColor, patterns.get(i).getPattern()));
}

return TextualBanners.getBanner(meta.getBaseColor().equals(DyeColor.WHITE) ? background : meta.getBaseColor(), patterns);
return TextualBanners
.getBanner(meta.getBaseColor().equals(DyeColor.WHITE) ? background : meta.getBaseColor(), patterns);
}
}
Loading

0 comments on commit cfcfb1b

Please sign in to comment.