mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-22 15:24:44 +02:00
Use EnumMaps where possible
This commit is contained in:
@ -10,6 +10,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -367,7 +368,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
public Map<SkillType, Integer> readRank(String playerName) {
|
||||
updateLeaderboards();
|
||||
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
||||
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class);
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||
@ -1081,8 +1082,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
private PlayerProfile loadFromLine(String[] character) {
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
|
||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||
Map<SkillType, Float> skillsXp = new EnumMap<SkillType, Float>(SkillType.class); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
|
||||
MobHealthbarType mobHealthbarType;
|
||||
|
||||
// TODO on updates, put new values in a try{} ?
|
||||
@ -1133,7 +1134,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
|
||||
|
||||
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
||||
|
@ -8,6 +8,7 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -415,7 +416,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
public Map<SkillType, Integer> readRank(String playerName) {
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
|
||||
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class);
|
||||
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement statement = null;
|
||||
@ -1238,9 +1239,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException {
|
||||
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
|
||||
Map<SkillType, Float> skillsXp = new EnumMap<SkillType, Float>(SkillType.class); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
|
||||
MobHealthbarType mobHealthbarType;
|
||||
UUID uuid;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -62,7 +62,7 @@ public class McMMOPlayer {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private final Map<SkillType, SkillManager> skillManagers = new HashMap<SkillType, SkillManager>();
|
||||
private final Map<SkillType, SkillManager> skillManagers = new EnumMap<SkillType, SkillManager>(SkillType.class);
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
@ -78,10 +78,10 @@ public class McMMOPlayer {
|
||||
private boolean abilityUse = true;
|
||||
private boolean godMode;
|
||||
|
||||
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
||||
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||
private final Map<AbilityType, Boolean> abilityMode = new EnumMap<AbilityType, Boolean>(AbilityType.class);
|
||||
private final Map<AbilityType, Boolean> abilityInformed = new EnumMap<AbilityType, Boolean>(AbilityType.class);
|
||||
|
||||
private final Map<ToolType, Boolean> toolMode = new HashMap<ToolType, Boolean>();
|
||||
private final Map<ToolType, Boolean> toolMode = new EnumMap<ToolType, Boolean>(ToolType.class);
|
||||
|
||||
private int recentlyHurt;
|
||||
private int respawnATS;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -17,6 +17,7 @@ import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class PlayerProfile {
|
||||
private final String playerName;
|
||||
@ -28,9 +29,9 @@ public class PlayerProfile {
|
||||
private MobHealthbarType mobHealthbarType;
|
||||
|
||||
/* Skill Data */
|
||||
private final Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||
private final Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
|
||||
private final Map<AbilityType, Integer> abilityDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
|
||||
private final Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
|
||||
private final Map<SkillType, Float> skillsXp = new EnumMap<SkillType, Float>(SkillType.class); // Skill & XP
|
||||
private final Map<AbilityType, Integer> abilityDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
|
||||
|
||||
@Deprecated
|
||||
public PlayerProfile(String playerName) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.util.skills;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -632,7 +631,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
private static Map<DamageModifier, Double> getModifiers(EntityDamageEvent event) {
|
||||
Map<DamageModifier, Double> modifiers = new HashMap<DamageModifier, Double>();
|
||||
Map<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
|
||||
for (DamageModifier modifier : DamageModifier.values()) {
|
||||
modifiers.put(modifier, event.getDamage(modifier));
|
||||
}
|
||||
@ -641,7 +640,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
private static Map<DamageModifier, Double> getScaledModifiers(double damage, Map<DamageModifier, Double> modifiers) {
|
||||
Map<DamageModifier, Double> scaledModifiers = new HashMap<DamageModifier, Double>();
|
||||
Map<DamageModifier, Double> scaledModifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
|
||||
|
||||
for (DamageModifier modifier : modifiers.keySet()) {
|
||||
if (modifier == DamageModifier.BASE) {
|
||||
|
Reference in New Issue
Block a user