mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
fix bug
This commit is contained in:
parent
de20747d45
commit
b1ef89dae9
@ -160,7 +160,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
}
|
}
|
||||||
catch (PlayerNotFoundException | CommandFailException | ConsoleOnlyException | ConsoleMustDefinePlayerException | PlayerNotBannedException ex)
|
catch (PlayerNotFoundException | CommandFailException | ConsoleOnlyException | ConsoleMustDefinePlayerException | PlayerNotBannedException ex)
|
||||||
{
|
{
|
||||||
send(sender, MiniMessage.miniMessage().deserialize(ex.getMessage()));
|
send(sender, PlexUtils.mmDeserialize(ex.getMessage()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -544,7 +544,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
*/
|
*/
|
||||||
protected Component mmString(String s)
|
protected Component mmString(String s)
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize(s);
|
return PlexUtils.mmDeserialize(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank getLevel()
|
public Rank getLevel()
|
||||||
|
@ -7,6 +7,7 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
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);
|
String prefix = StringUtils.join(args, " ", 1, args.length);
|
||||||
Component convertedComponent = removeEvents(noColorComponentFromString(prefix));
|
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))
|
if (PlainTextComponentSerializer.plainText().serialize(convertedComponent).length() > plugin.config.getInt("chat.max-tag-length", 16))
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ public class UnbanCMD extends PlexCommand
|
|||||||
PlexPlayer plexPlayer = getOfflinePlexPlayer(targetUUID);
|
PlexPlayer plexPlayer = getOfflinePlexPlayer(targetUUID);
|
||||||
if (!aBoolean)
|
if (!aBoolean)
|
||||||
{
|
{
|
||||||
send(sender, MiniMessage.miniMessage().deserialize(new PlayerNotBannedException().getMessage()));
|
send(sender, PlexUtils.mmDeserialize(new PlayerNotBannedException().getMessage()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.getPunishmentManager().unban(targetUUID);
|
plugin.getPunishmentManager().unban(targetUUID);
|
||||||
|
@ -8,7 +8,6 @@ import dev.plex.command.blocker.RegexCommand;
|
|||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -65,7 +64,7 @@ public class CommandListener extends PlexListener
|
|||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
//PlexLog.debug("Command blocked.");
|
//PlexLog.debug("Command blocked.");
|
||||||
player.sendMessage(MiniMessage.miniMessage().deserialize(PlexUtils.messageString("blockedCommandColor") + blockedCommand.getMessage()));
|
player.sendMessage(PlexUtils.mmDeserialize(PlexUtils.messageString("blockedCommandColor") + blockedCommand.getMessage()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public class PlayerListener extends PlexListener
|
|||||||
String loginMessage = plugin.getRankManager().getLoginMessage(plexPlayer);
|
String loginMessage = plugin.getRankManager().getLoginMessage(plexPlayer);
|
||||||
if (!loginMessage.isEmpty())
|
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)
|
if (plugin.getStorageType() != StorageType.MONGODB)
|
||||||
|
@ -95,7 +95,7 @@ public class RankManager
|
|||||||
{
|
{
|
||||||
if (!player.getPrefix().equals(""))
|
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()))
|
if (Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName()))
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.rank.enums;
|
package dev.plex.rank.enums;
|
||||||
|
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -47,7 +48,7 @@ public enum Rank
|
|||||||
|
|
||||||
public Component getPrefix()
|
public Component getPrefix()
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize(this.prefix);
|
return PlexUtils.mmDeserialize(this.prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject toJSON()
|
public JSONObject toJSON()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.rank.enums;
|
package dev.plex.rank.enums;
|
||||||
|
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -39,7 +40,7 @@ public enum Title
|
|||||||
|
|
||||||
public Component getPrefix()
|
public Component getPrefix()
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize(this.prefix);
|
return PlexUtils.mmDeserialize(this.prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject toJSON()
|
public JSONObject toJSON()
|
||||||
|
@ -7,7 +7,13 @@ import dev.plex.PlexBase;
|
|||||||
import dev.plex.config.Config;
|
import dev.plex.config.Config;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
import net.kyori.adventure.text.Component;
|
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.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 net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
@ -15,6 +21,8 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.PluginCommandYamlParser;
|
import org.bukkit.command.PluginCommandYamlParser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
@ -145,9 +153,32 @@ public class PlexUtils extends PlexBase
|
|||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
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)
|
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)
|
public static String messageString(String entry, Object... objects)
|
||||||
|
@ -149,7 +149,7 @@ public class UpdateChecker extends PlexBase
|
|||||||
|
|
||||||
private void sendMini(CommandSender sender, String message)
|
private void sendMini(CommandSender sender, String message)
|
||||||
{
|
{
|
||||||
sender.sendMessage(MiniMessage.miniMessage().deserialize(message));
|
sender.sendMessage(PlexUtils.mmDeserialize(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateJar(CommandSender sender)
|
public void updateJar(CommandSender sender)
|
||||||
|
Loading…
Reference in New Issue
Block a user