From d46b2dc298ee77eea19c7b56ae91f0e688089c63 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 14 Feb 2024 12:29:42 -0500 Subject: [PATCH] File reformat. --- src/engine/objects/ItemBase.java | 155 +++++++++++++++---------------- 1 file changed, 76 insertions(+), 79 deletions(-) diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index 6f449203..9dda9502 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -34,59 +34,58 @@ public class ItemBase { public static HashMap _itemBaseByUUID = new HashMap<>(); public static HashMap> ItemBaseTypeMap = new HashMap<>(); // Internal cache - private static HashMap itemHashIDMap = new HashMap<>(); - private static HashMap _IDsByNames = new HashMap<>(); - private static ArrayList _resourceList = new ArrayList<>(); + private static final HashMap itemHashIDMap = new HashMap<>(); + private static final HashMap _IDsByNames = new HashMap<>(); + private static final ArrayList _resourceList = new ArrayList<>(); private final int uuid; private final String name; - private float durability; - private int value; - private short weight; - private short color; - private ItemType type; + //requirements/restrictions + public EnumSet restrictedRaces; + public EnumSet requiredRaces; + public EnumSet restrictedClasses; + public EnumSet requiredClasses; + public EnumSet requiredDiscs; + public EnumSet restrictedDiscs; + private final float durability; + private final int value; + private final short weight; + private final short color; + private final ItemType type; private int vendorType; - private int modTable; - private int useID; + private final int modTable; + private final int useID; private int hashID; - private byte useAmount; + private final byte useAmount; // Armor and weapon related values - private int equipFlag; - private int restrictFlag; - private String skillRequired; - private short percentRequired; - private float slashResist; - private float crushResist; - private float pierceResist; - private float blockMod; - private short defense; - private float dexPenalty; - private float speed; - private float range; - private short minDamage; - private short maxDamage; - private String mastery; - private engine.Enum.DamageType damageType; - private boolean twoHanded; + private final int equipFlag; + private final int restrictFlag; + private final String skillRequired; + private final short percentRequired; + private final float slashResist; + private final float crushResist; + private final float pierceResist; + private final float blockMod; + private final short defense; + private final float dexPenalty; + private final float speed; + private final float range; + private final short minDamage; + private final short maxDamage; + private final String mastery; + private final engine.Enum.DamageType damageType; + private final boolean twoHanded; private boolean isConsumable; private boolean isStackable; - private int numCharges; + private final int numCharges; // Item stat modifiers - private HashMap bakedInStats = new HashMap<>(); - private HashMap usedStats = new HashMap<>(); - private float parryBonus; - private boolean isStrBased; + private final HashMap bakedInStats = new HashMap<>(); + private final HashMap usedStats = new HashMap<>(); + private final float parryBonus; + private final boolean isStrBased; private ArrayList animations = new ArrayList<>(); private ArrayList offHandAnimations = new ArrayList<>(); private boolean autoID = false; - //requirements/restrictions - public EnumSet restrictedRaces; - public EnumSet requiredRaces; - public EnumSet restrictedClasses; - public EnumSet requiredClasses; - public EnumSet requiredDiscs; - public EnumSet restrictedDiscs; - /** * ResultSet Constructor */ @@ -324,11 +323,8 @@ public class ItemBase { public boolean isDiscRune() { int ID = uuid; - if (ID > 2499 && ID < 3050) { //class, discipline runes - return true; - } else { - return false; - } + //class, discipline runes + return ID > 2499 && ID < 3050; } public boolean isGlass() { @@ -486,7 +482,7 @@ public class ItemBase { if (!validForSkills(abstractCharacter.getSkills())) return false; - if(this.canCharacterEquip(abstractCharacter) == false) + if (this.canCharacterEquip(abstractCharacter) == false) return false; return item.getItemBase().value != 0 || Kit.IsNoobGear(item.getItemBase().uuid); @@ -496,6 +492,7 @@ public class ItemBase { return true; //Mobiles and NPC's don't need to check equip } + public int getValidSlot() { int slotValue = 0; @@ -772,19 +769,19 @@ public class ItemBase { } public boolean isThrowing() { - return this.mastery.equals("Throwing") ? true : false; + return this.mastery.equals("Throwing"); } public boolean isStaff() { - return this.mastery.equals("Staff") ? true : false; + return this.mastery.equals("Staff"); } public boolean isScepter() { - return this.mastery.equals("Benediction") ? true : false; + return this.mastery.equals("Benediction"); } public boolean isArchery() { - return this.mastery.equals("Archery") ? true : false; + return this.mastery.equals("Archery"); } public boolean isMelee() { @@ -935,66 +932,66 @@ public class ItemBase { this.autoID = autoID; } - public boolean isArmor(){ + public boolean isArmor() { - if(this.isHeavyArmor()) + if (this.isHeavyArmor()) return true; - if(this.isMediumArmor()) + if (this.isMediumArmor()) return true; - if(this.isLightArmor()) + if (this.isLightArmor()) return true; - if(this.isClothArmor()) - return true; - - return false; + return this.isClothArmor(); } - public Boolean canCharacterEquip(AbstractCharacter character){ - return ValidRace(character.absRace) && ValidClass(character.absBaseClass,character.absPromotionClass) && ValidDiscipline(character.absDisciplines); + + public Boolean canCharacterEquip(AbstractCharacter character) { + return ValidRace(character.absRace) && ValidClass(character.absBaseClass, character.absPromotionClass) && ValidDiscipline(character.absDisciplines); } - public Boolean ValidRace(Enum.MonsterType race){ - if(this.requiredRaces.isEmpty() && this.restrictedRaces.isEmpty()) - return true; + public Boolean ValidRace(Enum.MonsterType race) { - if(this.requiredRaces.isEmpty() == false && race.elementOf(this.requiredRaces) == true) + if (this.requiredRaces.isEmpty() && this.restrictedRaces.isEmpty()) return true; - if(this.restrictedRaces.isEmpty() == false && race.elementOf(this.restrictedRaces) == false) + if (this.requiredRaces.isEmpty() == false && race.elementOf(this.requiredRaces) == true) return true; - return false; + return this.restrictedRaces.isEmpty() == false && race.elementOf(this.restrictedRaces) == false; } - public Boolean ValidClass(Enum.ClassType base,Enum.ClassType profession){ + public Boolean ValidClass(Enum.ClassType base, Enum.ClassType profession) { + boolean requiredEmpty = this.requiredClasses == null || this.requiredClasses.isEmpty(); boolean restrictedEmpty = this.restrictedClasses == null || this.restrictedClasses.isEmpty(); - if(requiredEmpty && restrictedEmpty) + + if (requiredEmpty && restrictedEmpty) return true; - if(this.requiredClasses != null && this.requiredClasses.isEmpty() == false) - if(this.requiredClasses.contains(base) || this.requiredClasses.contains(profession)) + if (this.requiredClasses != null && this.requiredClasses.isEmpty() == false) + if (this.requiredClasses.contains(base) || this.requiredClasses.contains(profession)) return true; - if(this.restrictedClasses != null && this.restrictedClasses.isEmpty() == false) - if(this.restrictedClasses.contains(base) == false && this.restrictedClasses.contains(profession) == false) - return true; + if (this.restrictedClasses != null && this.restrictedClasses.isEmpty() == false) + return this.restrictedClasses.contains(base) == false && this.restrictedClasses.contains(profession) == false; return false; } - public Boolean ValidDiscipline(EnumSet discs){ + public Boolean ValidDiscipline(EnumSet discs) { + boolean requiredEmpty = this.requiredDiscs == null || this.requiredDiscs.isEmpty(); boolean restrictedEmpty = this.restrictedDiscs == null || this.restrictedDiscs.isEmpty(); - if(requiredEmpty && restrictedEmpty) + + if (requiredEmpty && restrictedEmpty) return true; - for(Enum.DisciplineType disc : discs){ - if(this.requiredDiscs.isEmpty() == false && this.requiredDiscs.contains(disc)) + for (Enum.DisciplineType disc : discs) { + if (this.requiredDiscs.isEmpty() == false && this.requiredDiscs.contains(disc)) return true; - if(this.restrictedDiscs.isEmpty() == false && this.restrictedDiscs.contains(disc)) + + if (this.restrictedDiscs.isEmpty() == false && this.restrictedDiscs.contains(disc)) return false; } return false;