From 95c08f5e52c446bf4afe553f2c64d50cd8b66acc Mon Sep 17 00:00:00 2001 From: Guntram Blohm Date: Fri, 5 Apr 2019 14:06:35 +0200 Subject: [PATCH] only warn once for each file that isn't found --- src/main/java/de/craftlancer/imagemaps/ImageMaps.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/craftlancer/imagemaps/ImageMaps.java b/src/main/java/de/craftlancer/imagemaps/ImageMaps.java index 709462a..62e43ae 100644 --- a/src/main/java/de/craftlancer/imagemaps/ImageMaps.java +++ b/src/main/java/de/craftlancer/imagemaps/ImageMaps.java @@ -5,9 +5,11 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.logging.Level; import javax.imageio.ImageIO; @@ -222,6 +224,7 @@ public class ImageMaps extends JavaPlugin implements Listener { private void loadMaps() { File file = new File(getDataFolder(), "maps.yml"); FileConfiguration config = YamlConfiguration.loadConfiguration(file); + Set warnedFilenames=new HashSet<>(); for (String key : config.getKeys(false)) { int id = Integer.parseInt(key); @@ -242,7 +245,10 @@ public class ImageMaps extends JavaPlugin implements Listener { BufferedImage bimage = loadImage(image); if (bimage == null) { - getLogger().warning(() -> "Image file " + image + " not found, removing this map!"); + if (!warnedFilenames.contains(image)) { + warnedFilenames.add(image); + getLogger().warning(() -> "Image file " + image + " not found, removing this map!"); + } continue; }