mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
Remove non-ASCII characters from tags & chat messages (closes #48)
This commit is contained in:
parent
262af44193
commit
3611148b4c
@ -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 dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
@ -46,7 +47,7 @@ public class TagCMD extends PlexCommand
|
||||
{
|
||||
return usage("/tag set <prefix>");
|
||||
}
|
||||
String prefix = StringUtils.join(args, " ", 1, args.length);
|
||||
String prefix = PlexUtils.cleanString(StringUtils.join(args, " ", 1, args.length));
|
||||
|
||||
Component convertedComponent = SafeMiniMessage.mmDeserializeWithoutEvents(prefix);
|
||||
|
||||
|
@ -14,9 +14,6 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -73,7 +70,7 @@ public class ChatListener extends PlexListener
|
||||
@Override
|
||||
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer)
|
||||
{
|
||||
String text = PlexUtils.getTextFromComponent(message);
|
||||
String text = PlexUtils.cleanString(PlexUtils.getTextFromComponent(message));
|
||||
|
||||
Component component = Component.empty();
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.storage.StorageType;
|
||||
@ -229,4 +230,9 @@ public class PlexUtils implements PlexBase
|
||||
pl.sendMessage(component);
|
||||
});
|
||||
}
|
||||
|
||||
public static String cleanString(String input)
|
||||
{
|
||||
return CharMatcher.ascii().retainFrom(input);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user