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 2fadc3f1..1103d373 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/bridge/LuckPermsBridge.java @@ -1,16 +1,12 @@ 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; import org.bukkit.plugin.UnknownDependencyException; -import java.util.concurrent.Executor; - public class LuckPermsBridge { private final LuckPerms luckPerms; @@ -38,7 +34,8 @@ public class LuckPermsBridge if (!trackManager.isLoaded("fakeOp")) { - trackManager.createAndLoadTrack("fakeOp").whenComplete((track, exception) -> { + trackManager.createAndLoadTrack("fakeOp").whenComplete((track, exception) -> + { track.appendGroup(GroupProvider.NON_OP.getGroup().getLuckPermsGroup()); track.appendGroup(GroupProvider.OP.getGroup().getLuckPermsGroup()); }); @@ -46,7 +43,8 @@ public class LuckPermsBridge if (!trackManager.isLoaded("admin")) { - trackManager.createAndLoadTrack("admin").whenComplete((track, exception) -> { + trackManager.createAndLoadTrack("admin").whenComplete((track, exception) -> + { track.appendGroup(GroupProvider.ADMIN.getGroup().getLuckPermsGroup()); track.appendGroup(GroupProvider.SENIOR_ADMIN.getGroup().getLuckPermsGroup()); }); @@ -54,9 +52,8 @@ public class LuckPermsBridge if (!trackManager.isLoaded("builder")) { - trackManager.createAndLoadTrack("builder").whenComplete((track, exception) -> { - track.appendGroup(GroupProvider.MASTER_BUILDER.getGroup().getLuckPermsGroup()); - }); + trackManager.createAndLoadTrack("builder").whenComplete((track, exception) -> + track.appendGroup(GroupProvider.MASTER_BUILDER.getGroup().getLuckPermsGroup())); } } } diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java deleted file mode 100644 index 06d286b6..00000000 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_adventure.java +++ /dev/null @@ -1,60 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import org.bukkit.GameMode; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandPermissions(permission = "adventure", source = SourceType.BOTH) -@CommandParameters(description = "Quickly change your own gamemode to adventure, define someone's username to change theirs, or change everyone's gamemode on the server.", usage = "/ <[partialname] | -a>", aliases = "gma") -public class Command_adventure extends FreedomCommand -{ - - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (args.length == 0) - { - if (isConsole()) - { - msgNew("When used from the console, you must define a target player."); - return true; - } - - playerSender.setGameMode(GameMode.ADVENTURE); - msgNew("Your gamemode has been set to adventure."); - return true; - } - - checkPermission("tfm.adventure.other"); - - if (args[0].equals("-a")) - { - FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to adventure", false); - - server.getOnlinePlayers().forEach(player -> - { - player.setGameMode(GameMode.ADVENTURE); - msgNew("Your gamemode has been set to adventure."); - }); - - return true; - } - - Player player = getPlayer(args[0]); - - if (player == null) - { - msg(PLAYER_NOT_FOUND); - return true; - } - - msgNew("Setting to game mode adventure.", Placeholder.unparsed("player", player.getName())); - player.setGameMode(GameMode.ADVENTURE); - msgNew(player, " set your game mode to adventure.", Placeholder.unparsed("sender", sender.getName())); - - return true; - } -} \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java deleted file mode 100644 index 4c03f368..00000000 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_clearinventory.java +++ /dev/null @@ -1,72 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.List; - -@CommandPermissions(permission = "clearinventory", source = SourceType.BOTH) -@CommandParameters(description = "Clear your inventory.", usage = "/ [player]", aliases = "ci,clear") -public class Command_clearinventory extends FreedomCommand -{ - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (args.length < 1) - { - if (senderIsConsole) - { - return false; - } - - playerSender.getInventory().clear(); - msgNew("Your inventory has been cleared."); - } else - { - if (plugin.al.isAdmin(sender)) - { - if (args[0].equals("-a")) - { - FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true); - server.getOnlinePlayers().forEach(player -> player.getInventory().clear()); - msgNew("Successfully cleared everyone's inventory."); - } else - { - Player player = getPlayer(args[0]); - - if (player == null) - { - msg(PLAYER_NOT_FOUND); - return true; - } - - player.getInventory().clear(); - msgNew("Successfully cleared 's inventory.", Placeholder.unparsed("player", player.getName())); - msgNew(player, " has cleared your inventory.", Placeholder.unparsed("sender", sender.getName())); - } - } else - { - return noPerms(); - } - } - - return true; - } - - @Override - public List getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) - { - if (args.length == 1 && plugin.al.isAdmin(sender)) - { - List players = FUtil.getPlayerList(); - players.add("-a"); - return players; - } - - return Collections.emptyList(); - } -} \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java deleted file mode 100644 index 7862b06b..00000000 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_creative.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import org.bukkit.GameMode; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandPermissions(permission = "creative", source = SourceType.BOTH) -@CommandParameters(description = "Quickly change your own gamemode to creative, define someone's username to change theirs, or change everyone's gamemode on the server.", usage = "/ <-a | [partialname]>", aliases = "gmc") -public class Command_creative extends FreedomCommand -{ - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (args.length == 0) - { - if (isConsole()) - { - msgNew("When used from the console, you must define a target player."); - return true; - } - - playerSender.setGameMode(GameMode.CREATIVE); - msgNew("Your gamemode has been set to creative."); - return true; - } - - checkPermission("tfm.creative.other"); - - if (args[0].equals("-a")) - { - FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false); - - server.getOnlinePlayers().forEach(player -> - { - player.setGameMode(GameMode.CREATIVE); - msgNew(player, "Your gamemode has been set to creative."); - }); - - return true; - } - - Player player = getPlayer(args[0]); - - if (player == null) - { - msg(PLAYER_NOT_FOUND); - return true; - } - - msgNew("Setting to gamemode creative.", Placeholder.unparsed("player", player.getName())); - msgNew(player, " set your gamemode to creative.", Placeholder.unparsed("sender", sender.getName())); - player.setGameMode(GameMode.CREATIVE); - return true; - } -} \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickgradient.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickgradient.java deleted file mode 100644 index 833dc13b..00000000 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickgradient.java +++ /dev/null @@ -1,97 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import me.totalfreedom.totalfreedommod.api.Interpolator; -import me.totalfreedom.totalfreedommod.util.FUtil; -import org.apache.commons.lang3.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.List; - -@CommandPermissions(permission = "nickgradient", source = SourceType.ONLY_IN_GAME) -@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/ ", aliases = "nickgr") -public class Command_nickgradient extends FreedomCommand -{ - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (!server.getPluginManager().isPluginEnabled("Essentials")) - { - msg("Essentials is not enabled on this server."); - return true; - } - - if (args.length != 3) - { - return false; - } - - String nick = args[2].trim(); - - if (nick.length() < 3 || nick.length() > 30) - { - msg("Your nickname must be between 3 and 30 characters long."); - return true; - } - - for (Player player : Bukkit.getOnlinePlayers()) - { - if (player == playerSender) - { - continue; - } - if (player.getName().equalsIgnoreCase(nick) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nick)) - { - msg("That nickname is already in use."); - return true; - } - } - - String from = "", to = ""; - java.awt.Color awt1, awt2; - try - { - if (args[0].equalsIgnoreCase("random") || - args[0].equalsIgnoreCase("r")) - { - awt1 = FUtil.getRandomAWTColor(); - from = " (From: " + FUtil.getHexStringOfAWTColor(awt1) + ")"; - } else - { - awt1 = java.awt.Color.decode(args[0]); - } - if (args[1].equalsIgnoreCase("random") || - args[1].equalsIgnoreCase("r")) - { - awt2 = FUtil.getRandomAWTColor(); - to = " (To: " + FUtil.getHexStringOfAWTColor(awt2) + ")"; - } else - { - awt2 = java.awt.Color.decode(args[1]); - } - } catch (NumberFormatException ex) - { - msg("Invalid hex values."); - return true; - } - Color c1 = FUtil.fromAWT(awt1); - Color c2 = FUtil.fromAWT(awt2); - List gradient = FUtil.createColorGradient(c1, c2, nick.length()); - String[] splitNick = nick.split(""); - for (int i = 0; i < splitNick.length; i++) - { - splitNick[i] = net.md_5.bungee.api.ChatColor.of(FUtil.toAWT(gradient.get(i))) + splitNick[i]; - } - nick = StringUtils.join(splitNick, ""); - final String outputNick = FUtil.colorize(nick); - - plugin.esb.setNickname(sender.getName(), outputNick); - - msg("Your nickname is now: '" + outputNick + ChatColor.GRAY + "'" + from + to); - return true; - } -} \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickmm.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickmm.java new file mode 100644 index 00000000..0d69b9ec --- /dev/null +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickmm.java @@ -0,0 +1,44 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.util.FUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(permission = "nickmm", source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = """ + Essentials Interface Command - Colorify your nickname. + For Example: /nickmm will color your name red. + You can also use tags like and . + For example: /nickmm """, usage = "/ ") +public class Command_nickmm extends FreedomCommand +{ + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (!server.getPluginManager().isPluginEnabled("Essentials")) + { + msg("Essentials is not enabled on this server."); + return true; + } + + if (args[0].isEmpty()) { + return false; + } + + if (args[0].matches(ChatColor.COLOR_CHAR + "[0-9a-fkm-o]")) + { + msgNew("That nickname contains invalid characters."); + return true; + } + + Component parsed = FUtil.miniMessage(args[0], Placeholder.unparsed("", sender.getName())); + plugin.esb.setNickname(sender.getName(), FUtil.miniMessage(parsed)); + msgNew("Your nickname is now: " + FUtil.miniMessage(parsed)); + + return false; + } +} diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java deleted file mode 100644 index ade5ffe9..00000000 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_nickrainbow.java +++ /dev/null @@ -1,64 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandPermissions(permission = "nickrainbow", source = SourceType.ONLY_IN_GAME) -@CommandParameters(description = "Essentials Interface Command - Rainbowify your nickname.", usage = "/ ") -public class Command_nickrainbow extends FreedomCommand -{ - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (!server.getPluginManager().isPluginEnabled("Essentials")) - { - msgNew("Essentials is not enabled on this server."); - return true; - } - - if (args.length != 1) - { - return false; - } - - final String nickPlain = ChatColor.stripColor(FUtil.colorize(args[0].trim())); - - if (!nickPlain.matches("^[a-zA-Z_0-9" + ChatColor.COLOR_CHAR + "]+$")) - { - msgNew("That nickname contains invalid characters."); - return true; - } - - if (nickPlain.length() < 3 || nickPlain.length() > 30) - { - msgNew("Your nickname must be between 3 and 30 characters long."); - return true; - } - - for (Player player : Bukkit.getOnlinePlayers()) - { - if (player == playerSender) - { - continue; - } - if (player.getName().equalsIgnoreCase(nickPlain) || ChatColor.stripColor(player.getDisplayName()).trim().equalsIgnoreCase(nickPlain)) - { - msgNew("That nickname is already in use."); - return true; - } - } - - final String newNick = FUtil.rainbowify(ChatColor.stripColor(FUtil.colorize(nickPlain))); - - plugin.esb.setNickname(sender.getName(), newNick); - - msgNew("Your nickname is now: ", Placeholder.component("new", FUtil.colorizeAsComponent(newNick))); - - return true; - } -} diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java deleted file mode 100644 index a15109b7..00000000 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_spectator.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import org.bukkit.GameMode; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandPermissions(permission = "spectate", source = SourceType.BOTH) -@CommandParameters(description = "Quickly change your own gamemode to spectator, or define someone's username to change theirs.", usage = "/ <[partialname]>", aliases = "gmsp") -public class Command_spectator extends FreedomCommand -{ - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (args.length == 0) - { - if (isConsole()) - { - msgNew("When used from the console, you must define a target player."); - return true; - } - - playerSender.setGameMode(GameMode.SPECTATOR); - msgNew("Your gamemode has been set to spectator."); - return true; - } - - Player player = getPlayer(args[0]); - - if (player == null) - { - msg(PLAYER_NOT_FOUND); - return true; - } - - msgNew("Setting to gamemode spectator", Placeholder.unparsed("player", player.getName())); - player.setGameMode(GameMode.SPECTATOR); - msgNew(player, " set your gamemode to spectator.", Placeholder.unparsed("sender", sender.getName())); - return true; - } -} \ No newline at end of file diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java deleted file mode 100644 index 77082540..00000000 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/command/Command_survival.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.totalfreedom.totalfreedommod.command; - -import me.totalfreedom.totalfreedommod.util.FUtil; -import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -import org.bukkit.GameMode; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandPermissions(permission = "survival", source = SourceType.BOTH) -@CommandParameters(description = "Quickly change your own gamemode to survival, or define someone's username to change theirs.", usage = "/ <[partialname] | -a>", aliases = "gms") -public class Command_survival extends FreedomCommand -{ - - @Override - public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (args.length == 0) - { - if (isConsole()) - { - msgNew("When used from the console, you must define a target player."); - return true; - } - - playerSender.setGameMode(GameMode.SURVIVAL); - msgNew("Your gamemode has been set to survival."); - return true; - } - - checkPermission("tfm.survival.other"); - - if (args[0].equals("-a")) - { - FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to survival", false); - - server.getOnlinePlayers().forEach(player -> - { - player.setGameMode(GameMode.SURVIVAL); - msgNew(player, "Your gamemode has been set to survival."); - }); - - return true; - } - - Player player = getPlayer(args[0]); - - if (player == null) - { - msg(PLAYER_NOT_FOUND); - return true; - } - - msgNew("Setting to gamemode survival", Placeholder.unparsed("player", player.getName())); - player.setGameMode(GameMode.SURVIVAL); - msgNew(player, " set your gamemode to survival.", Placeholder.unparsed("sender", sender.getName())); - return true; - } -} 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 7f393128..621b6669 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/DisplayableGroup.java @@ -9,9 +9,7 @@ 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; import org.apache.commons.lang.StringUtils; -import org.bukkit.util.FileUtil; import org.jetbrains.annotations.NotNull; import java.util.Locale; @@ -52,20 +50,23 @@ public class DisplayableGroup implements Displayable { Group matched = TotalFreedomMod.getPlugin().lpb.getAPI().getGroupManager().getGroup(group); - if (matched == null) { + if (matched == null) + { CompletableFuture cfg = TotalFreedomMod.getPlugin() .lpb .getAPI() .getGroupManager() .createAndLoadGroup(group); - cfg.thenAcceptAsync(g -> { + 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(); - if (inheritance != null) { + if (inheritance != null) + { InheritanceNode inheritanceNode = InheritanceNode.builder(inheritance).build(); g.getData(DataType.NORMAL).add(inheritanceNode); } @@ -75,7 +76,8 @@ public class DisplayableGroup implements Displayable matched = TotalFreedomMod.getPlugin().lpb.getAPI().getGroupManager().getGroup(group); - if (matched == null) throw new IllegalArgumentException("Group " + group + " does not exist and could not be created."); + if (matched == null) + throw new IllegalArgumentException("Group " + group + " does not exist and could not be created."); } this.group = matched; @@ -103,7 +105,8 @@ public class DisplayableGroup implements Displayable return weight; } - public Group getLuckPermsGroup() { + public Group getLuckPermsGroup() + { return this.group; } 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 355751f8..5118aae4 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java @@ -1,7 +1,6 @@ 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,11 +8,7 @@ import me.totalfreedom.totalfreedommod.player.PlayerData; 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; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; @@ -174,8 +169,7 @@ public class RankManager extends FreedomService if (plugin.al.isAdmin(player) || data.isMasterBuilder() || FUtil.isDeveloper(player)) { player.playerListName(Component.text(player.getName()).color(display.getColor())); - } - else + } else { fPlayer.setTag(null); player.setPlayerListName(null); @@ -230,8 +224,7 @@ public class RankManager extends FreedomService if (playerData.hasLoginMessage()) { message = playerData.getLoginMessage(); - } - else + } else { if (display.hasDefaultLoginMessage()) { diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java index a7ddef65..9bfd2a8b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/rank/Title.java @@ -6,7 +6,6 @@ import net.kyori.adventure.text.format.TextColor; public enum Title implements Displayable { - MASTER_BUILDER(Component.text("a"), Component.text("Master Builder"), Component.text("Master Builders"), diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index 94a78b16..eadb880b 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -88,6 +88,7 @@ public class FUtil StandardTags.color(), StandardTags.rainbow(), StandardTags.gradient(), + StandardTags.newline(), StandardTags.decorations(TextDecoration.ITALIC), StandardTags.decorations(TextDecoration.BOLD), StandardTags.decorations(TextDecoration.STRIKETHROUGH), diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/Interpolation.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/Interpolation.java index 4b3fafbf..c85bd997 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/util/Interpolation.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/util/Interpolation.java @@ -1,6 +1,8 @@ package me.totalfreedom.totalfreedommod.util; import me.totalfreedom.totalfreedommod.api.Interpolator; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; import org.bukkit.Color; import java.util.LinkedHashSet; @@ -55,4 +57,54 @@ public class Interpolation } return gradient; } + + public LinkedHashSet rgbGradient(int length, Color from, Color to, Interpolator interpolator) + { + final double[] r = interpolator.interpolate(from.getRed(), to.getRed(), length); + final double[] g = interpolator.interpolate(from.getGreen(), to.getGreen(), length); + final double[] b = interpolator.interpolate(from.getBlue(), to.getBlue(), length); + + final LinkedHashSet gradient = new LinkedHashSet<>(); + + for (int i = 0; i < length; i++) + { + final Color color = Color.fromRGB((int) r[i], (int) g[i], (int) b[i]); + gradient.add(color); + } + return gradient; + } + + public LinkedHashSet componentRGBGradient(int length, TextColor from, TextColor to, Interpolator interpolator) + { + final double[] r = interpolator.interpolate(from.red(), to.red(), length); + final double[] g = interpolator.interpolate(from.green(), to.green(), length); + final double[] b = interpolator.interpolate(from.blue(), to.blue(), length); + + final LinkedHashSet gradient = new LinkedHashSet<>(); + + for (int i = 0; i < length; i++) + { + final TextColor color = TextColor.color((int) r[i], (int) g[i], (int) b[i]); + gradient.add(color); + } + return gradient; + } + + public LinkedHashSet rainbowComponent(int length) + { + LinkedHashSet base = new LinkedHashSet<>(); + LinkedHashSet redToOrange = componentRGBGradient(length, NamedTextColor.RED, NamedTextColor.GOLD, this::linear); + LinkedHashSet orangeToYellow = componentRGBGradient(length, NamedTextColor.GOLD, NamedTextColor.YELLOW, this::linear); + LinkedHashSet yellowToGreen = componentRGBGradient(length, NamedTextColor.YELLOW, NamedTextColor.GREEN, this::linear); + LinkedHashSet greenToBlue = componentRGBGradient(length, NamedTextColor.GREEN, NamedTextColor.BLUE, this::linear); + LinkedHashSet blueToPurple = componentRGBGradient(length, NamedTextColor.BLUE, NamedTextColor.LIGHT_PURPLE, this::linear); + LinkedHashSet purpleToRed = componentRGBGradient(length, TextColor.color(75, 0, 130), TextColor.color(255, 0, 0), this::linear); + base.addAll(redToOrange); + base.addAll(orangeToYellow); + base.addAll(yellowToGreen); + base.addAll(greenToBlue); + base.addAll(blueToPurple); + base.addAll(purpleToRed); + return base; + } } diff --git a/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java b/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java index 91d0fc38..c72b9165 100644 --- a/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java +++ b/discord/src/main/java/me/totalfreedom/discord/util/SnowflakeEntry.java @@ -36,8 +36,12 @@ public enum SnowflakeEntry return Snowflake.of(entry.getString()); } +<<<<<<< HEAD public static Set acceptableRoleIDs() { +======= + public static Set acceptableRoleIDs() { +>>>>>>> refs/remotes/origin/RELEASE-2023.03 Set acceptableRoleIDs = new HashSet<>(); acceptableRoleIDs.add(SnowflakeEntry.OWNER_ROLE_ID.getSnowflake()); acceptableRoleIDs.add(SnowflakeEntry.DEVELOPER_ROLE_ID.getSnowflake());