| 1 | package sh.okx.rankup.serialization; | |
| 2 | ||
| 3 | import java.util.ArrayList; | |
| 4 | import java.util.Collections; | |
| 5 | import java.util.HashMap; | |
| 6 | import java.util.List; | |
| 7 | import java.util.Map; | |
| 8 | import java.util.Set; | |
| 9 | import org.bukkit.configuration.ConfigurationSection; | |
| 10 | import org.bukkit.configuration.MemorySection; | |
| 11 | ||
| 12 | public class YamlDeserializer { | |
| 13 | ||
| 14 | public static List<RankSerialized> deserialize(ConfigurationSection ranks) { | |
| 15 | Set<String> rankKeys = ranks.getKeys(false); | |
| 16 | List<RankSerialized> ranksList = new ArrayList<>(rankKeys.size()); | |
| 17 | for (String rankKey : rankKeys) { | |
| 18 | ConfigurationSection section = ranks.getConfigurationSection(rankKey); | |
| 19 |
1
1. deserialize : negated conditional → KILLED |
if (section == null) continue; |
| 20 | String rank = section.getString("rank"); | |
| 21 | String next = section.getString("next"); | |
| 22 | String displayName = section.getString("display-name"); | |
| 23 | List<String> commands = section.getStringList("commands"); | |
| 24 | List<String> requirements; | |
| 25 | Map<String, List<String>> prestigeRequirements; | |
| 26 |
1
1. deserialize : negated conditional → KILLED |
if (section.isConfigurationSection("requirements")) { |
| 27 | requirements = null; | |
| 28 | ConfigurationSection requirementsSection = section.getConfigurationSection("requirements"); | |
| 29 | Set<String> keys = requirementsSection.getKeys(false); | |
| 30 | prestigeRequirements = new HashMap<>(keys.size()); | |
| 31 | for (String key : keys) { | |
| 32 | prestigeRequirements.put(key, requirementsSection.getStringList(key)); | |
| 33 | } | |
| 34 | } else { | |
| 35 | prestigeRequirements = null; | |
| 36 | requirements = section.getStringList("requirements"); | |
| 37 | } | |
| 38 | ||
| 39 | ConfigurationSection rankupSection = section.getConfigurationSection("rankup"); | |
| 40 | Map<String, String> messages; | |
| 41 |
1
1. deserialize : negated conditional → KILLED |
if (rankupSection != null) { |
| 42 | ||
| 43 | Set<String> rankup = rankupSection.getKeys(true); | |
| 44 | messages = new HashMap<>(rankup.size()); | |
| 45 | for (String key : rankup) { | |
| 46 |
1
1. deserialize : negated conditional → KILLED |
if (!rankupSection.isConfigurationSection(key)) { |
| 47 | messages.put(MemorySection.createPath(rankupSection, key, section), rankupSection.getString(key)); | |
| 48 | } | |
| 49 | } | |
| 50 | } else { | |
| 51 | messages = Collections.emptyMap(); | |
| 52 | } | |
| 53 | ||
| 54 | ranksList.add(new RankSerialized(rank, next, displayName, commands, requirements, prestigeRequirements, messages)); | |
| 55 | } | |
| 56 |
1
1. deserialize : replaced return value with Collections.emptyList for sh/okx/rankup/serialization/YamlDeserializer::deserialize → KILLED |
return ranksList; |
| 57 | } | |
| 58 | ||
| 59 | } | |
Mutations | ||
| 19 |
1.1 |
|
| 26 |
1.1 |
|
| 41 |
1.1 |
|
| 46 |
1.1 |
|
| 56 |
1.1 |