forked from 5gi/DeepJ
		
	fixed code from last commit
This commit is contained in:
		
							parent
							
								
									e25bff8f07
								
							
						
					
					
						commit
						e0f590b2bf
					
				@ -1,4 +1,4 @@
 | 
			
		||||
package tech.nevets.deepj;
 | 
			
		||||
package tech.nevets.DeepJ;
 | 
			
		||||
import org.json.JSONArray;
 | 
			
		||||
import org.json.JSONObject;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
@ -8,12 +8,14 @@ import java.net.http.HttpClient;
 | 
			
		||||
import java.net.http.HttpRequest;
 | 
			
		||||
import java.net.http.HttpResponse;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
public class Translator {
 | 
			
		||||
//TODO Test class to make sure multiple contructors work.
 | 
			
		||||
    public static String globalAuthKey = "null";
 | 
			
		||||
 | 
			
		||||
    public static void setGlobalAuthKey(String key) {
 | 
			
		||||
        this.globalAuthKey = key;
 | 
			
		||||
        globalAuthKey = key;
 | 
			
		||||
    }
 | 
			
		||||
    private Request request;
 | 
			
		||||
    public Translator() {
 | 
			
		||||
@ -22,18 +24,18 @@ public class Translator {
 | 
			
		||||
            "\n[DeepJ] If you are trying to use global auth keys, Call the method \"Translator.setGlobalAuthKey(String key)\" and then re-use this contructor." + 
 | 
			
		||||
             "\n[DeepJ] If you want to define an different authkey every time do: \"new Translator(String authKey)\"\n");
 | 
			
		||||
        } else {
 | 
			
		||||
            request = new request(globalAuthKey);
 | 
			
		||||
            request = new Request(globalAuthKey);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public Translator(@NotNull String authKey) {
 | 
			
		||||
        if (globalAuthKey != "null") {
 | 
			
		||||
    public Translator(String authKey) {
 | 
			
		||||
        if (!Objects.equals(globalAuthKey, "null")) {
 | 
			
		||||
            System.out.println("[DeepJ] Looks like you have defined a global auth key already! You can use if by just typing \"new Traslator()\"" +
 | 
			
		||||
            "\n instead of \"new Translator(String authKey)\". NOTE: This will work but just some advice :)");
 | 
			
		||||
        }
 | 
			
		||||
        request = new Request(authKey);
 | 
			
		||||
    }
 | 
			
		||||
    public Translator(@NotNull String authKey, @NotNull boolean silence) {
 | 
			
		||||
        if (globalAuthKey != "null" && silence == false) {
 | 
			
		||||
    public Translator(String authKey, boolean silence) {
 | 
			
		||||
        if (!Objects.equals(globalAuthKey, "null") && !silence) {
 | 
			
		||||
            System.out.println("[DeepJ] Looks like you have defined a global auth key already! You can use if by just typing \"new Traslator()\"" +
 | 
			
		||||
            "\n instead of \"new Translator(String authKey)\". NOTE: This will work but this is just some advice :)");
 | 
			
		||||
        }
 | 
			
		||||
@ -53,7 +55,7 @@ public class Translator {
 | 
			
		||||
        JSONArray jsonArray = jsonObject.getJSONArray("translations");
 | 
			
		||||
        for (int i = 0; i < jsonArray.length(); i++) {
 | 
			
		||||
            JSONObject jsonObject1 = jsonArray.getJSONObject(i);
 | 
			
		||||
            message = jsonObject.getString("text");
 | 
			
		||||
            message = jsonObject1.getString("text");
 | 
			
		||||
        }
 | 
			
		||||
        return message;
 | 
			
		||||
    }
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user