44import com .google .common .io .CharStreams ;
55import com .google .gson .Gson ;
66import com .google .gson .JsonArray ;
7- import com .google .gson .JsonElement ;
87import com .google .gson .JsonObject ;
98import org .checkerframework .checker .nullness .qual .Nullable ;
109
1716import java .util .concurrent .CompletableFuture ;
1817import java .util .concurrent .ExecutorService ;
1918import java .util .concurrent .Executors ;
19+ import java .util .zip .GZIPOutputStream ;
2020
2121public final class PasteUtil {
22- private static final String PASTE_URL = "https://paste.gg /" ;
23- private static final String PASTE_UPLOAD_URL = "https://api.paste.gg/v1/pastes " ;
22+ private static final String PASTE_URL = "https://pastes.dev /" ;
23+ private static final String PASTE_UPLOAD_URL = "https://api.pastes.dev/post " ;
2424 private static final ExecutorService PASTE_EXECUTOR_SERVICE = Executors .newSingleThreadExecutor ();
2525 private static final Gson GSON = new Gson ();
2626
@@ -42,7 +42,8 @@ public static CompletableFuture<PasteResult> createPaste(List<PasteFile> pages)
4242 connection .setDoInput (true );
4343 connection .setDoOutput (true );
4444 connection .setRequestProperty ("User-Agent" , "EssentialsX plugin" );
45- connection .setRequestProperty ("Content-Type" , "application/json" );
45+ connection .setRequestProperty ("Content-Type" , "text/json" );
46+ connection .setRequestProperty ("Content-Encoding" , "gzip" );
4647 final JsonObject body = new JsonObject ();
4748 final JsonArray files = new JsonArray ();
4849 for (final PasteFile page : pages ) {
@@ -56,24 +57,22 @@ public static CompletableFuture<PasteResult> createPaste(List<PasteFile> pages)
5657 }
5758 body .add ("files" , files );
5859
59- try (final OutputStream os = connection .getOutputStream ()) {
60+ try (final OutputStream os = new GZIPOutputStream ( connection .getOutputStream () )) {
6061 os .write (body .toString ().getBytes (Charsets .UTF_8 ));
6162 }
6263
6364 if (connection .getResponseCode () >= 400 ) {
64- //noinspection UnstableApiUsage
6565 future .completeExceptionally (new Error (CharStreams .toString (new InputStreamReader (connection .getErrorStream (), StandardCharsets .UTF_8 ))));
6666 return ;
6767 }
6868
6969 // Read URL
7070 final JsonObject object = GSON .fromJson (new InputStreamReader (connection .getInputStream (), Charsets .UTF_8 ), JsonObject .class );
71- final String pasteId = object .get ("result" ). getAsJsonObject (). get ( "id " ).getAsString ();
71+ final String pasteId = object .get ("key " ).getAsString ();
7272 final String pasteUrl = PASTE_URL + pasteId ;
73- final JsonElement deletionKey = object .get ("result" ).getAsJsonObject ().get ("deletion_key" );
7473 connection .disconnect ();
7574
76- final PasteResult result = new PasteResult (pasteId , pasteUrl , deletionKey != null ? deletionKey . getAsString () : null );
75+ final PasteResult result = new PasteResult (pasteId , pasteUrl , null );
7776 future .complete (result );
7877 } catch (Exception e ) {
7978 future .completeExceptionally (e );
0 commit comments