diff --git a/src/engine/Enum.java b/src/engine/Enum.java index e4b4b9a3..a171d4d9 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -46,7 +46,7 @@ public class Enum { EXPLOIT, BUG, GAME_STOPPER, - TECH_SUPPORT; + TECH_SUPPORT } @@ -112,7 +112,7 @@ public class Enum { Undead, Nephilim, Vampire, - SiegeEngineer; + SiegeEngineer } @@ -120,7 +120,7 @@ public class Enum { MALE, FEMALE, FUZZY, - OTHER; + OTHER } public enum RaceType { @@ -155,13 +155,13 @@ public class Enum { VAMPFEMALE(2029, MonsterType.Vampire, RunSpeed.STANDARD, CharacterSex.FEMALE, 1); @SuppressWarnings("unchecked") - private static HashMap _raceTypeByID = new HashMap<>(); + private static final HashMap _raceTypeByID = new HashMap<>(); int runeID; - private MonsterType monsterType; - private CharacterSex characterSex; - private RunSpeed runSpeed; - private float scaleHeight; + private final MonsterType monsterType; + private final CharacterSex characterSex; + private final RunSpeed runSpeed; + private final float scaleHeight; RaceType(int runeID, MonsterType aggroType, RunSpeed runspeed, CharacterSex characterSex, float scaleHeight) { this.runeID = runeID; @@ -210,13 +210,13 @@ public class Enum { CENTAUR(6.1900001f, 16.940001f, 5.5500002f, 16.940001f, 6.3299999f, 18.379999f, 6.5f), MINOTAUR(6.6300001f, 15.95f, 4.2199998f, 15.95f, 6.3299999f, 18.379999f, 6.5f); - private float walkStandard; - private float walkCombat; - private float runStandard; - private float runCombat; - private float swim; - private float flyRun; - private float flyWalk; + private final float walkStandard; + private final float walkCombat; + private final float runStandard; + private final float runCombat; + private final float swim; + private final float flyRun; + private final float flyWalk; RunSpeed(float walkStandard, float runStandard, float walkCombat, float runCombat, float flyWalk, float flyRun, float swim) { this.walkStandard = walkStandard; @@ -310,13 +310,13 @@ public class Enum { public enum PvpHistoryType { KILLS, - DEATHS; + DEATHS } public enum ChatMessageType { ERROR, INFO, - MOTD; + MOTD } public enum DataRecordType { @@ -327,7 +327,7 @@ public class Enum { CITY, ZONE, REALM, - MINE; + MINE } public enum RecordEventType { @@ -338,7 +338,7 @@ public class Enum { TRANSFER, PENDING, DEFEND, - LOST; // Realm event + LOST // Realm event } public enum CharterType { @@ -346,8 +346,8 @@ public class Enum { MERCANTILE(-15978914, 5060400), BELLIGERENT(762228431, 5060800); - private int charterID; - private int meshID; + private final int charterID; + private final int meshID; CharterType(int charterID, int meshID) { this.charterID = charterID; @@ -402,7 +402,7 @@ public class Enum { Npc, PlayerCharacter, Account, - Mob; + Mob } public enum SiegePhase { @@ -410,20 +410,20 @@ public class Enum { CHALLENGE, STANDOFF, WAR, - CEASEFIRE; + CEASEFIRE } public enum SiegeResult { PENDING, DEFEND, DESTROY, - CAPTURE; + CAPTURE } public enum TaxType { PROFIT, WEEKLY, - NONE; + NONE } @@ -1261,7 +1261,7 @@ public class Enum { SITTING, RUNNING, FLYING, - SWIMMING; + SWIMMING } public enum DoorState { @@ -1269,7 +1269,7 @@ public class Enum { OPEN, CLOSED, LOCKED, - UNLOCKED; + UNLOCKED } // Used with stored procedure GET_UID_ENUM() for @@ -1290,11 +1290,9 @@ public class Enum { SHRINE, WORLDSERVER, ZONE, - WAREHOUSE; + WAREHOUSE } - ; - /** * Enumeration of Building Protection Status stored in the database as a * mysql enumfield. WARNING: This enumeration is fragile. Do not rename. Do @@ -1309,11 +1307,64 @@ public class Enum { CONTRACT, DESTROYED, PENDING, - NPC; + NPC + } + + public enum DisciplineType { + + Alchemist, + Animator, + Archer, + Berserker, + BlackMask, + Blacksmith, + BladeMaster, + BladeWeaver, + BloodProphet, + BountyHunter, + Clanwarden, + Commander, + DarkKnight, + Duelist, + ForgeMaster, + GiantKiller, + Gladiator, + Huntsman, + Knight, + RatCatcher, + RuneCaster, + Enchanter, + StormLord, + Summoner, + Sundancer, + Trainer, + Traveler, + UndeadHunter, + Werebear, + Wererat, + Werewolf, + Wyrmslayer, + Conjurer, + Darksworn, + Valkyr, + BloodHorn, + Shroudborne, + Archmage, + Thrall, + Artillerist, + Savant, + SkyDancer, + Prospector, + Belgosch, + Drannok, + Gorgoi, + Strigoi, + Sapper, + Saboteur, + BattleMagus, + Sanctifier, } - ; - public enum CharacterSkills { Archery((1L << 1), -529201545, 20), @@ -1382,7 +1433,7 @@ public class Enum { private long flag; private int token; - private int reqLvl; + private final int reqLvl; CharacterSkills(long flag, int token, int reqLvl) { this.flag = flag; @@ -1421,8 +1472,6 @@ public class Enum { } } - ; - public enum GuildHistoryType { JOIN(1), LEAVE(4), @@ -1443,17 +1492,14 @@ public class Enum { public enum SexType { NONE, MALE, - FEMALE; + FEMALE } public enum ClassType { - FIGHTER, - HEALER, - ROGUE, - MAGE; - } - - public enum PromoteType { + Fighter(SexType.NONE), + Healer(SexType.NONE), + Rogue(SexType.NONE), + Mage(SexType.NONE), Assassin(SexType.NONE), Barbarian(SexType.NONE), Bard(SexType.NONE), @@ -1478,9 +1524,9 @@ public class Enum { Necromancer(SexType.NONE), ; - private SexType sexRestriction; + private final SexType sexRestriction; - PromoteType(SexType sexRestriction) { + ClassType(SexType sexRestriction) { this.sexRestriction = sexRestriction; } @@ -1660,13 +1706,13 @@ public class Enum { REGEN, FLIGHT, LOCATION, - MOVEMENTSTATE; + MOVEMENTSTATE } public enum ServerType { WORLDSERVER, LOGINSERVER, - NONE; + NONE } public enum ChatChannel implements EnumBitSetHelper { @@ -1720,7 +1766,7 @@ public class Enum { Thief, Warlock, Warrior, - Wizard; + Wizard } @@ -1728,13 +1774,13 @@ public class Enum { RecommendedAlly, RecommendedEnemy, Ally, - Enemy; + Enemy } public enum FriendStatus { Available, Away, - Busy; + Busy } public enum ProfitType { @@ -1749,7 +1795,7 @@ public class Enum { public String dbField; - private ProfitType(String dbField) { + ProfitType(String dbField) { this.dbField = dbField; } } @@ -1842,17 +1888,15 @@ public class Enum { WorldServerInfoSnapshot, Shrine, Zone, - Transaction; + Transaction } public enum ContainerType { BANK, INVENTORY, - VAULT; + VAULT } - ; - public enum CompoundCurveType { DefaultFlat(0), DefaultSlope(1), @@ -2160,7 +2204,7 @@ public class Enum { private final double value; - private CompoundCurveType(double value) { + CompoundCurveType(double value) { this.value = value; } @@ -2183,7 +2227,7 @@ public class Enum { Sit, TakeDamage, TerritoryClaim, - UnEquip; + UnEquip } public enum PowerSubType { @@ -2193,7 +2237,7 @@ public class Enum { DamageType1, DamageType2, DamageType3, - Cancel; + Cancel } public enum PowerCategoryType { @@ -2228,7 +2272,7 @@ public class Enum { RECALL, SPIREPROOFTELEPORT, SPIREDISABLE, - THIEF; + THIEF } public enum PowerTargetType { @@ -2247,7 +2291,7 @@ public class Enum { JEWELRY, WEAPONARMOR, ARMOR, - ITEM; + ITEM } public enum objectMaskType { @@ -2280,7 +2324,7 @@ public class Enum { BANK, VAULT, FORGE, - WAREHOUSE; + WAREHOUSE } public enum ItemSlotType implements EnumBitSetHelper { @@ -2301,7 +2345,7 @@ public class Enum { UPARM, WINGS, BEARD, - HAIR; + HAIR } public enum CityBoundsType { @@ -2317,8 +2361,12 @@ public class Enum { } } - public enum GuildType { - NONE("None", new String[][]{{"None"}}, new String[]{"Thearchy", "Common Rule", "Theocracy", "Republic Rule"}), + public enum GuildCharterType { + NONE("None", new String[][]{{"None"}}, new String[]{"Thearchy", "Common Rule", "Theocracy", "Republic Rule"}, + EnumSet.noneOf(ClassType.class), + EnumSet.noneOf(MonsterType.class), + EnumSet.noneOf(SexType.class)), + CATHEDRAL("Church of the All-Father", new String[][]{ {"Acolyte", "Acolyte"}, {"Catechist"}, @@ -2328,7 +2376,12 @@ public class Enum { {"Bishop", "Bishop"}, {"Lord Cardinal", "Lady Cardinal"}, {"Patriarch", "Matriarch"}}, - new String[]{"Thearchy", "Common Rule", "Theocracy", "Republic Rule"}), + new String[]{"Thearchy", "Common Rule", "Theocracy", "Republic Rule"}, + EnumSet.of(ClassType.Bard, ClassType.Channeler, ClassType.Crusader, ClassType.Nightstalker, + ClassType.Prelate, ClassType.Priest, ClassType.Sentinel, ClassType.Scout), + EnumSet.of(MonsterType.Aelfborn, MonsterType.Centaur, MonsterType.Elf, MonsterType.HalfGiant, + MonsterType.Human), + EnumSet.allOf(SexType.class)), MILITARY("Military", new String[][]{ {"Recruit"}, {"Footman"}, @@ -2338,7 +2391,11 @@ public class Enum { {"Captain"}, {"General"}, {"Lord Marshall", "Lady Marshall"}}, - new String[]{"Autocracy", "Common Rule", "Council Rule", "Militocracy"}), + new String[]{"Autocracy", "Common Rule", "Council Rule", "Militocracy"}, + EnumSet.of(ClassType.Bard, ClassType.Priest, ClassType.Scout, ClassType.Warlock, + ClassType.Warrior, ClassType.Wizard), + EnumSet.of(MonsterType.Centaur, MonsterType.HalfGiant, MonsterType.Human), + EnumSet.allOf(SexType.class)), TEMPLE("Temple of the Cleansing Flame", new String[][]{ {"Aspirant"}, {"Novice"}, @@ -2349,7 +2406,11 @@ public class Enum { {"Lictor"}, {"Justiciar"}, {"Pontifex", "Pontifectrix"}}, - new String[]{"Despot Rule", "Common Rule", "Protectorship", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Protectorship", "Republic Rule"}, + EnumSet.of(ClassType.Assassin, ClassType.Bard, ClassType.Channeler, ClassType.Confessor, + ClassType.Nightstalker, ClassType.Priest, ClassType.Scout, ClassType.Templar), + EnumSet.of(MonsterType.HalfGiant, MonsterType.Human), + EnumSet.allOf(SexType.class)), BARBARIAN("Barbarian Clan", new String[][]{ {"Barbarian"}, {"Skald"}, @@ -2358,7 +2419,11 @@ public class Enum { {"Jarl"}, {"Chieftain"}, {"Thane"}}, - new String[]{"Chiefdom", "Common Rule", "Council Rule", "Republic Rule"}), + new String[]{"Chiefdom", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Barbarian, ClassType.Bard, ClassType.Doomsayer, ClassType.Fury, + ClassType.Priest, ClassType.Scout, ClassType.Thief, ClassType.Warrior), + EnumSet.of(MonsterType.Aelfborn, MonsterType.HalfGiant, MonsterType.Human, MonsterType.Minotaur), + EnumSet.allOf(SexType.class)), RANGER("Ranger's Brotherhood", new String[][]{ {"Yeoman"}, {"Pathfinder"}, @@ -2367,7 +2432,11 @@ public class Enum { {"Protector"}, {"Guardian"}, {"Lord Protector", "Lady Protector"}}, - new String[]{"Despot Rule", "Collectivism", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Collectivism", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Bard, ClassType.Channeler, ClassType.Druid, ClassType.Priest, + ClassType.Ranger, ClassType.Scout, ClassType.Warrior), + EnumSet.of(MonsterType.Aelfborn, MonsterType.Elf, MonsterType.HalfGiant, MonsterType.Human, MonsterType.Shade), + EnumSet.allOf(SexType.class)), AMAZON("Amazon Temple", new String[][]{ {"Amazon Thrall", "Amazon"}, {"Amazon Slave", "Amazon Warrior"}, @@ -2375,7 +2444,11 @@ public class Enum { {"Amazon Consort", "Amazon Princess"}, {"Amazon Seneschal", "Majestrix"}, {"Amazon Regent", "Imperatrix"}}, - new String[]{"Despot Rule", "Common Rule", "Gynarchy", "Gynocracy"}), + new String[]{"Despot Rule", "Common Rule", "Gynarchy", "Gynocracy"}, + EnumSet.of(ClassType.Bard, ClassType.Druid, ClassType.Fury, ClassType.Huntress, + ClassType.Priest, ClassType.Scout, ClassType.Warrior, ClassType.Wizard), + EnumSet.of(MonsterType.Aelfborn, MonsterType.Elf, MonsterType.HalfGiant, MonsterType.Human), + EnumSet.of(SexType.FEMALE)), NOBLE("Noble House", new String[][]{ {"Serf"}, {"Vassal"}, @@ -2386,7 +2459,11 @@ public class Enum { {"Duke", "Duchess"}, {"King", "Queen"}, {"Emperor", "Empress"}}, - new String[]{"Monarchy", "Common Rule", "Feodality", "Republic"}), + new String[]{"Monarchy", "Common Rule", "Feodality", "Republic"}, + EnumSet.of(ClassType.Assassin, ClassType.Bard, ClassType.Channeler, ClassType.Priest, + ClassType.Scout, ClassType.Thief, ClassType.Warlock, ClassType.Warrior, ClassType.Wizard), + EnumSet.of(MonsterType.Aelfborn, MonsterType.HalfGiant, MonsterType.Human), + EnumSet.allOf(SexType.class)), WIZARD("Wizard's Conclave", new String[][]{ {"Apprentice"}, {"Neophyte"}, @@ -2395,7 +2472,11 @@ public class Enum { {"Magus"}, {"High Magus"}, {"Archmagus"}}, - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Magocracy"}), + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Magocracy"}, + EnumSet.of(ClassType.Assassin, ClassType.Bard, ClassType.Channeler, ClassType.Doomsayer, + ClassType.Fury, ClassType.Necromancer, ClassType.Priest, ClassType.Warlock, ClassType.Wizard), + EnumSet.of(MonsterType.Aelfborn, MonsterType.Elf, MonsterType.Human, MonsterType.Nephilim, MonsterType.Shade), + EnumSet.allOf(SexType.class)), MERCENARY("Mercenary Company", new String[][]{ {"Soldier"}, {"Man-at-Arms"}, @@ -2405,7 +2486,11 @@ public class Enum { {"Commander"}, {"High Commander"}, {"Warlord"}}, - new String[]{"Magistrature", "Mob Law", "Council Rule", "Republic Rule"}), + new String[]{"Magistrature", "Mob Law", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Assassin, ClassType.Bard, ClassType.Priest, ClassType.Scout, + ClassType.Thief, ClassType.Warlock, ClassType.Warrior), + EnumSet.of(MonsterType.Aelfborn, MonsterType.Aracoix, MonsterType.HalfGiant, MonsterType.Human, MonsterType.Shade), + EnumSet.allOf(SexType.class)), THIEVES("Thieve's Den", new String[][]{ {"Urchin"}, {"Footpad"}, @@ -2416,7 +2501,12 @@ public class Enum { {"Treasurer"}, {"Grandmaster Thief"}, {"Grandfather"}}, - new String[]{"Despot Rule", "Common Rule", "Oligarchy", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Oligarchy", "Republic Rule"}, + EnumSet.of(ClassType.Assassin, ClassType.Barbarian, ClassType.Bard, ClassType.Priest, + ClassType.Scout, ClassType.Thief, ClassType.Wizard), + EnumSet.of(MonsterType.Aelfborn, MonsterType.Aracoix, MonsterType.Elf, MonsterType.Human, MonsterType.Irekei, + MonsterType.Nephilim, MonsterType.Shade, MonsterType.Vampire), + EnumSet.allOf(SexType.class)), DWARF("Dwarf Hold", new String[][]{ {"Citizen"}, {"Master"}, @@ -2424,7 +2514,11 @@ public class Enum { {"Thane"}, {"Great Thane"}, {"High Thane"}}, - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Crusader, ClassType.Prelate, ClassType.Priest, ClassType.Sentinel, + ClassType.Warrior), + EnumSet.of(MonsterType.Dwarf), + EnumSet.allOf(SexType.class)), HIGHCOURT("High Court", new String[][]{ {"Eccekebe"}, {"Saedulor"}, @@ -2435,7 +2529,12 @@ public class Enum { {"Dar Thaelostor", "Dar Thaelostril"}, {"Aglaeron"}, {"Ellestor", "Elestril"}}, - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Assassin, ClassType.Bard, ClassType.Channeler, ClassType.Druid, + ClassType.Necromancer, ClassType.Priest, ClassType.Ranger, ClassType.Scout, + ClassType.Thief, ClassType.Warrior, ClassType.Wizard), + EnumSet.of(MonsterType.Elf, MonsterType.Minotaur), + EnumSet.allOf(SexType.class)), VIRAKT("Virakt", new String[][]{ {"Jov'uus"}, {"Urikhan"}, @@ -2445,7 +2544,12 @@ public class Enum { {"Khal'uvho"}, {"Khar'uus"}, {"Kryqh'khalin"}}, - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Assassin, ClassType.Bard, ClassType.Channeler, ClassType.Fury, + ClassType.Huntress, ClassType.Nightstalker, ClassType.Priest, ClassType.Ranger, + ClassType.Scout, ClassType.Thief, ClassType.Warrior, ClassType.Wizard), + EnumSet.of(MonsterType.Irekei), + EnumSet.allOf(SexType.class)), BRIALIA("Coven of Brialia", new String[][]{ // Unknown Rank names {"Devotee"}, {"Initiated"}, @@ -2455,7 +2559,11 @@ public class Enum { {"Elder"}, {"Hierophant"}, {"Witch King", "Witch Queen"}}, - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.allOf(ClassType.class), + EnumSet.allOf(MonsterType.class), + EnumSet.allOf(SexType.class)), + UNHOLY("Unholy Legion", new String[][]{ // Unknown Rank names {"Footman"}, {"Fell Legionaire"}, @@ -2465,14 +2573,23 @@ public class Enum { {"Dark Master", "Dark Mistress"}, {"Dread Master", "Dread Mistress"}, {"Dread Lord", "Dread Lady"}}, - new String[]{"Despot Rule", "Despot Rule", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Despot Rule", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Assassin, ClassType.Channeler, ClassType.Necromancer, ClassType.Priest, + ClassType.Scout, ClassType.Thief, ClassType.Warlock, ClassType.Warrior, + ClassType.Wizard), + EnumSet.of(MonsterType.Human, MonsterType.Shade, MonsterType.Vampire), + EnumSet.allOf(SexType.class)), SCOURGE("Cult of the Scourge", new String[][]{ {"Thrall"}, {"Mudir"}, {"Dark Brother", "Dark Sister"}, {"Hand of the Dark"}, {"Dark Father", "Dark Mother"}}, - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Bard, ClassType.Channeler, ClassType.Doomsayer, ClassType.Priest, + ClassType.Scout, ClassType.Warrior, ClassType.Wizard), + EnumSet.of(MonsterType.Aelfborn, MonsterType.Human, MonsterType.Minotaur, MonsterType.Nephilim), + EnumSet.allOf(SexType.class)), PIRATE("Pirate Crew", new String[][]{ {"Midshipman", "Midshipwoman"}, {"Sailor"}, @@ -2480,7 +2597,10 @@ public class Enum { {"Second Mat"}, {"First Mate"}, {"Captain"}}, - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.allOf(ClassType.class), + EnumSet.allOf(MonsterType.class), + EnumSet.allOf(SexType.class)), HERALD("Academy of Heralds", new String[][]{ {"Pupil"}, {"Scribe"}, @@ -2490,7 +2610,10 @@ public class Enum { {"Scholar"}, {"Archivist"}, {"Loremaster"}}, - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.allOf(ClassType.class), + EnumSet.allOf(MonsterType.class), + EnumSet.allOf(SexType.class)), CENTAUR("Centaur Cohort", new String[][]{ {"Hoplite"}, {"Peltast"}, @@ -2500,7 +2623,12 @@ public class Enum { {"Septenrion"}, {"Praetorian"}, {"Paragon"}}, - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}), + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Barbarian, ClassType.Crusader, ClassType.Druid, ClassType.Huntress, + ClassType.Prelate, ClassType.Priest, ClassType.Ranger, ClassType.Sentinel, + ClassType.Warrior), + EnumSet.of(MonsterType.Centaur), + EnumSet.allOf(SexType.class)), KHREE("Aracoix Kh'ree", new String[][]{ {"Duriacor"}, {"Exarch"}, @@ -2512,101 +2640,108 @@ public class Enum { {"Erentar"}, {"Araceos"}, {"Hierarch"}}, - - new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}); - + new String[]{"Despot Rule", "Common Rule", "Council Rule", "Republic Rule"}, + EnumSet.of(ClassType.Assassin, ClassType.Barbarian, ClassType.Bard, ClassType.Huntress, + ClassType.Priest, ClassType.Ranger, ClassType.Scout, ClassType.Thief, + ClassType.Warlock, ClassType.Warrior), + EnumSet.of(MonsterType.Aracoix), + EnumSet.allOf(SexType.class)); + + public final EnumSet requiredClasses; + public final EnumSet requiredRaces; + public final EnumSet sexRequired; private final String name; private final String[][] ranks; //Stored Rank#->Gender(M,F) private final String[] leadershipTypes; - GuildType(String name, String[][] ranks, String[] leadershipTypes) { + GuildCharterType(String name, String[][] ranks, String[] leadershipTypes, EnumSet requiredClasses, + EnumSet requiredRaces, EnumSet sexRequired) { this.name = name; this.ranks = ranks; this.leadershipTypes = leadershipTypes; + this.requiredClasses = requiredClasses; + this.requiredRaces = requiredRaces; + this.sexRequired = sexRequired; } - public static GuildType getGuildTypeFromCharter(ItemBase itemBase) { + public static GuildCharterType getGuildTypeFromCharter(ItemBase itemBase) { - GuildType charterType; + GuildCharterType charterType; // Must be a valid charter object if (itemBase.getType().equals(ItemType.GUILDCHARTER) == false) - return GuildType.NONE; //No guild Type - - // No switches on long in java. Cast to int - // when refactor to long uuid's. Loss won't matter - // with values this small. + return GuildCharterType.NONE; //No guild Type switch (itemBase.getUUID()) { case 559: - charterType = GuildType.CATHEDRAL; + charterType = GuildCharterType.CATHEDRAL; break; case 560: - charterType = GuildType.MILITARY; + charterType = GuildCharterType.MILITARY; break; case 561: - charterType = GuildType.TEMPLE; + charterType = GuildCharterType.TEMPLE; break; case 562: - charterType = GuildType.BARBARIAN; + charterType = GuildCharterType.BARBARIAN; break; case 563: - charterType = GuildType.RANGER; + charterType = GuildCharterType.RANGER; break; case 564: - charterType = GuildType.AMAZON; + charterType = GuildCharterType.AMAZON; break; case 565: - charterType = GuildType.NOBLE; + charterType = GuildCharterType.NOBLE; break; case 566: - charterType = GuildType.WIZARD; + charterType = GuildCharterType.WIZARD; break; case 567: - charterType = GuildType.MERCENARY; + charterType = GuildCharterType.MERCENARY; break; case 568: - charterType = GuildType.THIEVES; + charterType = GuildCharterType.THIEVES; break; case 569: - charterType = GuildType.DWARF; + charterType = GuildCharterType.DWARF; break; case 570: - charterType = GuildType.HIGHCOURT; + charterType = GuildCharterType.HIGHCOURT; break; case 571: - charterType = GuildType.VIRAKT; + charterType = GuildCharterType.VIRAKT; break; case 572: - charterType = GuildType.SCOURGE; + charterType = GuildCharterType.SCOURGE; break; case 573: - charterType = GuildType.KHREE; + charterType = GuildCharterType.KHREE; break; case 574: - charterType = GuildType.CENTAUR; + charterType = GuildCharterType.CENTAUR; break; case 575: - charterType = GuildType.UNHOLY; + charterType = GuildCharterType.UNHOLY; break; case 576: - charterType = GuildType.PIRATE; + charterType = GuildCharterType.PIRATE; break; case 577: - charterType = GuildType.BRIALIA; + charterType = GuildCharterType.BRIALIA; break; default: - charterType = GuildType.HERALD; + charterType = GuildCharterType.HERALD; } return charterType; } - public static GuildType getGuildTypeFromInt(int i) { - return GuildType.values()[i]; + public static GuildCharterType getGuildTypeFromInt(int i) { + return GuildCharterType.values()[i]; } public String getCharterName() { @@ -2632,12 +2767,15 @@ public class Enum { return leadershipTypes[i]; } + public boolean canJoin(AbstractCharacter character){ + return this.requiredRaces.contains(character.absRace) && this.requiredClasses.contains(character.absPromotionClass) && this.sexRequired.contains(character.absGender); + } } public enum MinionClass { MELEE, ARCHER, - MAGE; + MAGE } public enum MinionType { @@ -2707,14 +2845,14 @@ public class Enum { return race; } - public Boolean isMage(){ + public Boolean isMage() { return this.minionClass.ordinal() == MinionClass.MAGE.ordinal(); } } public enum GridObjectType { STATIC, - DYNAMIC; + DYNAMIC } public enum SupportMsgType { @@ -2817,7 +2955,7 @@ public class Enum { public enum AccountStatus { BANNED, ACTIVE, - ADMIN; + ADMIN } public enum MobBehaviourType { @@ -2882,6 +3020,6 @@ public class Enum { GUARDWALLARCHER, PET, CHARMED, - SIEGEENGINE; + SIEGEENGINE } } diff --git a/src/engine/db/archive/GuildRecord.java b/src/engine/db/archive/GuildRecord.java index 9447fd54..213b000b 100644 --- a/src/engine/db/archive/GuildRecord.java +++ b/src/engine/db/archive/GuildRecord.java @@ -89,7 +89,7 @@ public class GuildRecord extends DataRecord { guildRecord.guildHash = guildRecord.guild.getHash(); guildRecord.guildID = guildRecord.guild.getObjectUUID(); guildRecord.guildName = guildRecord.guild.getName(); - guildRecord.charterName = Enum.GuildType.getGuildTypeFromInt(guildRecord.guild.getCharter()).getCharterName(); + guildRecord.charterName = Enum.GuildCharterType.getGuildTypeFromInt(guildRecord.guild.getCharter()).getCharterName(); guildRecord.GLHash = DataWarehouse.hasher.encrypt(guildRecord.guild.getGuildLeaderUUID()); diff --git a/src/engine/db/handlers/dbGuildHandler.java b/src/engine/db/handlers/dbGuildHandler.java index a4f1998e..7a61f1a7 100644 --- a/src/engine/db/handlers/dbGuildHandler.java +++ b/src/engine/db/handlers/dbGuildHandler.java @@ -695,24 +695,4 @@ public class dbGuildHandler extends dbHandlerBase { } } - //TODO uncomment this when finished with guild history warehouse integration -// public HashMap GET_WAREHOUSE_GUILD_HISTORY(){ -// -// HashMap tempMap = new HashMap<>(); -// prepareCallable("SELECT * FROM `warehouse_guildhistory` WHERE `eventType` = 'CREATE'"); -// try { -// ResultSet rs = executeQuery(); -// -// while (rs.next()) { -// GuildRecord guildRecord = new GuildRecord(rs); -// tempMap.put(guildRecord.guildID, guildRecord); -// } -// }catch (Exception e){ -// Logger.error(e); -// } -// return tempMap; -// -// } - - } diff --git a/src/engine/db/handlers/dbItemBaseHandler.java b/src/engine/db/handlers/dbItemBaseHandler.java index bf12b434..e1b11523 100644 --- a/src/engine/db/handlers/dbItemBaseHandler.java +++ b/src/engine/db/handlers/dbItemBaseHandler.java @@ -86,6 +86,7 @@ public class dbItemBaseHandler extends dbHandlerBase { while (rs.next()) { recordsRead++; itemBase = new ItemBase(rs); + ItemBase.addToCache(itemBase); } diff --git a/src/engine/devcmd/cmds/ItemInfoCmd.java b/src/engine/devcmd/cmds/ItemInfoCmd.java new file mode 100644 index 00000000..5c18572f --- /dev/null +++ b/src/engine/devcmd/cmds/ItemInfoCmd.java @@ -0,0 +1,80 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.devcmd.cmds; + +import engine.Enum; +import engine.Enum.BuildingGroup; +import engine.Enum.GameObjectType; +import engine.Enum.TargetColor; +import engine.devcmd.AbstractDevCmd; +import engine.gameManager.BuildingManager; +import engine.gameManager.SessionManager; +import engine.math.Vector3fImmutable; +import engine.objects.*; +import engine.util.StringUtils; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; + + +/** + * @author + */ +public class ItemInfoCmd extends AbstractDevCmd { + + public ItemInfoCmd() { + super("iteminfo"); + } + + @Override + protected void _doCmd(PlayerCharacter pc, String[] words,AbstractGameObject target) { + if (pc == null) { + return; + } + if(target.getObjectType().equals(GameObjectType.Item) == false){ + throwbackInfo(pc, "Must Select An Item"); + return; + } + Item item = (Item)target; + String newline = "\r\n "; + String output = ""; + output += "Required Races:" + newline; + for(Enum.MonsterType required : item.getItemBase().requiredRaces) + output += " " + required.name() + newline; + output += "Restricted Races:" + newline; + for(Enum.MonsterType required : item.getItemBase().restrictedRaces) + output += " " + required.name() + newline; + output += "Required Classes:" + newline; + for(Enum.ClassType required : item.getItemBase().requiredClasses) + output += " " + required.name() + newline; + output += "Restricted Classes:" + newline; + for(Enum.ClassType required : item.getItemBase().restrictedClasses) + output += " " + required.name() + newline; + output += "Required Disciplines:" + newline; + for(Enum.DisciplineType required : item.getItemBase().requiredDiscs) + output += " " + required.name() + newline; + output += "Restricted Disciplines:" + newline; + for(Enum.DisciplineType required : item.getItemBase().restrictedDiscs) + output += " " + required.name() + newline; + throwbackInfo(pc, output); + } + + @Override + protected String _getHelpString() { + return "Gets information on an Object."; + } + + @Override + protected String _getUsageString() { + return "' /iteminfo'"; + } + +} diff --git a/src/engine/devcmd/cmds/SlotNpcCmd.java b/src/engine/devcmd/cmds/SlotNpcCmd.java index dcf2631e..38b06c7e 100644 --- a/src/engine/devcmd/cmds/SlotNpcCmd.java +++ b/src/engine/devcmd/cmds/SlotNpcCmd.java @@ -53,7 +53,7 @@ public class SlotNpcCmd extends AbstractDevCmd { if (stringIndex == -1) return false; - // Validate we have a corrent building group name + // Validate we have a correct building group name for (BuildingGroup group : BuildingGroup.values()) { if (group.name().equals(userInput[0].toUpperCase())) @@ -114,8 +114,7 @@ public class SlotNpcCmd extends AbstractDevCmd { if (!DbManager.ContractQueries.updateAllowedBuildings(contract, contract.getAllowedBuildings().toLong())) { Logger.error("Failed to update Database for Contract Allowed buildings"); - ChatManager.chatSystemError(pc, "Failed to update Database for Contract Allowed buildings. " + - "Contact A CCR, oh wait, you are a CCR. You're Fubared."); + ChatManager.chatSystemError(pc, "Failed to update Database for Contract Allowed buildings. "); return; } @@ -125,8 +124,7 @@ public class SlotNpcCmd extends AbstractDevCmd { contract.getAllowedBuildings().remove(buildingGroup); if (!DbManager.ContractQueries.updateAllowedBuildings(contract, contract.getAllowedBuildings().toLong())) { Logger.error("Failed to update Database for Contract Allowed buildings"); - ChatManager.chatSystemError(pc, "Failed to update Database for Contract Allowed buildings. " + - "Contact A CCR, oh wait, you are a CCR. You're Fubared."); + ChatManager.chatSystemError(pc, "Failed to update Database for Contract Allowed buildings. "); return; } @@ -138,14 +136,14 @@ public class SlotNpcCmd extends AbstractDevCmd { @Override protected String _getHelpString() { - return "Sets a building slot on a targeted npc"; + return "Toggles a building group on a targeted npc"; } // Class methods @Override protected String _getUsageString() { - String usage = "/npcslot [BuildingType] on-off \n"; + String usage = "/npcslot [BuildingGroup] on-off \n"; for (BuildingGroup group : BuildingGroup.values()) { usage += group.name() + ' '; diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index 7541a4e1..55e45912 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -30,6 +30,7 @@ public enum ConfigManager { MB_BIND_ADDR, MB_EXTERNAL_ADDR, + // Database connection config MB_DATABASE_ADDRESS, @@ -66,6 +67,7 @@ public enum ConfigManager { MB_WORLD_GREETING, MB_WORLD_KEYCLONE_MAX, MB_USE_RUINS, + MB_RULESET, // Mobile AI modifiers MB_AI_CAST_FREQUENCY, @@ -134,7 +136,6 @@ public enum ConfigManager { File file = new File("mbbranch.sh"); if (file.exists() && !file.isDirectory()) { - String[] command = {"./mbbranch.sh"}; try { diff --git a/src/engine/gameManager/DbManager.java b/src/engine/gameManager/DbManager.java index cbd52a3d..97040017 100644 --- a/src/engine/gameManager/DbManager.java +++ b/src/engine/gameManager/DbManager.java @@ -22,6 +22,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.EnumMap; +import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; public enum DbManager { @@ -266,6 +267,40 @@ public enum DbManager { } + public static > EnumSet parseEnumSet(String mysqlSet, Class enumClass) { + + // Create empty output set of the passed Enum class + + EnumSet enumSet = EnumSet.noneOf(enumClass); + + // Early exit for empty sets + + if (mysqlSet.isEmpty()) + return enumSet; + + // Split set string and trim each element + + String[] elements = mysqlSet.split(";"); + + for (String element : elements) { + + element = element.trim(); + + // Parse the element into an enum; add to the output set + + try { + E enumConstant = java.lang.Enum.valueOf(enumClass, element); + enumSet.add(enumConstant); + } catch (Exception e) { + Logger.error(" Parse error: " + mysqlSet); + } + } + + // Return the output set + + return enumSet; + } + public static void printCacheCount(PlayerCharacter pc) { ChatManager.chatSystemInfo(pc, "Cache Lists"); @@ -324,4 +359,5 @@ public enum DbManager { Logger.info("Database configured with " + connectionCount + " connections"); } + } diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 52c730b6..b79cb8de 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -58,6 +58,7 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new PrintResistsCmd()); DevCmdManager.registerDevCmd(new PrintLocationCmd()); DevCmdManager.registerDevCmd(new InfoCmd()); + DevCmdManager.registerDevCmd(new ItemInfoCmd()); DevCmdManager.registerDevCmd(new aiInfoCmd()); DevCmdManager.registerDevCmd(new SimulateBootyCmd()); DevCmdManager.registerDevCmd(new GetHeightCmd()); diff --git a/src/engine/gameManager/GuildManager.java b/src/engine/gameManager/GuildManager.java index e6b285ae..d5eef974 100644 --- a/src/engine/gameManager/GuildManager.java +++ b/src/engine/gameManager/GuildManager.java @@ -200,5 +200,13 @@ public enum GuildManager { } } - + public static Boolean meetsLoreRequirements(Guild guild, PlayerCharacter player){ + Enum.GuildCharterType charter = guild.getGuildType(); + if(charter.requiredClasses.contains(player.absPromotionClass)) + if(charter.requiredRaces.contains(player.absRace)) + if(charter.sexRequired.contains(player.absGender)) + return true; + + return false; + } } diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 1875a898..00c26948 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -170,6 +170,19 @@ public enum PowersManager { public static void usePower(final PerformActionMsg msg, ClientConnection origin, boolean sendCastToSelf) { + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerUsedID()); + PlayerCharacter caster = origin.getPlayerCharacter(); + PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID()); + if(pb != null && pb.isHarmful == false) { + if (caster.guild.equals(Guild.getErrantGuild())) + return; + + if (target != null && caster.guild.getGuildType().equals(target.guild.getGuildType()) == false) + return; + } + } + if (usePowerA(msg, origin, sendCastToSelf)) { // Cast failed for some reason, reset timer @@ -1258,7 +1271,13 @@ public enum PowersManager { return; } - + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if (pc.guild.getGuildType().equals(target.guild.getGuildType()) == false) { + ChatManager.chatInfoError(pc, + "Cannot summon player outside your charter."); + return; + } + } PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(), msg .getTrains(), msg.getSourceType(), msg.getSourceID(), target .getObjectType().ordinal(), target.getObjectUUID(), 0f, 0f, 0f, 1, 0); diff --git a/src/engine/net/client/handlers/ChangeGuildLeaderHandler.java b/src/engine/net/client/handlers/ChangeGuildLeaderHandler.java index fe21996b..2fa29725 100644 --- a/src/engine/net/client/handlers/ChangeGuildLeaderHandler.java +++ b/src/engine/net/client/handlers/ChangeGuildLeaderHandler.java @@ -76,7 +76,7 @@ public class ChangeGuildLeaderHandler extends AbstractClientMsgHandler { boolean isMale = true; boolean updateTarget; - Enum.GuildType t = Enum.GuildType.getGuildTypeFromInt(sourcePlayer.getGuild().getCharter()); + Enum.GuildCharterType t = Enum.GuildCharterType.getGuildTypeFromInt(sourcePlayer.getGuild().getCharter()); if (!DbManager.GuildQueries.SET_GUILD_LEADER(targetPlayer.getObjectUUID(), glGuild.getObjectUUID())) { diff --git a/src/engine/net/client/handlers/ChangeRankHandler.java b/src/engine/net/client/handlers/ChangeRankHandler.java index 8197fbff..36b5fcaf 100644 --- a/src/engine/net/client/handlers/ChangeRankHandler.java +++ b/src/engine/net/client/handlers/ChangeRankHandler.java @@ -60,7 +60,7 @@ public class ChangeRankHandler extends AbstractClientMsgHandler { boolean isMale; if (msg.getPreviousRank() != msg.getNewRank()) { - Enum.GuildType t = Enum.GuildType.getGuildTypeFromInt(sourcePlayer.getGuild().getCharter()); + Enum.GuildCharterType t = Enum.GuildCharterType.getGuildTypeFromInt(sourcePlayer.getGuild().getCharter()); if (targetPlayer != null) { targetPlayer.setGuildTitle(msg.getNewRank()); diff --git a/src/engine/net/client/handlers/GroupInviteHandler.java b/src/engine/net/client/handlers/GroupInviteHandler.java index bef9a198..5bba9132 100644 --- a/src/engine/net/client/handlers/GroupInviteHandler.java +++ b/src/engine/net/client/handlers/GroupInviteHandler.java @@ -12,7 +12,9 @@ package engine.net.client.handlers; import engine.Enum; import engine.Enum.GameObjectType; import engine.exception.MsgSendException; +import engine.gameManager.ConfigManager; import engine.gameManager.GroupManager; +import engine.gameManager.GuildManager; import engine.gameManager.SessionManager; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -21,6 +23,7 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.group.GroupInviteMsg; import engine.net.client.msg.group.GroupUpdateMsg; import engine.objects.Group; +import engine.objects.Guild; import engine.objects.PlayerCharacter; public class GroupInviteHandler extends AbstractClientMsgHandler { @@ -103,7 +106,15 @@ public class GroupInviteHandler extends AbstractClientMsgHandler { if (target.isIgnoringPlayer(source)) return false; + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(source.guild.equals(Guild.getErrantGuild())) + return false; + if (source.guild.getGuildType() != null) { + if (source.guild.getGuildType().equals(target.guild.getGuildType()) == false) + return false; + } + } // dont block invites to people already in a group and // dont check for pending invites, the client does it // Send invite message to target diff --git a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java index aed341f4..0bcdb7b3 100644 --- a/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java +++ b/src/engine/net/client/handlers/GuildCreationFinalizeHandler.java @@ -43,7 +43,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { PlayerCharacter player; GuildCreationFinalizeMsg msg; - Enum.GuildType charterType; + Enum.GuildCharterType charterType; Guild newGuild; Guild playerGuild; ItemBase itemBase; @@ -78,7 +78,7 @@ public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler { return true; } - charterType = Enum.GuildType.getGuildTypeFromCharter(itemBase); + charterType = Enum.GuildCharterType.getGuildTypeFromCharter(itemBase); if (charterType == null) { ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND); diff --git a/src/engine/net/client/handlers/InviteToGuildHandler.java b/src/engine/net/client/handlers/InviteToGuildHandler.java index cce00445..0c533798 100644 --- a/src/engine/net/client/handlers/InviteToGuildHandler.java +++ b/src/engine/net/client/handlers/InviteToGuildHandler.java @@ -14,6 +14,7 @@ import engine.Enum; import engine.Enum.GameObjectType; import engine.exception.MsgSendException; import engine.gameManager.ChatManager; +import engine.gameManager.ConfigManager; import engine.gameManager.GuildManager; import engine.gameManager.SessionManager; import engine.net.Dispatch; @@ -84,9 +85,9 @@ public class InviteToGuildHandler extends AbstractClientMsgHandler { return true; } - Enum.GuildType guildType = Enum.GuildType.values()[sourcePlayer.getGuild().getCharter()]; + Enum.GuildCharterType guildCharterType = Enum.GuildCharterType.values()[sourcePlayer.getGuild().getCharter()]; - if (guildType == null) { + if (guildCharterType == null) { ErrorPopupMsg.sendErrorPopup(sourcePlayer, GuildManager.NO_CHARTER_FOUND); return true; } @@ -124,7 +125,12 @@ public class InviteToGuildHandler extends AbstractClientMsgHandler { ErrorPopupMsg.sendErrorPopup(sourcePlayer, 135);// you do not meet the level required for this SWORN guild return true; } - + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if (GuildManager.meetsLoreRequirements(sourcePlayer.guild, targetPlayer) == false) { + ChatManager.chatGuildError(sourcePlayer,targetPlayer.getFirstName() + " does not meet charter requirements!"); + return true; + } + } targetPlayer.setLastGuildToInvite(sourcePlayer.getGuild().getObjectUUID()); // setup guild invite message to send to targetPlayer diff --git a/src/engine/net/client/handlers/InviteToSubHandler.java b/src/engine/net/client/handlers/InviteToSubHandler.java index bab06111..6492a231 100644 --- a/src/engine/net/client/handlers/InviteToSubHandler.java +++ b/src/engine/net/client/handlers/InviteToSubHandler.java @@ -12,9 +12,7 @@ package engine.net.client.handlers; import engine.Enum; import engine.Enum.GameObjectType; import engine.exception.MsgSendException; -import engine.gameManager.ChatManager; -import engine.gameManager.DbManager; -import engine.gameManager.SessionManager; +import engine.gameManager.*; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -111,7 +109,12 @@ public class InviteToSubHandler extends AbstractClientMsgHandler { sendChat(source, "This Guild can't be subbed."); return true; } - + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if (source.guild.getGuildType().equals(target.guild.getGuildType()) == false){ + sendChat(source, "You Must Be The Same Charter To Form A Nation."); + return true; + } + } //all tests passed, let's send invite. if (target.getClientConnection() != null) { diff --git a/src/engine/net/client/handlers/LeaveGuildHandler.java b/src/engine/net/client/handlers/LeaveGuildHandler.java index 0483469e..1dbc7306 100644 --- a/src/engine/net/client/handlers/LeaveGuildHandler.java +++ b/src/engine/net/client/handlers/LeaveGuildHandler.java @@ -11,17 +11,13 @@ package engine.net.client.handlers; import engine.Enum.GuildHistoryType; import engine.exception.MsgSendException; -import engine.gameManager.ChatManager; -import engine.gameManager.SessionManager; +import engine.gameManager.*; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.guild.LeaveGuildMsg; -import engine.objects.Guild; -import engine.objects.GuildStatusController; -import engine.objects.Mine; -import engine.objects.PlayerCharacter; +import engine.objects.*; public class LeaveGuildHandler extends AbstractClientMsgHandler { @@ -65,7 +61,10 @@ public class LeaveGuildHandler extends AbstractClientMsgHandler { ChatManager.chatGuildInfo(oldGuild, playerCharacter.getFirstName() + " has left the guild."); oldGuild.removePlayer(playerCharacter, GuildHistoryType.LEAVE); - + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(GroupManager.getGroup(playerCharacter) != null) + GroupManager.getGroup(playerCharacter).removeGroupMember(playerCharacter); + } // Send message back to client msg.setMessage("You have left the guild."); dispatch = Dispatch.borrow(playerCharacter, msg); diff --git a/src/engine/net/client/msg/guild/GuildListMsg.java b/src/engine/net/client/msg/guild/GuildListMsg.java index f40783be..80cc6cef 100644 --- a/src/engine/net/client/msg/guild/GuildListMsg.java +++ b/src/engine/net/client/msg/guild/GuildListMsg.java @@ -125,7 +125,7 @@ class GuildListMessageType1 extends GuildListMessageType { @Override void _serialize(ByteBufferWriter writer) { - Enum.GuildType gt = Enum.GuildType.getGuildTypeFromInt(g.getCharter()); + Enum.GuildCharterType gt = Enum.GuildCharterType.getGuildTypeFromInt(g.getCharter()); writer.putInt(1); writer.putInt(gt.ordinal()); //Charter Type diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 03aebf86..3c953c9b 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -27,7 +27,6 @@ import engine.math.Bounds; import engine.math.Vector3fImmutable; import engine.net.ByteBufferWriter; import engine.net.DispatchMessage; -import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.UpdateStateMsg; import engine.powers.EffectsBase; import engine.server.MBServerStatics; @@ -36,6 +35,7 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -125,6 +125,13 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public ArrayList runes; + + public Enum.MonsterType absRace; + public ClassType absBaseClass = null; + public ClassType absPromotionClass = null; + public Enum.SexType absGender = null; + public EnumSet absDisciplines; + public AbstractCharacter() { super(); this.firstName = ""; diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index d8c45c4d..d51c176f 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -325,8 +325,15 @@ public class City extends AbstractWorldObject { if (city.open && city.getTOL() != null && city.getTOL().getRank() > 4) { - if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc)) - cities.add(city); //verify nation or guild is same + if (!BuildingManager.IsPlayerHostile(city.getTOL(), pc)) { + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(city.getGuild().getGuildType().equals(pc.guild.getGuildType())){ + cities.add(city); + } + }else { + cities.add(city); //verify nation or guild is same + } + } } else if (Guild.sameNationExcludeErrant(city.getGuild(), pcG)) cities.add(city); @@ -345,7 +352,13 @@ public class City extends AbstractWorldObject { cities.add(city); } else if (pc.getLevel() >= g.getTeleportMin() && pc.getLevel() <= g.getTeleportMax()) - cities.add(city); + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(city.getGuild().getGuildType().equals(pc.guild.getGuildType())){ + cities.add(city); + } + }else { + cities.add(city); //verify nation or guild is same + } } } @@ -398,12 +411,24 @@ public class City extends AbstractWorldObject { if (city.isNpc == 1) if (city.isNoobIsle == 1) { if (playerCharacter.getLevel() < 21) - cities.add(city); + cities.add(city); //verify nation or guild is same } else if (playerCharacter.getLevel() > 9) - cities.add(city); + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(city.getGuild().getGuildType().equals(playerCharacter.guild.getGuildType())){ + cities.add(city); + } + }else { + cities.add(city); //verify nation or guild is same + } } else if (playerCharacter.getLevel() >= guild.getRepledgeMin() && playerCharacter.getLevel() <= guild.getRepledgeMax()) { - cities.add(city); + if(ConfigManager.MB_RULESET.getValue() == "LORE") { + if(city.getGuild().getGuildType().equals(playerCharacter.guild.getGuildType())){ + cities.add(city); + } + }else { + cities.add(city); //verify nation or guild is same + } } } } diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 9ea566e4..b84f6def 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -965,12 +965,12 @@ public class Guild extends AbstractWorldObject { DataWarehouse.writeHash(Enum.DataRecordType.GUILD, this.getObjectUUID()); } - public Enum.GuildType getGuildType() { + public GuildCharterType getGuildType() { try { - return Enum.GuildType.values()[this.charter]; + return GuildCharterType.values()[this.charter]; } catch (Exception e) { Logger.error(e); - return Enum.GuildType.NONE; + return GuildCharterType.NONE; } } diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index dfc3c03b..9dda9502 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -9,6 +9,7 @@ package engine.objects; +import engine.Enum; import engine.Enum.DamageType; import engine.Enum.GameObjectType; import engine.Enum.ItemType; @@ -19,6 +20,7 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; @@ -32,47 +34,54 @@ 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; @@ -116,6 +125,13 @@ public class ItemBase { this.minDamage = rs.getShort("minDamage"); this.maxDamage = rs.getShort("maxDamage"); + // Item restrictions and requirements + + this.requiredRaces = DbManager.parseEnumSet(rs.getString("race_required"), Enum.MonsterType.class); + this.restrictedRaces = DbManager.parseEnumSet(rs.getString("race_restricted"), Enum.MonsterType.class); + this.requiredClasses = DbManager.parseEnumSet(rs.getString("class_required"), Enum.ClassType.class); + this.requiredDiscs = DbManager.parseEnumSet(rs.getString("disc_required"), Enum.DisciplineType.class); + this.mastery = rs.getString("mastery"); damageType = DamageType.valueOf(rs.getString("damageType")); @@ -212,6 +228,7 @@ public class ItemBase { public static void loadAllItemBases() { DbManager.ItemBaseQueries.LOAD_ALL_ITEMBASES(); + AnniverseryGifts.add(971000); AnniverseryGifts.add(971001); AnniverseryGifts.add(971002); @@ -306,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() { @@ -468,6 +482,9 @@ public class ItemBase { if (!validForSkills(abstractCharacter.getSkills())) return false; + if (this.canCharacterEquip(abstractCharacter) == false) + return false; + return item.getItemBase().value != 0 || Kit.IsNoobGear(item.getItemBase().uuid); //players can't wear 0 value items. @@ -752,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() { @@ -915,20 +932,68 @@ public class ItemBase { this.autoID = autoID; } - public boolean isArmor(){ + public boolean isArmor() { + + if (this.isHeavyArmor()) + return true; + + if (this.isMediumArmor()) + return true; + + if (this.isLightArmor()) + return true; + + return this.isClothArmor(); + } + + 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.isHeavyArmor()) + if (this.requiredRaces.isEmpty() && this.restrictedRaces.isEmpty()) return true; - if(this.isMediumArmor()) + if (this.requiredRaces.isEmpty() == false && race.elementOf(this.requiredRaces) == true) return true; - if(this.isLightArmor()) + return this.restrictedRaces.isEmpty() == false && race.elementOf(this.restrictedRaces) == false; + } + + 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) return true; - if(this.isClothArmor()) + 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) + return this.restrictedClasses.contains(base) == false && this.restrictedClasses.contains(profession) == false; + + return false; + } + + public Boolean ValidDiscipline(EnumSet discs) { + + boolean requiredEmpty = this.requiredDiscs == null || this.requiredDiscs.isEmpty(); + boolean restrictedEmpty = this.restrictedDiscs == null || this.restrictedDiscs.isEmpty(); + + if (requiredEmpty && restrictedEmpty) return true; - return false; + 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)) + return false; + } + return false; } } diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index d68c16cd..eecca954 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4559,6 +4559,36 @@ public class PlayerCharacter extends AbstractCharacter { Bounds playerBounds = Bounds.borrow(); playerBounds.setBounds(this.getLoc()); this.setBounds(playerBounds); + + //assign enum values for restrictions + String race = this.getRace().getName().replace("-","").replace(", Male","").replace(", Female",""); + this.absRace = Enum.MonsterType.valueOf(race); + + if(this.baseClass != null) + this.absBaseClass = ClassType.valueOf(this.getBaseClass().getName()); + + if(this.promotionClass != null) + this.absPromotionClass = ClassType.valueOf(this.getPromotionClass().getName()); + + if(this.isMale()) + this.absGender = SexType.MALE; + else + this.absGender = SexType.FEMALE; + + + for(CharacterRune rune : this.runes){ + try { + DisciplineType disc = DisciplineType.valueOf(RuneBase.getRuneBase(rune.getRuneBaseID()).getName().replace("-", "").replace(" ", "")); + if (disc != null) { + if(this.absDisciplines == null) + this.absDisciplines = EnumSet.of(disc); + else + this.absDisciplines.add(disc); + } + } catch(Exception e){ + + } + } } @Override