mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-01 05:57:09 +00:00
Please read the commit description for a full changelog
- Reimplements the clownfish toggle in a much better way - Completely rewrites the plugin's chat formatting system - Tags now use MiniMessage instead of color codes. New tags are automatically converted. - /adminchat now uses MiniMessage for its messages - /autoclear and /autotp now use MiniMessage for their messages - /banip now uses MiniMessage for its messages - /bird now uses MiniMessage for its messages (and also now shows a rainbow message) - /blockcmd now uses MiniMessage for its messages - /clownfish now uses MiniMessage for its messages - /notes now uses MiniMessage for its messages - /op now uses MiniMessage for its messages - /plc now uses MiniMessage for its messages - Fixes bug in /stop where the stop message was not showing properly - Condenses /tagrainbow into /tag and integrates /tag gradient into /tag set using MiniMessage - /toggle now uses MiniMessage for its messages - /tossmob now uses MiniMessage for its messages - /unban, /unbanip, and /unbanname now use MiniMessage for its messages - /unblockcmd now uses MiniMessage for its messages - /uncage now uses MiniMessage for its messages - /undisguiseall now uses MiniMessage for its messages - /unlinkdiscord now uses MiniMessage for its messages - /unmute now uses MiniMessage for its messages - /vanish now uses MiniMessage for its messages - /vote now partially uses MiniMessage for its messages - /warn now uses MiniMessage for its messages - Deprecates FreedomCommand.msg(String) for now
This commit is contained in:
parent
922fa4a34f
commit
34269bde09
@ -1,20 +1,24 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
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.TextComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.StyleBuilderApplicable;
|
import net.kyori.adventure.text.format.StyleBuilderApplicable;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.SoundCategory;
|
import org.bukkit.SoundCategory;
|
||||||
@ -23,6 +27,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
|
|
||||||
public class ChatManager extends FreedomService
|
public class ChatManager extends FreedomService
|
||||||
@ -38,107 +45,103 @@ public class ChatManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
|
public void onPlayerChat(AsyncChatEvent event)
|
||||||
{
|
{
|
||||||
try
|
// Important information for later down the line
|
||||||
{
|
String steamrolled = FUtil.steamroll(event.originalMessage());
|
||||||
handleChatEvent(event);
|
Player player = event.getPlayer();
|
||||||
}
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
catch (Exception ex)
|
PlayerData playerData = plugin.pl.getData(player);
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleChatEvent(AsyncPlayerChatEvent event)
|
|
||||||
{
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
String message = event.getMessage().trim();
|
|
||||||
|
|
||||||
// Format colors and strip &k
|
|
||||||
message = FUtil.colorize(message);
|
|
||||||
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
|
||||||
|
|
||||||
|
// Chat is disabled
|
||||||
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.getPlayer().sendMessage(FUtil.miniMessage("<red>The chat is currently disabled."));
|
||||||
playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Truncate messages that are too long - 256 characters is vanilla client max
|
|
||||||
if (message.length() > 256)
|
|
||||||
{
|
|
||||||
message = message.substring(0, 256);
|
|
||||||
FSync.playerMsg(player, "Message was shortened because it was too long to send.");
|
|
||||||
}
|
|
||||||
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
|
||||||
if (fPlayer.isLockedUp())
|
|
||||||
{
|
|
||||||
FSync.playerMsg(player, "You're locked up and cannot talk.");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Locked up
|
||||||
// Check for adminchat
|
else if (fPlayer.isLockedUp())
|
||||||
if (fPlayer.inAdminChat())
|
|
||||||
{
|
{
|
||||||
FSync.adminChatMessage(player, message);
|
event.getPlayer().sendMessage(FUtil.miniMessage("<red>You are locked up and thus can't talk."));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Admin chat is enabled
|
||||||
// Check for 4chan trigger
|
else if (fPlayer.inAdminChat())
|
||||||
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
|
||||||
{
|
{
|
||||||
boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
|
adminChat(player, steamrolled);
|
||||||
boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// The event was already cancelled elsewhere or the player was muted
|
||||||
|
else if (event.isCancelled() || fPlayer.isMuted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (green)
|
// Tag
|
||||||
|
Component tag = Strings.isNullOrEmpty(fPlayer.getTag()) ? Component.empty() : FUtil.miniMessage(fPlayer.getTag())
|
||||||
|
.append(Component.space());
|
||||||
|
|
||||||
|
// Nickname
|
||||||
|
Component nickname = player.displayName();
|
||||||
|
|
||||||
|
// Splitter
|
||||||
|
Component splitter = Component.text("»", NamedTextColor.DARK_GRAY);
|
||||||
|
|
||||||
|
// Message
|
||||||
|
TextComponent.Builder message = Component.text();
|
||||||
|
|
||||||
|
// Truncate the message if it's too long
|
||||||
|
if (steamrolled.length() > 256)
|
||||||
|
{
|
||||||
|
steamrolled = steamrolled.substring(0, 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pinging
|
||||||
|
Arrays.stream(steamrolled.split(" ")).filter(string -> string.startsWith("@")).forEach(possiblePlayer ->
|
||||||
|
{
|
||||||
|
Player potential = server.getPlayer(possiblePlayer.replaceAll("@", ""));
|
||||||
|
|
||||||
|
// Ping only that particular player
|
||||||
|
if (potential != null)
|
||||||
{
|
{
|
||||||
message = ChatColor.GREEN + message;
|
ping(player);
|
||||||
}
|
}
|
||||||
else if (orange)
|
// Ping everyone (if the person pinging is an admin)
|
||||||
|
else if (possiblePlayer.equalsIgnoreCase("@everyone") && plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
message = ChatColor.GOLD + message;
|
server.getOnlinePlayers().forEach(this::ping);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Finally, set message
|
// Chat colorization
|
||||||
event.setMessage(message);
|
// -- 4chan mode --
|
||||||
|
if (steamrolled.startsWith("> ") && ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
||||||
// Make format
|
|
||||||
String format = "%1$s §8\u00BB §f%2$s";
|
|
||||||
|
|
||||||
String tag = fPlayer.getTag();
|
|
||||||
if (tag != null && !tag.isEmpty())
|
|
||||||
{
|
{
|
||||||
format = tag.replace("%", "%%") + " " + format;
|
message.append(Component.text(steamrolled, NamedTextColor.GREEN));
|
||||||
}
|
}
|
||||||
|
// -- Legacy chat colors --
|
||||||
// Check for mentions
|
else if (FUtil.containsChatColor(steamrolled))
|
||||||
String stripped = ChatColor.stripColor(message).toLowerCase();
|
|
||||||
|
|
||||||
/* There is an issue would have allowed muted players to ping players. The issue is caused by the order in which
|
|
||||||
* these event handlers are registered when the plugin starts up. Muter is registered after the ChatManager,
|
|
||||||
* which results in latter being called first (before the former can cancel it). EventPriority does not seem to
|
|
||||||
* make a difference. As a short-term solution I've added this mute check alongside the usual isCancelled check
|
|
||||||
* so that the issue is mitigated, but a long-term solution should be to change the order in which things like
|
|
||||||
* ChatManager and Muter are registered. */
|
|
||||||
if (!event.isCancelled() && !plugin.pl.getPlayer(player).isMuted())
|
|
||||||
{
|
{
|
||||||
server.getOnlinePlayers().forEach(pl ->
|
message.append(FUtil.colorizeAsComponent(steamrolled.replaceAll("&k", "")));
|
||||||
{
|
}
|
||||||
if (stripped.contains("@" + pl.getName()) || (plugin.al.isAdmin(player) && stripped.contains("@everyone")))
|
// -- MiniMessage --
|
||||||
{
|
else
|
||||||
pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, SoundCategory.MASTER, 1337F, 0.9F);
|
{
|
||||||
}
|
message.append(FUtil.miniMessage(steamrolled));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set format
|
// This simply filters out shit like &k in a simple but stupid way.
|
||||||
event.setFormat(format);
|
Component filtered = FUtil.miniMessage(FUtil.miniMessage(message.build()));
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
server.broadcast(FUtil.miniMessage("<tag><nickname> <splitter> <message>",
|
||||||
|
Placeholder.component("tag", tag),
|
||||||
|
Placeholder.component("nickname", nickname),
|
||||||
|
Placeholder.component("splitter", splitter),
|
||||||
|
Placeholder.component("message", filtered)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor(Displayable display)
|
public ChatColor getColor(Displayable display)
|
||||||
@ -193,9 +196,21 @@ public class ChatManager extends FreedomService
|
|||||||
|
|
||||||
public void messageAllAdmins(String message, TagResolver... placeholders)
|
public void messageAllAdmins(String message, TagResolver... placeholders)
|
||||||
{
|
{
|
||||||
Component parsed = FUtil.MINI_MESSAGE.deserialize(message, placeholders);
|
Component parsed = FUtil.miniMessage(message, placeholders);
|
||||||
plugin.getComponentLogger().info(parsed);
|
plugin.getComponentLogger().info(parsed);
|
||||||
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
|
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
|
||||||
player.sendMessage(parsed));
|
player.sendMessage(parsed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void broadcastSplit(String forAdmins, String forOperators, TagResolver... placeholders)
|
||||||
|
{
|
||||||
|
messageAllAdmins(forAdmins, placeholders);
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||||
|
player.sendMessage(FUtil.miniMessage(forOperators, placeholders)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ping(Player player)
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, SoundCategory.MASTER, 1337F, 0.9F);
|
||||||
|
}
|
||||||
}
|
}
|
@ -36,7 +36,6 @@ public class LoginProcess extends FreedomService
|
|||||||
private static boolean lockdownEnabled = false;
|
private static boolean lockdownEnabled = false;
|
||||||
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
||||||
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
||||||
public List<String> CLOWNFISH_TOGGLE = new ArrayList<>();
|
|
||||||
|
|
||||||
public static boolean isLockdownEnabled()
|
public static boolean isLockdownEnabled()
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -19,13 +20,13 @@ public class Command_adminchat extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
msg("You must be in-game to toggle admin chat, it cannot be toggled via CONSOLE or Telnet.");
|
msgNew("<red>You must be in-game to toggle admin chat, it cannot be toggled via CONSOLE or Telnet.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
|
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
|
||||||
userinfo.setAdminChat(!userinfo.inAdminChat());
|
userinfo.setAdminChat(!userinfo.inAdminChat());
|
||||||
msg("Admin chat turned " + (userinfo.inAdminChat() ? "on" : "off") + ".");
|
msgNew("Admin chat turned <status>.", Placeholder.unparsed("status", userinfo.inAdminChat() ? "on" : "off"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -15,7 +16,7 @@ public class Command_attributelist extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
msg("All possible attributes: " + FUtil.listToString(Arrays.stream(Attribute.values()).map(Enum::name).toList()));
|
msgNew("All possible attributes: <attributes>", Placeholder.unparsed("attributes", FUtil.listToString(Arrays.stream(Attribute.values()).map(Enum::name).toList())));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
@ -29,7 +30,8 @@ public class Command_autoclear extends FreedomCommand
|
|||||||
plugin.lp.CLEAR_ON_JOIN.add(args[0]);
|
plugin.lp.CLEAR_ON_JOIN.add(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " have their inventory cleared when they join.");
|
msgNew("<player> will <status> have their inventory cleared when they join.",
|
||||||
|
Placeholder.unparsed("player", args[0]), Placeholder.unparsed("status", enabled ? "no longer" : "now"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
@ -29,8 +30,8 @@ public class Command_autotp extends FreedomCommand
|
|||||||
plugin.lp.TELEPORT_ON_JOIN.add(args[0]);
|
plugin.lp.TELEPORT_ON_JOIN.add(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " be automatically teleported when they join.");
|
msgNew("<player> will <status> be automatically teleported when they join.",
|
||||||
|
Placeholder.unparsed("player", args[0]), Placeholder.unparsed("status", enabled ? "no longer" : "now"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,22 +62,15 @@ public class Command_banip extends FreedomCommand
|
|||||||
plugin.bm.addBan(ban);
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
// Kick player and handle others on IP
|
// Kick player and handle others on IP
|
||||||
for (Player player : server.getOnlinePlayers())
|
server.getOnlinePlayers().stream().filter(player -> FUtil.getIp(player).equalsIgnoreCase(ip)).forEach(player ->
|
||||||
{
|
player.kickPlayer(ban.bakeKickMessage()));
|
||||||
if (FUtil.getIp(player).equals(ip))
|
|
||||||
{
|
|
||||||
player.kickPlayer(ban.bakeKickMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!silent)
|
// Broadcasts the message
|
||||||
{
|
if (!silent)
|
||||||
// Broadcast
|
{
|
||||||
String message = sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
|
plugin.cm.broadcastSplit("<red><sender> - Banned the IP <ip>", "<red><sender> - Banned an IP", Placeholder.unparsed("ip", ip));
|
||||||
msg(player, message, ChatColor.RED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ public class Command_bird extends FreedomCommand
|
|||||||
{
|
{
|
||||||
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
|
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
|
||||||
playerSender.getWorld().spawnEntity(location, getRandomFish());
|
playerSender.getWorld().spawnEntity(location, getRandomFish());
|
||||||
msg(":goodbird:");
|
msgNew("<rainbow>:goodbird:");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
@ -36,7 +36,8 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
playerdata.setCommandsBlocked(false);
|
playerdata.setCommandsBlocked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg("Unblocked commands for " + counter + " players.");
|
|
||||||
|
msgNew("Unblocked commands for <count> players.", Placeholder.unparsed("count", String.valueOf(counter)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,10 +54,10 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
counter += 1;
|
counter += 1;
|
||||||
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
||||||
msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
msgNew(player, "<red>Your commands have been blocked by an admin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Blocked commands for " + counter + " players.");
|
msgNew("Blocked commands for <count> players.", Placeholder.unparsed("count", String.valueOf(counter)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
if (isAdmin(player))
|
if (isAdmin(player))
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is an admin, and cannot have their commands blocked.");
|
msgNew("<player> is an admin, and cannot have their commands blocked.", Placeholder.unparsed("player", player.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,13 +80,13 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
||||||
playerdata.setCommandsBlocked(true);
|
playerdata.setCommandsBlocked(true);
|
||||||
msg("Blocked commands for " + player.getName() + ".");
|
msgNew("Blocked commands for <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
|
|
||||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.BLOCKCMD, null));
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.BLOCKCMD, null));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("That players commands are already blocked.", ChatColor.RED);
|
msgNew("<red>That player's commands are already blocked.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -16,20 +17,27 @@ public class Command_clownfish extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (plugin.sh == null) {
|
if (plugin.sh == null)
|
||||||
sender.sendMessage(Component.text("The shop is currently disabled."));
|
{
|
||||||
|
msgNew("<red>Shop is currently disabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH) && (!plugin.lp.CLOWNFISH_TOGGLE.contains(playerSender.getName())))
|
if (plugin.pl.getData(playerSender).hasItem(ShopItem.CLOWN_FISH))
|
||||||
{
|
{
|
||||||
playerSender.getInventory().addItem(plugin.sh.getClownFish());
|
playerSender.getInventory().addItem(plugin.sh.getClownFish());
|
||||||
msg("You have been given a Clown Fish", ChatColor.GREEN);
|
msgNew("<green>You have been given a <name>.", Placeholder.unparsed("name", ShopItem.CLOWN_FISH.getName()));
|
||||||
|
}
|
||||||
|
else if (plugin.pl.getPlayer(playerSender).isClownfishDisabled())
|
||||||
|
{
|
||||||
|
msgNew("<red>An admin has disabled your ability to use the <name>. Guess you were the clown after all.",
|
||||||
|
Placeholder.unparsed("name", ShopItem.CLOWN_FISH.getName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("You do not own a Clown Fish or an admin has toggled your ability to use it. Purchase one from the shop.", ChatColor.RED);
|
msgNew("<red>You don't own a <name>! Purchase one from the shop.", Placeholder.unparsed("name", ShopItem.CLOWN_FISH.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ import java.util.List;
|
|||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
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.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
@ -17,7 +17,6 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Manage notes for a player", usage = "/<command> <name> <list | add <note> | remove <id> | clear>")
|
@CommandParameters(description = "Manage notes for a player", usage = "/<command> <name> <list | add <note> | remove <id> | clear>")
|
||||||
public class Command_notes extends FreedomCommand
|
public class Command_notes extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -35,7 +34,7 @@ public class Command_notes extends FreedomCommand
|
|||||||
|
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
{
|
{
|
||||||
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,16 +49,15 @@ public class Command_notes extends FreedomCommand
|
|||||||
{
|
{
|
||||||
case "list":
|
case "list":
|
||||||
{
|
{
|
||||||
final StringBuilder noteList = new StringBuilder();
|
msgNew("<green>Player notes for <player>:", Placeholder.unparsed("player", playerData.getName()));
|
||||||
noteList.append(ChatColor.GREEN).append("Player notes for ").append(playerData.getName()).append(":");
|
|
||||||
int id = 1;
|
int id = 1;
|
||||||
for (String note : playerData.getNotes())
|
for (String note : playerData.getNotes())
|
||||||
{
|
{
|
||||||
String noteLine = id + ". " + note;
|
msgNew("<num>. <note>",
|
||||||
noteList.append("\n").append(ChatColor.GOLD).append(noteLine);
|
Placeholder.unparsed("num", String.valueOf(id)),
|
||||||
|
Placeholder.unparsed("note", note));
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
msg(noteList.toString());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +70,7 @@ public class Command_notes extends FreedomCommand
|
|||||||
String note = sender.getName() + ": " + StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
|
String note = sender.getName() + ": " + StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
|
||||||
playerData.addNote(note);
|
playerData.addNote(note);
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
msg("Note added.", ChatColor.GREEN);
|
msgNew("<green>Note added.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +88,7 @@ public class Command_notes extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
msg("Invalid number: " + args[2], ChatColor.RED);
|
msgNew("<red>Invalid number: <num>", Placeholder.unparsed("num", args[2]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,12 +97,13 @@ public class Command_notes extends FreedomCommand
|
|||||||
if (playerData.removeNote(id))
|
if (playerData.removeNote(id))
|
||||||
{
|
{
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
msg("Note removed.");
|
msgNew("<green>Note removed.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("No note with the ID of " + args[2] + " exists.", ChatColor.RED);
|
msgNew("<red>No note with the ID of <id> exists.", Placeholder.unparsed("id", args[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +112,7 @@ public class Command_notes extends FreedomCommand
|
|||||||
int count = playerData.getNotes().size();
|
int count = playerData.getNotes().size();
|
||||||
playerData.clearNotes();
|
playerData.clearNotes();
|
||||||
plugin.pl.save(playerData);
|
plugin.pl.save(playerData);
|
||||||
msg("Cleared " + count + " notes.", ChatColor.GREEN);
|
msgNew("<green>Cleared <count> notes.", Placeholder.unparsed("count", String.valueOf(count)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class Command_op extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("Either the player is already opped, or the player could not be found.");
|
msgNew("Either the player is already opped, or the player could not be found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2,6 +2,10 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
|
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.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -33,9 +37,11 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
Arrays.stream(pm.getPlugins()).forEach(pl ->
|
Arrays.stream(pm.getPlugins()).forEach(pl ->
|
||||||
{
|
{
|
||||||
final String version = pl.getDescription().getVersion();
|
final String version = pl.getDescription().getVersion();
|
||||||
msg(ChatColor.GRAY + "- " + (pl.isEnabled() ? ChatColor.GREEN : ChatColor.RED) + pl.getName()
|
msgNew("<gray>- <statuscolor><name><version> by <authors>",
|
||||||
+ ChatColor.GOLD + (!version.isEmpty() ? " v" + version : "") + " by "
|
TagResolver.resolver("statuscolor", Tag.styling(pl.isEnabled() ? NamedTextColor.GREEN : NamedTextColor.RED)),
|
||||||
+ StringUtils.join(pl.getDescription().getAuthors(), ", "));
|
Placeholder.unparsed("name", pl.getName()),
|
||||||
|
Placeholder.unparsed("version", version.isEmpty() ? " v" + version : ""),
|
||||||
|
Placeholder.unparsed("authors", StringUtils.join(pl.getDescription().getAuthors(), ", ")));
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -53,7 +59,7 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (pl.isEnabled())
|
if (pl.isEnabled())
|
||||||
{
|
{
|
||||||
msg(pl.getName() + " is already enabled.");
|
msgNew("<red><plugin> is already enabled.", Placeholder.unparsed("plugin", pl.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,11 +67,11 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
|
|
||||||
if (pl.isEnabled())
|
if (pl.isEnabled())
|
||||||
{
|
{
|
||||||
msg(pl.getName() + " is now enabled.");
|
msgNew("<green><plugin> is now enabled.", Placeholder.unparsed("plugin", pl.getName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("An error occurred whilst attempting to enable " + pl.getName() + ".");
|
msgNew("<red>An error occurred whilst attempting to enable <plugin>", Placeholder.unparsed("plugin", pl.getName()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -73,32 +79,32 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!pl.isEnabled())
|
if (!pl.isEnabled())
|
||||||
{
|
{
|
||||||
msg(pl.getName() + " is already disabled.");
|
msgNew("<red><plugin> is already disabled.", Placeholder.unparsed("plugin", pl.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (UNTOUCHABLE_PLUGINS.contains(pl.getName()))
|
else if (UNTOUCHABLE_PLUGINS.contains(pl.getName()))
|
||||||
{
|
{
|
||||||
msg(pl.getName() + " can't be disabled.");
|
msgNew("<red><plugin> can't be disabled.", Placeholder.unparsed("plugin", pl.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pm.disablePlugin(pl);
|
pm.disablePlugin(pl);
|
||||||
|
|
||||||
msg(pl.getName() + " is now disabled.");
|
msgNew("<green><plugin> is now disabled.", Placeholder.unparsed("plugin", pl.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "reload" ->
|
case "reload" ->
|
||||||
{
|
{
|
||||||
if (UNTOUCHABLE_PLUGINS.contains(pl.getName()))
|
if (UNTOUCHABLE_PLUGINS.contains(pl.getName()))
|
||||||
{
|
{
|
||||||
msg(pl.getName() + " can't be reloaded.");
|
msgNew("<red><plugin> can't be reloaded.", Placeholder.unparsed("plugin", pl.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pm.disablePlugin(pl);
|
pm.disablePlugin(pl);
|
||||||
pm.enablePlugin(pl);
|
pm.enablePlugin(pl);
|
||||||
|
|
||||||
msg(pl.getName() + " has been reloaded.");
|
msgNew("<green><plugin> has been reloaded.", Placeholder.unparsed("plugin", pl.getName()));;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default ->
|
default ->
|
||||||
@ -109,7 +115,7 @@ public class Command_plugincontrol extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("Plugin not found!");
|
msgNew("<red>Plugin not found!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class Command_stop extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
String reason = args.length != 0 ? "Server is going offline, come back in about 20 seconds." : 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"))
|
if (sender.getName().equals("CONSOLE"))
|
||||||
{
|
{
|
||||||
|
@ -1,39 +1,37 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
|
|
||||||
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(rank = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Allows you to set your own prefix.", usage = "/<command> [-s[ave]] <set <tag..> | list | gradient <hex> <hex> <tag..> | off | clear <player> | clearall>")
|
@CommandParameters(description = "Allows you to set your own prefix.", usage = "/<command> [-ns] <set <tag..> | list | off | clear <player> | clearall>")
|
||||||
public class Command_tag extends FreedomCommand
|
public class Command_tag extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
boolean save = true;
|
||||||
boolean save = false;
|
|
||||||
|
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equals("-s") || args[0].equals("-save"))
|
if (args[0].equalsIgnoreCase("-ns"))
|
||||||
{
|
{
|
||||||
save = true;
|
save = false;
|
||||||
args = ArrayUtils.remove(args, 0);
|
args = ArrayUtils.remove(args, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,142 +144,50 @@ public class Command_tag extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
msg("\"/tag set\" can't be used from the console.");
|
msgNew("<red>\"/tag set\" can't be used from the console.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String inputTag = StringUtils.join(args, " ", 1, args.length);
|
final String inputTag = StringUtils.join(args, " ", 1, args.length);
|
||||||
final String strippedTag = StringUtils.replaceEachRepeatedly(StringUtils.strip(inputTag),
|
Component tag;
|
||||||
new String[]
|
|
||||||
{
|
|
||||||
"" + ChatColor.COLOR_CHAR, "&k"
|
|
||||||
},
|
|
||||||
new String[]
|
|
||||||
{
|
|
||||||
"", ""
|
|
||||||
});
|
|
||||||
|
|
||||||
final String outputTag = FUtil.colorize(strippedTag);
|
if (FUtil.containsChatColor(inputTag))
|
||||||
|
{
|
||||||
|
tag = FUtil.colorizeAsComponent(inputTag.replace("&k", ""));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tag = FUtil.miniMessage(inputTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
String steamrolled = FUtil.steamroll(tag);
|
||||||
int tagLimit = (plugin.al.isAdmin(sender) ? 30 : 20);
|
int tagLimit = (plugin.al.isAdmin(sender) ? 30 : 20);
|
||||||
final String rawTag = ChatColor.stripColor(outputTag).toLowerCase();
|
if (steamrolled.length() > tagLimit)
|
||||||
|
|
||||||
if (rawTag.length() > tagLimit)
|
|
||||||
{
|
{
|
||||||
msg("That tag is too long (Max is " + tagLimit + " characters).");
|
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)))
|
||||||
if (!plugin.al.isAdmin(sender))
|
|
||||||
{
|
{
|
||||||
for (String word : ConfigEntry.FORBIDDEN_WORDS.getStringList())
|
msgNew("<red>That tag contains a forbidden word.");
|
||||||
{
|
|
||||||
if (rawTag.contains(word))
|
|
||||||
{
|
|
||||||
msg("That tag contains a forbidden word.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.pl.getPlayer(playerSender).setTag(outputTag);
|
|
||||||
|
|
||||||
if (save)
|
|
||||||
{
|
|
||||||
save(playerSender, strippedTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Tag set to '" + outputTag + ChatColor.GRAY + "'." + (save ? " (Saved)" : ""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "gradient":
|
|
||||||
{
|
|
||||||
if (senderIsConsole)
|
|
||||||
{
|
|
||||||
msg("\"/tag gradient\" can't be used from the console.");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (args.length < 4)
|
|
||||||
{
|
{
|
||||||
return false;
|
String flattened = FUtil.miniMessage(tag);
|
||||||
}
|
|
||||||
|
|
||||||
String from = "", to = "";
|
plugin.pl.getPlayer(playerSender).setTag(flattened);
|
||||||
java.awt.Color awt1, awt2;
|
|
||||||
|
|
||||||
try
|
if (save)
|
||||||
{
|
|
||||||
if (args[1].equalsIgnoreCase("random") || args[1].equalsIgnoreCase("r"))
|
|
||||||
{
|
{
|
||||||
awt1 = FUtil.getRandomAWTColor();
|
save(playerSender, flattened);
|
||||||
from = " (From: " + FUtil.getHexStringOfAWTColor(awt1) + ")";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
awt1 = java.awt.Color.decode(args[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[2].equalsIgnoreCase("random") || args[2].equalsIgnoreCase("r"))
|
msgNew("Tag set to '<tag>' <saved>",
|
||||||
{
|
Placeholder.component("tag", tag.hoverEvent(HoverEvent.showText(Component.translatable("chat.copy")))
|
||||||
awt2 = FUtil.getRandomAWTColor();
|
.clickEvent(ClickEvent.copyToClipboard(flattened))),
|
||||||
to = " (To: " + FUtil.getHexStringOfAWTColor(awt2) + ")";
|
Placeholder.unparsed("saved", save ? "(Saved)" : ""));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
awt2 = java.awt.Color.decode(args[2]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
|
||||||
{
|
|
||||||
msg("Invalid hex values.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color c1 = FUtil.fromAWT(awt1);
|
|
||||||
Color c2 = FUtil.fromAWT(awt2);
|
|
||||||
String tag = StringUtils.join(args, " ", 3, args.length);
|
|
||||||
List<Color> gradient = FUtil.createColorGradient(c1, c2, tag.length());
|
|
||||||
String[] splitTag = tag.split("");
|
|
||||||
|
|
||||||
for (int i = 0; i < splitTag.length; i++)
|
|
||||||
{
|
|
||||||
splitTag[i] = net.md_5.bungee.api.ChatColor.of(FUtil.toAWT(gradient.get(i))) + splitTag[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
tag = StringUtils.join(splitTag, "");
|
|
||||||
final String outputTag = FUtil.colorize(tag);
|
|
||||||
|
|
||||||
int tagLimit = (plugin.al.isAdmin(sender) ? 30 : 20);
|
|
||||||
|
|
||||||
final String rawTag = ChatColor.stripColor(outputTag).toLowerCase();
|
|
||||||
|
|
||||||
if (rawTag.length() > tagLimit)
|
|
||||||
{
|
|
||||||
msg("That tag is too long (Max is " + tagLimit + " characters).");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(sender))
|
|
||||||
{
|
|
||||||
for (String word : ConfigEntry.FORBIDDEN_WORDS.getStringList())
|
|
||||||
{
|
|
||||||
if (rawTag.contains(word))
|
|
||||||
{
|
|
||||||
msg("That tag contains a forbidden word.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.pl.getPlayer(playerSender).setTag(outputTag);
|
|
||||||
|
|
||||||
if (save)
|
|
||||||
{
|
|
||||||
save(playerSender, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("Tag set to '" + outputTag + ChatColor.GRAY + "'." + (save ? " (Saved)" : "") + from + to);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
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 = "Give yourself a prefix with rainbow colors.", usage = "/<command> <tag>")
|
|
||||||
public class Command_tagrainbow extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String tag = ChatColor.stripColor(FUtil.colorize(StringUtils.join(args, " ")));
|
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(sender))
|
|
||||||
{
|
|
||||||
final String rawTag = ChatColor.stripColor(tag).toLowerCase();
|
|
||||||
|
|
||||||
if (rawTag.length() > 20)
|
|
||||||
{
|
|
||||||
msg("That tag is too long (Max is 20 characters).");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String word : ConfigEntry.FORBIDDEN_WORDS.getStringList())
|
|
||||||
{
|
|
||||||
if (rawTag.contains(word))
|
|
||||||
{
|
|
||||||
msg("That tag contains a forbidden word.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.pl.getPlayer(playerSender).setTag(FUtil.rainbowify(tag));
|
|
||||||
msg("Set tag to " + tag);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,11 +29,8 @@ public class Command_toggle extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
msg("Available toggles: ");
|
msgNew("Available toggles: ");
|
||||||
for (String toggle : toggles)
|
toggles.forEach(toggle -> msgNew("- <toggle>", Placeholder.unparsed("toggle", toggle)));
|
||||||
{
|
|
||||||
msg("- " + toggle);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +67,7 @@ public class Command_toggle extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("<red>The input provided is not a valid integer.");
|
msgNew("<red>The input provided is not a valid integer.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +103,7 @@ public class Command_toggle extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("<red>The input provided is not a valid integer.");
|
msgNew("<red>The input provided is not a valid integer.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,11 +136,8 @@ public class Command_toggle extends FreedomCommand
|
|||||||
case "chat" -> toggle("Chat is", ConfigEntry.TOGGLE_CHAT);
|
case "chat" -> toggle("Chat is", ConfigEntry.TOGGLE_CHAT);
|
||||||
default ->
|
default ->
|
||||||
{
|
{
|
||||||
msg("Available toggles: ");
|
msgNew("Available toggles: ");
|
||||||
for (String toggle : toggles)
|
toggles.forEach(toggle -> msgNew("- <toggle>", Placeholder.unparsed("toggle", toggle)));
|
||||||
{
|
|
||||||
msg("- " + toggle);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +146,8 @@ public class Command_toggle extends FreedomCommand
|
|||||||
|
|
||||||
private void toggle(final String name, final ConfigEntry entry)
|
private void toggle(final String name, final ConfigEntry entry)
|
||||||
{
|
{
|
||||||
msg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled."));
|
msgNew("<name> now <status>.", Placeholder.unparsed("name", name), Placeholder.unparsed("status",
|
||||||
|
entry.setBoolean(!entry.getBoolean()) ? "enabled" : "disabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
@ -9,7 +11,6 @@ import org.bukkit.entity.Player;
|
|||||||
@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
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -18,19 +19,19 @@ public class Command_toggleclownfish extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean enabled = plugin.lp.CLOWNFISH_TOGGLE.contains(args[0]);
|
Player player = server.getPlayer(args[0]);
|
||||||
|
if (player == null)
|
||||||
if (enabled)
|
|
||||||
{
|
{
|
||||||
plugin.lp.CLOWNFISH_TOGGLE.remove(args[0]);
|
msg(PLAYER_NOT_FOUND);
|
||||||
}
|
return true;
|
||||||
else
|
|
||||||
{
|
|
||||||
plugin.lp.CLOWNFISH_TOGGLE.add(args[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(args[0] + " will " + (enabled ? "now" : "no longer") + " have the ability to use clownfish.");
|
FPlayer fplayer = plugin.pl.getPlayer(player);
|
||||||
|
fplayer.setClownfishDisabled(!fplayer.isClownfishDisabled());
|
||||||
|
|
||||||
|
msgNew("<player> will <status> have the ability to use the Clownfish.",
|
||||||
|
Placeholder.unparsed("player", args[0]),
|
||||||
|
Placeholder.unparsed("status", fplayer.isClownfishDisabled() ? "no longer" : "now"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -24,7 +24,7 @@ public class Command_tossmob extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!ConfigEntry.TOSSMOB_ENABLED.getBoolean())
|
if (!ConfigEntry.TOSSMOB_ENABLED.getBoolean())
|
||||||
{
|
{
|
||||||
msg("Tossmob is currently disabled.");
|
msgNew("<red>Tossmob is currently disabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,13 +39,13 @@ public class Command_tossmob extends FreedomCommand
|
|||||||
if (args[0].equalsIgnoreCase("off"))
|
if (args[0].equalsIgnoreCase("off"))
|
||||||
{
|
{
|
||||||
playerData.disableMobThrower();
|
playerData.disableMobThrower();
|
||||||
msg("Turned off.", ChatColor.GREEN);
|
msgNew("<green>Tossmob has been turned off.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
msg("Supported mobs: " + Groups.MOB_TYPES.stream().map(Enum::name).toList(), ChatColor.GREEN);
|
msgNew("<green>Supported mobs: <mobs>", Placeholder.unparsed("mobs", String.join(", ", Groups.MOB_TYPES.stream().map(Enum::name).toList())));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +60,13 @@ public class Command_tossmob extends FreedomCommand
|
|||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
msg("Unknown entity type: " + args[0], ChatColor.RED);
|
msgNew("<red>Unknown entity type: <type>", Placeholder.unparsed("type", args[0]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Groups.MOB_TYPES.contains(type))
|
if (!Groups.MOB_TYPES.contains(type))
|
||||||
{
|
{
|
||||||
msg(FUtil.formatName(type.name()) + " is an entity, however it is not a mob.", ChatColor.RED);
|
msgNew("<red><entity> is an entity, however it is not a mob.", Placeholder.unparsed("entity", FUtil.formatName(type.name())));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public class Command_tossmob extends FreedomCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
msg("The input provided is not a valid integer.");
|
msgNew("<red>The input provided is not a valid integer.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,9 +94,11 @@ public class Command_tossmob extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
playerData.enableMobThrower(type, speed);
|
playerData.enableMobThrower(type, speed);
|
||||||
msg("MobThrower is enabled. Mob: " + type + " - Speed: " + speed + ".", ChatColor.GREEN);
|
msgNew("<green>Tossmob is enabled. Mob: <type> - Speed: <speed>.",
|
||||||
msg("Right click while holding a " + Material.BONE.toString() + " to throw mobs!", ChatColor.GREEN);
|
Placeholder.unparsed("type", String.valueOf(type)),
|
||||||
msg("Type '/tossmob off' to disable. -By Madgeek1450", ChatColor.GREEN);
|
Placeholder.unparsed("speed", String.valueOf(speed)));
|
||||||
|
msgNew("<green>Right click while holding a Bone to throw mobs!");
|
||||||
|
msgNew("<green>Type '/tossmob off' to disable. - By Madgeek1450");
|
||||||
|
|
||||||
Objects.requireNonNull(playerSender.getEquipment()).setItemInMainHand(new ItemStack(Material.BONE, 1));
|
Objects.requireNonNull(playerSender.getEquipment()).setItemInMainHand(new ItemStack(Material.BONE, 1));
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,6 +4,7 @@ import com.earth2me.essentials.User;
|
|||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
@ -45,14 +46,15 @@ public class Command_unban extends FreedomCommand
|
|||||||
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
||||||
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
||||||
plugin.bm.removeBan(plugin.bm.getByIp(ip));
|
plugin.bm.removeBan(plugin.bm.getByIp(ip));
|
||||||
msg(username + " has been unbanned along with the IP: " + ip);
|
msgNew("<player> has been unbanned along with the IP: <ip>",
|
||||||
|
Placeholder.unparsed("player", username), Placeholder.unparsed("ip", ip));
|
||||||
|
|
||||||
if (args.length >= 2)
|
if (args.length >= 2 && plugin.cpb.isEnabled())
|
||||||
{
|
{
|
||||||
if (args[1].equalsIgnoreCase("-r"))
|
if (args[1].equalsIgnoreCase("-r"))
|
||||||
{
|
{
|
||||||
plugin.cpb.restore(username);
|
plugin.cpb.restore(username);
|
||||||
msg("Restored edits for: " + username);
|
msgNew("Restored <player>'s edits as well.", Placeholder.unparsed("player", username));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -3,13 +3,14 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
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;
|
||||||
|
|
||||||
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(rank = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Unbans the specified ip.", usage = "/<command> <ip> [-q]")
|
@CommandParameters(description = "Unbans the specified IP.", usage = "/<command> <ip> [-q]")
|
||||||
public class Command_unbanip extends FreedomCommand
|
public class Command_unbanip extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ public class Command_unbanip extends FreedomCommand
|
|||||||
|
|
||||||
if (FUtil.isValidIPv4(ip))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,13 +36,13 @@ public class Command_unbanip extends FreedomCommand
|
|||||||
|
|
||||||
if (ban == null)
|
if (ban == null)
|
||||||
{
|
{
|
||||||
msg("The ip " + ip + " is not banned", ChatColor.RED);
|
msgNew("<red><ip> is not a banned IP address.", Placeholder.unparsed("ip", ip));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ban.hasUsername())
|
if (ban.hasUsername())
|
||||||
{
|
{
|
||||||
msg("This ban is not an ip-only ban.");
|
msgNew("<red>This ban is not an IP-only ban.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +55,9 @@ public class Command_unbanip extends FreedomCommand
|
|||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unbanned the ip " + ip, true);
|
plugin.cm.broadcastSplit("<red><sender> - Unbanned the IP <ip>", "<red><sender> - Unbanned an IP",
|
||||||
|
Placeholder.unparsed("sender", sender.getName()),
|
||||||
|
Placeholder.unparsed("ip", ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -29,13 +30,12 @@ public class Command_unbanname extends FreedomCommand
|
|||||||
|
|
||||||
if (ban == null)
|
if (ban == null)
|
||||||
{
|
{
|
||||||
msg("The name " + name + " is not banned", ChatColor.RED);
|
msgNew("<red>The name <name> is not banned.", Placeholder.unparsed("name", name));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (ban.hasIps())
|
||||||
if (ban.hasIps())
|
|
||||||
{
|
{
|
||||||
msg("This ban is not a name-only ban.");
|
msgNew("<red>This ban is not a name-only ban.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,11 +33,11 @@ public class Command_unblockcmd extends FreedomCommand
|
|||||||
{
|
{
|
||||||
fPlayer.setCommandsBlocked(false);
|
fPlayer.setCommandsBlocked(false);
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking all commands for " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Unblocking all commands for " + player.getName(), true);
|
||||||
msg("Unblocked commands for " + player.getName() + ".");
|
msgNew("Unblocked commands for <player>.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("That players commands aren't blocked.", ChatColor.RED);
|
msgNew("<red>That player's commands aren't blocked.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public class Command_uncage extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("That player is not caged!", ChatColor.RED);
|
msgNew("<red>That player is not caged!");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class Command_undisguiseall extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!plugin.ldb.isEnabled())
|
if (!plugin.ldb.isEnabled())
|
||||||
{
|
{
|
||||||
msg("LibsDisguises is not enabled.");
|
msgNew("<red>LibsDisguises is not enabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -17,7 +18,7 @@ public class Command_unlinkdiscord extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (plugin.dc == null || !plugin.dc.isEnabled())
|
if (plugin.dc == null || !plugin.dc.isEnabled())
|
||||||
{
|
{
|
||||||
msg("The Discord integration system is currently disabled.", ChatColor.RED);
|
msgNew("<red>The Discord integration system is currently disabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,19 +32,19 @@ public class Command_unlinkdiscord extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
playerData.setDiscordID(null);
|
playerData.setDiscordID(null);
|
||||||
msg("Unlinked " + args[0] + "'s Discord account.", ChatColor.GREEN);
|
msgNew("<green>Unlinked <player>'s Discord account.", Placeholder.unparsed("player", playerData.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerData data = plugin.pl.getData(playerSender);
|
PlayerData data = plugin.pl.getData(playerSender);
|
||||||
if (data.getDiscordID() == null)
|
if (data.getDiscordID() == null)
|
||||||
{
|
{
|
||||||
msg("Your Minecraft account is not linked to a Discord account.", ChatColor.RED);
|
msgNew("<red>Your Minecraft account is not linked to a Discord account.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
data.setDiscordID(null);
|
data.setDiscordID(null);
|
||||||
plugin.pl.save(data);
|
plugin.pl.save(data);
|
||||||
msg("Your Minecraft account has been successfully unlinked from the Discord account.", ChatColor.GREEN);
|
msgNew("<green>Your Minecraft account has been successfully unlinked from the Discord account.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -13,7 +14,6 @@ import org.bukkit.entity.Player;
|
|||||||
@CommandParameters(description = "Unmutes a player", usage = "/<command> [-q] <player>")
|
@CommandParameters(description = "Unmutes a player", usage = "/<command> [-q] <player>")
|
||||||
public class Command_unmute extends FreedomCommand
|
public class Command_unmute extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -45,22 +45,25 @@ public class Command_unmute extends FreedomCommand
|
|||||||
if (playerdata.isMuted())
|
if (playerdata.isMuted())
|
||||||
{
|
{
|
||||||
playerdata.setMuted(false);
|
playerdata.setMuted(false);
|
||||||
player.sendTitle(ChatColor.RED + "You've been unmuted.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
FUtil.playerTitle(sender, "<red>You have been unmuted.", "<yellow>Be sure to follow the rules!");
|
||||||
|
msgNew("<green>You have been unmuted.");
|
||||||
|
|
||||||
if (quiet)
|
if (quiet)
|
||||||
{
|
{
|
||||||
msg("Unmuted " + player.getName() + " quietly");
|
msgNew("Quietly unmuted <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
{
|
||||||
msg("Unmuted " + player.getName());
|
FUtil.adminAction(sender.getName(), "Unmuting " + player.getName(), true);
|
||||||
msg(player, "You have been unmuted.", ChatColor.RED);
|
msgNew("Unmuted <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg(ChatColor.RED + "That player is not muted.");
|
msgNew("<red>That player is not muted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ 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.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
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;
|
||||||
@ -38,11 +39,11 @@ public class Command_vanish extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (silent)
|
if (silent)
|
||||||
{
|
{
|
||||||
msg(ChatColor.GOLD + "Silently unvanished.");
|
msgNew("<gold>Silently unvanished.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("You have unvanished.", ChatColor.GOLD);
|
msgNew("<gold>You have unvanished.");
|
||||||
FUtil.bcastMsg(plugin.rm.craftLoginMessage(playerSender, null));
|
FUtil.bcastMsg(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));
|
||||||
@ -59,16 +60,11 @@ public class Command_vanish extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugin.pl.getData(playerSender).setTag(tag);
|
plugin.pl.getData(playerSender).setTag(tag);
|
||||||
FLog.info(playerSender.getName() + " is no longer vanished.");
|
plugin.cm.messageAllAdmins("<yellow><player> has unvanished and is now visible to everyone.", Placeholder.unparsed("player", sender.getName()));
|
||||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + sender.getName() + " has unvanished and is now visible to everyone.");
|
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||||
|
player.showPlayer(plugin, playerSender));
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (!plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
player.showPlayer(plugin, playerSender);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.esb.setVanished(playerSender.getName(), false);
|
plugin.esb.setVanished(playerSender.getName(), false);
|
||||||
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
playerSender.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
||||||
AdminList.vanished.remove(playerSender.getUniqueId());
|
AdminList.vanished.remove(playerSender.getUniqueId());
|
||||||
@ -93,11 +89,11 @@ public class Command_vanish extends FreedomCommand
|
|||||||
|
|
||||||
if (silent)
|
if (silent)
|
||||||
{
|
{
|
||||||
msg("Silently vanished.", ChatColor.GOLD);
|
msgNew("<gold>Silently vanished.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg("You have vanished.", ChatColor.GOLD);
|
msgNew("<gold>You have vanished.");
|
||||||
server.broadcast(Component.translatable("multiplayer.player.left", Component.text(playerSender.getName()))
|
server.broadcast(Component.translatable("multiplayer.player.left", Component.text(playerSender.getName()))
|
||||||
.color(NamedTextColor.YELLOW));
|
.color(NamedTextColor.YELLOW));
|
||||||
if (plugin.dc != null) {
|
if (plugin.dc != null) {
|
||||||
@ -105,8 +101,7 @@ public class Command_vanish extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FLog.info(playerSender.getName() + " is now vanished.");
|
plugin.cm.messageAllAdmins("<yellow><player> has vanished and is now only visible to admins.", Placeholder.unparsed("player", sender.getName()));
|
||||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + sender.getName() + " has vanished and is now only visible to admins.");
|
|
||||||
|
|
||||||
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||||
player.hidePlayer(plugin,playerSender));
|
player.hidePlayer(plugin,playerSender));
|
||||||
|
@ -22,7 +22,7 @@ public class Command_vote extends FreedomCommand
|
|||||||
|
|
||||||
if (voteInfo.isEmpty())
|
if (voteInfo.isEmpty())
|
||||||
{
|
{
|
||||||
msg(Component.text("The voting information section of the config.yml file has not been configured.", NamedTextColor.RED));
|
msgNew("<red>The voting information section of the config.yml file has not been configured.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -61,9 +61,7 @@ public class Command_warn extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
player.showTitle(Title.title(Component.text("You have been warned.", NamedTextColor.RED),
|
FUtil.playerTitle(player, "<red>You have been warned.", "<yellow>Reason: <reason>", Placeholder.unparsed("reason", warnReason));
|
||||||
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));
|
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.pl.getPlayer(player).incrementWarnings(quiet);
|
||||||
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.WARN, warnReason));
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.WARN, warnReason));
|
||||||
@ -74,15 +72,10 @@ public class Command_warn extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String adminNotice = ChatColor.RED +
|
plugin.cm.messageAllAdmins("<red><sender> - Warning: <player> - Reason: <yellow><reason> ",
|
||||||
sender.getName() +
|
Placeholder.unparsed("sender", sender.getName()),
|
||||||
" - " +
|
Placeholder.unparsed("player", player.getName()),
|
||||||
"Warning: " +
|
Placeholder.unparsed("reason", warnReason));
|
||||||
player.getName() +
|
|
||||||
" - Reason: " +
|
|
||||||
ChatColor.YELLOW +
|
|
||||||
warnReason;
|
|
||||||
plugin.al.messageAllAdmins(adminNotice);
|
|
||||||
|
|
||||||
msgNew("You have successfully warned <player>.", Placeholder.unparsed("player", player.getName()));
|
msgNew("You have successfully warned <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
}
|
}
|
||||||
|
@ -133,11 +133,13 @@ public abstract class FreedomCommand implements CommandExecutor, TabCompleter
|
|||||||
player.sendMessage(ChatColor.GRAY + message);
|
player.sendMessage(ChatColor.GRAY + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
protected void msg(Player player, String message, ChatColor color)
|
protected void msg(Player player, String message, ChatColor color)
|
||||||
{
|
{
|
||||||
player.sendMessage(color + message);
|
player.sendMessage(color + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
protected void msg(String message)
|
protected void msg(String message)
|
||||||
{
|
{
|
||||||
msg(sender, message);
|
msg(sender, message);
|
||||||
|
@ -228,7 +228,7 @@ public class ItemFun extends FreedomService
|
|||||||
final int RADIUS_HIT = 5;
|
final int RADIUS_HIT = 5;
|
||||||
final int STRENGTH = 4;
|
final int STRENGTH = 4;
|
||||||
|
|
||||||
if (plugin.lp.CLOWNFISH_TOGGLE.contains(player.getName()))
|
if (plugin.pl.getPlayer(player).isClownfishDisabled())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GRAY + "An admin has disabled your ability to use clownfish.");
|
player.sendMessage(ChatColor.GRAY + "An admin has disabled your ability to use clownfish.");
|
||||||
break;
|
break;
|
||||||
|
@ -63,6 +63,8 @@ public class FPlayer
|
|||||||
|
|
||||||
private boolean invSee = false;
|
private boolean invSee = false;
|
||||||
|
|
||||||
|
private boolean clownfishDisabled = false;
|
||||||
|
|
||||||
public FPlayer(TotalFreedomMod plugin, Player player)
|
public FPlayer(TotalFreedomMod plugin, Player player)
|
||||||
{
|
{
|
||||||
this(plugin, player.getUniqueId(), player.getName(), FUtil.getIp(player));
|
this(plugin, player.getUniqueId(), player.getName(), FUtil.getIp(player));
|
||||||
@ -350,14 +352,7 @@ public class FPlayer
|
|||||||
|
|
||||||
public void setTag(String tag)
|
public void setTag(String tag)
|
||||||
{
|
{
|
||||||
if (tag == null)
|
this.tag = tag;
|
||||||
{
|
|
||||||
this.tag = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.tag = FUtil.colorize(tag) + ChatColor.WHITE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incrementWarnings(boolean quiet)
|
public void incrementWarnings(boolean quiet)
|
||||||
@ -442,6 +437,16 @@ public class FPlayer
|
|||||||
this.invSee = invSee;
|
this.invSee = invSee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isClownfishDisabled()
|
||||||
|
{
|
||||||
|
return clownfishDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClownfishDisabled(boolean bool)
|
||||||
|
{
|
||||||
|
this.clownfishDisabled = bool;
|
||||||
|
}
|
||||||
|
|
||||||
private static class ArrowShooter extends BukkitRunnable
|
private static class ArrowShooter extends BukkitRunnable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -167,7 +167,8 @@ public class RankManager extends FreedomService
|
|||||||
fPlayer.setTag(null);
|
fPlayer.setTag(null);
|
||||||
player.setPlayerListName(null);
|
player.setPlayerListName(null);
|
||||||
}
|
}
|
||||||
fPlayer.setTag(getTag(player, display.getColoredTag()));
|
// FIXME: Adjust Rank to use MiniMessage instead of the legacy stuff
|
||||||
|
fPlayer.setTag(getTag(player, FUtil.miniMessage(FUtil.colorizeAsComponent(display.getColoredTag()))));
|
||||||
updatePlayerTeam(player);
|
updatePlayerTeam(player);
|
||||||
plugin.pem.setPermissions(player);
|
plugin.pem.setPermissions(player);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package me.totalfreedom.totalfreedommod.util;
|
package me.totalfreedom.totalfreedommod.util;
|
||||||
|
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class FConverter
|
public class FConverter
|
||||||
{
|
{
|
||||||
private static final Pattern godFuckingDamnit = Pattern.compile(".*(?i)(&((#[a-f0-9]{3,6})|([0-9a-fklmnopr]))|%[a-z]+%).*");
|
private static final Pattern godFuckingDamnit = Pattern.compile(".*(?i)(&((#[a-f0-9]{3,6})|([0-9a-fklmnor]))|%[a-z]+%).*");
|
||||||
|
|
||||||
public static boolean needsConversion(String messageOrFormat)
|
public static boolean needsConversion(String messageOrFormat)
|
||||||
{
|
{
|
||||||
@ -15,18 +13,11 @@ public class FConverter
|
|||||||
|
|
||||||
public static String convertAdminChatFormat(String format)
|
public static String convertAdminChatFormat(String format)
|
||||||
{
|
{
|
||||||
// %name%
|
|
||||||
// %rank%
|
|
||||||
// %rankcolor%
|
|
||||||
// %msg%
|
|
||||||
|
|
||||||
return FUtil.MINI_MESSAGE.serialize(FUtil.LEGACY_AMPERSAND.deserialize(
|
return FUtil.MINI_MESSAGE.serialize(FUtil.LEGACY_AMPERSAND.deserialize(
|
||||||
format.replaceAll("%name%", "<name>")
|
format.replaceAll("%name%", "<name>")
|
||||||
.replaceAll("%rank%", "<rank>")
|
.replaceAll("%rank%", "<rank>")
|
||||||
.replaceAll("%rankcolor%", "<rankcolor>")
|
.replaceAll("%rankcolor%", "<rankcolor>")
|
||||||
.replaceAll("%msg%", "<message>")))
|
.replaceAll("%msg%", "<message>")))
|
||||||
.replaceAll("\\\\<", "<"); // GOD FUCKING DAMMIT
|
.replaceAll("\\\\<", "<"); // GOD FUCKING DAMMIT
|
||||||
|
|
||||||
//zTagResolver.resolver("rankcolor", Tag.styling(lol -> lol.color()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
|||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import net.kyori.adventure.title.Title;
|
import net.kyori.adventure.title.Title;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.WordUtils;
|
import org.apache.commons.lang.WordUtils;
|
||||||
@ -19,7 +20,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.jetbrains.annotations.Contract;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
@ -80,6 +80,8 @@ public class FUtil
|
|||||||
"Taahh",
|
"Taahh",
|
||||||
"G6_",
|
"G6_",
|
||||||
"ayunami2000");
|
"ayunami2000");
|
||||||
|
|
||||||
|
private static final PlainTextComponentSerializer STEAMROLLER = PlainTextComponentSerializer.plainText();
|
||||||
public static final LegacyComponentSerializer LEGACY_AMPERSAND = LegacyComponentSerializer.legacyAmpersand();
|
public static final LegacyComponentSerializer LEGACY_AMPERSAND = LegacyComponentSerializer.legacyAmpersand();
|
||||||
public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().tags(TagResolver.resolver(
|
public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().tags(TagResolver.resolver(
|
||||||
StandardTags.color(),
|
StandardTags.color(),
|
||||||
@ -89,7 +91,6 @@ public class FUtil
|
|||||||
StandardTags.decorations(TextDecoration.BOLD),
|
StandardTags.decorations(TextDecoration.BOLD),
|
||||||
StandardTags.decorations(TextDecoration.STRIKETHROUGH),
|
StandardTags.decorations(TextDecoration.STRIKETHROUGH),
|
||||||
StandardTags.decorations(TextDecoration.UNDERLINED))).build();
|
StandardTags.decorations(TextDecoration.UNDERLINED))).build();
|
||||||
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
|
||||||
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
||||||
ChatColor.DARK_RED,
|
ChatColor.DARK_RED,
|
||||||
ChatColor.RED,
|
ChatColor.RED,
|
||||||
@ -103,15 +104,11 @@ public class FUtil
|
|||||||
ChatColor.DARK_BLUE,
|
ChatColor.DARK_BLUE,
|
||||||
ChatColor.DARK_PURPLE,
|
ChatColor.DARK_PURPLE,
|
||||||
ChatColor.LIGHT_PURPLE);
|
ChatColor.LIGHT_PURPLE);
|
||||||
|
private static final Pattern CHATCOLOR_PATTERN = Pattern.compile(".*(?i)(&((#[a-f0-9]{3,6})|([0-9a-fklmnor]))).*");
|
||||||
private static final SplittableRandom RANDOM = new SplittableRandom();
|
private static final SplittableRandom RANDOM = new SplittableRandom();
|
||||||
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
||||||
private static final List<String> regxList = Arrays.asList("y", "mo", "w", "d", "h", "m", "s");
|
private static final List<String> regxList = Arrays.asList("y", "mo", "w", "d", "h", "m", "s");
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
CHAT_COLOR_POOL.forEach(color -> CHAT_COLOR_NAMES.put(color.name().toLowerCase().replace("_", ""), color));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void cancel(BukkitTask task)
|
public static void cancel(BukkitTask task)
|
||||||
{
|
{
|
||||||
if (task == null)
|
if (task == null)
|
||||||
@ -498,6 +495,21 @@ public class FUtil
|
|||||||
return MINI_MESSAGE.deserialize(string, placeholders);
|
return MINI_MESSAGE.deserialize(string, placeholders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String miniMessage(Component component)
|
||||||
|
{
|
||||||
|
return MINI_MESSAGE.serialize(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String steamroll(Component text)
|
||||||
|
{
|
||||||
|
return STEAMROLLER.serialize(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean containsChatColor(String input)
|
||||||
|
{
|
||||||
|
return CHATCOLOR_PATTERN.matcher(input).find();
|
||||||
|
}
|
||||||
|
|
||||||
public static String stripColors(String string)
|
public static String stripColors(String string)
|
||||||
{
|
{
|
||||||
return string.replaceAll("§", "");
|
return string.replaceAll("§", "");
|
||||||
|
Loading…
Reference in New Issue
Block a user