mirror of
				https://github.com/PlaceholderAPI/PlaceholderAPI
				synced 2025-10-31 06:12:28 +01:00 
			
		
		
		
	Merge pull request #485 from PlaceholderAPI/fix/477-remove-gson
Remove Gson
This commit is contained in:
		| @@ -18,7 +18,6 @@ repositories { | |||||||
| } | } | ||||||
|  |  | ||||||
| dependencies { | dependencies { | ||||||
|     implementation "com.google.code.gson:gson:2.8.6" |  | ||||||
|     implementation "org.bstats:bstats-bukkit:1.5" |     implementation "org.bstats:bstats-bukkit:1.5" | ||||||
|  |  | ||||||
|     compileOnly "org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT" |     compileOnly "org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT" | ||||||
| @@ -60,7 +59,6 @@ shadowJar { | |||||||
|     archiveClassifier.set("") |     archiveClassifier.set("") | ||||||
|  |  | ||||||
|     relocate "org.bstats", "me.clip.placeholderapi.metrics" |     relocate "org.bstats", "me.clip.placeholderapi.metrics" | ||||||
|     relocate "com.google.gson", "me.clip.placeholderapi.libs.gson" |  | ||||||
| } | } | ||||||
|  |  | ||||||
| license { | license { | ||||||
|   | |||||||
| @@ -21,7 +21,17 @@ | |||||||
| package me.clip.placeholderapi.commands.impl.local; | package me.clip.placeholderapi.commands.impl.local; | ||||||
|  |  | ||||||
| import com.google.common.io.CharStreams; | 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.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||||
| @@ -41,20 +51,15 @@ import java.util.concurrent.CompletableFuture; | |||||||
| import java.util.concurrent.CompletionException; | import java.util.concurrent.CompletionException; | ||||||
| import java.util.logging.Level; | import java.util.logging.Level; | ||||||
| import java.util.stream.Collectors; | 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 { | public final class CommandDump extends PlaceholderCommand { | ||||||
|  |  | ||||||
|   @NotNull |   @NotNull | ||||||
|   private static final String URL = "https://paste.helpch.at/"; |   private static final String URL = "https://paste.helpch.at/"; | ||||||
|  |  | ||||||
|  |   @NotNull | ||||||
|  |   private static final Gson gson = new Gson(); | ||||||
|  |  | ||||||
|   @NotNull |   @NotNull | ||||||
|   private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter |   private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter | ||||||
|       .ofLocalizedDateTime(FormatStyle.LONG) |       .ofLocalizedDateTime(FormatStyle.LONG) | ||||||
| @@ -102,9 +107,8 @@ public final class CommandDump extends PlaceholderCommand { | |||||||
|  |  | ||||||
|         try (final InputStream stream = connection.getInputStream()) { |         try (final InputStream stream = connection.getInputStream()) { | ||||||
|           //noinspection UnstableApiUsage |           //noinspection UnstableApiUsage | ||||||
|           final String json = CharStreams |           final String json = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); | ||||||
|               .toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); |           return gson.fromJson(json, JsonObject.class).get("key").getAsString(); | ||||||
|           return JsonParser.parseString(json).getAsJsonObject().get("key").getAsString(); |  | ||||||
|         } |         } | ||||||
|       } catch (final IOException ex) { |       } catch (final IOException ex) { | ||||||
|         throw new CompletionException(ex); |         throw new CompletionException(ex); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user