From 5bca9dc41f6d3c50c55aa8a14cc3de8bb98a9463 Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Thu, 24 Sep 2020 22:31:26 +0200 Subject: [PATCH 1/2] Remove Gson --- build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index bc86bfc..2590b4f 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,6 @@ repositories { } dependencies { - implementation "com.google.code.gson:gson:2.8.6" implementation "org.bstats:bstats-bukkit:1.5" compileOnly "org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT" @@ -48,7 +47,6 @@ shadowJar { archiveClassifier.set("") relocate "org.bstats", "me.clip.placeholderapi.metrics" - relocate "com.google.gson", "me.clip.placeholderapi.libs.gson" } license { @@ -116,4 +114,4 @@ publishing { } } -publish.dependsOn clean, test, jar \ No newline at end of file +publish.dependsOn clean, test, jar From c64946173b09c04bc10d007c32d90e1879f3b6d3 Mon Sep 17 00:00:00 2001 From: darbyjack Date: Fri, 25 Sep 2020 19:08:56 -0500 Subject: [PATCH 2/2] Implemented working version for 1.8.8 - 1.16.3 --- .../commands/impl/local/CommandDump.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java index d3c3637..48ab55e 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandDump.java @@ -21,7 +21,17 @@ package me.clip.placeholderapi.commands.impl.local; import com.google.common.io.CharStreams; -import com.google.gson.JsonParser; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import me.clip.placeholderapi.PlaceholderAPIPlugin; +import me.clip.placeholderapi.commands.PlaceholderCommand; +import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import me.clip.placeholderapi.util.Msg; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -41,20 +51,15 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.logging.Level; import java.util.stream.Collectors; -import me.clip.placeholderapi.PlaceholderAPIPlugin; -import me.clip.placeholderapi.commands.PlaceholderCommand; -import me.clip.placeholderapi.expansion.PlaceholderExpansion; -import me.clip.placeholderapi.util.Msg; -import org.bukkit.command.CommandSender; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Unmodifiable; public final class CommandDump extends PlaceholderCommand { @NotNull private static final String URL = "https://paste.helpch.at/"; + @NotNull + private static final Gson gson = new Gson(); + @NotNull private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.LONG) @@ -102,9 +107,8 @@ public final class CommandDump extends PlaceholderCommand { try (final InputStream stream = connection.getInputStream()) { //noinspection UnstableApiUsage - final String json = CharStreams - .toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); - return JsonParser.parseString(json).getAsJsonObject().get("key").getAsString(); + final String json = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); + return gson.fromJson(json, JsonObject.class).get("key").getAsString(); } } catch (final IOException ex) { throw new CompletionException(ex);