mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Even more commands use Adventure now. Includes a bugfix for /creative.
This commit is contained in:
parent
e4782a3542
commit
2cd107c317
@ -4,6 +4,8 @@ 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;
|
||||
@ -22,11 +24,11 @@ public class Command_admininfo extends FreedomCommand
|
||||
|
||||
if (adminInfo.isEmpty())
|
||||
{
|
||||
msg("The admin information section of the config.yml file has not been configured.", ChatColor.RED);
|
||||
msg(Component.text("The admin information section of the config.yml file has not been configured.", NamedTextColor.RED));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(FUtil.colorize(StringUtils.join(adminInfo, "\n")));
|
||||
msg(FUtil.colorizeAsComponent(StringUtils.join(adminInfo, "\n")));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class Command_blockcmd extends FreedomCommand
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
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.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -21,11 +23,11 @@ public class Command_coins extends FreedomCommand
|
||||
{
|
||||
if (plugin.sh == null || !ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||
{
|
||||
msg("The shop is currently disabled!", ChatColor.RED);
|
||||
msg(Component.text("The shop is currently disabled!", NamedTextColor.RED));
|
||||
return true;
|
||||
}
|
||||
|
||||
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
|
||||
final Component prefix = FUtil.colorizeAsComponent(ConfigEntry.SHOP_PREFIX.getString() + " ");
|
||||
|
||||
switch (args.length)
|
||||
{
|
||||
@ -35,11 +37,13 @@ public class Command_coins extends FreedomCommand
|
||||
if (senderIsConsole)
|
||||
{
|
||||
msg("When used from the console, you must define a target player.");
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerData playerData = getData(playerSender);
|
||||
msg(prefix + ChatColor.GREEN + "You have " + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN
|
||||
+ " coins.");
|
||||
msg(prefix.append(Component.text("You have ", NamedTextColor.GREEN)
|
||||
.append(Component.text(playerData.getCoins(), NamedTextColor.GOLD))
|
||||
.append(Component.text(" coins.", NamedTextColor.GREEN))));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -53,10 +57,14 @@ public class Command_coins extends FreedomCommand
|
||||
if (target == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerData playerData = getData(target);
|
||||
msg(prefix + ChatColor.GREEN + target.getName() + " has " + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
|
||||
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))));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -79,37 +87,43 @@ public class Command_coins extends FreedomCommand
|
||||
{
|
||||
// Prevents players from trying to be cheeky with negative numbers.
|
||||
coinsToTransfer = Math.max(Math.abs(Integer.parseInt(args[2])), 1);
|
||||
} catch (NumberFormatException ex)
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
||||
msg(Component.text("Invalid number: " + args[2], NamedTextColor.RED));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Prevents players from performing transactions they can't afford to do.
|
||||
if (senderData.getCoins() < coinsToTransfer)
|
||||
{
|
||||
msg("You don't have enough coins to perform this transaction.", ChatColor.RED);
|
||||
msg(Component.text("You don't have enough coins to perform this transaction.", NamedTextColor.RED));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerData playerData = getData(target);
|
||||
playerData.setCoins(playerData.getCoins() + coinsToTransfer);
|
||||
senderData.setCoins(senderData.getCoins() - coinsToTransfer);
|
||||
|
||||
msg(target, sender.getName()
|
||||
+ ChatColor.GREEN + " has given you "
|
||||
+ ChatColor.GOLD + coinsToTransfer
|
||||
+ ChatColor.GREEN + " coin" + (coinsToTransfer > 1 ? "s" : "") + "!", ChatColor.GOLD);
|
||||
boolean plural = coinsToTransfer > 1;
|
||||
|
||||
msg("You have given "
|
||||
+ ChatColor.GOLD + coinsToTransfer
|
||||
+ ChatColor.GREEN + " coin" + (coinsToTransfer > 1 ? "s" : "")
|
||||
+ " to " + ChatColor.GOLD + target.getName() + ChatColor.GREEN + ".", ChatColor.GREEN);
|
||||
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)));
|
||||
|
||||
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)));
|
||||
|
||||
plugin.pl.save(playerData);
|
||||
plugin.pl.save(senderData);
|
||||
|
@ -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.Component;
|
||||
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 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)
|
||||
{
|
||||
@ -19,12 +19,12 @@ public class Command_creative extends FreedomCommand
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
msg("When used from the console, you must define a target player.");
|
||||
msg(Component.text("When used from the console, you must define a target player."));
|
||||
return true;
|
||||
}
|
||||
|
||||
playerSender.setGameMode(GameMode.CREATIVE);
|
||||
msg("Your gamemode has been set to creative.");
|
||||
msg(Component.text("Your gamemode has been set to creative."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -32,13 +32,14 @@ public class Command_creative extends FreedomCommand
|
||||
|
||||
if (args[0].equals("-a"))
|
||||
{
|
||||
for (Player targetPlayer : server.getOnlinePlayers())
|
||||
{
|
||||
targetPlayer.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
|
||||
msg("Your gamemode has been set to creative.");
|
||||
|
||||
server.getOnlinePlayers().forEach(player ->
|
||||
{
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
msg(player, Component.text("Your gamemode has been set to creative."));
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -50,10 +51,9 @@ public class Command_creative extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Setting " + player.getName() + " to game mode creative");
|
||||
msg(player, sender.getName() + " set your game mode to creative");
|
||||
msg(Component.text("Setting " + player.getName() + " to gamemode creative"));
|
||||
msg(player, Component.text(sender.getName() + " set your gamemode to creative."));
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -27,7 +28,7 @@ public class Command_explode extends FreedomCommand
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -50,7 +51,7 @@ public class Command_explode extends FreedomCommand
|
||||
player.getWorld().createExplosion(player.getLocation(), 4L);
|
||||
}
|
||||
player.setHealth(0.0);
|
||||
msg("Exploded " + player.getName());
|
||||
msg(Component.text("Exploded " + player.getName()));
|
||||
}
|
||||
}.runTaskLater(plugin, 40);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -23,13 +24,11 @@ public class Command_findip extends FreedomCommand
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Player IPs: " + StringUtils.join(plugin.pl.getData(player).getIps(), ", "));
|
||||
|
||||
msg(Component.text(player.getName() + "'s IPs: " + StringUtils.join(plugin.pl.getData(player).getIps(), ", ")));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -68,15 +68,15 @@ public class Command_freeze extends FreedomCommand
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
||||
msg(PLAYER_NOT_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
|
||||
fd.setFrozen(!fd.isFrozen());
|
||||
|
||||
msg(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||
msg(player, "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
|
||||
msg(Component.text(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + "."));
|
||||
msg(player, Component.text("You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + "."));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -43,7 +44,7 @@ public class Command_fuckoff extends FreedomCommand
|
||||
player.setFuckoff(radius);
|
||||
}
|
||||
|
||||
msg("Fuckoff " + (player.isFuckOff() ? ("enabled. Radius: " + player.getFuckoffRadius() + ".") : "disabled."));
|
||||
msg(Component.text("Fuckoff ").append(Component.text(player.isFuckOff() ? "enabled. Radius: " + player.getFuckoffRadius() : "disabled.")));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -36,25 +38,26 @@ public class Command_gcmd extends FreedomCommand
|
||||
|
||||
if (plugin.al.isAdmin(player))
|
||||
{
|
||||
msg(ChatColor.RED + "You can not use gcmd on admins");
|
||||
msg(Component.text("You can't use this command on other admins!", NamedTextColor.RED));
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
msg("Sending command as " + player.getName() + ": " + outCommand);
|
||||
msg(Component.text("Sending command as " + player.getName() + ": " + outCommand));
|
||||
|
||||
if (server.dispatchCommand(player, outCommand))
|
||||
{
|
||||
msg("Command sent.");
|
||||
msg(Component.text("Command sent.", NamedTextColor.GREEN));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Unknown error sending command.");
|
||||
msg(Component.text("Unknown error sending command.", NamedTextColor.RED));
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
msg("Error sending command: " + ex.getMessage());
|
||||
msg(Component.text("Error sending command: " + ex.getMessage(), NamedTextColor.RED));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -18,12 +19,12 @@ public class Command_spectator extends FreedomCommand
|
||||
{
|
||||
if (isConsole())
|
||||
{
|
||||
msg("When used from the console, you must define a target player.");
|
||||
msg(Component.text("When used from the console, you must define a target player."));
|
||||
return true;
|
||||
}
|
||||
|
||||
playerSender.setGameMode(GameMode.SPECTATOR);
|
||||
msg("Your gamemode has been set to spectator.");
|
||||
msg(Component.text("Your gamemode has been set to spectator."));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -35,8 +36,8 @@ public class Command_spectator extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
msg("Setting " + player.getName() + " to game mode spectator");
|
||||
msg(player, sender.getName() + " set your game mode to spectator");
|
||||
msg(Component.text("Setting " + player.getName() + " to gamemode spectator"));
|
||||
msg(player, Component.text(sender.getName() + " set your gamemode to spectator."));
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
return true;
|
||||
}
|
||||
|
@ -4,8 +4,9 @@ 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;
|
||||
@ -14,7 +15,6 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Information on how to vote", usage = "/<command>")
|
||||
public class Command_vote extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
@ -22,11 +22,11 @@ public class Command_vote extends FreedomCommand
|
||||
|
||||
if (voteInfo.isEmpty())
|
||||
{
|
||||
msg("The voting information section of the config.yml file has not been configured.", ChatColor.RED);
|
||||
msg(Component.text("The voting information section of the config.yml file has not been configured.", NamedTextColor.RED));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(FUtil.colorize(StringUtils.join(voteInfo, "\n")));
|
||||
msg(FUtil.colorizeAsComponent(StringUtils.join(voteInfo, "\n")));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,15 +1,16 @@
|
||||
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.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||
@ -31,35 +32,27 @@ public class Command_whohas extends FreedomCommand
|
||||
|
||||
if (material == null)
|
||||
{
|
||||
msg("Invalid item: " + materialName, ChatColor.RED);
|
||||
msg(Component.text("Invalid item: " + materialName, NamedTextColor.RED));
|
||||
return true;
|
||||
}
|
||||
|
||||
final List<String> players = new ArrayList<>();
|
||||
List<? extends Player> players = server.getOnlinePlayers().stream().filter(player -> player.getInventory().contains(material) &&
|
||||
(!plugin.al.isVanished(player.getUniqueId()) || plugin.al.isAdmin(sender))).toList();
|
||||
|
||||
for (final Player player : server.getOnlinePlayers())
|
||||
if (plugin.al.isAdmin(sender) && doClear)
|
||||
{
|
||||
if (!plugin.al.isAdmin(sender) && plugin.al.isVanished(player.getUniqueId()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (player.getInventory().contains(material))
|
||||
{
|
||||
players.add(player.getName());
|
||||
if (plugin.al.isAdmin(sender) && doClear && !plugin.al.isAdmin(player))
|
||||
{
|
||||
player.getInventory().remove(material);
|
||||
}
|
||||
}
|
||||
players.stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||
player.getInventory().remove(material));
|
||||
}
|
||||
|
||||
if (players.isEmpty())
|
||||
{
|
||||
msg("There are no players with that item");
|
||||
msg(Component.text("There are no players with that item."));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Players with item " + material.name() + ": " + StringUtils.join(players, ", "));
|
||||
msg(Component.text("Players with item " + material.name() + ": " +
|
||||
StringUtils.join(players.stream().map(HumanEntity::getName).toList(), ", ")));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -7,6 +7,8 @@ import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
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 org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -27,7 +29,7 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
public static final String COMMAND_PREFIX = "Command_";
|
||||
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
||||
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
|
||||
public static final Component PLAYER_NOT_FOUND = Component.text("Player not found!", NamedTextColor.GRAY);
|
||||
public static final String ONLY_CONSOLE = ChatColor.RED + "Only console senders may execute this command!";
|
||||
public static final String ONLY_IN_GAME = ChatColor.RED + "Only in-game players may execute this command!";
|
||||
public static final String NO_PERMISSION = ChatColor.RED + "You do not have permission to execute this command.";
|
||||
@ -109,6 +111,17 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
||||
cmd.setExecutor(this);
|
||||
}
|
||||
|
||||
protected void msg(CommandSender sender, Component message)
|
||||
{
|
||||
sender.sendMessage(message.colorIfAbsent(NamedTextColor.GRAY));
|
||||
}
|
||||
|
||||
protected void msg(Component message)
|
||||
{
|
||||
msg(sender, message);
|
||||
}
|
||||
|
||||
|
||||
protected void msg(CommandSender sender, String message)
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + message);
|
||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.util;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
@ -454,6 +455,11 @@ public class FUtil
|
||||
return string;
|
||||
}
|
||||
|
||||
public static Component colorizeAsComponent(String string)
|
||||
{
|
||||
return LEGACY_AMPERSAND.deserialize(string);
|
||||
}
|
||||
|
||||
public static String stripColors(String string)
|
||||
{
|
||||
return string.replaceAll("§", "");
|
||||
|
Loading…
Reference in New Issue
Block a user