From 5a4741ddf3c9bdfeb28ffca738bffd53bce315e6 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 23 Jul 2018 17:51:49 +0200 Subject: [PATCH] Support Java 9+ Drops support for Java 7 --- src/main/java/de/epiceric/shopchest/utils/Utils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/utils/Utils.java b/src/main/java/de/epiceric/shopchest/utils/Utils.java index d445898..eda47ad 100644 --- a/src/main/java/de/epiceric/shopchest/utils/Utils.java +++ b/src/main/java/de/epiceric/shopchest/utils/Utils.java @@ -14,11 +14,11 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.*; -import javax.xml.bind.DatatypeConverter; import java.lang.reflect.InvocationTargetException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; +import java.util.Base64; import java.util.HashMap; import java.util.List; @@ -360,7 +360,7 @@ public class Utils { public static String encode(ItemStack itemStack) { YamlConfiguration config = new YamlConfiguration(); config.set("i", itemStack); - return DatatypeConverter.printBase64Binary(config.saveToString().getBytes(StandardCharsets.UTF_8)); + return Base64.getEncoder().encodeToString(config.saveToString().getBytes(StandardCharsets.UTF_8)); } /** @@ -371,7 +371,7 @@ public class Utils { public static ItemStack decode(String string) { YamlConfiguration config = new YamlConfiguration(); try { - config.loadFromString(new String(DatatypeConverter.parseBase64Binary(string), StandardCharsets.UTF_8)); + config.loadFromString(new String(Base64.getDecoder().decode(string), StandardCharsets.UTF_8)); } catch (IllegalArgumentException | InvalidConfigurationException e) { e.printStackTrace(); return null;