diff --git a/build.gradle b/build.gradle index ba311ca..4457bf2 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ compileJava { sourceCompatibility = '1.8' targetCompatibility = '1.8' } -version = "1.4.9" +version = "1.4.10" group = "dev.meyi.bn" archivesBaseName = "BazaarNotifier" diff --git a/src/main/java/dev/meyi/bn/BazaarNotifier.java b/src/main/java/dev/meyi/bn/BazaarNotifier.java index ee7599e..c09a36c 100644 --- a/src/main/java/dev/meyi/bn/BazaarNotifier.java +++ b/src/main/java/dev/meyi/bn/BazaarNotifier.java @@ -13,17 +13,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; import java.text.DecimalFormat; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManagerFactory; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.common.MinecraftForge; @@ -38,10 +28,9 @@ public class BazaarNotifier { public static final String MODID = "BazaarNotifier"; - public static final String VERSION = "1.4.9"; + public static final String VERSION = "1.4.10"; public static final String prefix = - EnumChatFormatting.GOLD + "[" + EnumChatFormatting.YELLOW + "BN" + EnumChatFormatting.GOLD - + "] " + EnumChatFormatting.RESET; + EnumChatFormatting.GOLD + "[" + EnumChatFormatting.YELLOW + "BN" + EnumChatFormatting.GOLD + "] " + EnumChatFormatting.RESET; public static String apiKey = ""; public static DecimalFormat df = new DecimalFormat("#,###.0"); @@ -67,8 +56,6 @@ public class BazaarNotifier { public static ModuleList modules; - public static SSLSocketFactory sslSocketFactory; - public static void resetMod() { modules.resetAll(); orders = Defaults.DEFAULT_ORDERS_LAYOUT(); @@ -97,27 +84,6 @@ public void preInit(FMLPreInitializationEvent event) { @Mod.EventHandler public void init(FMLInitializationEvent event) { - - try { - Certificate certificate = CertificateFactory.getInstance("X.509").generateCertificate( - this.getClass().getClassLoader().getResourceAsStream("api-hypixel.crt")); - KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); - keyStore.load(null, null); - keyStore.setCertificateEntry("api-hypixel-bz", certificate); - - TrustManagerFactory trustManagerFactory = TrustManagerFactory - .getInstance(TrustManagerFactory.getDefaultAlgorithm()); - trustManagerFactory.init(keyStore); - - SSLContext sslContext = SSLContext.getInstance("TLS"); - sslContext.init(null, trustManagerFactory.getTrustManagers(), null); - - BazaarNotifier.sslSocketFactory = sslContext.getSocketFactory(); - - } catch (CertificateException | KeyStoreException | IOException | NoSuchAlgorithmException | KeyManagementException e) { - e.printStackTrace(); - } - MinecraftForge.EVENT_BUS.register(new EventHandler()); MinecraftForge.EVENT_BUS.register(new ChestTickHandler()); MinecraftForge.EVENT_BUS.register(new MouseHandler()); diff --git a/src/main/java/dev/meyi/bn/utilities/Utils.java b/src/main/java/dev/meyi/bn/utilities/Utils.java index 80bf9a5..e075088 100644 --- a/src/main/java/dev/meyi/bn/utilities/Utils.java +++ b/src/main/java/dev/meyi/bn/utilities/Utils.java @@ -9,14 +9,12 @@ import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.RoundingMode; -import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.net.ssl.HttpsURLConnection; import net.minecraft.client.Minecraft; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -25,7 +23,6 @@ import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; -import org.apache.http.conn.socket.LayeredConnectionSocketFactory; import org.apache.http.impl.client.HttpClientBuilder; import org.json.JSONArray; import org.json.JSONException; @@ -34,19 +31,18 @@ public class Utils { public static JSONObject getBazaarData() throws IOException { + HttpClient client = HttpClientBuilder.create().build(); String apiBit = ""; if (!BazaarNotifier.apiKeyDisabled) { apiBit = "?key=" + BazaarNotifier.apiKey; } - - HttpsURLConnection connection = (HttpsURLConnection) new URL("https://api.hypixel.net/skyblock/bazaar" + apiBit).openConnection(); - connection.setSSLSocketFactory(BazaarNotifier.sslSocketFactory); - connection.connect(); + HttpGet request = new HttpGet( + "https://api.hypixel.net/skyblock/bazaar" + apiBit); + HttpResponse response = client.execute(request); String result = IOUtils.toString(new BufferedReader (new InputStreamReader( - connection.getInputStream()))); - + response.getEntity().getContent()))); return new JSONObject(result).getJSONObject("products"); } diff --git a/src/main/resources/api-hypixel.crt b/src/main/resources/api-hypixel.crt deleted file mode 100644 index 2e49e94..0000000 --- a/src/main/resources/api-hypixel.crt +++ /dev/null @@ -1,23 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDvjCCA0WgAwIBAgISBLHHdJoMnT3I5N6iNeBVq92nMAoGCCqGSM49BAMDMDIx -CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQDEwJF -MTAeFw0yMjA1MDMwMzMxNDBaFw0yMjA4MDEwMzMxMzlaMBgxFjAUBgNVBAMMDSou -aHlwaXhlbC5uZXQwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARogny4rQN8PhG4 -1VOXMrmTKUiafoua0qdj4UaWe9KN0Bc3bX4iEj3YURIngOo3pNCeeSDKAGxEdS25 -q9TTtMUeo4ICUzCCAk8wDgYDVR0PAQH/BAQDAgeAMB0GA1UdJQQWMBQGCCsGAQUF -BwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQQVYmnqzcbVaax -0UyGFppdMGguSjAfBgNVHSMEGDAWgBRa8+0r/DbCN3m5UjDqVG/PVcsurDBVBggr -BgEFBQcBAQRJMEcwIQYIKwYBBQUHMAGGFWh0dHA6Ly9lMS5vLmxlbmNyLm9yZzAi -BggrBgEFBQcwAoYWaHR0cDovL2UxLmkubGVuY3Iub3JnLzAlBgNVHREEHjA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