From 51c807d318e85fd4d4fe2b311e8c1a2a5c71a3c2 Mon Sep 17 00:00:00 2001 From: Video Date: Wed, 5 Apr 2023 10:54:39 -0600 Subject: [PATCH] Bugfixes, begin working on LP tracks --- .../bridge/LuckPermsBridge.java | 33 +++++++++++++++++++ .../totalfreedommod/rank/GroupProvider.java | 5 +-- .../totalfreedommod/rank/RankManager.java | 3 ++ .../java/me/totalfreedom/discord/TFD4J.java | 2 ++ .../main/java/me/totalfreedom/shop/Shop.java | 2 +- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java index c75e4fe4..2fadc3f1 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java @@ -1,6 +1,9 @@ package me.totalfreedom.totalfreedommod.bridge; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.rank.GroupProvider; import net.luckperms.api.LuckPerms; +import net.luckperms.api.track.TrackManager; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; @@ -20,10 +23,40 @@ public class LuckPermsBridge if (provider == null) throw new UnknownDependencyException("LuckPerms must be present!"); this.luckPerms = provider.getProvider(); + + setupTracks(); } public LuckPerms getAPI() { return luckPerms; } + + public void setupTracks() + { + TrackManager trackManager = getAPI().getTrackManager(); + + if (!trackManager.isLoaded("fakeOp")) + { + trackManager.createAndLoadTrack("fakeOp").whenComplete((track, exception) -> { + track.appendGroup(GroupProvider.NON_OP.getGroup().getLuckPermsGroup()); + track.appendGroup(GroupProvider.OP.getGroup().getLuckPermsGroup()); + }); + } + + if (!trackManager.isLoaded("admin")) + { + trackManager.createAndLoadTrack("admin").whenComplete((track, exception) -> { + track.appendGroup(GroupProvider.ADMIN.getGroup().getLuckPermsGroup()); + track.appendGroup(GroupProvider.SENIOR_ADMIN.getGroup().getLuckPermsGroup()); + }); + } + + if (!trackManager.isLoaded("builder")) + { + trackManager.createAndLoadTrack("builder").whenComplete((track, exception) -> { + track.appendGroup(GroupProvider.MASTER_BUILDER.getGroup().getLuckPermsGroup()); + }); + } + } } 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 a1d025c3..172dc14b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/GroupProvider.java @@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.luckperms.api.model.user.User; +import net.luckperms.api.track.TrackManager; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -15,8 +16,8 @@ public interface GroupProvider Component OPEN = Component.text("[", NamedTextColor.DARK_GRAY); Component CLOSE = Component.text("]", NamedTextColor.DARK_GRAY); - 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 NON_OP = () -> new DisplayableGroup("default", null, Component.text("Non-Ops"), Component.empty(), 0, NamedTextColor.WHITE, null, false, false); + GroupProvider OP = () -> new DisplayableGroup("op", "default", 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); diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java index 6cdc1155..355751f8 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java @@ -1,6 +1,7 @@ package me.totalfreedom.totalfreedommod.rank; import me.totalfreedom.totalfreedommod.FreedomService; +import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.player.FPlayer; @@ -9,6 +10,8 @@ import me.totalfreedom.totalfreedommod.util.FUtil; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; +import net.luckperms.api.context.ContextSetFactory; +import net.luckperms.api.track.TrackManager; import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; diff --git a/discord/src/main/java/me/totalfreedom/discord/TFD4J.java b/discord/src/main/java/me/totalfreedom/discord/TFD4J.java index 899d1b18..08376d0b 100644 --- a/discord/src/main/java/me/totalfreedom/discord/TFD4J.java +++ b/discord/src/main/java/me/totalfreedom/discord/TFD4J.java @@ -12,6 +12,7 @@ import me.totalfreedom.discord.react.ReactiveBukkitScheduler; import me.totalfreedom.totalfreedommod.api.Context; import me.totalfreedom.totalfreedommod.api.TFD4JCommons; import org.apache.commons.lang.StringUtils; +import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.StringUtil; import org.slf4j.Logger; @@ -49,6 +50,7 @@ public class TFD4J extends JavaPlugin slf4j().info(string); this.bn = new BukkitNative(this); + Bukkit.getPluginManager().registerEvents(this.bn, this); slf4j().info("Bukkit Native listener successfully registered! Registering the Discord4J Listeners..."); this.mc = new MinecraftListener(this); diff --git a/shop/src/main/java/me/totalfreedom/shop/Shop.java b/shop/src/main/java/me/totalfreedom/shop/Shop.java index a853eb64..7c447924 100644 --- a/shop/src/main/java/me/totalfreedom/shop/Shop.java +++ b/shop/src/main/java/me/totalfreedom/shop/Shop.java @@ -434,7 +434,7 @@ public class Shop extends FreedomService implements ShoppeCommons @EventHandler public void onPlayerChat(AsyncChatEvent event) { - String message = event.message().toString(); + String message = FUtil.steamroll(event.message()); Player player = event.getPlayer(); if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean()