From e638e07afda022e5d58ce43e258c1b58d3c9c4f4 Mon Sep 17 00:00:00 2001 From: RaydanOMGr Date: Sat, 26 Oct 2024 15:50:21 +0200 Subject: [PATCH] Change HashMap to Map --- .../glowingeyes/client/gui/preset/PresetsScreen.java | 4 ++-- .../andreasmelone/glowingeyes/client/presets/Preset.java | 7 ++++--- .../glowingeyes/client/presets/PresetManager.java | 8 ++++---- .../fabric/common/component/eyes/GlowingEyesImpl.java | 7 ++++--- .../forge/common/component/eyes/GlowingEyesImpl.java | 7 ++++--- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Common/src/main/java/me/andreasmelone/glowingeyes/client/gui/preset/PresetsScreen.java b/Common/src/main/java/me/andreasmelone/glowingeyes/client/gui/preset/PresetsScreen.java index dbe32ab..ccb5afb 100644 --- a/Common/src/main/java/me/andreasmelone/glowingeyes/client/gui/preset/PresetsScreen.java +++ b/Common/src/main/java/me/andreasmelone/glowingeyes/client/gui/preset/PresetsScreen.java @@ -21,8 +21,8 @@ import java.awt.*; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; +import java.util.Map; public class PresetsScreen extends Screen { private int guiLeft, guiTop; @@ -40,7 +40,7 @@ public class PresetsScreen extends Screen { boolean isLocked = false; boolean editing = false; - HashMap savedPixelMap = null; + Map savedPixelMap = null; List presetButtons; Button createEditButton; private Screen parent; diff --git a/Common/src/main/java/me/andreasmelone/glowingeyes/client/presets/Preset.java b/Common/src/main/java/me/andreasmelone/glowingeyes/client/presets/Preset.java index edd9fde..d9a1322 100644 --- a/Common/src/main/java/me/andreasmelone/glowingeyes/client/presets/Preset.java +++ b/Common/src/main/java/me/andreasmelone/glowingeyes/client/presets/Preset.java @@ -8,13 +8,14 @@ import java.awt.*; import java.util.HashMap; +import java.util.Map; public class Preset { private String name; private final ResourceLocation id; - private final HashMap content; + private final Map content; - public Preset(String name, ResourceLocation id, HashMap content) { + public Preset(String name, ResourceLocation id, Map content) { this.name = name; this.id = id; this.content = content; @@ -36,7 +37,7 @@ public ResourceLocation getResourceLocation() { ); } - public HashMap getContent() { + public Map getContent() { // return a copy so that the original content can't be modified return new HashMap<>(this.content); } diff --git a/Common/src/main/java/me/andreasmelone/glowingeyes/client/presets/PresetManager.java b/Common/src/main/java/me/andreasmelone/glowingeyes/client/presets/PresetManager.java index 927dbd9..7eb9878 100644 --- a/Common/src/main/java/me/andreasmelone/glowingeyes/client/presets/PresetManager.java +++ b/Common/src/main/java/me/andreasmelone/glowingeyes/client/presets/PresetManager.java @@ -27,7 +27,7 @@ public class PresetManager { private static final PresetManager INSTANCE = new PresetManager(); Gson gson = new GsonBuilder() - .registerTypeAdapter(HashMap.class, new PointColorMapSerializer()) + .registerTypeAdapter(Map.class, new PointColorMapSerializer()) .registerTypeAdapter(ResourceLocation.class, new ResourceLocationSerializer()) .setPrettyPrinting() .create(); @@ -175,17 +175,17 @@ private int addPreset(Preset preset, int number) { return this.presets.size() - 1; } - public int createPreset(String name, HashMap content) { + public int createPreset(String name, Map content) { return this.createPreset(name, content, new ResourceLocation(GlowingEyes.MOD_ID, "preset_" + sanitizeForId(name))); } - public int createPreset(String name, HashMap content, ResourceLocation id) { + public int createPreset(String name, Map content, ResourceLocation id) { int minX = 0; int minY = 0; int maxX = 15; int maxY = 15; - HashMap contentCopy = new HashMap<>(content); + Map contentCopy = new HashMap<>(content); // check if the content has pixels outside range x 0, y 0 - x 16, y 16 for(Point point : contentCopy.keySet()) { if(point.x < minX || point.x > maxX || point.y < minY || point.y > maxY) { diff --git a/Fabric/src/main/java/me/andreasmelone/glowingeyes/fabric/common/component/eyes/GlowingEyesImpl.java b/Fabric/src/main/java/me/andreasmelone/glowingeyes/fabric/common/component/eyes/GlowingEyesImpl.java index 473f8ed..c63f0d5 100644 --- a/Fabric/src/main/java/me/andreasmelone/glowingeyes/fabric/common/component/eyes/GlowingEyesImpl.java +++ b/Fabric/src/main/java/me/andreasmelone/glowingeyes/fabric/common/component/eyes/GlowingEyesImpl.java @@ -5,18 +5,19 @@ import java.awt.*; import java.util.HashMap; +import java.util.Map; public class GlowingEyesImpl implements IGlowingEyes { private boolean toggledOn = true; - private HashMap glowingEyesMap = new HashMap<>(); + private Map glowingEyesMap = new HashMap<>(); @Override - public HashMap getGlowingEyesMap() { + public Map getGlowingEyesMap() { return this.glowingEyesMap; } @Override - public void setGlowingEyesMap(HashMap glowingEyesMap) { + public void setGlowingEyesMap(Map glowingEyesMap) { this.glowingEyesMap = glowingEyesMap; } diff --git a/Forge/src/main/java/me/andreasmelone/glowingeyes/forge/common/component/eyes/GlowingEyesImpl.java b/Forge/src/main/java/me/andreasmelone/glowingeyes/forge/common/component/eyes/GlowingEyesImpl.java index bfc9118..21e8439 100644 --- a/Forge/src/main/java/me/andreasmelone/glowingeyes/forge/common/component/eyes/GlowingEyesImpl.java +++ b/Forge/src/main/java/me/andreasmelone/glowingeyes/forge/common/component/eyes/GlowingEyesImpl.java @@ -3,19 +3,20 @@ import javax.annotation.Nonnull; import java.awt.*; import java.util.HashMap; +import java.util.Map; public class GlowingEyesImpl implements IGlowingEyes { private boolean toggledOn = true; - private HashMap glowingEyesMap = new HashMap<>(); + private Map glowingEyesMap = new HashMap<>(); @Nonnull @Override - public HashMap getGlowingEyesMap() { + public Map getGlowingEyesMap() { return this.glowingEyesMap; } @Override - public void setGlowingEyesMap(@Nonnull HashMap glowingEyesMap) { + public void setGlowingEyesMap(@Nonnull Map glowingEyesMap) { this.glowingEyesMap = glowingEyesMap; }