aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-10-16 15:50:41 -0400
committerGitHub <noreply@github.com>2021-10-16 15:50:41 -0400
commit7c00af18febf6c0b833c7633b4fb60a9a1bb93af (patch)
treef02de145362d6a1399651ade4a130d565d7f0ba3 /src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
parentb11742988dec635b5c5da7c2363803cbfafb37b1 (diff)
downloadnotenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.gz
notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.bz2
notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.zip
Code Clean Up (#2)
* intellij code clean up * optimize imports * format * intellij suggestions * fix empty catch issues
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
index 70753e10..127a5177 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
@@ -26,12 +26,12 @@ public class HastebinUploader {
* @param mode the mode in which the thing should return NORMAL = returns the url, RAW = returns the raw url, NO_URL = returns the slug.
* @return The url if mode is NORMAL OR RAW, the slug if mode is NO_URL, and null if an error occurred.
*/
- public static String upload(String data, Mode mode){
+ public static String upload(String data, Mode mode) {
try {
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
- HttpURLConnection connection = (HttpURLConnection)new URL(UPLOAD_URL).openConnection();
+ HttpURLConnection connection = (HttpURLConnection) new URL(UPLOAD_URL).openConnection();
connection.setRequestMethod("POST");
- connection.addRequestProperty("User-Agent", "Minecraft Mod ("+ NotEnoughUpdates.MODID +"/"+NotEnoughUpdates.VERSION+")");
+ connection.addRequestProperty("User-Agent", "Minecraft Mod (" + NotEnoughUpdates.MODID + "/" + NotEnoughUpdates.VERSION + ")");
connection.addRequestProperty("Content-Length", String.valueOf(bytes.length));
connection.setReadTimeout(15000);
connection.setConnectTimeout(15000);
@@ -41,9 +41,12 @@ public class HastebinUploader {
if (!json.has("key")) return null;
final String key = json.get("key").getAsString();
switch (mode) {
- case RAW: return RAW_RETURN_URL + key;
- case NORMAL: return RETURN_URL + key;
- case NO_URL: return key;
+ case RAW:
+ return RAW_RETURN_URL + key;
+ case NORMAL:
+ return RETURN_URL + key;
+ case NO_URL:
+ return key;
}
} catch (Exception e) {
e.printStackTrace();