Now buildable.

This commit is contained in:
Paul Reilly
2023-03-30 20:36:00 -05:00
parent 8a58782d99
commit ee39e6f534
15 changed files with 258 additions and 248 deletions

View File

@ -1,13 +1,16 @@
package me.totalfreedom.totalfreedommod.rank;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.luckperms.api.model.data.DataType;
import net.luckperms.api.model.group.Group;
import net.luckperms.api.node.types.PrefixNode;
import net.luckperms.api.node.types.WeightNode;
import net.md_5.bungee.api.ChatColor;
import org.apache.commons.lang.StringUtils;
import org.bukkit.util.FileUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
@ -17,18 +20,18 @@ public class DisplayableGroup implements Displayable
{
private final Group group;
private final String name;
private final Component name;
private final String abbr;
private final String plural;
private final String article;
private final Component abbr;
private final Component plural;
private final Component article;
private final int weight;
private final String tag;
private final Component tag;
private final Component coloredTag;
private final ChatColor color;
private final TextColor color;
private final org.bukkit.ChatColor teamColor;
@ -37,10 +40,10 @@ public class DisplayableGroup implements Displayable
private final boolean hasDefaultLoginMessage;
public DisplayableGroup(String group,
String plural,
String tag,
Component plural,
Component tag,
int weight,
ChatColor color,
TextColor color,
org.bukkit.ChatColor teamColor,
boolean hasTeam,
boolean hasDefaultLoginMessage)
@ -56,7 +59,7 @@ public class DisplayableGroup implements Displayable
cfg.thenAcceptAsync(g -> {
WeightNode weightNode = WeightNode.builder(weight).build();
PrefixNode prefixNode = PrefixNode.builder().prefix(ChatColor.DARK_GRAY + "[" + color + tag + ChatColor.DARK_GRAY + "]" + getColor()).build();
PrefixNode prefixNode = PrefixNode.builder().prefix(FUtil.miniMessage(GroupProvider.OPEN.append(tag.color(color)).append(GroupProvider.CLOSE))).build();
g.getData(DataType.NORMAL).add(prefixNode);
g.getData(DataType.NORMAL).add(weightNode);
}).join(); // Block until the group is created and loaded.
@ -67,16 +70,16 @@ public class DisplayableGroup implements Displayable
}
this.group = matched;
this.name = (matched.getDisplayName() != null) ? matched.getDisplayName() : matched.getName();
this.name = (matched.getDisplayName() != null) ? FUtil.miniMessage(matched.getDisplayName()) : FUtil.miniMessage(matched.getName());
this.plural = plural;
this.article = StringUtils.startsWithAny(this.name.toLowerCase(Locale.ROOT), new String[]{"a", "e", "i", "o", "u"}) ? "an" : "a";
this.article = StringUtils.startsWithAny(this.name.toString().toLowerCase(Locale.ROOT), new String[]{"a", "e", "i", "o", "u"}) ? Component.text("an") : Component.text("a");
this.abbr = tag;
this.weight = weight;
this.tag = "[" + tag + "]";
this.tag = GroupProvider.OPEN.append(tag).append(GroupProvider.CLOSE);
this.color = color;
this.teamColor = teamColor;
this.hasTeam = hasTeam;
this.coloredTag = generateColoredTag(color + tag);
this.coloredTag = tag.color(color);
this.hasDefaultLoginMessage = hasDefaultLoginMessage;
}
@ -96,37 +99,37 @@ public class DisplayableGroup implements Displayable
}
@Override
public String getArticle()
public Component getArticle()
{
return this.article;
}
@Override
public String getName()
public Component getName()
{
return name;
}
@Override
public String getTag()
public Component getTag()
{
return tag;
}
@Override
public String getAbbr()
public Component getAbbr()
{
return abbr;
}
@Override
public String getPlural()
public Component getPlural()
{
return plural;
}
@Override
public ChatColor getColor()
public TextColor getColor()
{
return color;
}
@ -138,9 +141,9 @@ public class DisplayableGroup implements Displayable
}
@Override
public String getColoredName()
public Component getColoredName()
{
return color + name;
return name.color(color);
}
@Override
@ -150,9 +153,9 @@ public class DisplayableGroup implements Displayable
}
@Override
public String getColoredLoginMessage()
public Component getColoredLoginMessage()
{
return article + ' ' + color + name;
return article.append(Component.text(" ")).append(name.color(color));
}
@Override