mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Read the commit details for more information
- Removes several old unused commands - Begins implementing MiniMessage into several commands
This commit is contained in:
parent
2cd107c317
commit
733f668145
@ -3,11 +3,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -24,12 +19,13 @@ public class Command_admininfo extends FreedomCommand
|
||||
|
||||
if (adminInfo.isEmpty())
|
||||
{
|
||||
msg(Component.text("The admin information section of the config.yml file has not been configured.", NamedTextColor.RED));
|
||||
msgNew("<red>The admin information section of the config.yml file has not been configured.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(FUtil.colorizeAsComponent(StringUtils.join(adminInfo, "\n")));
|
||||
adminInfo.forEach(this::msgNew);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -32,13 +33,13 @@ public class Command_banip extends FreedomCommand
|
||||
|
||||
if (FUtil.isValidIPv4(ip))
|
||||
{
|
||||
msg(ip + " is not a valid IP address", ChatColor.RED);
|
||||
msgNew("<red><ip> is not a valid IP address.", Placeholder.unparsed("ip", ip));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.bm.getByIp(ip) != null)
|
||||
{
|
||||
msg("The IP " + ip + " is already banned", ChatColor.RED);
|
||||
msgNew("<red>The IP <ip> is already banned.", Placeholder.unparsed("ip", ip));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -71,12 +72,12 @@ public class Command_banip extends FreedomCommand
|
||||
if (!silent)
|
||||
{
|
||||
// Broadcast
|
||||
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
|
||||
String message = sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
|
||||
msg(player, message, ChatColor.RED);
|
||||
}
|
||||
}
|
||||
|
||||
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,15 +2,18 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
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(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Shows all banned player names. Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||
public class Command_banlist extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -19,18 +22,23 @@ public class Command_banlist extends FreedomCommand
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
checkRank(Rank.SENIOR_ADMIN);
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
||||
int amount = plugin.bm.purge();
|
||||
msg("Purged " + amount + " player bans.");
|
||||
msgNew("<green>Purged <amount> player bans.", Placeholder.unparsed("amount", String.valueOf(plugin.bm.purge())));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
msg(plugin.bm.getAllBans().size() + " player bans ("
|
||||
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
||||
+ plugin.bm.getIpBans().size() + " IPs)");
|
||||
msgNew("<total> player bans (<usernames> usernames, <ips> IPs)",
|
||||
Placeholder.unparsed("total", String.valueOf(plugin.bm.getAllBans().size())),
|
||||
Placeholder.unparsed("usernames", String.valueOf(plugin.bm.getUsernameBans())),
|
||||
Placeholder.unparsed("ips", String.valueOf(plugin.bm.getIpBans().size())));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
return args.length == 1 && plugin.al.isSeniorAdmin(sender) ? Collections.singletonList("purge") : Collections.emptyList();
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -14,35 +13,16 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
@CommandParameters(description = "For the people that are still alive - gives a cake to everyone on the server.", usage = "/<command>")
|
||||
public class Command_cake extends FreedomCommand
|
||||
{
|
||||
|
||||
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
||||
|
||||
@Override
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
final StringBuilder output = new StringBuilder();
|
||||
|
||||
for (final String word : CAKE_LYRICS.split(" "))
|
||||
{
|
||||
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||
}
|
||||
|
||||
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||
assert heldItemMeta != null;
|
||||
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
||||
heldItemMeta.displayName(FUtil.miniMessage("<white>The <dark_gray>Lie"));
|
||||
heldItem.setItemMeta(heldItemMeta);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
final int firstEmpty = player.getInventory().firstEmpty();
|
||||
if (firstEmpty >= 0)
|
||||
{
|
||||
player.getInventory().setItem(firstEmpty, heldItem);
|
||||
}
|
||||
}
|
||||
|
||||
FUtil.bcastMsg(output.toString());
|
||||
server.getOnlinePlayers().forEach(player -> player.getInventory().addItem(heldItem));
|
||||
server.broadcast(FUtil.miniMessage("<rainbow>But there's no sense crying over every mistake. You just keep on trying till you run out of cake."));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Sit in nearest minecart. If target is in a minecart already, they will disembark.", usage = "/<command> [partialname]")
|
||||
public class Command_cartsit extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
Player targetPlayer = playerSender;
|
||||
|
||||
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||
{
|
||||
targetPlayer = getPlayer(args[0]);
|
||||
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (senderIsConsole)
|
||||
{
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
msg("When used from the console, you must define a target player: /cartsit <player>");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetPlayer.isInsideVehicle())
|
||||
{
|
||||
Objects.requireNonNull(targetPlayer.getVehicle()).eject();
|
||||
}
|
||||
else
|
||||
{
|
||||
Minecart nearest_cart = null;
|
||||
for (Minecart cart : targetPlayer.getWorld().getEntitiesByClass(Minecart.class))
|
||||
{
|
||||
if (cart.isEmpty())
|
||||
{
|
||||
if (nearest_cart == null)
|
||||
{
|
||||
nearest_cart = cart;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cart.getLocation().distanceSquared(targetPlayer.getLocation()) < nearest_cart.getLocation().distanceSquared(targetPlayer.getLocation()))
|
||||
{
|
||||
nearest_cart = cart;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nearest_cart != null)
|
||||
{
|
||||
nearest_cart.addPassenger(targetPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("There are no empty minecarts in the target world.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -13,13 +13,14 @@ public class Command_cleardiscordqueue extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (plugin.dc == null) {
|
||||
msg("Discord is not enabled.");
|
||||
if (plugin.dc == null)
|
||||
{
|
||||
msgNew("<red>Discord is not enabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.dc.clearQueue();
|
||||
msg("Cleared the discord message queue.");
|
||||
msg("<green>Cleared the Discord message queue.");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -16,7 +17,7 @@ public class Command_cmdspy extends FreedomCommand
|
||||
{
|
||||
Admin admin = plugin.al.getAdmin(playerSender);
|
||||
admin.setCommandSpy(!admin.getCommandSpy());
|
||||
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
|
||||
msgNew("CommandSpy <status>.", Placeholder.unparsed("status", admin.getCommandSpy() ? "enabled." : "disabled."));
|
||||
plugin.al.save(admin);
|
||||
plugin.al.updateTables();
|
||||
return true;
|
||||
|
@ -6,6 +6,7 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -23,12 +24,10 @@ public class Command_coins extends FreedomCommand
|
||||
{
|
||||
if (plugin.sh == null || !ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
{
|
||||
msg(Component.text("The shop is currently disabled!", NamedTextColor.RED));
|
||||
msgNew("<red>The shop is currently disabled!");
|
||||
return true;
|
||||
}
|
||||
|
||||
final Component prefix = FUtil.colorizeAsComponent(ConfigEntry.SHOP_PREFIX.getString() + " ");
|
||||
|
||||
switch (args.length)
|
||||
{
|
||||
// Mode for seeing how many coins the sender has (doesn't work from console)
|
||||
@ -36,14 +35,14 @@ public class Command_coins extends FreedomCommand
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg("When used from the console, you must define a target player.");
|
||||
msgNew("When used from the console, you must define a target player.");
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerData playerData = getData(playerSender);
|
||||
msg(prefix.append(Component.text("You have ", NamedTextColor.GREEN)
|
||||
.append(Component.text(playerData.getCoins(), NamedTextColor.GOLD))
|
||||
.append(Component.text(" coins.", NamedTextColor.GREEN))));
|
||||
msgNew("<green>You have <gold><coins></gold> coin<plural>.",
|
||||
Placeholder.unparsed("coins", String.valueOf(playerData.getCoins())),
|
||||
Placeholder.unparsed("plural", playerData.getCoins() > 1 ? "s" : ""));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -61,10 +60,10 @@ public class Command_coins extends FreedomCommand
|
||||
else
|
||||
{
|
||||
PlayerData playerData = getData(target);
|
||||
msg(prefix.append(Component.text(target.getName(), NamedTextColor.GOLD)
|
||||
.append(Component.text(" has ", NamedTextColor.GREEN))
|
||||
.append(Component.text(playerData.getCoins(), NamedTextColor.GOLD))
|
||||
.append(Component.text(" coins.", NamedTextColor.GREEN))));
|
||||
msgNew("<green><gold><player></gold> has <gold><coins></gold> coin<plural>.",
|
||||
Placeholder.unparsed("player", target.getName()),
|
||||
Placeholder.unparsed("coins", String.valueOf(playerData.getCoins())),
|
||||
Placeholder.unparsed("plural", playerData.getCoins() > 1 ? "s" : ""));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -90,14 +89,14 @@ public class Command_coins extends FreedomCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg(Component.text("Invalid number: " + args[2], NamedTextColor.RED));
|
||||
msgNew("<red>Invalid number: <num>", Placeholder.unparsed("num", args[2]));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Prevents players from performing transactions they can't afford to do.
|
||||
if (senderData.getCoins() < coinsToTransfer)
|
||||
{
|
||||
msg(Component.text("You don't have enough coins to perform this transaction.", NamedTextColor.RED));
|
||||
msgNew("<red>You don't have enough coins to perform this transaction.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -113,17 +112,15 @@ public class Command_coins extends FreedomCommand
|
||||
|
||||
boolean plural = coinsToTransfer > 1;
|
||||
|
||||
msg(target, Component.text(sender.getName(), NamedTextColor.GOLD)
|
||||
.append(Component.text(" has given you ", NamedTextColor.GREEN))
|
||||
.append(Component.text(coinsToTransfer, NamedTextColor.GOLD))
|
||||
.append(Component.text(" coin" + (plural ? "s" : "") + "!", NamedTextColor.GREEN)));
|
||||
msgNew(target, "<green><gold><sender></gold> has given you <gold><coins></gold> coin<plural>!",
|
||||
Placeholder.unparsed("sender", sender.getName()),
|
||||
Placeholder.unparsed("coins", String.valueOf(coinsToTransfer)),
|
||||
Placeholder.unparsed("plural", plural ? "s" : ""));
|
||||
|
||||
msg(target, Component.text("You have given ", NamedTextColor.GREEN)
|
||||
.append(Component.text(coinsToTransfer, NamedTextColor.GOLD))
|
||||
.append(Component.text(" coin" + (plural ? "s" : ""), NamedTextColor.GOLD))
|
||||
.append(Component.text(" to ", NamedTextColor.GREEN))
|
||||
.append(Component.text(target.getName(), NamedTextColor.GOLD))
|
||||
.append(Component.text(".", NamedTextColor.GREEN)));
|
||||
msgNew("<green>You have given <gold><coins></gold> coin<plural> to <gold><player></gold>.",
|
||||
Placeholder.unparsed("player", target.getName()),
|
||||
Placeholder.unparsed("coins", String.valueOf(coinsToTransfer)),
|
||||
Placeholder.unparsed("plural", plural ? "s" : ""));
|
||||
|
||||
plugin.pl.save(playerData);
|
||||
plugin.pl.save(senderData);
|
||||
|
@ -1,55 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Essentials Interface Command - Set your nickname to a certain color.", usage = "/<command> <color>")
|
||||
public class Command_colorme extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
|
||||
return true;
|
||||
}
|
||||
|
||||
final String needle = args[0].trim().toLowerCase();
|
||||
ChatColor color = null;
|
||||
for (Map.Entry<String, ChatColor> entry : FUtil.CHAT_COLOR_NAMES.entrySet())
|
||||
{
|
||||
if (entry.getKey().contains(needle))
|
||||
{
|
||||
color = entry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (color == null)
|
||||
{
|
||||
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
|
||||
return true;
|
||||
}
|
||||
|
||||
final String newNick = color + ChatColor.stripColor(playerSender.getDisplayName()).trim() + ChatColor.WHITE;
|
||||
|
||||
plugin.esb.setNickname(sender.getName(), newNick);
|
||||
|
||||
msg("Your nickname is now: " + newNick);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandPermissions(rank = Rank.NON_OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>", aliases = "cmdlist")
|
||||
public class Command_commandlist extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
for (Plugin targetPlugin : server.getPluginManager().getPlugins())
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginDescriptionFile desc = targetPlugin.getDescription();
|
||||
Map<String, Map<String, Object>> map = desc.getCommands();
|
||||
|
||||
for (Entry<String, Map<String, Object>> entry : map.entrySet())
|
||||
{
|
||||
String command_name = entry.getKey();
|
||||
commands.add(command_name);
|
||||
}
|
||||
} catch (Throwable ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(commands);
|
||||
|
||||
msg(StringUtils.join(commands, ", "));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -22,10 +24,9 @@ public class Command_consolesay extends FreedomCommand
|
||||
return false;
|
||||
}
|
||||
|
||||
server.broadcast(Component.text("[CONSOLE] ", NamedTextColor.GRAY)
|
||||
.append(Component.text(sender.getName(), NamedTextColor.RED))
|
||||
.append(Component.text("» ", NamedTextColor.DARK_GRAY))
|
||||
.append(Component.text(StringUtils.join(args, " "), NamedTextColor.WHITE)));
|
||||
server.broadcast(FUtil.miniMessage("<gray>[CONSOLE] <red><sender> <dark_gray>» <white><message>",
|
||||
Placeholder.unparsed("sender", sender.getName()),
|
||||
Placeholder.unparsed("message", StringUtils.join(args, " "))));
|
||||
|
||||
if (plugin.dc != null)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -19,12 +19,12 @@ public class Command_creative extends FreedomCommand
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
msg(Component.text("When used from the console, you must define a target player."));
|
||||
msgNew("When used from the console, you must define a target player.");
|
||||
return true;
|
||||
}
|
||||
|
||||
playerSender.setGameMode(GameMode.CREATIVE);
|
||||
msg(Component.text("Your gamemode has been set to creative."));
|
||||
msgNew("Your gamemode has been set to creative.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ public class Command_creative extends FreedomCommand
|
||||
server.getOnlinePlayers().forEach(player ->
|
||||
{
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
msg(player, Component.text("Your gamemode has been set to creative."));
|
||||
msgNew(player, "Your gamemode has been set to creative.");
|
||||
});
|
||||
|
||||
return true;
|
||||
@ -51,8 +51,8 @@ public class Command_creative extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
msg(Component.text("Setting " + player.getName() + " to gamemode creative"));
|
||||
msg(player, Component.text(sender.getName() + " set your gamemode to creative."));
|
||||
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;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -17,7 +18,6 @@ import java.time.Duration;
|
||||
@CommandParameters(description = "Freeze/Unfreeze a specified player, or all non-admins on the server.", usage = "/<command> [target | purge]", aliases = "fr")
|
||||
public class Command_freeze extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -29,38 +29,28 @@ public class Command_freeze extends FreedomCommand
|
||||
if (!gFreeze)
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
|
||||
msg("Players are now free to move.");
|
||||
return true;
|
||||
msgNew("Players are now free to move.");
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Freezing all players", false);
|
||||
server.getOnlinePlayers().stream().filter(player -> !isAdmin(player)).forEach(player ->
|
||||
{
|
||||
FUtil.playerTitle(player, "<red>You have been frozen.", "<yellow>Please be patient and you will be unfrozen shortly.");
|
||||
msgNew(player, "<red>You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon.");
|
||||
});
|
||||
|
||||
msgNew("Players are now frozen.");
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Freezing all players", false);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!isAdmin(player))
|
||||
{
|
||||
player.showTitle(Title.title(Component.text("You have been frozen.", NamedTextColor.RED),
|
||||
Component.text("Please be patient and you will be unfrozen shortly.", NamedTextColor.YELLOW),
|
||||
Title.Times.of(Duration.ofSeconds(1), Duration.ofSeconds(5), Duration.ofSeconds(3))));
|
||||
msg(player, "You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon.", ChatColor.RED);
|
||||
}
|
||||
}
|
||||
msg("Players are now frozen.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
if (!isAdmin(player))
|
||||
{
|
||||
player.showTitle(Title.title(Component.text("You have been unfrozen.", NamedTextColor.GREEN),
|
||||
Component.text("You may now move again.", NamedTextColor.YELLOW),
|
||||
Title.Times.of(Duration.ofSeconds(1), Duration.ofSeconds(5), Duration.ofSeconds(3))));
|
||||
}
|
||||
}
|
||||
plugin.fm.purge();
|
||||
server.getOnlinePlayers().stream().filter(player -> !isAdmin(player)).forEach(player -> FUtil.playerTitle(player, "<green>You have been unfrozen.", "<yellow>You may now move again."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -75,8 +65,9 @@ public class Command_freeze extends FreedomCommand
|
||||
final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
|
||||
fd.setFrozen(!fd.isFrozen());
|
||||
|
||||
msg(Component.text(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + "."));
|
||||
msg(player, Component.text("You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + "."));
|
||||
msgNew("<player> has been <status>.", Placeholder.unparsed("player", player.getName()),
|
||||
Placeholder.unparsed("status", fd.isFrozen() ? "frozen" : "unfrozen"));
|
||||
msgNew(player, "You have been <status>.", Placeholder.unparsed("status", fd.isFrozen() ? "frozen" : "unfrozen"));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -11,7 +12,6 @@ import org.bukkit.entity.Player;
|
||||
@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)
|
||||
{
|
||||
@ -19,12 +19,12 @@ public class Command_spectator extends FreedomCommand
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
msg(Component.text("When used from the console, you must define a target player."));
|
||||
msgNew("When used from the console, you must define a target player.");
|
||||
return true;
|
||||
}
|
||||
|
||||
playerSender.setGameMode(GameMode.SPECTATOR);
|
||||
msg(Component.text("Your gamemode has been set to spectator."));
|
||||
msgNew("Your gamemode has been set to spectator.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -36,9 +36,9 @@ public class Command_spectator extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
msg(Component.text("Setting " + player.getName() + " to gamemode spectator"));
|
||||
msg(player, Component.text(sender.getName() + " set your gamemode to spectator."));
|
||||
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;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -20,13 +21,7 @@ public class Command_stop extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
String reason = "Server is going offline, come back in about 20 seconds.";
|
||||
|
||||
if (args.length != 0)
|
||||
{
|
||||
reason = StringUtils.join(args, " ");
|
||||
}
|
||||
String reason = args.length != 0 ? "Server is going offline, come back in about 20 seconds." : StringUtils.join(args, " ");
|
||||
|
||||
if (sender.getName().equals("CONSOLE"))
|
||||
{
|
||||
@ -40,7 +35,7 @@ public class Command_stop extends FreedomCommand
|
||||
}
|
||||
|
||||
|
||||
msg("Warning: You're about to stop the server. Type /stop again to confirm you want to do this.");
|
||||
msgNew("Warning: You're about to stop the server. Type /stop again to confirm you want to do this.");
|
||||
|
||||
STOP_CONFIRM.put(sender, reason);
|
||||
new BukkitRunnable()
|
||||
@ -51,7 +46,7 @@ public class Command_stop extends FreedomCommand
|
||||
if (STOP_CONFIRM.containsKey(sender))
|
||||
{
|
||||
STOP_CONFIRM.remove(sender);
|
||||
msg("Stop request expired.");
|
||||
msgNew("Stop request expired.");
|
||||
}
|
||||
}
|
||||
}.runTaskLater(plugin, 15 * 20);
|
||||
@ -60,15 +55,10 @@ public class Command_stop extends FreedomCommand
|
||||
|
||||
public void shutdown(String reason)
|
||||
{
|
||||
FUtil.bcastMsg("Server is going offline!", ChatColor.LIGHT_PURPLE);
|
||||
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
player.kickPlayer(ChatColor.LIGHT_PURPLE + reason);
|
||||
}
|
||||
|
||||
server.broadcast(FUtil.miniMessage("<light_purple>Server is going offline!"));
|
||||
server.getOnlinePlayers().forEach(player ->
|
||||
player.kick(FUtil.miniMessage("<light_purple><reason>", Placeholder.unparsed("reason", reason))));
|
||||
STOP_CONFIRM.remove(sender);
|
||||
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.Command;
|
||||
@ -14,38 +16,21 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Stops all sounds or a specified sound.", usage = "/<command> [sound]")
|
||||
public class Command_stopsound extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
Sound sound = null;
|
||||
Arrays.stream(Sound.values()).filter(snd -> snd != null && snd.name().equalsIgnoreCase(args[0])).findAny().ifPresentOrElse(sound ->
|
||||
{
|
||||
playerSender.stopSound(sound);
|
||||
msgNew("<green>Stopped all <sound> sounds.", Placeholder.unparsed("sound", sound.name()));
|
||||
}, () -> msgNew("<red><sound> is not a valid sound.", Placeholder.unparsed("sound", args[0])));
|
||||
|
||||
for (Sound loop : Sound.values())
|
||||
{
|
||||
if (loop != null && loop.name().equalsIgnoreCase(args[0]))
|
||||
{
|
||||
sound = Sound.valueOf(args[0].toUpperCase());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sound == null)
|
||||
{
|
||||
msg(args[0] + " is not a valid sound.", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
|
||||
playerSender.stopSound(sound);
|
||||
msg("Stopped all " + sound.name() + " sounds", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Sound sound : Sound.values())
|
||||
{
|
||||
playerSender.stopSound(sound);
|
||||
}
|
||||
playerSender.stopAllSounds();
|
||||
|
||||
msg("Stopped all sounds.", ChatColor.GREEN);
|
||||
return true;
|
||||
@ -54,20 +39,11 @@ public class Command_stopsound extends FreedomCommand
|
||||
@Override
|
||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
if (args.length <= 1)
|
||||
{
|
||||
return soundList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return Arrays.stream(Sound.values()).map(Enum::name).toList();
|
||||
}
|
||||
|
||||
public List<String> soundList()
|
||||
{
|
||||
List<String> sounds = new ArrayList<>();
|
||||
for (Sound sound : Sound.values())
|
||||
{
|
||||
sounds.add(sound.name());
|
||||
}
|
||||
return sounds;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
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;
|
||||
@ -19,12 +20,12 @@ public class Command_survival extends FreedomCommand
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
msg("When used from the console, you must define a target player.");
|
||||
msgNew("When used from the console, you must define a target player.");
|
||||
return true;
|
||||
}
|
||||
|
||||
playerSender.setGameMode(GameMode.SURVIVAL);
|
||||
msg("Your gamemode has been set to survival.");
|
||||
msgNew("Your gamemode has been set to survival.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -32,13 +33,14 @@ public class Command_survival extends FreedomCommand
|
||||
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
for (Player targetPlayer : server.getOnlinePlayers())
|
||||
{
|
||||
targetPlayer.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to survival", false);
|
||||
msg("Your gamemode has been set to survival.");
|
||||
|
||||
server.getOnlinePlayers().forEach(player ->
|
||||
{
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
msgNew(player, "Your gamemode has been set to survival.");
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -50,9 +52,9 @@ public class Command_survival extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Setting " + player.getName() + " to game mode survival.");
|
||||
msg(player, sender.getName() + " set your game mode to survival.");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,10 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -11,6 +15,8 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Warns the specified player.", usage = "/<command> [-q] <player> <reason>")
|
||||
public class Command_warn extends FreedomCommand
|
||||
@ -44,25 +50,27 @@ public class Command_warn extends FreedomCommand
|
||||
|
||||
if (playerSender == player)
|
||||
{
|
||||
msg(ChatColor.RED + "Please, don't try to warn yourself.");
|
||||
msgNew("<red>Please, don't try to warn yourself.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msg(ChatColor.RED + "You can not warn admins");
|
||||
msgNew("<red>You can't warn other admins!");
|
||||
return true;
|
||||
}
|
||||
|
||||
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||
player.sendTitle(ChatColor.RED + "You've been warned.", ChatColor.YELLOW + "Reason: " + warnReason, 20, 100, 60);
|
||||
msg(player, ChatColor.RED + "[WARNING] You received a warning from " + sender.getName() + ": " + warnReason);
|
||||
player.showTitle(Title.title(Component.text("You have been warned.", NamedTextColor.RED),
|
||||
Component.text("Reason: " + warnReason, NamedTextColor.YELLOW),
|
||||
Title.Times.times(Duration.ofSeconds(1), Duration.ofSeconds(5), Duration.ofSeconds(3))));
|
||||
msgNew("<red>[WARNING] You received a warning from <sender>: <reason>", Placeholder.unparsed("sender", sender.getName()), Placeholder.unparsed("reason", warnReason));
|
||||
plugin.pl.getPlayer(player).incrementWarnings(quiet);
|
||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.WARN, warnReason));
|
||||
|
||||
if (quiet)
|
||||
{
|
||||
msg("You have successfully warned " + player.getName() + " quietly.");
|
||||
msgNew("You have successfully warned <player> quietly.", Placeholder.unparsed("player", player.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -76,7 +84,7 @@ public class Command_warn extends FreedomCommand
|
||||
warnReason;
|
||||
plugin.al.messageAllAdmins(adminNotice);
|
||||
|
||||
msg("You have successfully warned " + player.getName() + ".");
|
||||
msgNew("You have successfully warned <player>.", Placeholder.unparsed("player", player.getName()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import java.util.*;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
@ -27,11 +29,11 @@ public class Command_whitelist extends FreedomCommand
|
||||
{
|
||||
if (server.getWhitelistedPlayers().isEmpty())
|
||||
{
|
||||
msg("There are no whitelisted players.");
|
||||
msgNew("There are no whitelisted players.");
|
||||
return true;
|
||||
}
|
||||
msg("Whitelisted players: " + FUtil.listToString(server.getWhitelistedPlayers().stream().map(player ->
|
||||
player.getName() != null ? player.getName() : player.getUniqueId().toString()).toList()));
|
||||
msgNew("Whitelisted players: <players>", Placeholder.unparsed("players", FUtil.listToString(server.getWhitelistedPlayers().stream().map(player ->
|
||||
player.getName() != null ? player.getName() : player.getUniqueId().toString()).toList())));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,9 +57,9 @@ public class Command_whitelist extends FreedomCommand
|
||||
totalWPs++;
|
||||
}
|
||||
|
||||
msg("Online whitelisted players: " + onlineWPs);
|
||||
msg("Offline whitelisted players: " + offlineWPs);
|
||||
msg("Total whitelisted players: " + totalWPs);
|
||||
msgNew("Online whitelisted players: <online>", Placeholder.unparsed("online", String.valueOf(onlineWPs)));
|
||||
msgNew("Offline whitelisted players: <offline>", Placeholder.unparsed("offline", String.valueOf(offlineWPs)));
|
||||
msgNew("Total whitelisted players: <total>", Placeholder.unparsed("total", String.valueOf(totalWPs)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -126,7 +128,7 @@ public class Command_whitelist extends FreedomCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("That player is not whitelisted");
|
||||
msgNew("That player is not whitelisted");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -145,7 +147,7 @@ public class Command_whitelist extends FreedomCommand
|
||||
}
|
||||
}
|
||||
|
||||
msg("Whitelisted " + counter + " players.");
|
||||
msgNew("Whitelisted <count> players.", Placeholder.unparsed("count", String.valueOf(counter)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -157,7 +159,7 @@ public class Command_whitelist extends FreedomCommand
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Removing all players from the whitelist", false);
|
||||
msg("Removed " + purge() + " players from the whitelist.");
|
||||
msgNew("Removed <count> players from the whitelist.", Placeholder.unparsed("count", String.valueOf(purge())));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -32,7 +33,7 @@ public class Command_whohas extends FreedomCommand
|
||||
|
||||
if (material == null)
|
||||
{
|
||||
msg(Component.text("Invalid item: " + materialName, NamedTextColor.RED));
|
||||
msgNew("<red>Invalid item: <type>", Placeholder.unparsed("type", materialName));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -47,12 +48,12 @@ public class Command_whohas extends FreedomCommand
|
||||
|
||||
if (players.isEmpty())
|
||||
{
|
||||
msg(Component.text("There are no players with that item."));
|
||||
msgNew("There are no players with that item.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(Component.text("Players with item " + material.name() + ": " +
|
||||
StringUtils.join(players.stream().map(HumanEntity::getName).toList(), ", ")));
|
||||
msgNew("Players with item <type>: <players>", Placeholder.unparsed("type", material.name()),
|
||||
Placeholder.unparsed("players", StringUtils.join(players.stream().map(HumanEntity::getName).toList(), ", ")));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -16,7 +17,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Run any command on all users, username placeholder = ?.", usage = "/<command> [fluff] ? [fluff] ?")
|
||||
public class Command_wildcard extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -30,7 +30,7 @@ public class Command_wildcard extends FreedomCommand
|
||||
boolean alias = plugin.cl.isAlias(args[0]);
|
||||
if (runCmd == null && fCmd == null && !alias)
|
||||
{
|
||||
msg("Unknown command: " + args[0], ChatColor.RED);
|
||||
msgNew("<red>Unknown command: <command>", Placeholder.unparsed("command", args[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ public class Command_wildcard extends FreedomCommand
|
||||
{
|
||||
if (blockedCommand.equals(args[0].toLowerCase()) || aliases.contains(blockedCommand))
|
||||
{
|
||||
msg("Did you really think that was going to work?", ChatColor.RED);
|
||||
msgNew("<red>Did you really think that was going to work?");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -66,7 +66,7 @@ public class Command_wildcard extends FreedomCommand
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
String runCommand = baseCommand.replaceAll("\\x3f", player.getName());
|
||||
msg("Running Command: " + runCommand);
|
||||
msgNew("Running command: <command>", Placeholder.unparsed("command", baseCommand));
|
||||
server.dispatchCommand(sender, runCommand);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -142,6 +143,18 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
msg(sender, message);
|
||||
}
|
||||
|
||||
protected void msgNew(CommandSender sender, String message, TagResolver... placeholders)
|
||||
{
|
||||
sender.sendMessage(FUtil.miniMessage("<gray>" + message, placeholders));
|
||||
}
|
||||
|
||||
protected void msgNew(String message, TagResolver... placeholders)
|
||||
{
|
||||
msgNew(sender, message, placeholders);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void msg(String message, ChatColor color)
|
||||
{
|
||||
msg(color + message);
|
||||
|
Loading…
Reference in New Issue
Block a user