mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 20:47:37 +00:00
Merge branch 'RELEASE-2023.03' into proper-resultset-retrieval
This commit is contained in:
commit
d6c68adb41
@ -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());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,14 @@ public class PlayerData
|
||||
ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
|
||||
notes.clear();
|
||||
notes.addAll(FUtil.stringToList(resultSet.getString("notes")));
|
||||
tag = FUtil.miniMessage(resultSet.getString("tag"));
|
||||
String tempTag = resultSet.getString("tag");
|
||||
//--
|
||||
if (!Strings.isNullOrEmpty(tempTag) && FUtil.containsChatColor(tempTag))
|
||||
{
|
||||
tempTag = FUtil.miniMessage(FUtil.colorizeAsComponentSection(tempTag));
|
||||
}
|
||||
//--
|
||||
tag = FUtil.miniMessage(tempTag);
|
||||
discordID = resultSet.getString("discord_id");
|
||||
masterBuilder = resultSet.getBoolean("master_builder");
|
||||
rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase());
|
||||
|
@ -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.
|
||||
|
@ -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,11 +16,11 @@ public interface GroupProvider<T extends DisplayableGroup>
|
||||
Component OPEN = Component.text("[", NamedTextColor.DARK_GRAY);
|
||||
Component CLOSE = Component.text("]", NamedTextColor.DARK_GRAY);
|
||||
|
||||
GroupProvider<DisplayableGroup> NON_OP = () -> new DisplayableGroup("non_op", Component.text("Non-Ops"), Component.empty(), 0, NamedTextColor.WHITE, null, false, false);
|
||||
GroupProvider<DisplayableGroup> OP = () -> new DisplayableGroup("op", Component.text("Operators"), Component.text("Op"), 1, NamedTextColor.GREEN, null, false, false);
|
||||
GroupProvider<DisplayableGroup> MASTER_BUILDER = () -> new DisplayableGroup("builder", Component.text("Master Builders"), Component.text("MB"), 2, NamedTextColor.DARK_AQUA, ChatColor.DARK_AQUA, true, true);
|
||||
GroupProvider<DisplayableGroup> ADMIN = () -> new DisplayableGroup("admin", Component.text("Administrators"), Component.text("Admin"), 3, NamedTextColor.DARK_GREEN, ChatColor.DARK_GREEN, true, true);
|
||||
GroupProvider<DisplayableGroup> SENIOR_ADMIN = () -> new DisplayableGroup("senior", Component.text("Senior Administrators"), Component.text("SrA"), 4, NamedTextColor.GOLD, ChatColor.GOLD, true, true);
|
||||
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", "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> 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);
|
||||
|
||||
static User getUser(Player player)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -83,6 +83,7 @@ public class FUtil
|
||||
|
||||
private static final PlainTextComponentSerializer STEAMROLLER = PlainTextComponentSerializer.plainText();
|
||||
public static final LegacyComponentSerializer LEGACY_AMPERSAND = LegacyComponentSerializer.legacyAmpersand();
|
||||
public static final LegacyComponentSerializer LEGACY_SECTION = LegacyComponentSerializer.legacySection();
|
||||
public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().tags(TagResolver.resolver(
|
||||
StandardTags.color(),
|
||||
StandardTags.rainbow(),
|
||||
@ -104,7 +105,7 @@ public class FUtil
|
||||
ChatColor.DARK_BLUE,
|
||||
ChatColor.DARK_PURPLE,
|
||||
ChatColor.LIGHT_PURPLE);
|
||||
private static final Pattern CHATCOLOR_PATTERN = Pattern.compile(".*(?i)(&((#[a-f0-9]{3,6})|([0-9a-fklmnor]))).*");
|
||||
private static final Pattern CHATCOLOR_PATTERN = Pattern.compile(".*(?i)(([§&])((#[a-f0-9]{3,6})|([0-9a-fklmnor]))).*");
|
||||
private static final SplittableRandom RANDOM = new SplittableRandom();
|
||||
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
||||
private static final List<String> regxList = Arrays.asList("y", "mo", "w", "d", "h", "m", "s");
|
||||
@ -490,6 +491,11 @@ public class FUtil
|
||||
return LEGACY_AMPERSAND.deserialize(string);
|
||||
}
|
||||
|
||||
public static Component colorizeAsComponentSection(String string)
|
||||
{
|
||||
return LEGACY_SECTION.deserialize(string);
|
||||
}
|
||||
|
||||
public static Component miniMessage(String string, TagResolver... placeholders)
|
||||
{
|
||||
return MINI_MESSAGE.deserialize(string, placeholders);
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user