From f474ce99fdce6bdeef5d2db434e6a33df13755c2 Mon Sep 17 00:00:00 2001 From: Paul Reilly Date: Tue, 4 Apr 2023 17:42:05 -0500 Subject: [PATCH] Added inheritance to the groups when created by TFM. --- .../totalfreedommod/rank/DisplayableGroup.java | 11 ++++++++++- .../totalfreedommod/rank/GroupProvider.java | 10 +++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java index 73c56960..7f393128 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java @@ -6,6 +6,7 @@ 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.InheritanceNode; import net.luckperms.api.node.types.PrefixNode; import net.luckperms.api.node.types.WeightNode; import net.md_5.bungee.api.ChatColor; @@ -40,6 +41,7 @@ public class DisplayableGroup implements Displayable private final boolean hasDefaultLoginMessage; public DisplayableGroup(String group, + String inheritance, Component plural, Component tag, int weight, @@ -59,7 +61,14 @@ public class DisplayableGroup implements Displayable cfg.thenAcceptAsync(g -> { WeightNode weightNode = WeightNode.builder(weight).build(); - PrefixNode prefixNode = PrefixNode.builder().prefix(FUtil.miniMessage(GroupProvider.OPEN.append(tag.color(color)).append(GroupProvider.CLOSE))).priority(1).build(); + PrefixNode prefixNode = PrefixNode.builder() + .prefix(FUtil.miniMessage(GroupProvider.OPEN.append(tag.color(color)).append(GroupProvider.CLOSE))) + .priority(1) + .build(); + if (inheritance != null) { + InheritanceNode inheritanceNode = InheritanceNode.builder(inheritance).build(); + g.getData(DataType.NORMAL).add(inheritanceNode); + } g.getData(DataType.NORMAL).add(prefixNode); g.getData(DataType.NORMAL).add(weightNode); }).join(); // Block until the group is created and loaded. diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java index e87839c5..a1d025c3 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java @@ -15,11 +15,11 @@ public interface GroupProvider Component OPEN = Component.text("[", NamedTextColor.DARK_GRAY); Component CLOSE = Component.text("]", NamedTextColor.DARK_GRAY); - GroupProvider NON_OP = () -> new DisplayableGroup("non_op", Component.text("Non-Ops"), Component.empty(), 0, NamedTextColor.WHITE, null, false, false); - GroupProvider OP = () -> new DisplayableGroup("op", Component.text("Operators"), Component.text("Op"), 1, NamedTextColor.GREEN, null, false, false); - GroupProvider MASTER_BUILDER = () -> new DisplayableGroup("builder", Component.text("Master Builders"), Component.text("MB"), 2, NamedTextColor.DARK_AQUA, ChatColor.DARK_AQUA, true, true); - GroupProvider ADMIN = () -> new DisplayableGroup("admin", Component.text("Administrators"), Component.text("Admin"), 3, NamedTextColor.DARK_GREEN, ChatColor.DARK_GREEN, true, true); - GroupProvider SENIOR_ADMIN = () -> new DisplayableGroup("senior", Component.text("Senior Administrators"), Component.text("SrA"), 4, NamedTextColor.GOLD, ChatColor.GOLD, true, true); + GroupProvider NON_OP = () -> new DisplayableGroup("non_op", null,Component.text("Non-Ops"), Component.empty(), 0, NamedTextColor.WHITE, null, false, false); + GroupProvider OP = () -> new DisplayableGroup("op", "non_op", Component.text("Operators"), Component.text("Op"), 1, NamedTextColor.GREEN, null, false, false); + GroupProvider MASTER_BUILDER = () -> new DisplayableGroup("builder", "op", Component.text("Master Builders"), Component.text("MB"), 2, NamedTextColor.DARK_AQUA, ChatColor.DARK_AQUA, true, true); + GroupProvider ADMIN = () -> new DisplayableGroup("admin", "builder", Component.text("Administrators"), Component.text("Admin"), 3, NamedTextColor.DARK_GREEN, ChatColor.DARK_GREEN, true, true); + GroupProvider SENIOR_ADMIN = () -> new DisplayableGroup("senior", "admin", Component.text("Senior Administrators"), Component.text("SrA"), 4, NamedTextColor.GOLD, ChatColor.GOLD, true, true); static User getUser(Player player) {