This commit is contained in:
ayunami2000 2022-04-09 21:53:27 -04:00
parent de20747d45
commit b1ef89dae9
10 changed files with 45 additions and 12 deletions

View File

@ -160,7 +160,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
}
catch (PlayerNotFoundException | CommandFailException | ConsoleOnlyException | ConsoleMustDefinePlayerException | PlayerNotBannedException ex)
{
send(sender, MiniMessage.miniMessage().deserialize(ex.getMessage()));
send(sender, PlexUtils.mmDeserialize(ex.getMessage()));
}
return true;
}
@ -544,7 +544,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
*/
protected Component mmString(String s)
{
return MiniMessage.miniMessage().deserialize(s);
return PlexUtils.mmDeserialize(s);
}
public Rank getLevel()

View File

@ -7,6 +7,7 @@ import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.player.PlexPlayer;
import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
@ -48,7 +49,7 @@ public class TagCMD extends PlexCommand
}
String prefix = StringUtils.join(args, " ", 1, args.length);
Component convertedComponent = removeEvents(noColorComponentFromString(prefix));
convertedComponent = removeEvents(MiniMessage.miniMessage().deserialize(LegacyComponentSerializer.legacySection().serialize(convertedComponent)));
convertedComponent = removeEvents(PlexUtils.mmDeserialize(LegacyComponentSerializer.legacySection().serialize(convertedComponent)));
if (PlainTextComponentSerializer.plainText().serialize(convertedComponent).length() > plugin.config.getInt("chat.max-tag-length", 16))
{

View File

@ -47,7 +47,7 @@ public class UnbanCMD extends PlexCommand
PlexPlayer plexPlayer = getOfflinePlexPlayer(targetUUID);
if (!aBoolean)
{
send(sender, MiniMessage.miniMessage().deserialize(new PlayerNotBannedException().getMessage()));
send(sender, PlexUtils.mmDeserialize(new PlayerNotBannedException().getMessage()));
return;
}
plugin.getPunishmentManager().unban(targetUUID);

View File

@ -8,7 +8,6 @@ import dev.plex.command.blocker.RegexCommand;
import dev.plex.listener.PlexListener;
import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -65,7 +64,7 @@ public class CommandListener extends PlexListener
{
event.setCancelled(true);
//PlexLog.debug("Command blocked.");
player.sendMessage(MiniMessage.miniMessage().deserialize(PlexUtils.messageString("blockedCommandColor") + blockedCommand.getMessage()));
player.sendMessage(PlexUtils.mmDeserialize(PlexUtils.messageString("blockedCommandColor") + blockedCommand.getMessage()));
return;
}
}

View File

@ -77,7 +77,7 @@ public class PlayerListener extends PlexListener
String loginMessage = plugin.getRankManager().getLoginMessage(plexPlayer);
if (!loginMessage.isEmpty())
{
PlexUtils.broadcast(MiniMessage.miniMessage().deserialize("<aqua>" + player.getName() + " is " + loginMessage));
PlexUtils.broadcast(PlexUtils.mmDeserialize("<aqua>" + player.getName() + " is " + loginMessage));
}
if (plugin.getStorageType() != StorageType.MONGODB)

View File

@ -95,7 +95,7 @@ public class RankManager
{
if (!player.getPrefix().equals(""))
{
return MiniMessage.miniMessage().deserialize(player.getPrefix());
return PlexUtils.mmDeserialize(player.getPrefix());
}
if (Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName()))
{

View File

@ -1,5 +1,6 @@
package dev.plex.rank.enums;
import dev.plex.util.PlexUtils;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
@ -47,7 +48,7 @@ public enum Rank
public Component getPrefix()
{
return MiniMessage.miniMessage().deserialize(this.prefix);
return PlexUtils.mmDeserialize(this.prefix);
}
public JSONObject toJSON()

View File

@ -1,5 +1,6 @@
package dev.plex.rank.enums;
import dev.plex.util.PlexUtils;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
@ -39,7 +40,7 @@ public enum Title
public Component getPrefix()
{
return MiniMessage.miniMessage().deserialize(this.prefix);
return PlexUtils.mmDeserialize(this.prefix);
}
public JSONObject toJSON()

View File

@ -7,7 +7,13 @@ import dev.plex.PlexBase;
import dev.plex.config.Config;
import dev.plex.storage.StorageType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.Context;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.ParsingException;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import net.kyori.adventure.text.minimessage.tag.standard.*;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.*;
@ -15,6 +21,8 @@ import org.bukkit.command.Command;
import org.bukkit.command.PluginCommandYamlParser;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
@ -145,9 +153,32 @@ public class PlexUtils extends PlexBase
return ChatColor.translateAlternateColorCodes('&', string);
}
private static MiniMessage eggMessage = MiniMessage.builder().tags(new TagResolver()
{
@Override
public @Nullable Tag resolve(@NotNull String name, @NotNull ArgumentQueue arguments, @NotNull Context ctx) throws ParsingException
{
return StandardTags.rainbow().resolve("rainbow", arguments, ctx);
}
@Override
public boolean has(@NotNull String name)
{
return true;
}
}
).build();
public static Component mmDeserialize(String input)
{
Calendar calendar = Calendar.getInstance();
MiniMessage mm = (calendar.get(Calendar.MONTH) == Calendar.APRIL && calendar.get(Calendar.DAY_OF_MONTH) == 1 && (!plugin.config.contains("april_fools") || plugin.config.getBoolean("april_fools"))) ? eggMessage : MiniMessage.miniMessage();
return mm.deserialize(input);
}
public static Component messageComponent(String entry, Object... objects)
{
return MiniMessage.miniMessage().deserialize(messageString(entry, objects));
return mmDeserialize(messageString(entry, objects));
}
public static String messageString(String entry, Object... objects)

View File

@ -149,7 +149,7 @@ public class UpdateChecker extends PlexBase
private void sendMini(CommandSender sender, String message)
{
sender.sendMessage(MiniMessage.miniMessage().deserialize(message));
sender.sendMessage(PlexUtils.mmDeserialize(message));
}
public void updateJar(CommandSender sender)