Fixed HashMap over Map

This commit is contained in:
Auxilor 2021-07-22 01:22:42 +01:00
parent a8186c0dd7
commit a9bcd29949
9 changed files with 16 additions and 9 deletions

View File

@ -21,7 +21,7 @@ public final class FastGetEnchants implements FastGetEnchantsProxy {
final boolean checkStored) {
net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagList enchantmentNBT = checkStored && nmsStack.getItem() == Items.ENCHANTED_BOOK ? ItemEnchantedBook.d(nmsStack) : nmsStack.getEnchantments();
HashMap<Enchantment, Integer> foundEnchantments = new HashMap<>();
Map<Enchantment, Integer> foundEnchantments = new HashMap<>();
for (NBTBase base : enchantmentNBT) {
NBTTagCompound compound = (NBTTagCompound) base;

View File

@ -21,7 +21,7 @@ public final class FastGetEnchants implements FastGetEnchantsProxy {
final boolean checkStored) {
net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
NBTTagList enchantmentNBT = checkStored && itemStack.getType() == Material.ENCHANTED_BOOK ? ItemEnchantedBook.d(nmsStack) : nmsStack.getEnchantments();
HashMap<Enchantment, Integer> foundEnchantments = new HashMap<>();
Map<Enchantment, Integer> foundEnchantments = new HashMap<>();
for (NBTBase base : enchantmentNBT) {
NBTTagCompound compound = (NBTTagCompound) base;

View File

@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* All methods and fields pertaining to showing players the enchantments on their items.
@ -119,7 +120,7 @@ public class EnchantDisplay extends DisplayModule {
List<Enchantment> unsorted = new ArrayList<>();
enchantments.forEach((enchantment, integer) -> unsorted.add(enchantment));
HashMap<Enchantment, Integer> tempEnchantments = new HashMap<>(enchantments);
Map<Enchantment, Integer> tempEnchantments = new HashMap<>(enchantments);
options.getSorter().sortEnchantments(unsorted);

View File

@ -18,9 +18,10 @@ import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class CallingCurse extends EcoEnchant implements TimedRunnable {
private final HashMap<Player, Integer> players = new HashMap<>();
private final Map<Player, Integer> players = new HashMap<>();
private double distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance");
public CallingCurse() {

View File

@ -16,9 +16,10 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class Forcefield extends EcoEnchant implements TimedRunnable {
private final HashMap<Player, Integer> players = new HashMap<>();
private final Map<Player, Integer> players = new HashMap<>();
private double initialDistance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "initial-distance");
private double bonus = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bonus-per-level");
private double damagePerPoint = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level");

View File

@ -28,10 +28,11 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class InfernalTouch extends EcoEnchant {
private static final HashMap<Material, Pair<Material, Integer>> RECIPES = new HashMap<>();
private static final Map<Material, Pair<Material, Integer>> RECIPES = new HashMap<>();
private static final Set<Material> FORTUNE_MATERIALS = new HashSet<>(
Arrays.asList(
Material.GOLD_INGOT,

View File

@ -18,9 +18,10 @@ import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class Magnetic extends EcoEnchant implements TimedRunnable {
private final HashMap<Player, Integer> players = new HashMap<>();
private final Map<Player, Integer> players = new HashMap<>();
private double initialDistance = 1;
private double bonus = 1;

View File

@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
@ -24,7 +25,7 @@ public class AnvilListeners extends PluginDependent<EcoPlugin> implements Listen
/**
* Map to prevent incrementing cost several times as inventory events are fired 3 times.
*/
private static final HashMap<UUID, Integer> ANTI_REPEAT = new HashMap<>();
private static final Map<UUID, Integer> ANTI_REPEAT = new HashMap<>();
/**
* Class for AnvilGUI wrappers to ignore them.

View File

@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
@ -74,7 +75,7 @@ public class LootPopulator extends BlockPopulator {
continue;
}
HashMap<Enchantment, Integer> toAdd = new HashMap<>();
Map<Enchantment, Integer> toAdd = new HashMap<>();
ArrayList<EcoEnchant> enchantments = new ArrayList<>(EcoEnchants.values());
Collections.shuffle(enchantments); // Prevent list bias towards early enchantments like telekinesis