From ae7fecbf6d02066d02e932efff0d363be4f8bae7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 1 Apr 2024 12:41:33 -0400 Subject: [PATCH] Effectbase updated with new enum --- src/engine/Enum.java | 2 +- src/engine/objects/ItemTemplate.java | 2 +- src/engine/objects/Resists.java | 2 +- src/engine/powers/EffectsBase.java | 19 +++++-------------- .../DamageShieldEffectModifier.java | 2 +- .../effectmodifiers/HealthEffectModifier.java | 2 +- .../effectmodifiers/ManaEffectModifier.java | 2 +- .../StaminaEffectModifier.java | 2 +- .../poweractions/TransferStatPowerAction.java | 2 +- 9 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 80d19c1c..20f10866 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -759,7 +759,7 @@ public class Enum { STEAL, DRAIN; - public static DamageType GetDamageType(String modName) { + public static DamageType getDamageType(String modName) { DamageType damageType; if (modName.isEmpty()) return DamageType.NONE; diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index dd1d861a..7e550a5e 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -227,7 +227,7 @@ public class ItemTemplate { if (weapon_damage.isEmpty() == false) for (Object o : weapon_damage) { JSONObject damage_entry = (JSONObject) o; - Enum.DamageType damageType = Enum.DamageType.GetDamageType(((String) damage_entry.get("damage_type"))); + Enum.DamageType damageType = Enum.DamageType.getDamageType(((String) damage_entry.get("damage_type"))); int min = ((Long) damage_entry.get("damage_min")).intValue(); int max = ((Long) damage_entry.get("damage_max")).intValue(); int[] minMax = {min, max}; diff --git a/src/engine/objects/Resists.java b/src/engine/objects/Resists.java index 15cb5b9e..57bb331c 100644 --- a/src/engine/objects/Resists.java +++ b/src/engine/objects/Resists.java @@ -135,7 +135,7 @@ public class Resists { //Test if Damagetype is valid for foritude private static boolean isValidDamageCapType(HashSet forts, Enum.DamageType damageType, boolean exclusive) { for (SourceType fort : forts) { - Enum.DamageType dt = Enum.DamageType.GetDamageType(fort.name()); + Enum.DamageType dt = Enum.DamageType.getDamageType(fort.name()); if (dt.equals(Enum.DamageType.NONE)) continue; diff --git a/src/engine/powers/EffectsBase.java b/src/engine/powers/EffectsBase.java index c507131f..039f13db 100644 --- a/src/engine/powers/EffectsBase.java +++ b/src/engine/powers/EffectsBase.java @@ -46,7 +46,7 @@ public class EffectsBase { public static HashMap>> NewEffectsMap = new HashMap<>(); public static HashMap>> ChangedEffectsMap = new HashMap<>(); public static HashMap> EffectFailConditions = new HashMap<>(); - public static HashMap> EffectDamageTypes = new HashMap<>(); + public static HashMap> EffectDamageTypes = new HashMap<>(); public static HashSet DefaultModifiers = new HashSet<>(); private static ConcurrentHashMap itemEffectsByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private static int NewID = 3000; @@ -224,14 +224,14 @@ public class EffectsBase { if (!EffectsBase.EffectDamageTypes.containsKey(eb.getToken())) EffectsBase.EffectDamageTypes.put(eb.getToken(), new HashSet<>()); - Enum.SourceType dt = getDamageType(damageType1); + Enum.DamageType dt = Enum.DamageType.getDamageType(damageType1); if (dt != null) EffectsBase.EffectDamageTypes.get(eb.token).add(dt); - dt = getDamageType(damageType2); + dt = Enum.DamageType.getDamageType(damageType2); if (dt != null) EffectsBase.EffectDamageTypes.get(eb.token).add(dt); - dt = getDamageType(damageType3); + dt = Enum.DamageType.getDamageType(damageType3); if (dt != null) EffectsBase.EffectDamageTypes.get(eb.token).add(dt); break; @@ -277,15 +277,6 @@ public class EffectsBase { } } - private static Enum.SourceType getDamageType(String name) { - - if (name.isEmpty()) - return null; - else - return Enum.SourceType.valueOf(name.toUpperCase()); - - } - public static String getItemEffectsByName(String string) { if (EffectsBase.itemEffectsByName.containsKey(string)) return EffectsBase.itemEffectsByName.get(string); @@ -704,7 +695,7 @@ public class EffectsBase { String text = ""; if (!EffectsBase.EffectDamageTypes.containsKey(this.token)) return text; - for (Enum.SourceType type : EffectsBase.EffectDamageTypes.get(this.token)) { + for (Enum.DamageType type : EffectsBase.EffectDamageTypes.get(this.token)) { text += type.name() + ' '; } return text; diff --git a/src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java b/src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java index 2059e90d..7795a825 100644 --- a/src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java +++ b/src/engine/powers/effectmodifiers/DamageShieldEffectModifier.java @@ -49,7 +49,7 @@ public class DamageShieldEffectModifier extends AbstractEffectModifier { amount *= (1 + mod); } - Enum.DamageType dt = Enum.DamageType.GetDamageType(this.type); + Enum.DamageType dt = Enum.DamageType.getDamageType(this.type); if (dt != null) { diff --git a/src/engine/powers/effectmodifiers/HealthEffectModifier.java b/src/engine/powers/effectmodifiers/HealthEffectModifier.java index 89a010d6..9dfcd69a 100644 --- a/src/engine/powers/effectmodifiers/HealthEffectModifier.java +++ b/src/engine/powers/effectmodifiers/HealthEffectModifier.java @@ -34,7 +34,7 @@ public class HealthEffectModifier extends AbstractEffectModifier { super(rs); String damageTypeDB = rs.getString("type"); try { - this.damageType = Enum.DamageType.GetDamageType(damageTypeDB); + this.damageType = Enum.DamageType.getDamageType(damageTypeDB); } catch (IllegalArgumentException e) { Logger.error("DamageType could not be loaded from database. " + "UUID = " + this.UUID + " value received = '" + damageTypeDB.toUpperCase() + '\'', e); diff --git a/src/engine/powers/effectmodifiers/ManaEffectModifier.java b/src/engine/powers/effectmodifiers/ManaEffectModifier.java index 28544b86..54ec6513 100644 --- a/src/engine/powers/effectmodifiers/ManaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/ManaEffectModifier.java @@ -36,7 +36,7 @@ public class ManaEffectModifier extends AbstractEffectModifier { super(rs); String damageTypeDB = rs.getString("type"); try { - this.damageType = Enum.DamageType.GetDamageType(damageTypeDB); + this.damageType = Enum.DamageType.getDamageType(damageTypeDB); } catch (IllegalArgumentException e) { Logger.error("DamageType could not be loaded from database. " + "UUID = " + this.UUID + " value received = '" + damageTypeDB.toUpperCase() + '\'', e); diff --git a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java index 0ee02aa2..f19b505c 100644 --- a/src/engine/powers/effectmodifiers/StaminaEffectModifier.java +++ b/src/engine/powers/effectmodifiers/StaminaEffectModifier.java @@ -36,7 +36,7 @@ public class StaminaEffectModifier extends AbstractEffectModifier { super(rs); String damageTypeDB = rs.getString("type"); try { - this.damageType = Enum.DamageType.GetDamageType(damageTypeDB); + this.damageType = Enum.DamageType.getDamageType(damageTypeDB); } catch (IllegalArgumentException e) { Logger.error("DamageType could not be loaded from database. " + "UUID = " + this.UUID + " value received = '" + damageTypeDB.toUpperCase() + '\'', e); diff --git a/src/engine/powers/poweractions/TransferStatPowerAction.java b/src/engine/powers/poweractions/TransferStatPowerAction.java index 986064ac..cca03e81 100644 --- a/src/engine/powers/poweractions/TransferStatPowerAction.java +++ b/src/engine/powers/poweractions/TransferStatPowerAction.java @@ -78,7 +78,7 @@ public class TransferStatPowerAction extends AbstractPowerAction { // Damage type can sometimes be null in the DB. if (damageString.isEmpty() == false) - this.damageType = Enum.DamageType.GetDamageType(damageString); + this.damageType = Enum.DamageType.getDamageType(damageString); } catch (Exception e) { this.damageType = null; }