package xyz.etztech.minealert; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; public class Webhook { public static void send(String webhook, String embed) throws Exception { URL url = new URL(webhook); URLConnection con = url.openConnection(); HttpURLConnection http = (HttpURLConnection) con; http.setRequestMethod("POST"); http.setDoOutput(true); byte[] out = embed.getBytes(StandardCharsets.UTF_8); int length = out.length; http.setFixedLengthStreamingMode(length); http.setRequestProperty("Content-Type", "application/json; utf-8"); http.setRequestProperty("User-Agent", "MineAlert Agent"); try (OutputStream os = http.getOutputStream()) { os.write(out, 0, out.length); } } }