diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index bdafdc4293..ab8d41bd21 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -47,7 +47,7 @@ /** * This class houses a lot of instances of {@link Map} and {@link List} that hold * various mappings and collections related to {@link SlimefunItem}. - * + * * @author TheBusyBiscuit * */ @@ -87,7 +87,7 @@ public final class SlimefunRegistry { private final Map worlds = new ConcurrentHashMap<>(); private final Map chunks = new HashMap<>(); private final Map guides = new EnumMap<>(SlimefunGuideMode.class); - private final Map> mobDrops = new EnumMap<>(EntityType.class); + private final Map> mobDrops = new HashMap<>(); private final Map blockMenuPresets = new HashMap<>(); private final Map universalInventories = new HashMap<>(); @@ -120,7 +120,7 @@ public void load(@Nonnull Slimefun plugin, @Nonnull Config cfg) { * Auto-Loading will automatically call {@link SlimefunItem#load()} when the item is registered. * Normally that method is called after the {@link Server} finished starting up. * But in the unusual scenario if a {@link SlimefunItem} is registered after that, this is gonna cover that. - * + * * @return Whether auto-loading is enabled */ public boolean isAutoLoadingEnabled() { @@ -132,7 +132,7 @@ public boolean isAutoLoadingEnabled() { * call {@link SlimefunItem#load()}. * Normally this method call is delayed but when the {@link Server} is already running, * the method can be called instantaneously. - * + * * @param mode * Whether auto-loading should be enabled */ @@ -142,7 +142,7 @@ public void setAutoLoadingMode(boolean mode) { /** * This returns a {@link List} containing every enabled {@link ItemGroup}. - * + * * @return {@link List} containing every enabled {@link ItemGroup} */ public @Nonnull List getAllItemGroups() { @@ -151,7 +151,7 @@ public void setAutoLoadingMode(boolean mode) { /** * This {@link List} contains every {@link SlimefunItem}, even disabled items. - * + * * @return A {@link List} containing every {@link SlimefunItem} */ public @Nonnull List getAllSlimefunItems() { @@ -160,7 +160,7 @@ public void setAutoLoadingMode(boolean mode) { /** * This {@link List} contains every enabled {@link SlimefunItem}. - * + * * @return A {@link List} containing every enabled {@link SlimefunItem} */ @Nonnull @@ -170,7 +170,7 @@ public List getEnabledSlimefunItems() { /** * This returns a {@link List} containing every enabled {@link Research}. - * + * * @return A {@link List} containing every enabled {@link Research} */ @Nonnull @@ -181,7 +181,7 @@ public List getResearches() { /** * This method returns a {@link Set} containing the {@link UUID} of every * {@link Player} who is currently unlocking a {@link Research}. - * + * * @return A {@link Set} holding the {@link UUID} from every {@link Player} * who is currently unlocking a {@link Research} */ @@ -226,7 +226,7 @@ public boolean isLearningAnimationDisabled() { /** * This method returns a {@link List} of every enabled {@link MultiBlock}. - * + * * @return A {@link List} containing every enabled {@link MultiBlock} */ @Nonnull @@ -241,10 +241,10 @@ public List getMultiBlocks() { * This mainly only exists for internal purposes, if you want to open a certain section * using the {@link SlimefunGuide}, then please use the static methods provided in the * {@link SlimefunGuide} class. - * + * * @param mode * The {@link SlimefunGuideMode} - * + * * @return The corresponding {@link SlimefunGuideImplementation} */ @Nonnull @@ -263,7 +263,7 @@ public SlimefunGuideImplementation getSlimefunGuide(@Nonnull SlimefunGuideMode m /** * This returns a {@link Map} connecting the {@link EntityType} with a {@link Set} * of {@link ItemStack ItemStacks} which would be dropped when an {@link Entity} of that type was killed. - * + * * @return The {@link Map} of custom mob drops */ @Nonnull @@ -274,7 +274,7 @@ public Map> getMobDrops() { /** * This returns a {@link Set} of {@link ItemStack ItemStacks} which can be obtained by bartering * with {@link Piglin Piglins}. - * + * * @return A {@link Set} of bartering drops */ @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java index 962bc2d32f..6dcd35c335 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java @@ -1,6 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import java.util.EnumMap; +import java.util.HashMap; import java.util.Map; import javax.annotation.Nonnull; @@ -33,8 +33,8 @@ */ public class AutoBrewer extends AContainer implements NotHopperable { - private static final Map potionRecipes = new EnumMap<>(Material.class); - private static final Map fermentations = new EnumMap<>(PotionType.class); + private static final Map potionRecipes = new HashMap<>(); + private static final Map fermentations = new HashMap<>(); static { potionRecipes.put(Material.SUGAR, VersionedPotionType.SWIFTNESS); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java index 33e54e7544..05d0af26a5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/runes/EnchantmentRune.java @@ -2,7 +2,7 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.EnumMap; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -43,7 +43,7 @@ public class EnchantmentRune extends SimpleSlimefunItem { private static final double RANGE = 1.5; - private final Map> applicableEnchantments = new EnumMap<>(Material.class); + private final Map> applicableEnchantments = new HashMap<>(); @ParametersAreNonnullByDefault public EnchantmentRune(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java index 265db240ed..3974b63243 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java @@ -2,7 +2,7 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.EnumMap; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -62,7 +62,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements private final ItemSetting dualWielding = new ItemSetting<>(this, "dual-wielding", true); private final ItemSetting damageOnUse = new ItemSetting<>(this, "damage-on-use", true); - private final Map surfaces = new EnumMap<>(Material.class); + private final Map surfaces = new HashMap<>(); private final Set users = new HashSet<>(); @ParametersAreNonnullByDefault @@ -97,7 +97,7 @@ protected void addSurface(@Nonnull Material type, double defaultValue) { /** * This returns whether the {@link ClimbingPick} needs to be held in both * arms to work. - * + * * @return Whether dual wielding is enabled */ public boolean isDualWieldingEnabled() { @@ -107,7 +107,7 @@ public boolean isDualWieldingEnabled() { /** * This method returns a {@link Collection} of every {@link ClimbableSurface} the * {@link ClimbingPick} can climb. - * + * * @return A {@link Collection} of every {@link ClimbableSurface} */ @Nonnull @@ -117,10 +117,10 @@ public Collection getClimbableSurfaces() { /** * This returns the climbing speed for a given {@link Material}. - * + * * @param type * The {@link Material} - * + * * @return The climbing speed for this {@link Material} or 0. */ public double getClimbingSpeed(@Nonnull Material type) { @@ -136,12 +136,12 @@ public double getClimbingSpeed(@Nonnull Material type) { /** * This returns the climbing speed for a given {@link Material} and the used {@link ItemStack}. - * + * * @param item * the {@link ClimbingPick}'s {@link ItemStack} * @param type * The {@link Material} - * + * * @return The climbing speed or 0. */ public double getClimbingSpeed(@Nonnull ItemStack item, @Nonnull Material type) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java index e257f40647..a52a3bc2ae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMap.java @@ -16,7 +16,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; -import java.util.EnumMap; +import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; @@ -31,6 +31,11 @@ * The most common type is {@link Integer}, if you are using complex objects and try to read * your {@link BiomeMap} from a {@link JsonElement}, make sure to provide an adequate * {@link BiomeDataConverter} to convert the raw json data. +<<<<<<< HEAD +======= + * + * @author TheBusyBiscuit +>>>>>>> 47092df9a (Remove EnumMap and EnumSet usages (#4258)) * * @param The stored data type * @@ -39,9 +44,9 @@ public class BiomeMap implements Keyed { /** - * Our internal {@link EnumMap} holding all the data. + * Our internal {@link HashMap} holding all the data. */ - private final Map dataMap = new EnumMap<>(Biome.class); + private final Map dataMap = new HashMap<>(); /** * The {@link NamespacedKey} to identify this {@link BiomeMap}. @@ -51,7 +56,12 @@ public class BiomeMap implements Keyed { /** * This constructs a new {@link BiomeMap} with the given {@link NamespacedKey}. * +<<<<<<< HEAD * @param namespacedKey The {@link NamespacedKey} for this {@link BiomeMap} +======= + * @param namespacedKey + * The {@link NamespacedKey} for this {@link BiomeMap} +>>>>>>> 47092df9a (Remove EnumMap and EnumSet usages (#4258)) */ @ParametersAreNonnullByDefault public BiomeMap(NamespacedKey namespacedKey) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java index 56bf92979b..09d089bd7c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/biomes/BiomeMapParser.java @@ -1,7 +1,8 @@ package io.github.thebusybiscuit.slimefun4.utils.biomes; -import java.util.EnumMap; -import java.util.EnumSet; + +import java.util.HashMap; +import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.Set; @@ -25,12 +26,12 @@ /** * The {@link BiomeMapParser} allows you to parse json data into a {@link BiomeMap}. - * + * * @author TheBusyBiscuit * * @param * The data type of the resulting {@link BiomeMap} - * + * * @see BiomeMap */ public class BiomeMapParser { @@ -40,7 +41,7 @@ public class BiomeMapParser { private final NamespacedKey key; private final BiomeDataConverter valueConverter; - private final Map map = new EnumMap<>(Biome.class); + private final Map map = new HashMap<>(); /** * This flag specifies whether the parsing is "lenient" or not. @@ -54,7 +55,7 @@ public class BiomeMapParser { * This constructs a new {@link BiomeMapParser}. *

* To parse data, use the {@link #read(JsonArray)} or {@link #read(String)} method. - * + * * @param key * The {@link NamespacedKey} for the resulting {@link BiomeMap} * @param valueConverter @@ -75,7 +76,7 @@ public class BiomeMapParser { * A lenient parser will not throw a {@link BiomeMapException} if the {@link Biome} * could not be found. * The default value is false. - * + * * @param isLenient * Whether this parser should be lenient or not. */ @@ -89,7 +90,7 @@ void setLenient(boolean isLenient) { * A lenient parser will not throw a {@link BiomeMapException} if the {@link Biome} * could not be found. * The default value is false. - * + * * @return Whether this parser is lenient or not. */ boolean isLenient() { @@ -159,7 +160,7 @@ private void readEntry(@Nonnull JsonObject entry) throws BiomeMapException { private @Nonnull Set readBiomes(@Nonnull JsonArray array) throws BiomeMapException { Validate.notNull(array, "The JSON array should not be null!"); - Set biomes = EnumSet.noneOf(Biome.class); + Set biomes = new HashSet<>(); for (JsonElement element : array) { if (element.isJsonPrimitive() && element.getAsJsonPrimitive().isString()) { @@ -196,7 +197,7 @@ private void readEntry(@Nonnull JsonObject entry) throws BiomeMapException { *

* Make sure to parse data via {@link #read(JsonArray)} or {@link #read(String)} * before calling this method! Otherwise the resulting {@link BiomeMap} will be empty. - * + * * @return The resulting {@link BiomeMap} */ @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java index 7962c7b027..7eab9b680f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java @@ -1,7 +1,6 @@ package io.github.thebusybiscuit.slimefun4.utils.tags; import java.util.Collections; -import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; @@ -298,7 +297,7 @@ public enum SlimefunTag implements Tag { } private final NamespacedKey key; - private final Set includedMaterials = EnumSet.noneOf(Material.class); + private final Set includedMaterials = new HashSet<>(); private final Set> additionalTags = new HashSet<>(); /** @@ -370,8 +369,7 @@ public boolean isTagged(@Nonnull Material item) { if (additionalTags.isEmpty()) { return Collections.unmodifiableSet(includedMaterials); } else { - Set materials = EnumSet.noneOf(Material.class); - materials.addAll(includedMaterials); + Set materials = new HashSet<>(includedMaterials); for (Tag tag : additionalTags) { materials.addAll(tag.getValues()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java index 76ef463645..7667e9ceed 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/TagParser.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; -import java.util.EnumSet; import java.util.HashSet; import java.util.Locale; import java.util.Set; @@ -35,9 +34,9 @@ /** * The {@link TagParser} is responsible for parsing a JSON input into a {@link SlimefunTag}. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunTag * */ @@ -51,7 +50,7 @@ public class TagParser implements Keyed { /** * This constructs a new {@link TagParser}. - * + * * @param key * The {@link NamespacedKey} of the resulting {@link SlimefunTag} */ @@ -61,7 +60,7 @@ public TagParser(@Nonnull NamespacedKey key) { /** * This constructs a new {@link TagParser} for the given {@link SlimefunTag} - * + * * @param tag * The {@link SlimefunTag} to parse inputs for */ @@ -82,12 +81,12 @@ void parse(@Nonnull SlimefunTag tag, @Nonnull BiConsumer, Set, Set materials = EnumSet.noneOf(Material.class); + Set materials = new HashSet<>(); Set> tags = new HashSet<>(); JsonObject root = JsonUtils.parseString(json).getAsJsonObject();