Bugfixes, begin working on LP tracks

This commit is contained in:
Video 2023-04-05 10:54:39 -06:00
parent 5422ad6ac7
commit 51c807d318
5 changed files with 42 additions and 3 deletions

View File

@ -1,6 +1,9 @@
package me.totalfreedom.totalfreedommod.bridge; 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.LuckPerms;
import net.luckperms.api.track.TrackManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
@ -20,10 +23,40 @@ public class LuckPermsBridge
if (provider == null) throw new UnknownDependencyException("LuckPerms must be present!"); if (provider == null) throw new UnknownDependencyException("LuckPerms must be present!");
this.luckPerms = provider.getProvider(); this.luckPerms = provider.getProvider();
setupTracks();
} }
public LuckPerms getAPI() public LuckPerms getAPI()
{ {
return luckPerms; 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());
});
}
}
} }

View File

@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.luckperms.api.model.user.User; import net.luckperms.api.model.user.User;
import net.luckperms.api.track.TrackManager;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -15,8 +16,8 @@ public interface GroupProvider<T extends DisplayableGroup>
Component OPEN = Component.text("[", NamedTextColor.DARK_GRAY); Component OPEN = Component.text("[", NamedTextColor.DARK_GRAY);
Component CLOSE = Component.text("]", NamedTextColor.DARK_GRAY); Component CLOSE = Component.text("]", NamedTextColor.DARK_GRAY);
GroupProvider<DisplayableGroup> NON_OP = () -> new DisplayableGroup("non_op", null,Component.text("Non-Ops"), Component.empty(), 0, NamedTextColor.WHITE, null, false, false); GroupProvider<DisplayableGroup> NON_OP = () -> new DisplayableGroup("default", null, Component.text("Non-Ops"), Component.empty(), 0, NamedTextColor.WHITE, null, false, false);
GroupProvider<DisplayableGroup> OP = () -> new DisplayableGroup("op", "non_op", Component.text("Operators"), Component.text("Op"), 1, NamedTextColor.GREEN, null, false, false); GroupProvider<DisplayableGroup> OP = () -> new DisplayableGroup("op", "default", Component.text("Operators"), Component.text("Op"), 1, NamedTextColor.GREEN, null, false, false);
GroupProvider<DisplayableGroup> MASTER_BUILDER = () -> new DisplayableGroup("builder", "op", Component.text("Master Builders"), Component.text("MB"), 2, NamedTextColor.DARK_AQUA, ChatColor.DARK_AQUA, true, true); GroupProvider<DisplayableGroup> MASTER_BUILDER = () -> new DisplayableGroup("builder", "op", Component.text("Master Builders"), Component.text("MB"), 2, NamedTextColor.DARK_AQUA, ChatColor.DARK_AQUA, true, true);
GroupProvider<DisplayableGroup> ADMIN = () -> new DisplayableGroup("admin", "builder", Component.text("Administrators"), Component.text("Admin"), 3, NamedTextColor.DARK_GREEN, ChatColor.DARK_GREEN, true, true); GroupProvider<DisplayableGroup> ADMIN = () -> new DisplayableGroup("admin", "builder", Component.text("Administrators"), Component.text("Admin"), 3, NamedTextColor.DARK_GREEN, ChatColor.DARK_GREEN, true, true);
GroupProvider<DisplayableGroup> SENIOR_ADMIN = () -> new DisplayableGroup("senior", "admin", Component.text("Senior Administrators"), Component.text("SrA"), 4, NamedTextColor.GOLD, ChatColor.GOLD, true, true); GroupProvider<DisplayableGroup> SENIOR_ADMIN = () -> new DisplayableGroup("senior", "admin", Component.text("Senior Administrators"), Component.text("SrA"), 4, NamedTextColor.GOLD, ChatColor.GOLD, true, true);

View File

@ -1,6 +1,7 @@
package me.totalfreedom.totalfreedommod.rank; package me.totalfreedom.totalfreedommod.rank;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer; 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.Component;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; 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.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -12,6 +12,7 @@ import me.totalfreedom.discord.react.ReactiveBukkitScheduler;
import me.totalfreedom.totalfreedommod.api.Context; import me.totalfreedom.totalfreedommod.api.Context;
import me.totalfreedom.totalfreedommod.api.TFD4JCommons; import me.totalfreedom.totalfreedommod.api.TFD4JCommons;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -49,6 +50,7 @@ public class TFD4J extends JavaPlugin
slf4j().info(string); slf4j().info(string);
this.bn = new BukkitNative(this); this.bn = new BukkitNative(this);
Bukkit.getPluginManager().registerEvents(this.bn, this);
slf4j().info("Bukkit Native listener successfully registered! Registering the Discord4J Listeners..."); slf4j().info("Bukkit Native listener successfully registered! Registering the Discord4J Listeners...");
this.mc = new MinecraftListener(this); this.mc = new MinecraftListener(this);

View File

@ -434,7 +434,7 @@ public class Shop extends FreedomService implements ShoppeCommons
@EventHandler @EventHandler
public void onPlayerChat(AsyncChatEvent event) public void onPlayerChat(AsyncChatEvent event)
{ {
String message = event.message().toString(); String message = FUtil.steamroll(event.message());
Player player = event.getPlayer(); Player player = event.getPlayer();
if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean()