mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-26 18:39:43 -05:00
Improve
This commit is contained in:
1 parent
125aa43ba5
commit
85d3dcc121
4 files changed
+20
-8
No files matched your search
@@ -9,9 +9,10 @@ import java.util.*;
|
||||
|
||||
public class MessageTranslator {
|
||||
|
||||
private static final HashMap<Character, String> colors = new HashMap<>();
|
||||
private static final HashMap<Character, String> colors = new HashMap<>(), endingColors = new HashMap<>();
|
||||
private static boolean support;
|
||||
private static Translator translator = null;
|
||||
private static final List<Character> notColors = Arrays.asList('m', 'r', 'k', 'l', 'o');
|
||||
|
||||
public static void initialize() {
|
||||
colors.put('1', "<dark_blue>");
|
||||
@@ -35,6 +36,9 @@ public class MessageTranslator {
|
||||
colors.put('o', "<i>");
|
||||
colors.put('l', "<b>");
|
||||
|
||||
for (Map.Entry<Character, String> entry : colors.entrySet())
|
||||
endingColors.put(entry.getKey(), "</" + entry.getValue().substring(1));
|
||||
|
||||
support = Reflection.getMinor() >= 18
|
||||
|| Reflection.isProxyServer();
|
||||
|
||||
|
||||
@@ -27,7 +27,9 @@ public class BukkitMessageTranslator implements Translator {
|
||||
@Override
|
||||
public void send(Object target, String text) {
|
||||
Audience audience = target instanceof Player ? audiences.player((Player) target) : audiences.sender((CommandSender) target);
|
||||
audience.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(text));
|
||||
text = this.miniMessage.serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(text.replace("§", "&")));
|
||||
if(text.contains("\\")) text = text.replace("\\", "");
|
||||
audience.sendMessage(this.miniMessage.deserialize(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,9 +26,10 @@ public class BungeeMessageTranslator implements Translator {
|
||||
|
||||
@Override
|
||||
public void send(Object target, String text) {
|
||||
boolean isPlayer = target instanceof ProxiedPlayer;
|
||||
Audience audience = isPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
|
||||
audience.sendMessage((isPlayer ? LegacyComponentSerializer.legacyAmpersand() : this.miniMessage).deserialize(text));
|
||||
Audience audience = target instanceof ProxiedPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
|
||||
text = this.miniMessage.serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(text.replace("§", "&")));
|
||||
if(text.contains("\\")) text = text.replace("\\", "");
|
||||
audience.sendMessage(this.miniMessage.deserialize(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.rayzs.pat.utils.message.translators;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
import de.rayzs.pat.utils.message.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
@@ -17,12 +18,16 @@ public class VelocityMessageTranslator implements Translator {
|
||||
|
||||
@Override
|
||||
public void send(Object target, String text) {
|
||||
text = this.miniMessage.serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(text.replace("§", "&")));
|
||||
if(text.contains("\\")) text = text.replace("\\", "");
|
||||
final Component component = this.miniMessage.deserialize(text);
|
||||
|
||||
if(target instanceof Player)
|
||||
((Player) target).sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(text));
|
||||
((Player) target).sendMessage(component);
|
||||
else if(target instanceof CommandSource)
|
||||
((ConsoleCommandSource) target).sendMessage(miniMessage.deserialize(MessageTranslator.translateLegacy(text)));
|
||||
((ConsoleCommandSource) target).sendMessage(component);
|
||||
else if(target instanceof ConsoleCommandSource)
|
||||
((ConsoleCommandSource) target).sendMessage(miniMessage.deserialize(MessageTranslator.translateLegacy(text)));
|
||||
((ConsoleCommandSource) target).sendMessage(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user