Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #451 from EbatteSratte/main
Browse files Browse the repository at this point in the history
ChatUtils -> Translit
  • Loading branch information
Pan4ur authored Aug 3, 2024
2 parents 2f7f35a + 0cfd328 commit 26aadbc
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions src/main/java/thunder/hack/modules/misc/ChatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ public class ChatUtils extends Module {
private final Setting<PMSound> pmSound = new Setting<>("PMSound", PMSound.Default);
private final Setting<Boolean> zov = new Setting<>("ZOV", false);
private final Setting<Boolean> wavy = new Setting<>("wAvY",false);
private final Setting<Boolean> translit = new Setting<>("Translit",false);
private final Setting<Boolean> antiCoordLeak = new Setting<>("AntiCoordLeak", false);

private final Timer timer = new Timer();
private final Timer antiSpam = new Timer();
private final Timer messageTimer = new Timer();

private final LinkedHashMap<UUID, String> nameMap = new LinkedHashMap<>();
private String skip;


public ChatUtils() {
super("ChatUtils", Category.MISC);
}
Expand Down Expand Up @@ -152,6 +153,25 @@ public boolean antiBot(@NotNull String s) {
}
return false;
}
private static final char[] cyrillicChars = {
'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И',
'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т',
'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь',
'Э', 'Ю', 'Я', 'а', 'б', 'в', 'г', 'д', 'е', 'ё',
'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п',
'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ',
'ъ', 'ы', 'ь', 'э', 'ю', 'я'
};

private static final String[] latinChars = {
"A", "B", "V", "G", "D", "E", "YO", "ZH", "Z", "I",
"Y", "K", "L", "M", "N", "O", "P", "R", "S", "T",
"U", "F", "KH", "TS", "CH", "SH", "SCH", "", "Y", "",
"E", "YU", "YA", "a", "b", "v", "g", "d", "e", "yo",
"zh", "z", "i", "y", "k", "l", "m", "n", "o", "p",
"r", "s", "t", "u", "f", "kh", "ts", "ch", "sh", "sch",
"", "y", "", "e", "yu", "ya"
};

private final String[] bb = new String[]{
"See you later, ",
Expand Down Expand Up @@ -203,7 +223,7 @@ public void onPacketSend(PacketEvent.@NotNull Send e) {
}

if (fullNullCheck()) return;
if (e.getPacket() instanceof ChatMessageC2SPacket pac && (zov.getValue() || wavy.getValue())) {
if (e.getPacket() instanceof ChatMessageC2SPacket pac && (zov.getValue() || wavy.getValue() || translit.getValue())) {

if (Objects.equals(pac.chatMessage(), skip)) {
return;
Expand Down Expand Up @@ -243,12 +263,36 @@ public void onPacketSend(PacketEvent.@NotNull Send e) {
}
message = builder.toString();
}
if(translit.getValue()){
message = transliterate(message.toString());
}
skip = message;
mc.player.networkHandler.sendChatMessage(skip);
e.cancel();
}
}
public static String transliterate(String text) {
StringBuilder result = new StringBuilder();

for (char ch : text.toCharArray()) {
int index = -1;

for (int i = 0; i < cyrillicChars.length; i++) {
if (cyrillicChars[i] == ch) {
index = i;
break;
}
}

if (index != -1) {
result.append(latinChars[index]);
} else {
result.append(ch);
}
}

return result.toString();
}
private enum Welcomer {
Off, Server, Client
}
Expand Down

0 comments on commit 26aadbc

Please sign in to comment.