mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Luck Perms is actually based but also not based
This commit is contained in:
parent
cb818c0056
commit
d1569cb3c0
@ -1,16 +1,12 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||||
import net.luckperms.api.LuckPerms;
|
import net.luckperms.api.LuckPerms;
|
||||||
import net.luckperms.api.track.TrackManager;
|
import net.luckperms.api.track.TrackManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.UnknownDependencyException;
|
import org.bukkit.plugin.UnknownDependencyException;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
|
|
||||||
public class LuckPermsBridge
|
public class LuckPermsBridge
|
||||||
{
|
{
|
||||||
private final LuckPerms luckPerms;
|
private final LuckPerms luckPerms;
|
||||||
@ -38,7 +34,8 @@ public class LuckPermsBridge
|
|||||||
|
|
||||||
if (!trackManager.isLoaded("fakeOp"))
|
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.NON_OP.getGroup().getLuckPermsGroup());
|
||||||
track.appendGroup(GroupProvider.OP.getGroup().getLuckPermsGroup());
|
track.appendGroup(GroupProvider.OP.getGroup().getLuckPermsGroup());
|
||||||
});
|
});
|
||||||
@ -46,7 +43,8 @@ public class LuckPermsBridge
|
|||||||
|
|
||||||
if (!trackManager.isLoaded("admin"))
|
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.ADMIN.getGroup().getLuckPermsGroup());
|
||||||
track.appendGroup(GroupProvider.SENIOR_ADMIN.getGroup().getLuckPermsGroup());
|
track.appendGroup(GroupProvider.SENIOR_ADMIN.getGroup().getLuckPermsGroup());
|
||||||
});
|
});
|
||||||
@ -54,9 +52,8 @@ public class LuckPermsBridge
|
|||||||
|
|
||||||
if (!trackManager.isLoaded("builder"))
|
if (!trackManager.isLoaded("builder"))
|
||||||
{
|
{
|
||||||
trackManager.createAndLoadTrack("builder").whenComplete((track, exception) -> {
|
trackManager.createAndLoadTrack("builder").whenComplete((track, exception) ->
|
||||||
track.appendGroup(GroupProvider.MASTER_BUILDER.getGroup().getLuckPermsGroup());
|
track.appendGroup(GroupProvider.MASTER_BUILDER.getGroup().getLuckPermsGroup()));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 = "/<command> <[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 <player> to game mode adventure.", Placeholder.unparsed("player", player.getName()));
|
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
|
||||||
msgNew(player, "<sender> set your game mode to adventure.", Placeholder.unparsed("sender", sender.getName()));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 = "/<command> [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("<green>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("<green>Successfully cleared everyone's inventory.");
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
Player player = getPlayer(args[0]);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
msg(PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.getInventory().clear();
|
|
||||||
msgNew("<green>Successfully cleared <player>'s inventory.", Placeholder.unparsed("player", player.getName()));
|
|
||||||
msgNew(player, "<sender> has cleared your inventory.", Placeholder.unparsed("sender", sender.getName()));
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
return noPerms();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
||||||
{
|
|
||||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
|
||||||
{
|
|
||||||
List<String> players = FUtil.getPlayerList();
|
|
||||||
players.add("-a");
|
|
||||||
return players;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 = "/<command> <-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 <player> to gamemode creative.", Placeholder.unparsed("player", player.getName()));
|
|
||||||
msgNew(player, "<sender> set your gamemode to creative.", Placeholder.unparsed("sender", sender.getName()));
|
|
||||||
player.setGameMode(GameMode.CREATIVE);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,40 @@
|
|||||||
|
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.", usage = "/<command>")
|
||||||
|
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("<red>That nickname contains invalid characters.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Component parsed = FUtil.miniMessage(args[0], Placeholder.unparsed("<name>", sender.getName()));
|
||||||
|
plugin.esb.setNickname(sender.getName(), FUtil.miniMessage(parsed));
|
||||||
|
msgNew("Your nickname is now: " + FUtil.miniMessage(parsed));
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -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 = "/<command> <[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 <player> to gamemode spectator", Placeholder.unparsed("player", player.getName()));
|
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
|
||||||
msgNew(player, "<sender> set your gamemode to spectator.", Placeholder.unparsed("sender", sender.getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 = "/<command> <[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 <player> to gamemode survival", Placeholder.unparsed("player", player.getName()));
|
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
|
||||||
msgNew(player, "<sender> set your gamemode to survival.", Placeholder.unparsed("sender", sender.getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,9 +9,7 @@ import net.luckperms.api.model.group.Group;
|
|||||||
import net.luckperms.api.node.types.InheritanceNode;
|
import net.luckperms.api.node.types.InheritanceNode;
|
||||||
import net.luckperms.api.node.types.PrefixNode;
|
import net.luckperms.api.node.types.PrefixNode;
|
||||||
import net.luckperms.api.node.types.WeightNode;
|
import net.luckperms.api.node.types.WeightNode;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.util.FileUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -52,20 +50,23 @@ public class DisplayableGroup implements Displayable
|
|||||||
{
|
{
|
||||||
Group matched = TotalFreedomMod.getPlugin().lpb.getAPI().getGroupManager().getGroup(group);
|
Group matched = TotalFreedomMod.getPlugin().lpb.getAPI().getGroupManager().getGroup(group);
|
||||||
|
|
||||||
if (matched == null) {
|
if (matched == null)
|
||||||
|
{
|
||||||
CompletableFuture<Group> cfg = TotalFreedomMod.getPlugin()
|
CompletableFuture<Group> cfg = TotalFreedomMod.getPlugin()
|
||||||
.lpb
|
.lpb
|
||||||
.getAPI()
|
.getAPI()
|
||||||
.getGroupManager()
|
.getGroupManager()
|
||||||
.createAndLoadGroup(group);
|
.createAndLoadGroup(group);
|
||||||
|
|
||||||
cfg.thenAcceptAsync(g -> {
|
cfg.thenAcceptAsync(g ->
|
||||||
|
{
|
||||||
WeightNode weightNode = WeightNode.builder(weight).build();
|
WeightNode weightNode = WeightNode.builder(weight).build();
|
||||||
PrefixNode prefixNode = PrefixNode.builder()
|
PrefixNode prefixNode = PrefixNode.builder()
|
||||||
.prefix(FUtil.miniMessage(GroupProvider.OPEN.append(tag.color(color)).append(GroupProvider.CLOSE)))
|
.prefix(FUtil.miniMessage(GroupProvider.OPEN.append(tag.color(color)).append(GroupProvider.CLOSE)))
|
||||||
.priority(1)
|
.priority(1)
|
||||||
.build();
|
.build();
|
||||||
if (inheritance != null) {
|
if (inheritance != null)
|
||||||
|
{
|
||||||
InheritanceNode inheritanceNode = InheritanceNode.builder(inheritance).build();
|
InheritanceNode inheritanceNode = InheritanceNode.builder(inheritance).build();
|
||||||
g.getData(DataType.NORMAL).add(inheritanceNode);
|
g.getData(DataType.NORMAL).add(inheritanceNode);
|
||||||
}
|
}
|
||||||
@ -75,7 +76,8 @@ public class DisplayableGroup implements Displayable
|
|||||||
|
|
||||||
matched = TotalFreedomMod.getPlugin().lpb.getAPI().getGroupManager().getGroup(group);
|
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;
|
this.group = matched;
|
||||||
@ -103,7 +105,8 @@ public class DisplayableGroup implements Displayable
|
|||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Group getLuckPermsGroup() {
|
public Group getLuckPermsGroup()
|
||||||
|
{
|
||||||
return this.group;
|
return this.group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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,11 +8,7 @@ import me.totalfreedom.totalfreedommod.player.PlayerData;
|
|||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
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.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.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -174,8 +169,7 @@ public class RankManager extends FreedomService
|
|||||||
if (plugin.al.isAdmin(player) || data.isMasterBuilder() || FUtil.isDeveloper(player))
|
if (plugin.al.isAdmin(player) || data.isMasterBuilder() || FUtil.isDeveloper(player))
|
||||||
{
|
{
|
||||||
player.playerListName(Component.text(player.getName()).color(display.getColor()));
|
player.playerListName(Component.text(player.getName()).color(display.getColor()));
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
fPlayer.setTag(null);
|
fPlayer.setTag(null);
|
||||||
player.setPlayerListName(null);
|
player.setPlayerListName(null);
|
||||||
@ -230,8 +224,7 @@ public class RankManager extends FreedomService
|
|||||||
if (playerData.hasLoginMessage())
|
if (playerData.hasLoginMessage())
|
||||||
{
|
{
|
||||||
message = playerData.getLoginMessage();
|
message = playerData.getLoginMessage();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (display.hasDefaultLoginMessage())
|
if (display.hasDefaultLoginMessage())
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.util;
|
package me.totalfreedom.totalfreedommod.util;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.api.Interpolator;
|
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 org.bukkit.Color;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@ -55,4 +57,54 @@ public class Interpolation
|
|||||||
}
|
}
|
||||||
return gradient;
|
return gradient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinkedHashSet<Color> 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<Color> 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<TextColor> 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<TextColor> 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<TextColor> rainbowComponent(int length)
|
||||||
|
{
|
||||||
|
LinkedHashSet<TextColor> base = new LinkedHashSet<>();
|
||||||
|
LinkedHashSet<TextColor> redToOrange = componentRGBGradient(length, NamedTextColor.RED, NamedTextColor.GOLD, this::linear);
|
||||||
|
LinkedHashSet<TextColor> orangeToYellow = componentRGBGradient(length, NamedTextColor.GOLD, NamedTextColor.YELLOW, this::linear);
|
||||||
|
LinkedHashSet<TextColor> yellowToGreen = componentRGBGradient(length, NamedTextColor.YELLOW, NamedTextColor.GREEN, this::linear);
|
||||||
|
LinkedHashSet<TextColor> greenToBlue = componentRGBGradient(length, NamedTextColor.GREEN, NamedTextColor.BLUE, this::linear);
|
||||||
|
LinkedHashSet<TextColor> blueToPurple = componentRGBGradient(length, NamedTextColor.BLUE, NamedTextColor.LIGHT_PURPLE, this::linear);
|
||||||
|
LinkedHashSet<TextColor> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user