Skip to content

Commit

Permalink
fix: fixes for nitro
Browse files Browse the repository at this point in the history
  • Loading branch information
thauanvargas committed Jan 6, 2024
1 parent b346c75 commit b8d8579
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 17 deletions.
35 changes: 24 additions & 11 deletions src/main/java/extension/AnonChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,22 @@
import gearth.protocol.HMessage;
import gearth.protocol.HPacket;
import javafx.application.Platform;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.control.*;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import utils.WebUtils;

import javax.swing.*;
import javax.swing.Timer;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.TreeMap;
import java.util.*;

@ExtensionInfo(
Title = "AnonChat",
Description = "Make Habbo don't see what you are typing!",
Version = "1.3",
Version = "1.4",
Author = "Thauan"
)

Expand All @@ -49,15 +44,29 @@ public class AnonChat extends ExtensionForm {
public Label labelStatus;
public String host;
public int roomId = -1;
public Label labelLanguage;
public ChoiceBox<String> languageChoiceBox;
// public CheckBox noQuoteCheckbox;


@Override
protected void onStartConnection() {
}

@Override
protected void onShow() {

if(Objects.equals(this.host, "")) {
WebUtils.codeToLangMap.entrySet().stream()
.sorted(Map.Entry.comparingByValue())
.forEach(o -> {
languageChoiceBox.getItems().add(o.getKey());
});
languageChoiceBox.setValue("en");
}else {
languageChoiceBox.setVisible(false);
labelLanguage.setVisible(false);
}

new Thread(() -> {
sendToServer(new HPacket("InfoRetrieve", HMessage.Direction.TOSERVER));
sendToServer(new HPacket("AvatarExpression", HMessage.Direction.TOSERVER, 0));
Expand Down Expand Up @@ -108,7 +117,11 @@ protected void initExtension() {
});

onConnect((host, port, APIVersion, versionClient, client) -> {
this.host = host.substring(5, 7);
try {
this.host = host.substring(5, 7);
}catch (Exception err) {
this.host = "";
}
});

intercept(HMessage.Direction.TOCLIENT, "RoomEntryInfo", hMessage -> {
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/utils/WebUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.TreeMap;

public class WebUtils {

private static final TreeMap<String, String> codeToLangMap = new TreeMap<>();
public static final TreeMap<String, String> codeToLangMap = new TreeMap<>();

static {
codeToLangMap.put("br", "pt-br");
codeToLangMap.put("de", "de");
Expand Down Expand Up @@ -52,12 +54,8 @@ public static String fetchMessage(String key, String message, int room) throws I
content.addProperty("message", message);
content.addProperty("room", room);

System.out.println(content);

JsonObject result = sendPostRequest("https://xeol.online/anonchat-fetch-message", content.toString());

System.out.println(result);

return result.get("realMessage").getAsString();

}
Expand All @@ -78,7 +76,12 @@ public static String getRandomQuote(int minLength, int maxLength) throws IOExcep

JsonObject content = new JsonObject();

content.addProperty("lang", codeToLangMap.get(AnonChat.RUNNING_INSTANCE.host));
if(Objects.equals(AnonChat.RUNNING_INSTANCE.host, "")) {
content.addProperty("lang", codeToLangMap.get(AnonChat.RUNNING_INSTANCE.languageChoiceBox.getValue()));
}else {
content.addProperty("lang", codeToLangMap.get(AnonChat.RUNNING_INSTANCE.host));
}

content.addProperty("minLength", minLength);
content.addProperty("maxLength", maxLength);

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/AnonChat.fxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TextField?>
Expand Down Expand Up @@ -34,6 +35,8 @@
<Label layoutX="123.0" layoutY="244.0" text="Type a secret key that only you and your friends will know" />
<ListView fx:id="usersInChatListView" layoutX="39.0" layoutY="61.0" prefHeight="162.0" prefWidth="113.0" />
<Label layoutX="39.0" layoutY="37.0" text="Users in your chat:" />
<ChoiceBox fx:id="languageChoiceBox" layoutX="398.0" layoutY="89.0" prefHeight="25.0" prefWidth="98.0" />
<Label layoutX="377.0" layoutY="61.0" prefHeight="17.0" prefWidth="141.0" text="Language of Translation:" fx:id="labelLanguage" />
<!-- <CheckBox fx:id="noQuoteCheckbox" layoutX="372.0" layoutY="274.0" mnemonicParsing="false" onAction="#toggleStatus" text="Don't Quote" />-->
</children>
</AnchorPane>

0 comments on commit b8d8579

Please sign in to comment.