From b3169a64422391b4d042415508d753ee4c0808b8 Mon Sep 17 00:00:00 2001 From: Jurgen Date: Sun, 1 May 2022 16:24:34 +0200 Subject: [PATCH] updated deprecated interfaces where possible, there are still many left, like ForgeRegistry.BIOME, ForgeRegistry.BLOCK_STATE_IDS, and many more I couln't find a fix for. --- .../org/dynmap/hdmap/CustomBlockModel.java | 2 +- .../java/org/dynmap/hdmap/TexturePack.java | 4 +- .../helper/BukkitVersionHelperGeneric.java | 38 +++++++++---------- .../org/dynmap/forge_1_14_4/DynmapPlugin.java | 19 +++------- 4 files changed, 27 insertions(+), 36 deletions(-) diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/CustomBlockModel.java b/DynmapCore/src/main/java/org/dynmap/hdmap/CustomBlockModel.java index ec298d08..a89670e8 100644 --- a/DynmapCore/src/main/java/org/dynmap/hdmap/CustomBlockModel.java +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/CustomBlockModel.java @@ -16,7 +16,7 @@ public class CustomBlockModel extends HDBlockModel { super(bstate, databits, blockset); try { Class cls = Class.forName(classname); /* Get class */ - render = (CustomRenderer) cls.newInstance(); + render = (CustomRenderer) cls.getDeclaredConstructor().newInstance(); if(render.initializeRenderer(HDBlockModels.pdf, bstate.blockName, databits, classparm) == false) { Log.severe("Error loading custom renderer - " + classname); render = null; diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java b/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java index dc59fa18..c81cc5c8 100644 --- a/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java @@ -2097,7 +2097,7 @@ public class TexturePack { else if(av[0].equals("custColorMult")) { try { Class cls = Class.forName(av[1]); - custColorMult = (CustomColorMultiplier)cls.newInstance(); + custColorMult = (CustomColorMultiplier)cls.getDeclaredConstructor().newInstance(); } catch (Exception x) { Log.severe("Error loading custom color multiplier - " + av[1] + ": " + x.getMessage()); } @@ -2263,7 +2263,7 @@ public class TexturePack { else if(av[0].equals("custColorMult")) { try { Class cls = Class.forName(av[1]); - custColorMult = (CustomColorMultiplier)cls.newInstance(); + custColorMult = (CustomColorMultiplier)cls.getDeclaredConstructor().newInstance(); } catch (Exception x) { Log.severe("Error loading custom color multiplier - " + av[1] + ": " + x.getMessage()); } diff --git a/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/BukkitVersionHelperGeneric.java b/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/BukkitVersionHelperGeneric.java index 22eec1cf..edb0faf8 100644 --- a/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/BukkitVersionHelperGeneric.java +++ b/bukkit-helper/src/main/java/org/dynmap/bukkit/helper/BukkitVersionHelperGeneric.java @@ -397,7 +397,7 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper { /** * Get inhabited ticks count from chunk */ - private static final Long zero = new Long(0); + private static final Long zero = Long.valueOf(0); public long getInhabitedTicks(Chunk c) { if (nmsc_inhabitedticks == null) { return 0; @@ -557,25 +557,25 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper { if (profile != null) { Object propmap = callMethod(profile, cmaprofile_getproperties, nullargs, null); if ((propmap != null) && (propmap instanceof ForwardingMultimap)) { - ForwardingMultimap fmm = (ForwardingMultimap) propmap; - Collection txt = fmm.get("textures"); - Object textureProperty = Iterables.getFirst(fmm.get("textures"), null); - if (textureProperty != null) { - String val = (String) callMethod(textureProperty, cmaproperty_getvalue, nullargs, null); - if (val != null) { - TexturesPayload result = null; - try { + ForwardingMultimap fmm = (ForwardingMultimap) propmap; + Collection txt = fmm.get("textures"); + Object textureProperty = Iterables.getFirst(fmm.get("textures"), null); + if (textureProperty != null) { + String val = (String) callMethod(textureProperty, cmaproperty_getvalue, nullargs, null); + if (val != null) { + TexturesPayload result = null; + try { String json = new String(Base64.getDecoder().decode(val), StandardCharsets.UTF_8); - result = gson.fromJson(json, TexturesPayload.class); - } catch (JsonParseException e) { - } catch (IllegalArgumentException x) { - Log.warning("Malformed response from skin URL check: " + val); - } - if ((result != null) && (result.textures != null) && (result.textures.containsKey("SKIN"))) { - url = result.textures.get("SKIN").url; - } - } - } + result = gson.fromJson(json, TexturesPayload.class); + } catch (JsonParseException e) { + } catch (IllegalArgumentException x) { + Log.warning("Malformed response from skin URL check: " + val); + } + if ((result != null) && (result.textures != null) && (result.textures.containsKey("SKIN"))) { + url = result.textures.get("SKIN").url; + } + } + } } } diff --git a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java index f6648e4c..b770de74 100644 --- a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java +++ b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java @@ -6,20 +6,8 @@ import java.lang.reflect.Field; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Optional; -import java.util.PriorityQueue; -import java.util.Set; -import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.ConcurrentLinkedQueue; @@ -253,7 +241,10 @@ public class DynmapPlugin if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + try { + statename += p.getName() + "=" + bs.get(p).toString(); + } catch (IllegalFormatConversionException e){ + } } int lightAtten = bs.isOpaqueCube(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);