From 45abf6a5c01b1fa89df076341dc78525fe717c49 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 6 Jan 2020 20:37:41 +0100 Subject: [PATCH] Reworking Techhider HiddenBlock configuration for usage in 1.14 and 1.15 Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/Config.java | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_API/src/de/steamwar/fightsystem/Config.java index c317ccc..02249f5 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/Config.java @@ -6,13 +6,12 @@ import de.steamwar.sql.Team; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; -import java.util.Collections; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.logging.Level; public class Config { @@ -99,9 +98,9 @@ public class Config { public static final String LeaderDefault; //tech hider parameter - public static final List HiddenBlocks; - public static final List HiddenBlockTags; - public static final List HiddenBlockEntities; + public static final Set HiddenBlocks; + public static final Set HiddenBlockTags; + public static final Set HiddenBlockEntities; public static final int ObfuscateWith; public static final String ObfuscateWithTag; @@ -177,9 +176,23 @@ public class Config { MemberDefault = config.getString("Kits.MemberDefault"); LeaderDefault = config.getString("Kits.LeaderDefault"); - HiddenBlocks = Collections.unmodifiableList(config.getIntegerList("Techhider.HiddenBlocks")); - HiddenBlockTags = config.getStringList("Techhider.HiddenBlockTags"); - HiddenBlockEntities = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlockEntities")); + ConfigurationSection techhiderConfig = config.getConfigurationSection("Techhider.HiddenBlocks"); + Set blocks = new HashSet<>(); + Set blockTags = new HashSet<>(); + for(String key : techhiderConfig.getKeys(false)){ + blockTags.add(key); + if(techhiderConfig.isInt(key)) + blocks.add(techhiderConfig.getInt(key)); + else{ + List minmax = techhiderConfig.getIntegerList(key); // Entry 0: Minimum, Entry 1: Maximum + for(int i = minmax.get(0); i <= minmax.get(1); i++) + blocks.add(i); + } + + } + HiddenBlocks = Collections.unmodifiableSet(blocks); + HiddenBlockTags = Collections.unmodifiableSet(blockTags); + HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities"))); ObfuscateWith = config.getInt("Techhider.ObfuscateWith"); ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag"); -- 2.39.5