mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-01 05:57:09 +00:00
Lots of fixes and cool shit
- Fixes bug that caused login messages to not show properly - Fixes bug that caused names to now show properly in tab - Adds the ability for commands to be ignored if plugins that they require aren't present - Fixes bug that caused the admin list to fail to load properly - Fixes bug that caused tags to not show properly - Login messages now use MiniMessage
This commit is contained in:
parent
74408b85bf
commit
f53ba1bd76
@ -173,7 +173,8 @@ public class ChatManager extends FreedomService
|
|||||||
Placeholder.unparsed("rank", flatAbv),
|
Placeholder.unparsed("rank", flatAbv),
|
||||||
TagResolver.resolver("rankcolor", Tag.styling(getColor(display))),
|
TagResolver.resolver("rankcolor", Tag.styling(getColor(display))),
|
||||||
Placeholder.unparsed("message", message)));
|
Placeholder.unparsed("message", message)));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Component defaultFormat = FUtil.miniMessage("<dark_gray>[<aqua>ADMIN<dark_gray>] <dark_red><name> <dark_gray><tag><dark_gray>]<white>: <gold><message>",
|
Component defaultFormat = FUtil.miniMessage("<dark_gray>[<aqua>ADMIN<dark_gray>] <dark_red><name> <dark_gray><tag><dark_gray>]<white>: <gold><message>",
|
||||||
Placeholder.unparsed("<name>", sender.getName()),
|
Placeholder.unparsed("<name>", sender.getName()),
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface CommandDependencies
|
||||||
|
{
|
||||||
|
String[] value();
|
||||||
|
}
|
@ -63,10 +63,25 @@ public class CommandLoader extends FreedomService
|
|||||||
|
|
||||||
Set<Class<? extends FreedomCommand>> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
|
Set<Class<? extends FreedomCommand>> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
|
||||||
|
|
||||||
|
commandLoading:
|
||||||
for (Class<? extends FreedomCommand> commandClass : commandClasses)
|
for (Class<? extends FreedomCommand> commandClass : commandClasses)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (commandClass.isAnnotationPresent(CommandDependencies.class))
|
||||||
|
{
|
||||||
|
String[] dependencies = commandClass.getAnnotation(CommandDependencies.class).value();
|
||||||
|
|
||||||
|
for (String plugin : dependencies)
|
||||||
|
{
|
||||||
|
if (!server.getPluginManager().isPluginEnabled(plugin))
|
||||||
|
{
|
||||||
|
FLog.warning("Not loading command due to missing dependency (" + plugin + "): /" + commandClass.getSimpleName().replace("Command_", ""));
|
||||||
|
continue commandLoading;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
add(commandClass.newInstance());
|
add(commandClass.newInstance());
|
||||||
}
|
}
|
||||||
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
|
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
|
||||||
|
@ -4,8 +4,9 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TFD4J"})
|
||||||
@CommandPermissions(permission = "cleardiscordqueue", source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(permission = "cleardiscordqueue", source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "Clear the discord message queue.", usage = "/<command>")
|
@CommandParameters(description = "Clear the Discord message queue.", usage = "/<command>")
|
||||||
public class Command_cleardiscordqueue extends FreedomCommand
|
public class Command_cleardiscordqueue extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "clownfish", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "clownfish", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Obtain a clown fish", usage = "/<command>")
|
@CommandParameters(description = "Obtain a clown fish", usage = "/<command>")
|
||||||
public class Command_clownfish extends FreedomCommand
|
public class Command_clownfish extends FreedomCommand
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "coins", source = SourceType.BOTH)
|
@CommandPermissions(permission = "coins", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Shows the amount of coins you or another player has. Also allows you to give coins to other players.", usage = "/<command> [player] | pay <player> <amount>")
|
@CommandParameters(description = "Shows the amount of coins you or another player has. Also allows you to give coins to other players.", usage = "/<command> [player] | pay <player> <amount>")
|
||||||
public class Command_coins extends FreedomCommand
|
public class Command_coins extends FreedomCommand
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "fireball", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "fireball", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Obtain a fire ball", usage = "/<command>")
|
@CommandParameters(description = "Obtain a fire ball", usage = "/<command>")
|
||||||
public class Command_fireball extends FreedomCommand
|
public class Command_fireball extends FreedomCommand
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "grapplinghook", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "grapplinghook", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Obtain a grappling hook", usage = "/<command>")
|
@CommandParameters(description = "Obtain a grappling hook", usage = "/<command>")
|
||||||
public class Command_grapplinghook extends FreedomCommand
|
public class Command_grapplinghook extends FreedomCommand
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "lightningrod", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "lightningrod", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Obtain a lightning rod", usage = "/<command>")
|
@CommandParameters(description = "Obtain a lightning rod", usage = "/<command>")
|
||||||
public class Command_lightningrod extends FreedomCommand
|
public class Command_lightningrod extends FreedomCommand
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TFD4J"})
|
||||||
@CommandPermissions(permission = "linkdiscord", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "linkdiscord", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Link your Discord account to your Minecraft account", usage = "/<command> [<name> <id>]")
|
@CommandParameters(description = "Link your Discord account to your Minecraft account", usage = "/<command> [<name> <id>]")
|
||||||
public class Command_linkdiscord extends FreedomCommand
|
public class Command_linkdiscord extends FreedomCommand
|
||||||
|
@ -2,6 +2,8 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -30,21 +32,25 @@ public class Command_loginmessage extends FreedomCommand
|
|||||||
checkPermission("tfm.loginmessage.custom");
|
checkPermission("tfm.loginmessage.custom");
|
||||||
|
|
||||||
String message = StringUtils.join(args, " ");
|
String message = StringUtils.join(args, " ");
|
||||||
if (!message.contains("%rank%") && !message.contains("%coloredrank%"))
|
if (!message.contains("<rank>") && !message.contains("<coloredrank>"))
|
||||||
{
|
{
|
||||||
msg("Your login message must contain your rank. Use either %rank% or %coloredrank% to specify where you want the rank", ChatColor.RED);
|
msgNew("<red>Your login message must contain your rank. Use either \\\\<rank> or \\\\<coloredrank> to specify where you want the rank.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int length = message.replace("%name%", "").replace("%rank%", "").replace("%coloredrank%", "").replace("%art%", "").length();
|
int length = FUtil.steamroll(FUtil.miniMessage(message, Placeholder.unparsed("name", ""),
|
||||||
|
Placeholder.unparsed("rank", ""),
|
||||||
|
Placeholder.unparsed("coloredrank", ""),
|
||||||
|
Placeholder.unparsed("art", ""))).length();
|
||||||
if (length > 100)
|
if (length > 100)
|
||||||
{
|
{
|
||||||
msg("Your login message cannot be more than 100 characters (excluding your rank and your name)", ChatColor.RED);
|
msgNew("<red>Your login message cannot be more than 100 characters (excluding your rank and your name)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PlayerData data = getData(playerSender);
|
PlayerData data = getData(playerSender);
|
||||||
data.setLoginMessage(message);
|
data.setLoginMessage(message);
|
||||||
plugin.pl.save(data);
|
plugin.pl.save(data);
|
||||||
msg("Your login message is now the following:\n" + plugin.rm.craftLoginMessage(playerSender, message), ChatColor.GREEN);
|
msgNew("<green>Your login message is now the following:");
|
||||||
|
msg(plugin.rm.craftLoginMessage(playerSender, message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "manageshop", source = SourceType.BOTH)
|
@CommandPermissions(permission = "manageshop", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all> | items: <give | take> <item> <player>", aliases = "ms")
|
@CommandParameters(description = "Manage the shop", usage = "/<command> <coins: <add | set | remove> <amount> <player | all> | items: <give | take> <item> <player>", aliases = "ms")
|
||||||
public class Command_manageshop extends FreedomCommand
|
public class Command_manageshop extends FreedomCommand
|
||||||
|
@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@CommandPermissions(permission = "tfm.mute", source = SourceType.BOTH)
|
@CommandPermissions(permission = "mute", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
@CommandParameters(description = "Mutes a player with brute force.", usage = "/<command> <[-q] <player> [reason] | list | purge | all>", aliases = "stfu")
|
||||||
public class Command_mute extends FreedomCommand
|
public class Command_mute extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ public class Command_myadmin extends FreedomCommand
|
|||||||
target = getAdmin(targetPlayer);
|
target = getAdmin(targetPlayer);
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
msgNew("<red>That player is not an admin");
|
msgNew("<red>That player is not an admin.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"PlotSquared"})
|
||||||
@CommandPermissions(permission = "plotworld", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "plotworld", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Go to the PlotWorld.", usage = "/<command>", aliases = "pw")
|
@CommandParameters(description = "Go to the PlotWorld.", usage = "/<command>", aliases = "pw")
|
||||||
public class Command_plotworld extends FreedomCommand
|
public class Command_plotworld extends FreedomCommand
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "rideablepearl", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "rideablepearl", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Obtain a rideable ender pearl", usage = "/<command>")
|
@CommandParameters(description = "Obtain a rideable ender pearl", usage = "/<command>")
|
||||||
public class Command_rideablepearl extends FreedomCommand
|
public class Command_rideablepearl extends FreedomCommand
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"WorldEdit"})
|
||||||
@CommandPermissions(permission = "worldedit.limit", source = SourceType.BOTH)
|
@CommandPermissions(permission = "worldedit.limit", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Sets everyone's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> [limit]", aliases = "setl,swl")
|
@CommandParameters(description = "Sets everyone's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> [limit]", aliases = "setl,swl")
|
||||||
public class Command_setlimit extends FreedomCommand
|
public class Command_setlimit extends FreedomCommand
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"WorldEdit"})
|
||||||
@CommandPermissions(permission = "worldedit.limit.other", source = SourceType.BOTH)
|
@CommandPermissions(permission = "worldedit.limit.other", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Sets a specific player's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> <player> [limit]", aliases = "setpl,spl")
|
@CommandParameters(description = "Sets a specific player's WorldEdit block modification limit to the default limit or to a custom limit.", usage = "/<command> <player> [limit]", aliases = "setpl,spl")
|
||||||
public class Command_setplayerlimit extends FreedomCommand
|
public class Command_setplayerlimit extends FreedomCommand
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "shop", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "shop", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Open the shop GUI", usage = "/<command>", aliases = "sh")
|
@CommandParameters(description = "Open the shop GUI", usage = "/<command>", aliases = "sh")
|
||||||
public class Command_shop extends FreedomCommand
|
public class Command_shop extends FreedomCommand
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "stackingpotato", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "stackingpotato", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Obtain a stacking potato", usage = "/<command>")
|
@CommandParameters(description = "Obtain a stacking potato", usage = "/<command>")
|
||||||
public class Command_stackingpotato extends FreedomCommand
|
public class Command_stackingpotato extends FreedomCommand
|
||||||
|
@ -40,27 +40,17 @@ public class Command_tag extends FreedomCommand
|
|||||||
{
|
{
|
||||||
case "list":
|
case "list":
|
||||||
{
|
{
|
||||||
msg("Tags for all online players:");
|
msgNew("Tags for all online players:");
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> !(plugin.al.isVanished(player.getUniqueId()) && !isAdmin(sender)) && plugin.pl.getPlayer(player).getTag() != null).forEach(player -> {
|
||||||
for (final Player player : server.getOnlinePlayers())
|
msgNew("<player>: <tag>", Placeholder.unparsed("player", player.getName()),
|
||||||
{
|
Placeholder.component("tag", plugin.pl.getPlayer(player).getTag()));
|
||||||
if (plugin.al.isVanished(player.getUniqueId()) && !plugin.al.isAdmin(sender))
|
});
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
|
||||||
if (playerdata.getTag() != null)
|
|
||||||
{
|
|
||||||
msg(player.getName() + ": " + playerdata.getTag());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "clearall":
|
case "clearall":
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(sender))
|
if (!sender.hasPermission("tfm.tag.clear.all"))
|
||||||
{
|
{
|
||||||
noPerms();
|
noPerms();
|
||||||
return true;
|
return true;
|
||||||
@ -79,7 +69,7 @@ public class Command_tag extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(count + " tag(s) removed.");
|
msgNew("<count> tag(s) removed.", Placeholder.unparsed("count", String.valueOf(count)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +77,9 @@ public class Command_tag extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
msg("\"/tag off\" can't be used from the console. Use \"/tag clear <player>\" or \"/tag clearall\" instead.");
|
msgNew("<red>\"/tag off\" can't be used from the console.");
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
plugin.pl.getPlayer(playerSender).setTag(null);
|
plugin.pl.getPlayer(playerSender).setTag(null);
|
||||||
|
|
||||||
@ -97,7 +88,8 @@ public class Command_tag extends FreedomCommand
|
|||||||
save(playerSender, null);
|
save(playerSender, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Your tag has been removed." + (save ? " (Saved)" : ""));
|
msgNew("Your tag has been removed. <saved>",
|
||||||
|
Placeholder.unparsed("saved", save ? "(Saved)" : ""));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -107,13 +99,14 @@ public class Command_tag extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (args.length >= 2)
|
}
|
||||||
|
else if (args.length >= 2)
|
||||||
{
|
{
|
||||||
switch (args[0].toLowerCase())
|
switch (args[0].toLowerCase())
|
||||||
{
|
{
|
||||||
case "clear":
|
case "clear":
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(sender))
|
if (!sender.hasPermission("tfm.tag.clear.others"))
|
||||||
{
|
{
|
||||||
noPerms();
|
noPerms();
|
||||||
return true;
|
return true;
|
||||||
@ -133,7 +126,9 @@ public class Command_tag extends FreedomCommand
|
|||||||
save(player, null);
|
save(player, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Removed " + player.getName() + "'s tag." + (save ? " (Saved)" : ""));
|
msgNew("Removed <player>'s tag. <saved>",
|
||||||
|
Placeholder.unparsed("player", player.getName()),
|
||||||
|
Placeholder.unparsed("saved", save ? "(Saved)" : ""));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,11 +157,13 @@ public class Command_tag extends FreedomCommand
|
|||||||
{
|
{
|
||||||
msgNew("<red>That tag is too long (Max is <max> characters).", Placeholder.unparsed("max", String.valueOf(tagLimit)));
|
msgNew("<red>That tag is too long (Max is <max> characters).", Placeholder.unparsed("max", String.valueOf(tagLimit)));
|
||||||
return true;
|
return true;
|
||||||
} else if (!plugin.al.isAdmin(sender) && ConfigEntry.FORBIDDEN_WORDS.getStringList().stream().anyMatch(word -> steamrolled.toLowerCase().contains(word)))
|
}
|
||||||
|
else if (!plugin.al.isAdmin(sender) && ConfigEntry.FORBIDDEN_WORDS.getStringList().stream().anyMatch(word -> steamrolled.toLowerCase().contains(word)))
|
||||||
{
|
{
|
||||||
msgNew("<red>That tag contains a forbidden word.");
|
msgNew("<red>That tag contains a forbidden word.");
|
||||||
return true;
|
return true;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
plugin.pl.getPlayer(playerSender).setTag(tag);
|
plugin.pl.getPlayer(playerSender).setTag(tag);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "clownfish.toggle", source = SourceType.BOTH)
|
@CommandPermissions(permission = "clownfish.toggle", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle whether or not a player has the ability to use clownfish", usage = "/<command> <player>", aliases = "togglecf")
|
@CommandParameters(description = "Toggle whether or not a player has the ability to use clownfish", usage = "/<command> <player>", aliases = "togglecf")
|
||||||
public class Command_toggleclownfish extends FreedomCommand
|
public class Command_toggleclownfish extends FreedomCommand
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TFD4J"})
|
||||||
@CommandPermissions(permission = "discord.toggle", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "discord.toggle", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Toggle the display of Discord messages in-game.", usage = "/<command>", aliases = "tdiscord,tdisc")
|
@CommandParameters(description = "Toggle the display of Discord messages in-game.", usage = "/<command>", aliases = "tdiscord,tdisc")
|
||||||
public class Command_togglediscord extends FreedomCommand
|
public class Command_togglediscord extends FreedomCommand
|
||||||
|
@ -6,8 +6,9 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TF-Shoppe"})
|
||||||
@CommandPermissions(permission = "trail", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "trail", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Trails rainbow wool behind you as you walk/fly.", usage = "/<command>")
|
@CommandParameters(description = "Trails rainbow particles behind you as you walk/fly.", usage = "/<command>")
|
||||||
public class Command_trail extends FreedomCommand
|
public class Command_trail extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"LibsDisguises"})
|
||||||
@CommandPermissions(permission = "undisguiseall", source = SourceType.BOTH)
|
@CommandPermissions(permission = "undisguiseall", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Undisguise all online players on the server", usage = "/<command> [-a]", aliases = "uall")
|
@CommandParameters(description = "Undisguise all online players on the server", usage = "/<command> [-a]", aliases = "uall")
|
||||||
public class Command_undisguiseall extends FreedomCommand
|
public class Command_undisguiseall extends FreedomCommand
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandDependencies({"TFD4J"})
|
||||||
@CommandPermissions(permission = "unlinkdiscord", source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "unlinkdiscord", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/<command> [player]")
|
@CommandParameters(description = "Unlink your Discord account from your Minecraft account", usage = "/<command> [player]")
|
||||||
public class Command_unlinkdiscord extends FreedomCommand
|
public class Command_unlinkdiscord extends FreedomCommand
|
||||||
|
@ -34,7 +34,7 @@ public class Command_vanish extends FreedomCommand
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
msgNew("<gold>You have unvanished.");
|
msgNew("<gold>You have unvanished.");
|
||||||
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
|
server.broadcast(plugin.rm.craftLoginMessage(playerSender, null));
|
||||||
server.broadcast(Component.translatable("multiplayer.player.joined", Component.text(playerSender.getName()))
|
server.broadcast(Component.translatable("multiplayer.player.joined", Component.text(playerSender.getName()))
|
||||||
.color(NamedTextColor.YELLOW));
|
.color(NamedTextColor.YELLOW));
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||||||
|
|
||||||
public boolean permissionCheck()
|
public boolean permissionCheck()
|
||||||
{
|
{
|
||||||
if (!sender.hasPermission(permission) || !(sender instanceof ConsoleCommandSender))
|
if (!sender.hasPermission(permission) || !source.permissionCheck(sender))
|
||||||
{
|
{
|
||||||
msg(ChatColor.RED + "You do not have permission to use this command.");
|
msg(ChatColor.RED + "You do not have permission to use this command.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public enum SourceType
|
public enum SourceType
|
||||||
{
|
{
|
||||||
ONLY_IN_GAME, ONLY_CONSOLE, BOTH
|
ONLY_IN_GAME, ONLY_CONSOLE, BOTH;
|
||||||
|
|
||||||
|
public boolean permissionCheck(CommandSender sender)
|
||||||
|
{
|
||||||
|
return (sender instanceof Player && this == ONLY_IN_GAME) || (sender instanceof ConsoleCommandSender && this == ONLY_CONSOLE) || this == BOTH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod.player;
|
package me.totalfreedom.totalfreedommod.player;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FConverter;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
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.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -50,7 +53,7 @@ public class PlayerData
|
|||||||
ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
|
ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
|
||||||
notes.clear();
|
notes.clear();
|
||||||
notes.addAll(FUtil.stringToList(resultSet.getString("notes")));
|
notes.addAll(FUtil.stringToList(resultSet.getString("notes")));
|
||||||
tag = LegacyComponentSerializer.legacyAmpersand().deserialize(resultSet.getString("tag"));
|
tag = FUtil.miniMessage(resultSet.getString("tag"));
|
||||||
discordID = resultSet.getString("discord_id");
|
discordID = resultSet.getString("discord_id");
|
||||||
masterBuilder = resultSet.getBoolean("master_builder");
|
masterBuilder = resultSet.getBoolean("master_builder");
|
||||||
rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase());
|
rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase());
|
||||||
@ -59,11 +62,19 @@ public class PlayerData
|
|||||||
items.addAll(FUtil.stringToList(resultSet.getString("items")));
|
items.addAll(FUtil.stringToList(resultSet.getString("items")));
|
||||||
totalVotes = resultSet.getInt("total_votes");
|
totalVotes = resultSet.getInt("total_votes");
|
||||||
displayDiscord = resultSet.getBoolean("display_discord");
|
displayDiscord = resultSet.getBoolean("display_discord");
|
||||||
loginMessage = resultSet.getString("login_message");
|
//--
|
||||||
|
String tempLoginMessage = resultSet.getString("login_message");
|
||||||
|
if (!Strings.isNullOrEmpty(tempLoginMessage) && FConverter.needsConversion(tempLoginMessage))
|
||||||
|
{
|
||||||
|
tempLoginMessage = FConverter.convertLoginMessage(tempLoginMessage);
|
||||||
|
}
|
||||||
|
loginMessage = tempLoginMessage;
|
||||||
|
//--
|
||||||
inspect = resultSet.getBoolean("inspect");
|
inspect = resultSet.getBoolean("inspect");
|
||||||
} catch (SQLException e)
|
} catch (SQLException e)
|
||||||
{
|
{
|
||||||
FLog.severe("Failed to load player: " + e.getMessage());
|
FLog.severe("Failed to load player: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +201,7 @@ public class PlayerData
|
|||||||
objectMap.put("uuid", uuid.toString());
|
objectMap.put("uuid", uuid.toString());
|
||||||
objectMap.put("ips", FUtil.listToString(ips));
|
objectMap.put("ips", FUtil.listToString(ips));
|
||||||
objectMap.put("notes", FUtil.listToString(notes));
|
objectMap.put("notes", FUtil.listToString(notes));
|
||||||
objectMap.put("tag", tag.toString());
|
objectMap.put("tag", FUtil.miniMessage(tag));
|
||||||
objectMap.put("discord_id", discordID);
|
objectMap.put("discord_id", discordID);
|
||||||
objectMap.put("master_builder", masterBuilder);
|
objectMap.put("master_builder", masterBuilder);
|
||||||
objectMap.put("ride_mode", rideMode.name());
|
objectMap.put("ride_mode", rideMode.name());
|
||||||
|
@ -59,7 +59,7 @@ public class DisplayableGroup implements Displayable
|
|||||||
|
|
||||||
cfg.thenAcceptAsync(g -> {
|
cfg.thenAcceptAsync(g -> {
|
||||||
WeightNode weightNode = WeightNode.builder(weight).build();
|
WeightNode weightNode = WeightNode.builder(weight).build();
|
||||||
PrefixNode prefixNode = PrefixNode.builder().prefix(FUtil.miniMessage(GroupProvider.OPEN.append(tag.color(color)).append(GroupProvider.CLOSE))).build();
|
PrefixNode prefixNode = PrefixNode.builder().prefix(FUtil.miniMessage(GroupProvider.OPEN.append(tag.color(color)).append(GroupProvider.CLOSE))).priority(1).build();
|
||||||
g.getData(DataType.NORMAL).add(prefixNode);
|
g.getData(DataType.NORMAL).add(prefixNode);
|
||||||
g.getData(DataType.NORMAL).add(weightNode);
|
g.getData(DataType.NORMAL).add(weightNode);
|
||||||
}).join(); // Block until the group is created and loaded.
|
}).join(); // Block until the group is created and loaded.
|
||||||
|
@ -7,6 +7,8 @@ import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
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.TagResolver;
|
||||||
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;
|
||||||
@ -165,11 +167,12 @@ public class RankManager extends FreedomService
|
|||||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
PlayerData data = plugin.pl.getData(player);
|
PlayerData data = plugin.pl.getData(player);
|
||||||
Displayable display = getDisplay(player);
|
Displayable display = getDisplay(player);
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player) || data.isMasterBuilder() || FUtil.isDeveloper(player))
|
if (plugin.al.isAdmin(player) || data.isMasterBuilder() || FUtil.isDeveloper(player))
|
||||||
{
|
{
|
||||||
String displayName = display.getColor() + player.getName();
|
player.playerListName(Component.text(player.getName()).color(display.getColor()));
|
||||||
player.setPlayerListName(displayName);
|
}
|
||||||
} else
|
else
|
||||||
{
|
{
|
||||||
fPlayer.setTag(null);
|
fPlayer.setTag(null);
|
||||||
player.setPlayerListName(null);
|
player.setPlayerListName(null);
|
||||||
@ -203,7 +206,7 @@ public class RankManager extends FreedomService
|
|||||||
if ((isAdmin || FUtil.isDeveloper(player) || plugin.pl.getData(player).isMasterBuilder()
|
if ((isAdmin || FUtil.isDeveloper(player) || plugin.pl.getData(player).isMasterBuilder()
|
||||||
|| plugin.pl.getData(player).hasLoginMessage()) && !plugin.al.isVanished(player.getUniqueId()))
|
|| plugin.pl.getData(player).hasLoginMessage()) && !plugin.al.isVanished(player.getUniqueId()))
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(craftLoginMessage(player, null));
|
server.broadcast(craftLoginMessage(player, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set display
|
// Set display
|
||||||
@ -215,7 +218,7 @@ public class RankManager extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String craftLoginMessage(Player player, String message)
|
public Component craftLoginMessage(Player player, String message)
|
||||||
{
|
{
|
||||||
Displayable display = plugin.rm.getDisplay(player);
|
Displayable display = plugin.rm.getDisplay(player);
|
||||||
PlayerData playerData = plugin.pl.getData(player);
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
@ -224,21 +227,22 @@ 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())
|
||||||
{
|
{
|
||||||
message = "%name% is %art% %coloredrank%";
|
message = "<aqua><name> is <art> <coloredrank>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (message != null)
|
if (message != null)
|
||||||
{
|
{
|
||||||
return FUtil.colorize(ChatColor.AQUA + (message.contains("%name%") ? "" : player.getName() + " is ")
|
return FUtil.miniMessage(message,
|
||||||
+ FUtil.colorize(message).replace("%name%", player.getName())
|
Placeholder.unparsed("name", player.getName()),
|
||||||
.replace("%rank%", FUtil.miniMessage(display.getName()))
|
Placeholder.component("rank", display.getName()),
|
||||||
.replace("%coloredrank%", FUtil.miniMessage(display.getColoredName()))
|
Placeholder.component("coloredrank", display.getColoredName()),
|
||||||
.replace("%art%", FUtil.miniMessage(display.getArticle())));
|
Placeholder.component("art", display.getArticle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -20,4 +20,14 @@ public class FConverter
|
|||||||
.replaceAll("%msg%", "<message>")))
|
.replaceAll("%msg%", "<message>")))
|
||||||
.replaceAll("\\\\<", "<"); // GOD FUCKING DAMMIT
|
.replaceAll("\\\\<", "<"); // GOD FUCKING DAMMIT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String convertLoginMessage(String message)
|
||||||
|
{
|
||||||
|
return FUtil.MINI_MESSAGE.serialize(FUtil.LEGACY_AMPERSAND.deserialize(
|
||||||
|
message.replaceAll("%name%", "<name>")
|
||||||
|
.replaceAll("%rank%", "<rank>")
|
||||||
|
.replaceAll("%coloredrank%", "<coloredrank>")
|
||||||
|
.replaceAll("%art%", "<art>")))
|
||||||
|
.replaceAll("\\\\<", "<"); // GOD FUCKING DAMMIT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ public class Shop extends FreedomService implements ShoppeCommons
|
|||||||
ItemStack icon = new ItemStack(Material.NAME_TAG);
|
ItemStack icon = new ItemStack(Material.NAME_TAG);
|
||||||
ItemMeta meta = icon.getItemMeta();
|
ItemMeta meta = icon.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
meta.setDisplayName(FUtil.colorize(plugin.rm.craftLoginMessage(player, loginMessage)));
|
meta.displayName(plugin.rm.craftLoginMessage(player, loginMessage));
|
||||||
icon.setItemMeta(meta);
|
icon.setItemMeta(meta);
|
||||||
gui.setItem(slot, icon);
|
gui.setItem(slot, icon);
|
||||||
slot++;
|
slot++;
|
||||||
@ -423,7 +423,8 @@ public class Shop extends FreedomService implements ShoppeCommons
|
|||||||
String message = ConfigEntry.SHOP_LOGIN_MESSAGES.getStringList().get(slot);
|
String message = ConfigEntry.SHOP_LOGIN_MESSAGES.getStringList().get(slot);
|
||||||
data.setLoginMessage(message);
|
data.setLoginMessage(message);
|
||||||
plugin.pl.save(data);
|
plugin.pl.save(data);
|
||||||
player.sendMessage(ChatColor.GREEN + "Your login message is now the following:\n" + plugin.rm.craftLoginMessage(player, message));
|
player.sendMessage(ChatColor.GREEN + "Your login message is now the following:");
|
||||||
|
player.sendMessage(plugin.rm.craftLoginMessage(player, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
Loading…
Reference in New Issue
Block a user